29 #include <stdio.h> |
29 #include <stdio.h> |
30 #include <stdlib.h> |
30 #include <stdlib.h> |
31 |
31 |
32 #include "keyfile.h" |
32 #include "keyfile.h" |
33 |
33 |
34 KeyfileConfig *load_keyfile_config(char *file) { |
34 KeyfileConfig *load_keyfile_config(const char *file) { |
35 FILE *in = fopen(file, "r"); |
35 FILE *in = fopen(file, "r"); |
36 if(in == NULL) { |
36 if(in == NULL) { |
37 return NULL; |
37 return NULL; |
38 } |
38 } |
39 |
39 |
40 KeyfileConfig *conf = malloc(sizeof(KeyfileConfig)); |
40 KeyfileConfig *conf = malloc(sizeof(KeyfileConfig)); |
41 conf->parser.parse = keyfile_parse; |
41 conf->parser.parse = keyfile_parse; |
42 conf->file = file; |
42 conf->file = strdup(file); |
43 conf->users = NULL; |
43 conf->users = NULL; |
44 |
44 |
45 int r = cfg_parse_basic_file((ConfigParser*)conf, in); |
45 int r = cfg_parse_basic_file((ConfigParser*)conf, in); |
46 if(r != 0) { |
46 if(r != 0) { |
47 fclose(in); |
47 fclose(in); |