int pmdaGetOpt(int argc, char *const *argv, const char *optstring, pmdaInterface *dispatch, int *err)
The options that pmdaGetOpt will trap are:
Only one of -i, -p and -u may be specified. If none of these three options is given, a pipe (-p) is assumed. When these options are encountered by pmdaGetOpt, the option is processed and the next option is examined. Therefore, pmdaGetOpt will only return when an option other than those listed above is found, or the end of the list is reached. The returned value will be the argument or EOF, respectively.
A PMDA can control which of these options the program will accept with the optstring argument. To accept all the options, the PMDA should call pmdaGetOpt with the option string "D:d:h:i:l:pu:". Any PMDA specific options should be added to this string in the style of getopt(3), and returned by pmdaGetOpt if encountered. However, the PMDA cannot reuse any of the options specified above.
pmdaGetOpt takes a pointer to an int, err, which is used as an error count. This variable should be initialized to zero before pmdaGetOpt is first called, and tested when pmdaGetOpt returns EOF.
pmdaGetOpt does not modify argc or argv.
pmdaInterface dispatch;
int err = 0;
int c = 0;
while ((c = pmdaGetOpt(argv, argc, "d:h:i:l:pu:n:",
dispatch &err)) != EOF) {
/* process argument 'n', may use optarg etc. */
}
if (err)
usage(argv[0]);
The global variables used by getopt (3) may be used by the caller of pmdaGetOpt within the argument parsing loop.
The PMDA must be using PMDA_INTERFACE_2 or later, as specified in the call to pmdaDSO(3) or pmdaDaemon(3).