1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

fixed parseconfig usage

This commit is contained in:
Aurelien Foret 2005-10-29 07:18:40 +00:00
parent 617263a605
commit bbfe57b95a
2 changed files with 5 additions and 4 deletions

View File

@ -71,7 +71,7 @@ int config_free(config_t *config)
return(0); return(0);
} }
int parseconfig(config_t *config) int parseconfig(char *file, config_t *config)
{ {
FILE *fp = NULL; FILE *fp = NULL;
char line[PATH_MAX+1]; char line[PATH_MAX+1];
@ -85,7 +85,7 @@ int parseconfig(config_t *config)
return(-1); return(-1);
} }
fp = fopen(config->configfile, "r"); fp = fopen(file, "r");
if(fp == NULL) { if(fp == NULL) {
return(0); return(0);
} }
@ -169,7 +169,7 @@ int parseconfig(config_t *config)
char conf[PATH_MAX]; char conf[PATH_MAX];
strncpy(conf, ptr, PATH_MAX); strncpy(conf, ptr, PATH_MAX);
vprint("config: including %s\n", conf); vprint("config: including %s\n", conf);
parseconfig(conf); parseconfig(conf, config);
} else if(!strcmp(section, "options")) { } else if(!strcmp(section, "options")) {
if(!strcmp(key, "NOUPGRADE")) { if(!strcmp(key, "NOUPGRADE")) {
char *p = ptr; char *p = ptr;

View File

@ -62,9 +62,10 @@ typedef struct __config_t {
} config_t; } config_t;
#define FREECONF(p) do { if(p) { config_free(p); p = NULL; } } while(0) #define FREECONF(p) do { if(p) { config_free(p); p = NULL; } } while(0)
config_t *config_new(); config_t *config_new();
int config_free(config_t *config); int config_free(config_t *config);
int parseconfig(config_t *config); int parseconfig(char *file, config_t *config);
#endif /* _PM_CONF_H */ #endif /* _PM_CONF_H */