get rid of shared/fileio.*: it malloced/freed every byte read
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
noinst_LIBRARIES = libLCDstuff.a
|
noinst_LIBRARIES = libLCDstuff.a
|
||||||
|
|
||||||
libLCDstuff_a_SOURCES = LL.c LL.h sockets.c sockets.h str.c str.h configfile.c configfile.h debug.h report.c report.h snprintf.c snprintf.h fileio.c fileio.h
|
libLCDstuff_a_SOURCES = LL.c LL.h sockets.c sockets.h str.c str.h configfile.c configfile.h debug.h report.c report.h snprintf.c snprintf.h
|
||||||
|
|
||||||
libLCDstuff_a_LIBADD = @LIBOBJS@
|
libLCDstuff_a_LIBADD = @LIBOBJS@
|
||||||
|
|
||||||
|
|||||||
+18
-19
@@ -25,7 +25,6 @@
|
|||||||
#endif /* WITH_LDAP_SUPPORT */
|
#endif /* WITH_LDAP_SUPPORT */
|
||||||
|
|
||||||
#include "shared/report.h"
|
#include "shared/report.h"
|
||||||
#include "shared/fileio.h"
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct key {
|
typedef struct key {
|
||||||
@@ -49,8 +48,8 @@ section * find_section(char * sectionname);
|
|||||||
section * add_section(char * sectionname);
|
section * add_section(char * sectionname);
|
||||||
key * find_key(section * s, char * keyname, int skip);
|
key * find_key(section * s, char * keyname, int skip);
|
||||||
key * add_key(section * s, char * keyname, char * value);
|
key * add_key(section * s, char * keyname, char * value);
|
||||||
char get_next_char_f(buffile * f);
|
char get_next_char_f(FILE *f);
|
||||||
int process_config(section ** current_section, char(*get_next_char)(), char modify_section_allowed, char * source_descr, buffile * f);
|
int process_config(section ** current_section, char(*get_next_char)(), char modify_section_allowed, char * source_descr, FILE *f);
|
||||||
|
|
||||||
|
|
||||||
#ifdef WITH_LDAP_SUPPORT
|
#ifdef WITH_LDAP_SUPPORT
|
||||||
@@ -73,7 +72,7 @@ int ldap_port;
|
|||||||
|
|
||||||
int config_read_file(char *filename)
|
int config_read_file(char *filename)
|
||||||
{
|
{
|
||||||
buffile *f;
|
FILE *f;
|
||||||
section *curr_section = NULL;
|
section *curr_section = NULL;
|
||||||
|
|
||||||
#ifdef WITH_LDAP_SUPPORT
|
#ifdef WITH_LDAP_SUPPORT
|
||||||
@@ -111,14 +110,14 @@ int config_read_file(char *filename)
|
|||||||
}
|
}
|
||||||
#endif /* WITH_LDAP_SUPPORT */
|
#endif /* WITH_LDAP_SUPPORT */
|
||||||
|
|
||||||
f = buffile_open(filename, "r");
|
f = fopen(filename, "r");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
process_config(&curr_section, get_next_char_f, 1, filename, f);
|
process_config(&curr_section, get_next_char_f, 1, filename, f);
|
||||||
|
|
||||||
buffile_close(f);
|
fclose(f);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -536,13 +535,11 @@ key * add_key(section * s, char * keyname, char * value)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char get_next_char_f(buffile * f)
|
char get_next_char_f(FILE *f)
|
||||||
{
|
{
|
||||||
char * buf = buffile_read(f, 1);
|
int c = fgetc(f);
|
||||||
char c = buf[0];
|
|
||||||
|
|
||||||
free(buf);
|
return((c == EOF) ? '\0' : c);
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -567,7 +564,7 @@ char get_next_char_f(buffile * f)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int process_config(section ** current_section, char(*get_next_char)(), char modify_section_allowed, char * source_descr, buffile * f)
|
int process_config(section ** current_section, char(*get_next_char)(), char modify_section_allowed, char * source_descr, FILE *f)
|
||||||
{
|
{
|
||||||
char state = ST_INITIAL;
|
char state = ST_INITIAL;
|
||||||
char ch;
|
char ch;
|
||||||
@@ -577,7 +574,7 @@ int process_config(section ** current_section, char(*get_next_char)(), char modi
|
|||||||
int keyname_pos = 0;
|
int keyname_pos = 0;
|
||||||
char value[MAXVALUELENGTH+1];
|
char value[MAXVALUELENGTH+1];
|
||||||
int value_pos = 0;
|
int value_pos = 0;
|
||||||
int quote = 0;
|
int escape = 0;
|
||||||
key *k;
|
key *k;
|
||||||
int line_nr = 1;
|
int line_nr = 1;
|
||||||
|
|
||||||
@@ -762,24 +759,26 @@ int process_config(section ** current_section, char(*get_next_char)(), char modi
|
|||||||
state = ST_INITIAL;
|
state = ST_INITIAL;
|
||||||
break;
|
break;
|
||||||
case '\\':
|
case '\\':
|
||||||
if (!quote) {
|
if (!escape) {
|
||||||
quote = 1;
|
escape = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* fall though */
|
||||||
case '"':
|
case '"':
|
||||||
if (!quote) {
|
if (!escape) {
|
||||||
state = ST_VALUE;
|
state = ST_VALUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* fall though */
|
||||||
default:
|
default:
|
||||||
if (quote) {
|
if (escape) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'n': ch = '\n'; break;
|
case 'n': ch = '\n'; break;
|
||||||
case 'r': ch = '\r'; break;
|
case 'r': ch = '\r'; break;
|
||||||
case 't': ch = '\t'; break;
|
case 't': ch = '\t'; break;
|
||||||
/* default: litteral*/
|
/* default: literal char (i.e. ignore \) */
|
||||||
}
|
}
|
||||||
quote = 0;
|
escape = 0;
|
||||||
}
|
}
|
||||||
value[value_pos++] = ch;
|
value[value_pos++] = ch;
|
||||||
value[value_pos] = '\0';
|
value[value_pos] = '\0';
|
||||||
|
|||||||
Reference in New Issue
Block a user