restructured workdir

This commit is contained in:
Chris Cromer 2016-10-13 21:07:35 -03:00
parent 4d6c51e37b
commit 5fa25a03da
5 changed files with 15 additions and 1 deletions

View File

@ -3,7 +3,7 @@ BINDIR=out
DEBUG_FLAGS=-Wall -Werror DEBUG_FLAGS=-Wall -Werror
CFLAGS=$(DEBUG_FLAGS) -ggdb $(shell pkg-config libxml-2.0 --cflags) -ansi -I ./headers CFLAGS=$(DEBUG_FLAGS) -ggdb $(shell pkg-config libxml-2.0 --cflags) -ansi
LDFLAGS=$(shell pkg-config libxml-2.0 --libs) LDFLAGS=$(shell pkg-config libxml-2.0 --libs)
BINARY=generarxml BINARY=generarxml

8
main.c
View File

@ -31,12 +31,20 @@ int main(int argc, char **argv) {
} }
else { else {
/* Incorrect usage */ /* Incorrect usage */
if (config_file != NULL) {
free(config_file);
}
printusage(1); printusage(1);
return 1; return 1;
} }
} }
config = (CONFIG *) malloc(sizeof(CONFIG)); config = (CONFIG *) malloc(sizeof(CONFIG));
config->file = NULL;
config->bible = NULL;
config->book = NULL;
config->chapter = NULL;
config->chapter_numbers = NULL;
int status = readconfig(config_file, config); int status = readconfig(config_file, config);
free(config_file); free(config_file);

View File

@ -41,6 +41,12 @@ int readconfig(char *config_file, CONFIG *config) {
root = xmlDocGetRootElement(config_xml); root = xmlDocGetRootElement(config_xml);
if (root == NULL) {
fprintf(stderr,"El archivo %s no contiene xml\n", config_file);
xmlFreeDoc(config_xml);
return 1;
}
/* Run through the nodes to find the config information. */ /* Run through the nodes to find the config information. */
node = root->xmlChildrenNode; node = root->xmlChildrenNode;
while (node != NULL) { while (node != NULL) {