1PMDAGETOPT(3)              Library Functions Manual              PMDAGETOPT(3)
2
3
4

NAME

6       pmdaGetOpt  -  get  options from argument vector, trapping generic PMDA
7       options
8

C SYNOPSIS

10       #include <pcp/pmapi.h>
11       #include <pcp/impl.h>
12       #include <pcp/pmda.h>
13
14       int pmdaGetOpt(int argc, char  *const  *argv,  const  char  *optstring,
15       pmdaInterface *dispatch, int *err)
16
17       cc ... -lpcp_pmda -lpcp
18

DESCRIPTION

20       This function is a wrapper for getopt(3).  The behavior of the function
21       is identical except that certain options are assumed to have  a  prede‐
22       fined  behavior  which  initializes several fields in the pmdaInterface
23       structure.
24
25       The options that pmdaGetOpt will trap are:
26
27       -Dtrace        Set the PMAPI(3) debug  control  variable  (pmDebug)  to
28                      trace.   Used  for  controlling  levels  of trace output
29                      while debugging.
30
31       -ddomain       Set the domain number of this agent.
32
33       -hhelpfile     Obtain the help text (see pmdaText(3)) for  the  metrics
34                      from  this file rather than from the path specified with
35                      pmdaDSO(3) or pmdaDaemon(3).
36
37       -iport         Expect PMCD to connect on inet port (number or name).
38
39       -llogfile      Redirect diagnostics and trace output to logfile.
40
41       -p             Expect PMCD to supply stdin/stdout pipe.
42
43       -usocket       Expect PMCD to connect on unix domain socket.
44
45       Only one of -i, -p and -u may be specified.  If  none  of  these  three
46       options  is  given,  a  pipe  (-p)  is assumed.  When these options are
47       encountered by pmdaGetOpt, the option is processed and the next  option
48       is  examined.   Therefore,  pmdaGetOpt  will only return when an option
49       other than those listed above is found, or  the  end  of  the  list  is
50       reached.  The returned value will be the argument or EOF, respectively.
51
52       A  PMDA can control which of these options the program will accept with
53       the optstring argument.  To accept all the  options,  the  PMDA  should
54       call  pmdaGetOpt with the option string "D:d:h:i:l:pu:".  Any PMDA spe‐
55       cific options should be added to this string in the style of getopt(3),
56       and  returned  by  pmdaGetOpt if encountered.  However, the PMDA cannot
57       reuse any of the options specified above.
58
59       pmdaGetOpt takes a pointer to an int, err, which is used  as  an  error
60       count.   This  variable should be initialized to zero before pmdaGetOpt
61       is first called, and tested when pmdaGetOpt returns EOF.
62
63       pmdaGetOpt does not modify argc or argv.
64

EXAMPLE

66       A PMDA which takes the additional argument -n and does not use  pmDebug
67       might call pmdaGetOpt like this:
68
69                pmdaInterface dispatch;
70                int           err = 0;
71                int           c = 0;
72
73                while ((c = pmdaGetOpt(argv, argc, "d:h:i:l:pu:n:",
74                                       dispatch &err)) != EOF) {
75                    /* process argument 'n', may use optarg etc. */
76                }
77
78                if (err)
79                    usage(argv[0]);
80
81       The  global  variables  used by getopt (3) may be used by the caller of
82       pmdaGetOpt within the argument parsing loop.
83

DIAGNOSTICS

85       pmdaGetOpt will display the same error messages as getopt.
86

CAVEAT

88       The options -D, -d, -i, -l, -p and -u cannot be reused for  other  pur‐
89       poses by the PMDA.
90
91       The  PMDA  must be using PMDA_INTERFACE_2 or later, as specified in the
92       call to pmdaDSO(3) or pmdaDaemon(3).
93

SEE ALSO

95       pmdbg(1), getopt(3), PMAPI(3), PMDA(3), pmdaDaemon(3),  pmdaDSO(3)  and
96       pmdaText(3).
97
98
99
100Performance Co-Pilot                  SGI                        PMDAGETOPT(3)
Impressum