read_config.h
上传用户:wxp200602
上传日期:2007-10-30
资源大小:4028k
文件大小:7k
源码类别:

SNMP编程

开发平台:

Unix_Linux

  1. /*
  2.  *  read_config.h: reads configuration files for extensible sections.
  3.  *
  4.  */
  5. #ifndef READ_CONFIG_H
  6. #define READ_CONFIG_H
  7. #ifdef __cplusplus
  8. extern          "C" {
  9. #endif
  10. #define STRINGMAX 1024
  11. #define NORMAL_CONFIG 0
  12. #define PREMIB_CONFIG 1
  13. #define EITHER_CONFIG 2
  14.     /*
  15.      * Defines a set of file types and the parse and free functions
  16.      * which process the syntax following a given token in a given file.
  17.      */
  18.     struct config_files {
  19.         char           *fileHeader;     /* Label for entire file. */
  20.         struct config_line *start;
  21.         struct config_files *next;
  22.     };
  23.     struct config_line {
  24.         char           *config_token;   /* Label for each line parser
  25.                                          * in the given file. */
  26.         void            (*parse_line) (const char *, char *);
  27.         void            (*free_func) (void);
  28.         struct config_line *next;
  29.         char            config_time;    /* {NORMAL,PREMIB,EITHER}_CONFIG */
  30.         char           *help;
  31.     };
  32.     struct read_config_memory {
  33.         char           *line;
  34.         struct read_config_memory *next;
  35.     };
  36.     int             netsnmp_config(char *);     /* parse a simple line: token=values */
  37.     void            netsnmp_config_remember(char *);    /* process later, during snmp_init() */
  38.     void            netsnmp_config_process_memories(void);      /* run all memories through parser */
  39.     void            read_config(const char *, struct config_line *, int);
  40.     void            read_configs(void);
  41.     void            read_premib_configs(void);
  42.     void            read_config_files(int);
  43.     void            free_config(void);
  44.     void            config_perror(const char *);
  45.     void            config_pwarn(const char *);
  46.     char           *skip_white(char *);
  47.     char           *skip_not_white(char *);
  48.     char           *skip_token(char *);
  49.     char           *copy_nword(char *, char *, int);
  50.     char           *copy_word(char *, char *);  /* do not use */
  51.     void            read_config_with_type(const char *, const char *);
  52.     struct config_line *register_config_handler(const char *, const char *,
  53.                                                 void (*parser) (const char
  54.                                                                 *, char *),
  55.                                                 void (*releaser) (void),
  56.                                                 const char *);
  57.     struct config_line *register_app_config_handler(const char *,
  58.                                                     void (*parser) (const
  59.                                                                     char *,
  60.                                                                     char
  61.                                                                     *),
  62.                                                     void (*releaser)
  63.                                                     (void), const char *);
  64.     struct config_line *register_prenetsnmp_mib_handler(const char *,
  65.                                                         const char *,
  66.                                                         void (*parser)
  67.                                                         (const char *,
  68.                                                          char *),
  69.                                                         void (*releaser)
  70.                                                         (void),
  71.                                                         const char *);
  72.     struct config_line *register_app_prenetsnmp_mib_handler(const char *,
  73.                                                             void (*parser)
  74.                                                             (const char *,
  75.                                                              char *),
  76.                                                             void
  77.                                                             (*releaser)
  78.                                                             (void),
  79.                                                             const char *);
  80.     void            unregister_config_handler(const char *, const char *);
  81.     void            unregister_app_config_handler(const char *);
  82.     void            unregister_all_config_handlers(void);
  83.     void            read_config_print_usage(const char *lead);
  84.     char           *read_config_save_octet_string(char *saveto,
  85.                                                   u_char * str,
  86.                                                   size_t len);
  87.     char           *read_config_read_octet_string(char *readfrom,
  88.                                                   u_char ** str,
  89.                                                   size_t * len);
  90.     char           *read_config_read_objid(char *readfrom, oid ** objid,
  91.                                            size_t * len);
  92.     char           *read_config_save_objid(char *saveto, oid * objid,
  93.                                            size_t len);
  94.     char           *read_config_read_data(int type, char *readfrom,
  95.                                           void *dataptr, size_t * len);
  96.     char           *read_config_read_memory(int type, char *readfrom,
  97.                                             char *dataptr, size_t * len);
  98.     char           *read_config_store_data(int type, char *storeto,
  99.                                            void *dataptr, size_t * len);
  100.     char           *read_config_store_data_prefix(char prefix, int type,
  101.                                                   char *storeto,
  102.                                                   void *dataptr, size_t len);
  103.     void            read_config_store(const char *type, const char *line);
  104.     void            read_app_config_store(const char *line);
  105.     void            snmp_save_persistent(const char *type);
  106.     void            snmp_clean_persistent(const char *type);
  107.     struct config_line *read_config_get_handlers(const char *type);
  108.     /*
  109.      * external memory list handlers 
  110.      */
  111.     void            snmp_config_remember_in_list(char *line,
  112.                                                  struct read_config_memory
  113.                                                  **mem);
  114.     void            snmp_config_process_memory_list(struct
  115.                                                     read_config_memory
  116.                                                     **mem, int, int);
  117.     void            snmp_config_remember_free_list(struct
  118.                                                    read_config_memory
  119.                                                    **mem);
  120.     void            set_configuration_directory(const char *dir);
  121.     const char     *get_configuration_directory(void);
  122.     void            set_persistent_directory(const char *dir);
  123.     const char     *get_persistent_directory(void);
  124.     void            set_temp_file_pattern(const char *pattern);
  125.     const char     *get_temp_file_pattern(void);
  126.     void            handle_long_opt(const char *myoptarg);
  127. #ifdef __cplusplus
  128. }
  129. #endif
  130. #endif                          /* READ_CONFIG_H */