use nitems
An incremental improvement to the current argument parsing.
Welcome nopt, a simple table based argument parser using genget.

usage template for when no additional arguments are desired:

static struct nopts authopts[] = {
   { "ac",         req_arg,        'a' },
   { "dev",        req_arg,        'd' },
   { "svc",        req_arg,        's' },
   { NULL,         0,              0 }
};

/* parse */
noptind = 0;
while ((ch = nopt(argc, argv, authopts)) != -1)
	switch (ch) {
	case 'a':       /* ac */
		strlcpy(dst, argv[noptind - 1], sizeof(dst));
...
		break;
	case 'd':       /* dev */
...
		break;
	case 's':       /* svc */
...
		break;
	default:
		printf("%% nopt table error\n");
		return(0);
	}
	argc -= noptind;
	argv += noptind;

        if (argc != 0) {
                /* leftover salmon */
                printf("%% %s", nopterr);
                if (argv[noptind])
                        printf(": %s", argv[noptind]);
                printf("\n");
                usage();
                return(0);
        }