|
NAMEARGBEGIN, ARGEND, ARGC, ARGF, EARGF, arginit, argopt - process option letters from argvSYNOPSIS#include <u.h>#include <libc.h> ARGBEGIN { char *ARGF(); char *EARGF(code); Rune ARGC(); } ARGEND extern char *argv0; DESCRIPTIONThese macros assume the names argc and argv are in scope; see ARGBEGIN and ARGEND surround code for processing program options. The code should be the cases of a C switch on option characters; it is executed once for each option character. Options end after an argument --, before an argument -, or before an argument that doesn't begin with -.The function macro ARGC returns the current option character, as an integer. The function macro ARGF returns the current option argument: a pointer to the rest of the option string if not empty, or the next argument in argv if any, or 0. ARGF must be called just once for each option that takes an argument. The macro EARGF is like ARGF but instead of returning zero runs code and, if that returns, calls A typical value for code is usage(), as in EARGF(usage()). After ARGBEGIN, argv0 is a copy of argv[0] (conventionally the name of the program). After ARGEND, argv points at a zero-terminated list of the remaining argc arguments. EXAMPLEThis C program can take option b and option f, which requires an argument.
Here is the output from running the command prog -bffile1 -r -f file2 arg1 arg2
SOURCE/include/libc.h Visit the GSP FreeBSD Man Page Interface. |