1 #ifndef SNMP_PARSE_ARGS_H
2 #define SNMP_PARSE_ARGS_H
3 
4 /**
5  * @file snmp_parse_args.h
6  *
7  * Support for initializing variables of type netsnmp_session from command
8  * line arguments
9  */
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 /** Don't enable any logging even if there is no -L argument */
16 #define NETSNMP_PARSE_ARGS_NOLOGGING    0x0001
17 /** Don't zero out sensitive arguments as they are not on the command line
18  *  anyway, typically used when the function is called from an internal
19  *  config-line handler
20  */
21 #define NETSNMP_PARSE_ARGS_NOZERO       0x0002
22 
23 /**
24  * Parsing of command line arguments succeeded and application is expected
25  * to continue with normal operation.
26  */
27 #define NETSNMP_PARSE_ARGS_SUCCESS       0
28 /**
29   * Parsing of command line arguments succeeded, but the application is expected
30   * to exit with zero exit code. For example, '-V' parameter has been found.
31   */
32 #define NETSNMP_PARSE_ARGS_SUCCESS_EXIT  -2
33 /**
34  * Parsing of command line arguments failed and application is expected to show
35  * usage (i.e. list of parameters) and exit with nozero exit code.
36  */
37 #define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
38 /**
39  * Parsing of command line arguments failed and application is expected to exit
40  * with nozero exit code.  netsnmp_parse_args() has already printed what went
41  * wrong.
42  */
43 #define NETSNMP_PARSE_ARGS_ERROR         -3
44 
45 /**
46  *  Parse an argument list and initialize \link netsnmp_session
47  *  session\endlink
48  *  from it.
49  *  @param argc Number of elements in argv
50  *  @param argv string array of at least argc elements
51  *  @param session
52  *  @param localOpts Additional option characters to accept
53  *  @param proc function pointer used to process any unhandled arguments
54  *  @param flags flags directing how to handle the string
55  *
56  *  @retval 0 (= #NETSNMP_PARSE_ARGS_SUCCESS) on success
57  *  @retval #NETSNMP_PARSE_ARGS_SUCCESS_EXIT when the application is expected
58  *  to exit with zero exit code (e.g. '-V' option was found)
59  *  @retval #NETSNMP_PARSE_ARGS_ERROR_USAGE when the function failed to parse
60  *  the command line and the application is expected to show it's usage
61  *  @retval #NETSNMP_PARSE_ARGS_ERROR when the function failed to parse
62  *  the command line and it has already printed enough information for the user
63  *  and no other output is needed
64  *
65  *  The proc function is called with argc, argv and the currently processed
66  *  option as arguments
67  */
68 NETSNMP_IMPORT int
69 netsnmp_parse_args(int argc, char **argv, netsnmp_session *session,
70                    const char *localOpts, void (*proc)(int, char *const *, int),
71                    int flags);
72 
73 /**
74  *  Calls \link netsnmp_parse_args()
75  *  netsnmp_parse_args(argc, argv, session, localOpts, proc, 0)\endlink
76  */
77 NETSNMP_IMPORT
78 int
79 snmp_parse_args(int argc, char **argv, netsnmp_session *session,
80 		const char *localOpts, void (*proc)(int, char *const *, int));
81 
82 NETSNMP_IMPORT
83 void
84 snmp_parse_args_descriptions(FILE *);
85 
86 NETSNMP_IMPORT
87 void
88 snmp_parse_args_usage(FILE *);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 #endif
94