3 ARGBEGIN, ARGEND, ARGC, ARGF, EARGF, arginit, argopt \- process option letters from argv
16 .B extern char *argv0;
18 These macros assume the names
27 surround code for processing program options.
29 should be the cases of a C switch on
31 it is executed once for each option character.
32 Options end after an argument
36 or before an argument that doesn't begin with
41 returns the current option character, as an integer.
45 returns the current option argument:
46 a pointer to the rest of the option string if not empty,
47 or the next argument in
51 must be called just once for each option
52 that takes an argument.
57 but instead of returning zero
60 and, if that returns, calls
74 (conventionally the name of the program).
79 points at a zero-terminated list of the remaining
83 This C program can take option
87 which requires an argument.
90 .ta \w'12345678'u +\w'12345678'u +\w'12345678'u +\w'12345678'u +\w'12345678'u
94 main(int argc, char *argv[])
103 print(" -f(%s)", (f=ARGF())? f: "no arg");
106 print(" badflag('%c')", ARGC());
108 print(" %d args:", argc);
110 print(" '%s'", *argv++);
116 Here is the output from running the command
118 prog -bffile1 -r -f file2 arg1 arg2
121 prog -b -f(file1) badflag('r') -f(file2) 2 args: 'arg1' 'arg2'
124 .B \*9/include/libc.h