#include <cat/gen.h>
int catgen_getopt(int argc, char **argv, const char *opts);
Standard Agent options are handled automatically and thus cannot be part of the opts argument.
This function is useful for a program that wants to use its own command line options in addition to the standard Agent options. If only standard Agent options are used, catgen_parseargs() should be used instead.
On error, the variable catgen_operrstring will be set to a descriptive error message.
cat_optind.
cat_optopt requires an argument.
cat_optopt is unknown.
"-C" option received faulty data.
catgen_opterrstring to an error message.
#include <cat/gen.h> #include <stdio.h>
int
main(int argc, char **argv)
{
int c;
while ((c = catgen_getopt(argc, argv, "a:x")) > 0) {
switch (c) {
case 'a':
handle_a_arg(cat_optarg);
break;
case 'x':
x_flag++; /* Should be declared and used somewhere... */
break;
case ':': /* Option requires an argument */
case '?': /* Unknown option */
default: /* Other error */
fputs(catgen_opterrstring, stderr);
exit(1);
}
}
return catgen_server("agent-2.3", argc, argv, sesshandler, NULL);
}
May interfere with the standard input, so no data should be read from it.