net-snmp
5.4.1
|
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 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 int netsnmp_config(char *); /* parse a simple line: token=values */ 00047 void netsnmp_config_remember(char *); /* process later, during snmp_init() */ 00048 void netsnmp_config_process_memories(void); /* run all memories through parser */ 00049 void read_config(const char *, struct config_line *, int); 00050 void read_configs(void); 00051 void read_premib_configs(void); 00052 void read_config_files(int); 00053 void free_config(void); 00054 void config_perror(const char *); 00055 void config_pwarn(const char *); 00056 char *skip_white(char *); 00057 char *skip_not_white(char *); 00058 char *skip_token(char *); 00059 char *copy_nword(char *, char *, int); 00060 char *copy_word(char *, char *); /* do not use */ 00061 void read_config_with_type(const char *, const char *); 00062 struct config_line *register_config_handler(const char *, const char *, 00063 void (*parser) (const char 00064 *, char *), 00065 void (*releaser) (void), 00066 const char *); 00067 struct config_line *register_app_config_handler(const char *, 00068 void (*parser) (const 00069 char *, 00070 char 00071 *), 00072 void (*releaser) 00073 (void), const char *); 00074 struct config_line *register_prenetsnmp_mib_handler(const char *, 00075 const char *, 00076 void (*parser) 00077 (const char *, 00078 char *), 00079 void (*releaser) 00080 (void), 00081 const char *); 00082 struct config_line *register_app_prenetsnmp_mib_handler(const char *, 00083 void (*parser) 00084 (const char *, 00085 char *), 00086 void 00087 (*releaser) 00088 (void), 00089 const char *); 00090 void unregister_config_handler(const char *, const char *); 00091 void unregister_app_config_handler(const char *); 00092 void unregister_all_config_handlers(void); 00093 void read_config_print_usage(const char *lead); 00094 char *read_config_save_octet_string(char *saveto, 00095 u_char * str, 00096 size_t len); 00097 char *read_config_read_octet_string(char *readfrom, 00098 u_char ** str, 00099 size_t * len); 00100 char *read_config_read_objid(char *readfrom, oid ** objid, 00101 size_t * len); 00102 char *read_config_save_objid(char *saveto, oid * objid, 00103 size_t len); 00104 char *read_config_read_data(int type, char *readfrom, 00105 void *dataptr, size_t * len); 00106 char *read_config_read_memory(int type, char *readfrom, 00107 char *dataptr, size_t * len); 00108 char *read_config_store_data(int type, char *storeto, 00109 void *dataptr, size_t * len); 00110 char *read_config_store_data_prefix(char prefix, int type, 00111 char *storeto, 00112 void *dataptr, size_t len); 00113 void read_config_store(const char *type, const char *line); 00114 void read_app_config_store(const char *line); 00115 void snmp_save_persistent(const char *type); 00116 void snmp_clean_persistent(const char *type); 00117 struct config_line *read_config_get_handlers(const char *type); 00118 00119 /* 00120 * external memory list handlers 00121 */ 00122 void snmp_config_remember_in_list(char *line, 00123 struct read_config_memory 00124 **mem); 00125 void snmp_config_process_memory_list(struct 00126 read_config_memory 00127 **mem, int, int); 00128 void snmp_config_remember_free_list(struct 00129 read_config_memory 00130 **mem); 00131 00132 void set_configuration_directory(const char *dir); 00133 const char *get_configuration_directory(void); 00134 void set_persistent_directory(const char *dir); 00135 const char *get_persistent_directory(void); 00136 void set_temp_file_pattern(const char *pattern); 00137 const char *get_temp_file_pattern(void); 00138 void handle_long_opt(const char *myoptarg); 00139 00140 #ifdef __cplusplus 00141 } 00142 #endif 00143 #endif /* READ_CONFIG_H */