some commandline parsing stolen from the libc manual