char *optarg;
int argp = 1;
int getopt(int argc, char *argv[], char *opts)
{
  char *c = opts;

  if (argp == argc)
    return -1;
  if (argv[argp][0] == '-') {
    c = strchr(opts, argv[argp][1]);
    if (c == NULL)
      return -1;
    argp++;
    if (c[1] == ':')
      optarg = argv[argp++];
    return *c;
  }
  return 0;
}
