Add getopt and getopt_long (libc) support

Test code is taken from the functions' manpages and libc files from OpenBSD.