net-snmp 5.7
Defines | Functions
snmp_parse_args.h File Reference

Support for initializing variables of type netsnmp_session from command line arguments. More...

Go to the source code of this file.

Defines

#define NETSNMP_PARSE_ARGS_NOLOGGING   0x0001
 Don't enable any logging even if there is no -L argument.
#define NETSNMP_PARSE_ARGS_NOZERO   0x0002
 Don't zero out sensitive arguments as they are not on the command line anyway, typically used when the function is called from an internal config-line handler.
#define NETSNMP_PARSE_ARGS_SUCCESS   0
 Parsing of command line arguments succeeded and application is expected to continue with normal operation.
#define NETSNMP_PARSE_ARGS_SUCCESS_EXIT   -2
 Parsing of command line arguments succeeded, but the application is expected to exit with zero exit code.
#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1
 Parsing of command line arguments failed and application is expected to show usage (i.e.
#define NETSNMP_PARSE_ARGS_ERROR   -3
 Parsing of command line arguments failed and application is expected to exit with nozero exit code.

Functions

NETSNMP_IMPORT int netsnmp_parse_args (int argc, char **argv, netsnmp_session *session, const char *localOpts, void(*proc)(int, char *const *, int), int flags)
 Parse an argument list and initialize session from it.
NETSNMP_IMPORT int snmp_parse_args (int argc, char **argv, netsnmp_session *session, const char *localOpts, void(*proc)(int, char *const *, int))
 Calls netsnmp_parse_args(argc, argv, session, localOpts, proc, 0).
NETSNMP_IMPORT void snmp_parse_args_descriptions (FILE *)
NETSNMP_IMPORT void snmp_parse_args_usage (FILE *)

Detailed Description

Support for initializing variables of type netsnmp_session from command line arguments.

Definition in file snmp_parse_args.h.


Define Documentation

#define NETSNMP_PARSE_ARGS_ERROR   -3

Parsing of command line arguments failed and application is expected to exit with nozero exit code.

netsnmp_parse_args() has already printed what went wrong.

Definition at line 42 of file snmp_parse_args.h.

#define NETSNMP_PARSE_ARGS_ERROR_USAGE   -1

Parsing of command line arguments failed and application is expected to show usage (i.e.

list of parameters) and exit with nozero exit code.

Definition at line 36 of file snmp_parse_args.h.

#define NETSNMP_PARSE_ARGS_NOLOGGING   0x0001

Don't enable any logging even if there is no -L argument.

Definition at line 15 of file snmp_parse_args.h.

#define NETSNMP_PARSE_ARGS_NOZERO   0x0002

Don't zero out sensitive arguments as they are not on the command line anyway, typically used when the function is called from an internal config-line handler.

Definition at line 20 of file snmp_parse_args.h.

#define NETSNMP_PARSE_ARGS_SUCCESS   0

Parsing of command line arguments succeeded and application is expected to continue with normal operation.

Definition at line 26 of file snmp_parse_args.h.

#define NETSNMP_PARSE_ARGS_SUCCESS_EXIT   -2

Parsing of command line arguments succeeded, but the application is expected to exit with zero exit code.

For example, '-V' parameter has been found.

Definition at line 31 of file snmp_parse_args.h.


Function Documentation

NETSNMP_IMPORT int netsnmp_parse_args ( int  argc,
char **  argv,
netsnmp_session session,
const char *  localOpts,
void(*)(int, char *const *, int)  proc,
int  flags 
)

Parse an argument list and initialize session from it.

Parameters:
argcNumber of elements in argv
argvstring array of at least argc elements
localOptsAdditional option characters to accept
procfunction pointer used to process any unhandled arguments
flagsflags directing how to handle the string

0 (= NETSNMP_PARSE_ARGS_SUCCESS) on success

Return values:
NETSNMP_PARSE_ARGS_SUCCESS_EXITwhen the application is expected to exit with zero exit code (e.g. '-V' option was found)
NETSNMP_PARSE_ARGS_ERROR_USAGEwhen the function failed to parse the command line and the application is expected to show it's usage
NETSNMP_PARSE_ARGS_ERRORwhen the function failed to parse the command line and it has already printed enough information for the user and no other output is needed

The proc function is called with argc, argv and the currently processed option as arguments

Definition at line 192 of file snmp_parse_args.c.

NETSNMP_IMPORT int snmp_parse_args ( int  argc,
char **  argv,
netsnmp_session session,
const char *  localOpts,
void(*)(int, char *const *, int)  proc 
)