Subversion Repositories Tewi

Rev

Rev 4 | Rev 6 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4 Rev 5
Line 1... Line 1...
1
/* $Id: config.c 4 2024-09-13 09:39:33Z nishi $ */
1
/* $Id: config.c 5 2024-09-13 10:08:00Z nishi $ */
2
 
2
 
3
#include "tw_config.h"
3
#include "tw_config.h"
4
 
4
 
5
#include <stdio.h>
5
#include <stdio.h>
6
#include <stdlib.h>
6
#include <stdlib.h>
Line 20... Line 20...
20
		while(1){
20
		while(1){
21
			int c = fread(cbuf, 1, 1, f);
21
			int c = fread(cbuf, 1, 1, f);
22
			if(cbuf[0] == '\n' || c <= 0){
22
			if(cbuf[0] == '\n' || c <= 0){
23
				char* l = cm_trim(line);
23
				char* l = cm_trim(line);
24
				if(strlen(l) > 0 && l[0] != '#'){
24
				if(strlen(l) > 0 && l[0] != '#'){
-
 
25
					char** r = cm_split(l, " \t");
-
 
26
					int i;
-
 
27
					if(cm_strcaseequ(r[0], "Include") || cm_strcaseequ(r[0], "IncludeOptional")){
-
 
28
						for(i = 1; r[i] != NULL; i++){
-
 
29
							if(tw_config_read(r[i]) != 0 && cm_strcaseequ(r[0], "Include")){
-
 
30
								for(i = 0; r[i] != NULL; i++) free(r[i]);
-
 
31
								free(r);
25
					printf("[%s]\n", l);
32
								free(line);
-
 
33
								free(l);
-
 
34
								fclose(f);
-
 
35
								return 1;
-
 
36
							}
-
 
37
						}
-
 
38
					}
-
 
39
					for(i = 0; r[i] != NULL; i++) free(r[i]);
-
 
40
					free(r);
26
				}
41
				}
27
				free(l);
42
				free(l);
28
				free(line);
43
				free(line);
29
				line = malloc(1);
44
				line = malloc(1);
30
				line[0] = 0;
45
				line[0] = 0;
Line 37... Line 52...
37
		}
52
		}
38
		free(line);
53
		free(line);
39
		fclose(f);
54
		fclose(f);
40
		return 0;
55
		return 0;
41
	}else{
56
	}else{
-
 
57
		cm_log("Config", "Could not open the file");
42
		return 1;
58
		return 1;
43
	}
59
	}
44
}
60
}