123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- #ifndef ESL_CONFIG_H
- #define ESL_CONFIG_H
- #include "esl.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define ESL_URL_SEPARATOR "://"
- #ifdef WIN32
- #define ESL_PATH_SEPARATOR "\\"
- #ifndef ESL_CONFIG_DIR
- #define ESL_CONFIG_DIR "c:\\openesl"
- #endif
- #define esl_is_file_path(file) (*(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR))
- #else
- #define ESL_PATH_SEPARATOR "/"
- #ifndef ESL_CONFIG_DIR
- #define ESL_CONFIG_DIR "/etc/openesl"
- #endif
- #define esl_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))
- #endif
- static __inline__ int esl_true(const char *expr) {
- return (expr && (!strcasecmp(expr, "yes")
- || !strcasecmp(expr, "on")
- || !strcasecmp(expr, "true")
- || !strcasecmp(expr, "enabled")
- || !strcasecmp(expr, "active")
- || !strcasecmp(expr, "allow")
- || atoi(expr)));
- }
- static __inline__ int esl_false(const char *expr) {
- return (expr && (!strcasecmp(expr, "no")
- || !strcasecmp(expr, "off")
- || !strcasecmp(expr, "false")
- || !strcasecmp(expr, "disabled")
- || !strcasecmp(expr, "inactive")
- || !strcasecmp(expr, "disallow")
- || !atoi(expr)));
- }
- typedef struct esl_config esl_config_t;
- struct esl_config {
-
- FILE *file;
-
- char path[512];
-
- char category[256];
-
- char section[256];
-
- char buf[1024];
-
- int lineno;
-
- int catno;
-
- int sectno;
- int lockto;
- };
- ESL_DECLARE(int) esl_config_open_file(esl_config_t * cfg, const char *file_path);
- ESL_DECLARE(void) esl_config_close_file(esl_config_t * cfg);
- ESL_DECLARE(int) esl_config_next_pair(esl_config_t * cfg, char **var, char **val);
- ESL_DECLARE(int) esl_config_get_cas_bits(char *strvalue, unsigned char *outbits);
- #ifdef __cplusplus
- }
- #endif
- #endif
|