net-snmp 5.7
read_config.h
00001 /*
00002  *  read_config.h: reads configuration files for extensible sections.
00003  *
00004  */
00005 #ifndef READ_CONFIG_H
00006 #define READ_CONFIG_H
00007 
00008 #ifdef __cplusplus
00009 extern          "C" {
00010 #endif
00011 
00012 #define STRINGMAX 1024
00013 
00014 #define NORMAL_CONFIG 0
00015 #define PREMIB_CONFIG 1
00016 #define EITHER_CONFIG 2
00017 
00018 #include <net-snmp/config_api.h>
00019 
00020     /*
00021      * Defines a set of file types and the parse and free functions
00022      * which process the syntax following a given token in a given file.
00023      */
00024     struct config_files {
00025         char           *fileHeader;     /* Label for entire file. */
00026         struct config_line *start;
00027         struct config_files *next;
00028     };
00029 
00030     struct config_line {
00031         char           *config_token;   /* Label for each line parser
00032                                          * in the given file. */
00033         void            (*parse_line) (const char *, char *);
00034         void            (*free_func) (void);
00035         struct config_line *next;
00036         char            config_time;    /* {NORMAL,PREMIB,EITHER}_CONFIG */
00037         char           *help;
00038     };
00039 
00040     struct read_config_memory {
00041         char           *line;
00042         struct read_config_memory *next;
00043     };
00044 
00045 
00046     NETSNMP_IMPORT
00047     int             netsnmp_config(char *);     /* parse a simple line: token=values */
00048     NETSNMP_IMPORT
00049     void            netsnmp_config_remember(char *);    /* process later, during snmp_init() */
00050     void            netsnmp_config_process_memories(void);      /* run all memories through parser */
00051     int             read_config(const char *, struct config_line *, int);
00052     int             read_config_files(int);
00053     NETSNMP_IMPORT
00054     void            free_config(void);
00055 #if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2&& __GNUC_MINOR__ < 8)
00056     NETSNMP_IMPORT
00057     void            netsnmp_config_error(const char *, ...);
00058     void            netsnmp_config_warn(const char *, ...);
00059 #else
00060     NETSNMP_IMPORT
00061     void            netsnmp_config_error(const char *, ...)
00062         __attribute__((__format__(__printf__, 1, 2)));
00063     void            netsnmp_config_warn(const char *, ...)
00064         __attribute__((__format__(__printf__, 1, 2)));
00065 #endif
00066 
00067     NETSNMP_IMPORT
00068     char           *skip_white(char *);
00069     const char     *skip_white_const(const char *);
00070     NETSNMP_IMPORT
00071     char           *skip_not_white(char *);
00072     const char     *skip_not_white_const(const char *);
00073     NETSNMP_IMPORT
00074     char           *skip_token(char *);
00075     NETSNMP_IMPORT
00076     const char     *skip_token_const(const char *);
00077     NETSNMP_IMPORT
00078     char           *copy_nword(char *, char *, int);
00079     NETSNMP_IMPORT
00080     const char     *copy_nword_const(const char *, char *, int);
00081     NETSNMP_IMPORT
00082     char           *copy_word(char *, char *);  /* do not use */
00083     NETSNMP_IMPORT
00084     int             read_config_with_type(const char *, const char *);
00085     NETSNMP_IMPORT
00086     char           *read_config_save_octet_string(char *saveto,
00087                                                   u_char * str,
00088                                                   size_t len);
00089     NETSNMP_IMPORT
00090     char           *read_config_read_octet_string(const char *readfrom,
00091                                                   u_char ** str,
00092                                                   size_t * len);
00093     const char     *read_config_read_octet_string_const(const char *readfrom,
00094                                                         u_char ** str,
00095                                                         size_t * len);
00096     NETSNMP_IMPORT
00097     char           *read_config_read_objid(char *readfrom, oid ** objid,
00098                                            size_t * len);
00099     const char     *read_config_read_objid_const(const char *readfrom,
00100                                                  oid ** objid,
00101                                                  size_t * len);
00102     NETSNMP_IMPORT
00103     char           *read_config_save_objid(char *saveto, oid * objid,
00104                                            size_t len);
00105     NETSNMP_IMPORT
00106     char           *read_config_read_data(int type, char *readfrom,
00107                                           void *dataptr, size_t * len);
00108     NETSNMP_IMPORT
00109     char           *read_config_read_memory(int type, char *readfrom,
00110                                             char *dataptr, size_t * len);
00111     NETSNMP_IMPORT
00112     char           *read_config_store_data(int type, char *storeto,
00113                                            void *dataptr, size_t * len);
00114     char           *read_config_store_data_prefix(char prefix, int type,
00115                                                   char *storeto,
00116                                                   void *dataptr, size_t len);
00117     int  read_config_files_of_type(int when, struct config_files *ctmp);
00118     NETSNMP_IMPORT
00119     void            read_config_store(const char *type, const char *line);
00120     NETSNMP_IMPORT
00121     void            read_app_config_store(const char *line);
00122     NETSNMP_IMPORT
00123     void            snmp_save_persistent(const char *type);
00124     NETSNMP_IMPORT
00125     void            snmp_clean_persistent(const char *type);
00126     struct config_line *read_config_get_handlers(const char *type);
00127 
00128     /*
00129      * external memory list handlers 
00130      */
00131     void            snmp_config_remember_in_list(char *line,
00132                                                  struct read_config_memory
00133                                                  **mem);
00134     void            snmp_config_process_memory_list(struct
00135                                                     read_config_memory
00136                                                     **mem, int, int);
00137     void            snmp_config_remember_free_list(struct
00138                                                    read_config_memory
00139                                                    **mem);
00140 
00141     void            set_configuration_directory(const char *dir);
00142     NETSNMP_IMPORT
00143     const char     *get_configuration_directory(void);
00144     void            set_persistent_directory(const char *dir);
00145     const char     *get_persistent_directory(void);
00146     void            set_temp_file_pattern(const char *pattern);
00147     NETSNMP_IMPORT
00148     const char     *get_temp_file_pattern(void);
00149     NETSNMP_IMPORT
00150     void            handle_long_opt(const char *myoptarg);
00151 
00152 
00153 #ifdef __cplusplus
00154 }
00155 #endif
00156 #endif                          /* READ_CONFIG_H */