21 keywordlen = strlen(keyword);
22 if (keywordlen>*maxlen) *maxlen = keywordlen;
27 warningf(
"Error in line %i of '%s'", lineno, fname);
31 FILE *in = fopen(fname,
"r");
34 if (!ok && errno==ENOENT) {
35 FILE *out = fopen(fname,
"w");
38 fprintf(out,
";\n; arb_treegen CFG-File '%s'\n;\n\n", fname);
41 warningf(
"'%s' has been generated.", fname);
43 in = fopen(fname,
"r");
59 wordRead = (
int*)malloc(keywords*
sizeof(
int));
60 for (x = 0; x<keywords; x++) wordRead[x] = 0;
68 if (!fgets(linebuf,
MAXLEN, in))
break;
71 firstWord = strtok(linebuf,
" \n");
73 if (firstWord && firstWord[0]!=
COMMENT && firstWord[0]!=0) {
76 for (search = 0; search<keywords; search++) {
77 if (strcmp(line[search].keyword, firstWord)==0) {
78 str restDerZeile = strtok(NULL,
"\n");
82 decoded = line[search].
decode(restDerZeile, line[search].varPointer);
87 else warningf(
"Can't interpret '%s'", line[search].keyword);
91 if (wordRead[search]) {
94 warningf(
"Keyword '%s' duplicated (already specified in line %i)", firstWord, wordRead[search]);
99 wordRead[search] = lineno;
108 if (search==keywords) {
110 warningf(
"Unknown Keyword '%s'", firstWord);
121 if (ok && readLines<keywords) {
122 FILE *out = fopen(fname,
"a");
125 for (x = 0; x<keywords; x++) {
139 warningf(
"Missing keywords appended to '%s'.", fname);
void warningf(int warning_num, const char *warning_messagef,...) __ATTR__FORMAT(2)
void warning(int warning_num, const char *warning_message)
void message(char *errortext)
static void scanKeywords(struct S_cfgLine line[], int *lineanz, int *maxlen)
int readCfg(cstr fname, struct S_cfgLine line[])
static cstr error_message
static void cfgReadWarning(cstr fname, int lineno)
void setCfgError(cstr message)