read_config.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. * Value of 'type' parameter of various snmp_config calls,
  16. * used by Net-SNMP client utilities.
  17. */
  18. #define NETSNMP_APPLICATION_CONFIG_TYPE "snmpapp"
  19. #include <net-snmp/config_api.h>
  20. #include <net-snmp/library/netsnmp-attribute-format.h>
  21. /*
  22. * Defines a set of file types and the parse and free functions
  23. * which process the syntax following a given token in a given file.
  24. */
  25. struct config_files {
  26. char *fileHeader; /* Label for entire file. */
  27. struct config_line *start;
  28. struct config_files *next;
  29. };
  30. struct config_line {
  31. char *config_token; /* Label for each line parser
  32. * in the given file. */
  33. void (*parse_line) (const char *, char *);
  34. void (*free_func) (void);
  35. struct config_line *next;
  36. char config_time; /* {NORMAL,PREMIB,EITHER}_CONFIG */
  37. char *help;
  38. };
  39. struct read_config_memory {
  40. char *line;
  41. struct read_config_memory *next;
  42. };
  43. NETSNMP_IMPORT
  44. int netsnmp_config(char *); /* parse a simple line: token=values */
  45. NETSNMP_IMPORT
  46. void netsnmp_config_remember(char *); /* process later, during snmp_init() */
  47. void netsnmp_config_process_memories(void); /* run all memories through parser */
  48. int read_config(const char *, struct config_line *, int);
  49. int read_config_files(int);
  50. NETSNMP_IMPORT
  51. void free_config(void);
  52. NETSNMP_IMPORT
  53. void netsnmp_config_error(const char *, ...)
  54. NETSNMP_ATTRIBUTE_FORMAT(printf, 1, 2);
  55. NETSNMP_IMPORT
  56. void netsnmp_config_warn(const char *, ...)
  57. NETSNMP_ATTRIBUTE_FORMAT(printf, 1, 2);
  58. NETSNMP_IMPORT
  59. char *skip_white(char *);
  60. NETSNMP_IMPORT
  61. const char *skip_white_const(const char *);
  62. NETSNMP_IMPORT
  63. char *skip_not_white(char *);
  64. NETSNMP_IMPORT
  65. const char *skip_not_white_const(const char *);
  66. NETSNMP_IMPORT
  67. char *skip_token(char *);
  68. NETSNMP_IMPORT
  69. const char *skip_token_const(const char *);
  70. NETSNMP_IMPORT
  71. char *copy_nword(char *, char *, int);
  72. NETSNMP_IMPORT
  73. const char *copy_nword_const(const char *, char *, int);
  74. NETSNMP_IMPORT
  75. char *copy_word(char *, char *); /* do not use */
  76. NETSNMP_IMPORT
  77. int read_config_with_type(const char *, const char *);
  78. NETSNMP_IMPORT
  79. char *read_config_save_octet_string(char *saveto,
  80. const u_char * str,
  81. size_t len);
  82. NETSNMP_IMPORT
  83. char *read_config_read_octet_string(const char *readfrom,
  84. u_char ** str,
  85. size_t * len);
  86. NETSNMP_IMPORT
  87. const char *read_config_read_octet_string_const(const char *readfrom,
  88. u_char ** str,
  89. size_t * len);
  90. NETSNMP_IMPORT
  91. char *read_config_read_objid(char *readfrom, oid ** objid,
  92. size_t * len);
  93. const char *read_config_read_objid_const(const char *readfrom,
  94. oid ** objid,
  95. size_t * len);
  96. NETSNMP_IMPORT
  97. char *read_config_save_objid(char *saveto, oid * objid,
  98. size_t len);
  99. NETSNMP_IMPORT
  100. char *read_config_read_data(int type, char *readfrom,
  101. void *dataptr, size_t * len);
  102. NETSNMP_IMPORT
  103. char *read_config_read_memory(int type, char *readfrom,
  104. char *dataptr, size_t * len);
  105. NETSNMP_IMPORT
  106. char *read_config_store_data(int type, char *storeto,
  107. void *dataptr, size_t * len);
  108. char *read_config_store_data_prefix(char prefix, int type,
  109. char *storeto,
  110. void *dataptr, size_t len);
  111. int read_config_files_of_type(int when, struct config_files *ctmp);
  112. NETSNMP_IMPORT
  113. void read_config_store(const char *type, const char *line);
  114. NETSNMP_IMPORT
  115. void read_app_config_store(const char *line);
  116. NETSNMP_IMPORT
  117. void snmp_save_persistent(const char *type);
  118. NETSNMP_IMPORT
  119. void snmp_clean_persistent(const char *type);
  120. struct config_line *read_config_get_handlers(const char *type);
  121. /*
  122. * external memory list handlers
  123. */
  124. void snmp_config_remember_in_list(char *line,
  125. struct read_config_memory
  126. **mem);
  127. void snmp_config_process_memory_list(struct
  128. read_config_memory
  129. **mem, int, int);
  130. void snmp_config_remember_free_list(struct
  131. read_config_memory
  132. **mem);
  133. void set_configuration_directory(const char *dir);
  134. NETSNMP_IMPORT
  135. const char *get_configuration_directory(void);
  136. void set_persistent_directory(const char *dir);
  137. const char *get_persistent_directory(void);
  138. void set_temp_file_pattern(const char *pattern);
  139. NETSNMP_IMPORT
  140. const char *get_temp_file_pattern(void);
  141. NETSNMP_IMPORT
  142. void handle_long_opt(const char *myoptarg);
  143. #ifdef __cplusplus
  144. }
  145. #endif
  146. #endif /* READ_CONFIG_H */