X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=blobdiff_plain;f=libatalk%2Finiparser%2Finiparser.c;h=343a6d063b5cbd5028934f05e5b63c9f7f567d9c;hp=735812cd5b651edecefbf219b37016327ea0fc03;hb=d7e5521f69859b3df89da09bf50621945f119d97;hpb=d0eca3045ed53d88e95147d0a99871143f1e32b2 diff --git a/libatalk/iniparser/iniparser.c b/libatalk/iniparser/iniparser.c index 735812cd..343a6d06 100644 --- a/libatalk/iniparser/iniparser.c +++ b/libatalk/iniparser/iniparser.c @@ -8,6 +8,10 @@ */ /*---------------------------- Includes ------------------------------------*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + #include #include @@ -84,7 +88,7 @@ static char * strstrip(char * s) This function returns -1 in case of error. */ /*--------------------------------------------------------------------------*/ -int iniparser_getnsec(const dictionary * d) +int atalk_iniparser_getnsec(const dictionary * d) { int i ; int nsec ; @@ -115,7 +119,7 @@ int iniparser_getnsec(const dictionary * d) This function returns NULL in case of error. */ /*--------------------------------------------------------------------------*/ -const char * iniparser_getsecname(const dictionary * d, int n) +const char * atalk_iniparser_getsecname(const dictionary * d, int n) { int i ; int foundsec ; @@ -150,7 +154,7 @@ const char * iniparser_getsecname(const dictionary * d, int n) purposes mostly. */ /*--------------------------------------------------------------------------*/ -void iniparser_dump(const dictionary * d, FILE * f) +void atalk_iniparser_dump(const dictionary * d, FILE * f) { int i ; @@ -178,7 +182,7 @@ void iniparser_dump(const dictionary * d, FILE * f) It is Ok to specify @c stderr or @c stdout as output files. */ /*--------------------------------------------------------------------------*/ -void iniparser_dump_ini(const dictionary * d, FILE * f) +void atalk_iniparser_dump_ini(const dictionary * d, FILE * f) { int i, j ; char keym[ASCIILINESZ+1]; @@ -188,7 +192,7 @@ void iniparser_dump_ini(const dictionary * d, FILE * f) if (d==NULL || f==NULL) return ; - nsec = iniparser_getnsec(d); + nsec = atalk_iniparser_getnsec(d); if (nsec<1) { /* No section in file: dump all keys as they are */ for (i=0 ; isize ; i++) { @@ -199,7 +203,7 @@ void iniparser_dump_ini(const dictionary * d, FILE * f) return ; } for (i=0 ; i=0) && ((line[len]=='\n') || (isspace(line[len])))) { @@ -593,15 +587,21 @@ dictionary * iniparser_load(const char * ininame) } else { last=0 ; } - switch (iniparser_line(line, section, key, val)) { + switch (atalk_iniparser_line(line, section, key, val)) { case LINE_EMPTY: case LINE_COMMENT: break ; case LINE_SECTION: - errs = dictionary_set(dict, section, NULL, NULL); + if (strchr(section, ':') != NULL) + LOG(log_error, logtype_default, "iniparser: syntax error \"%s\" section name must not contain \":\".", section); + errs = atalkdict_set(dict, section, NULL, NULL); break ; case LINE_VALUE: if (strcmp(key, "include") == 0) { + errs = atalkdict_set(dict, section, key, val); + if (errs < 0) { + LOG(log_error, logtype_default, "iniparser: memory allocation failure"); + } if ((include = fopen(val, "r")) == NULL) { LOG(log_error, logtype_default, "iniparser: cannot open \"%s\"", val); continue; @@ -609,7 +609,7 @@ dictionary * iniparser_load(const char * ininame) in = include; continue; } - errs = dictionary_set(dict, section, key, val) ; + errs = atalkdict_set(dict, section, key, val) ; break ; case LINE_ERROR: LOG(log_error, logtype_default, "iniparser: syntax error in %s (lineno: %d): %s", @@ -627,7 +627,7 @@ dictionary * iniparser_load(const char * ininame) } } if (errs) { - dictionary_del(dict); + atalkdict_del(dict); dict = NULL ; } fclose(in); @@ -645,8 +645,8 @@ dictionary * iniparser_load(const char * ininame) gets out of the current context. */ /*--------------------------------------------------------------------------*/ -void iniparser_freedict(dictionary * d) +void atalk_iniparser_freedict(dictionary * d) { - dictionary_del(d); + atalkdict_del(d); }