cleanup
This commit is contained in:
parent
d176cfbb49
commit
f398929260
@ -1,2 +1,5 @@
|
|||||||
|
23/10/2016
|
||||||
|
Cleaned up the project a bit.
|
||||||
|
|
||||||
21/10/2016
|
21/10/2016
|
||||||
Created first version.
|
Created first version.
|
||||||
|
18
Makefile.am
18
Makefile.am
@ -3,12 +3,12 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
|
|||||||
SUBDIRS = src
|
SUBDIRS = src
|
||||||
|
|
||||||
EXTRA_DIST = misc/Biblia.txt \
|
EXTRA_DIST = misc/Biblia.txt \
|
||||||
misc/config.dtd \
|
misc/config.dtd \
|
||||||
misc/generarxml.dtd \
|
misc/generarxml.dtd \
|
||||||
misc/chris.conf \
|
misc/chris.conf \
|
||||||
misc/carlos.conf \
|
misc/carlos.conf \
|
||||||
misc/enzo.conf \
|
misc/enzo.conf \
|
||||||
misc/erwin.conf \
|
misc/erwin.conf \
|
||||||
misc/martin.conf \
|
misc/martin.conf \
|
||||||
misc/pablo.conf \
|
misc/pablo.conf \
|
||||||
misc/paula.conf
|
misc/paula.conf
|
||||||
|
5
NEWS
5
NEWS
@ -1,2 +1,5 @@
|
|||||||
|
23/10/2016
|
||||||
|
Just some cleanup.
|
||||||
|
|
||||||
21/10/2016
|
21/10/2016
|
||||||
Version 1.0 is complete.
|
Version 1.0 is complete.
|
||||||
|
20
configure
vendored
20
configure
vendored
@ -3653,12 +3653,12 @@ fi
|
|||||||
# Check whether --with-debug was given.
|
# Check whether --with-debug was given.
|
||||||
if test "${with_debug+set}" = set; then :
|
if test "${with_debug+set}" = set; then :
|
||||||
withval=$with_debug; case $with_debug in
|
withval=$with_debug; case $with_debug in
|
||||||
yes) $as_echo "#define DEBUG 1" >>confdefs.h
|
yes) $as_echo "#define DEBUG 1" >>confdefs.h
|
||||||
|
|
||||||
;;
|
;;
|
||||||
no) ;;
|
no) ;;
|
||||||
*) as_fn_error $? "\"--with-debug does not take an argument.\"" "$LINENO" 5
|
*) as_fn_error $? "\"--with-debug does not take an argument.\"" "$LINENO" 5
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -3667,12 +3667,12 @@ fi
|
|||||||
# Check whether --with-debug_encoding was given.
|
# Check whether --with-debug_encoding was given.
|
||||||
if test "${with_debug_encoding+set}" = set; then :
|
if test "${with_debug_encoding+set}" = set; then :
|
||||||
withval=$with_debug_encoding; case $with_debug_encoding in
|
withval=$with_debug_encoding; case $with_debug_encoding in
|
||||||
yes) $as_echo "#define DEBUG_ENCODING 1" >>confdefs.h
|
yes) $as_echo "#define DEBUG_ENCODING 1" >>confdefs.h
|
||||||
|
|
||||||
;;
|
;;
|
||||||
no) ;;
|
no) ;;
|
||||||
*) as_fn_error $? "\"--with-debug-encoding does not take an argument.\"" "$LINENO" 5
|
*) as_fn_error $? "\"--with-debug-encoding does not take an argument.\"" "$LINENO" 5
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
21
configure.ac
21
configure.ac
@ -20,20 +20,20 @@ AC_PATH_PROG([M4], [m4])
|
|||||||
|
|
||||||
AC_ARG_WITH(debug, [AS_HELP_STRING([--with-debug], [include debug messages])],
|
AC_ARG_WITH(debug, [AS_HELP_STRING([--with-debug], [include debug messages])],
|
||||||
[case $with_debug in
|
[case $with_debug in
|
||||||
yes) AC_DEFINE(DEBUG)
|
yes) AC_DEFINE(DEBUG)
|
||||||
;;
|
;;
|
||||||
no) ;;
|
no) ;;
|
||||||
*) AC_MSG_ERROR(["--with-debug does not take an argument."])
|
*) AC_MSG_ERROR(["--with-debug does not take an argument."])
|
||||||
;;
|
;;
|
||||||
esac])
|
esac])
|
||||||
|
|
||||||
AC_ARG_WITH(debug_encoding, [AS_HELP_STRING([--with-debug-encoding], [include encoding debug messages])],
|
AC_ARG_WITH(debug_encoding, [AS_HELP_STRING([--with-debug-encoding], [include encoding debug messages])],
|
||||||
[case $with_debug_encoding in
|
[case $with_debug_encoding in
|
||||||
yes) AC_DEFINE(DEBUG_ENCODING)
|
yes) AC_DEFINE(DEBUG_ENCODING)
|
||||||
;;
|
;;
|
||||||
no) ;;
|
no) ;;
|
||||||
*) AC_MSG_ERROR(["--with-debug-encoding does not take an argument."])
|
*) AC_MSG_ERROR(["--with-debug-encoding does not take an argument."])
|
||||||
;;
|
;;
|
||||||
esac])
|
esac])
|
||||||
|
|
||||||
AC_DEFINE(_DEFAULT_SOURCE)
|
AC_DEFINE(_DEFAULT_SOURCE)
|
||||||
@ -50,5 +50,4 @@ AC_CONFIG_FILES([Makefile
|
|||||||
src/Makefile
|
src/Makefile
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
@ -2,15 +2,15 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
|
|||||||
|
|
||||||
bin_PROGRAMS = generarxml
|
bin_PROGRAMS = generarxml
|
||||||
generarxml_SOURCES = main.c \
|
generarxml_SOURCES = main.c \
|
||||||
main.h \
|
main.h \
|
||||||
readconfig.c \
|
readconfig.c \
|
||||||
readconfig.h \
|
readconfig.h \
|
||||||
readfile.c \
|
readfile.c \
|
||||||
readfile.h \
|
readfile.h \
|
||||||
makexml.c \
|
makexml.c \
|
||||||
makexml.h \
|
makexml.h \
|
||||||
encoding.c \
|
encoding.c \
|
||||||
encoding.h
|
encoding.h
|
||||||
generarxml_CPPFLAGS = $(XML_CPPFLAGS)
|
generarxml_CPPFLAGS = $(XML_CPPFLAGS)
|
||||||
generarxml_LDFLAGS= $(XML_LIBS)
|
generarxml_LDFLAGS= $(XML_LIBS)
|
||||||
generarxml_LDADD = ${libxml2_LIBS}
|
generarxml_LDADD = ${libxml2_LIBS}
|
||||||
|
@ -261,15 +261,15 @@ top_builddir = @top_builddir@
|
|||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
|
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
|
||||||
generarxml_SOURCES = main.c \
|
generarxml_SOURCES = main.c \
|
||||||
main.h \
|
main.h \
|
||||||
readconfig.c \
|
readconfig.c \
|
||||||
readconfig.h \
|
readconfig.h \
|
||||||
readfile.c \
|
readfile.c \
|
||||||
readfile.h \
|
readfile.h \
|
||||||
makexml.c \
|
makexml.c \
|
||||||
makexml.h \
|
makexml.h \
|
||||||
encoding.c \
|
encoding.c \
|
||||||
encoding.h
|
encoding.h
|
||||||
|
|
||||||
generarxml_CPPFLAGS = $(XML_CPPFLAGS)
|
generarxml_CPPFLAGS = $(XML_CPPFLAGS)
|
||||||
generarxml_LDFLAGS = $(XML_LIBS)
|
generarxml_LDFLAGS = $(XML_LIBS)
|
||||||
|
@ -6,14 +6,14 @@
|
|||||||
/*
|
/*
|
||||||
* This function converts the latin1 ISO_8859-1 encoding into utf-8.
|
* This function converts the latin1 ISO_8859-1 encoding into utf-8.
|
||||||
*/
|
*/
|
||||||
char *latin2utf8(char *input) {
|
char *latin_to_utf8(char *input) {
|
||||||
if (input && strlen(input) > 0) {
|
if (input && strlen(input) > 0) {
|
||||||
iconv_t cd = iconv_open("UTF-8", "ISO_8859-1");
|
iconv_t cd = iconv_open("UTF-8", "ISO_8859-1");
|
||||||
|
|
||||||
char temp[strlen(input)];
|
char temp[strlen(input)];
|
||||||
memcpy(temp, input, strlen(input) + 1);
|
memcpy(temp, input, strlen(input) + 1);
|
||||||
|
|
||||||
char *in_buf = &temp[0];
|
char *in_buffer = &temp[0];
|
||||||
size_t in_left = sizeof(temp);
|
size_t in_left = sizeof(temp);
|
||||||
|
|
||||||
/* The more tildes and ñs that the string has, the longer the size needs to be.
|
/* The more tildes and ñs that the string has, the longer the size needs to be.
|
||||||
@ -21,11 +21,11 @@ char *latin2utf8(char *input) {
|
|||||||
* double the size.
|
* double the size.
|
||||||
*/
|
*/
|
||||||
char output[strlen(temp) * 2];
|
char output[strlen(temp) * 2];
|
||||||
char *out_buf = &output[0];
|
char *out_buffer = &output[0];
|
||||||
size_t out_left = sizeof(output);
|
size_t out_left = sizeof(output);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (iconv(cd, &in_buf, &in_left, &out_buf, &out_left) == (size_t) -1) {
|
if (iconv(cd, &in_buffer, &in_left, &out_buffer, &out_left) == (size_t) -1) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("%s\n", input);
|
printf("%s\n", input);
|
||||||
perror("iconv");
|
perror("iconv");
|
||||||
@ -35,11 +35,11 @@ char *latin2utf8(char *input) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (in_left > 0 && out_left > 0);
|
while (in_left > 0 && out_left > 0);
|
||||||
*out_buf = 0;
|
*out_buffer = 0;
|
||||||
|
|
||||||
#if defined(DEBUG) && defined(DEBUG_ENCODING)
|
#if defined(DEBUG) && defined(DEBUG_ENCODING)
|
||||||
printf("latin2utf8: input: %s\n", input);
|
printf("latin to UTF-8: input: %s\n", input);
|
||||||
printf("latin2utf8: output: %s\n", output);
|
printf("latin to UTF-8: output: %s\n", output);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *temp2 = (char *) malloc((strlen(output) + 1) * sizeof(char));
|
char *temp2 = (char *) malloc((strlen(output) + 1) * sizeof(char));
|
||||||
@ -55,14 +55,14 @@ char *latin2utf8(char *input) {
|
|||||||
/*
|
/*
|
||||||
* This function converts the utf-8 encoding into latin1 ISO_8859-1.
|
* This function converts the utf-8 encoding into latin1 ISO_8859-1.
|
||||||
*/
|
*/
|
||||||
char *utf82latin(char *input) {
|
char *utf8_to_latin(char *input) {
|
||||||
if (input && strlen(input) > 0) {
|
if (input && strlen(input) > 0) {
|
||||||
iconv_t cd = iconv_open("ISO_8859-1", "UTF-8");
|
iconv_t cd = iconv_open("ISO_8859-1", "UTF-8");
|
||||||
|
|
||||||
char temp[strlen(input)];
|
char temp[strlen(input)];
|
||||||
memcpy(temp, input, strlen(input) + 1);
|
memcpy(temp, input, strlen(input) + 1);
|
||||||
|
|
||||||
char *in_buf = &temp[0];
|
char *in_buffer = &temp[0];
|
||||||
size_t in_left = sizeof(temp);
|
size_t in_left = sizeof(temp);
|
||||||
|
|
||||||
/* The more tildes and ñs that the string has, the longer the size needs to be.
|
/* The more tildes and ñs that the string has, the longer the size needs to be.
|
||||||
@ -70,11 +70,11 @@ char *utf82latin(char *input) {
|
|||||||
* double the size.
|
* double the size.
|
||||||
*/
|
*/
|
||||||
char output[strlen(temp) * 2];
|
char output[strlen(temp) * 2];
|
||||||
char *out_buf = &output[0];
|
char *out_buffer = &output[0];
|
||||||
size_t out_left = sizeof(output);
|
size_t out_left = sizeof(output);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (iconv(cd, &in_buf, &in_left, &out_buf, &out_left) == (size_t) -1) {
|
if (iconv(cd, &in_buffer, &in_left, &out_buffer, &out_left) == (size_t) -1) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("%s\n", input);
|
printf("%s\n", input);
|
||||||
perror("iconv");
|
perror("iconv");
|
||||||
@ -84,11 +84,11 @@ char *utf82latin(char *input) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (in_left > 0 && out_left > 0);
|
while (in_left > 0 && out_left > 0);
|
||||||
*out_buf = 0;
|
*out_buffer = 0;
|
||||||
|
|
||||||
#if defined(DEBUG) && defined(DEBUG_ENCODING)
|
#if defined(DEBUG) && defined(DEBUG_ENCODING)
|
||||||
printf("latin2utf8: input: %s\n", input);
|
printf("UTF-8 to latin: input: %s\n", input);
|
||||||
printf("latin2utf8: output: %s\n", output);
|
printf("UTF-8 to latin: output: %s\n", output);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *temp2 = (char *) malloc((strlen(output) + 1) * sizeof(char));
|
char *temp2 = (char *) malloc((strlen(output) + 1) * sizeof(char));
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* This function converts the latin1 ISO_8859-1 encoding into utf-8.
|
* This function converts the latin1 ISO_8859-1 encoding into utf-8.
|
||||||
*/
|
*/
|
||||||
char *latin2utf8(char *input);
|
char *latin_to_utf8(char *input);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function converts the utf-8 encoding into latin1 ISO_8859-1.
|
* This function converts the utf-8 encoding into latin1 ISO_8859-1.
|
||||||
*/
|
*/
|
||||||
char *utf82latin(char *input);
|
char *utf8_to_latin(char *input);
|
||||||
|
14
src/main.c
14
src/main.c
@ -23,7 +23,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
/* No arguments were passed */
|
/* No arguments were passed */
|
||||||
printusage(0);
|
print_usage(0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ int main(int argc, char **argv) {
|
|||||||
if (config_file != NULL) {
|
if (config_file != NULL) {
|
||||||
free(config_file);
|
free(config_file);
|
||||||
}
|
}
|
||||||
printusage(1);
|
print_usage(1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ int main(int argc, char **argv) {
|
|||||||
if (config_file != NULL) {
|
if (config_file != NULL) {
|
||||||
free(config_file);
|
free(config_file);
|
||||||
}
|
}
|
||||||
printusage(1);
|
print_usage(1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ int main(int argc, char **argv) {
|
|||||||
config->chapter = NULL;
|
config->chapter = NULL;
|
||||||
config->chapter_numbers = NULL;
|
config->chapter_numbers = NULL;
|
||||||
|
|
||||||
status = readconfig(config_file);
|
status = read_config(config_file);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -108,13 +108,13 @@ int main(int argc, char **argv) {
|
|||||||
printf("\tNumeros de capitulo: %s\n", config->chapter_numbers);
|
printf("\tNumeros de capitulo: %s\n", config->chapter_numbers);
|
||||||
|
|
||||||
book = (BOOK *) malloc(sizeof(BOOK));
|
book = (BOOK *) malloc(sizeof(BOOK));
|
||||||
status = readfile();
|
status = read_file();
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
printf("Falló leer Biblia.txt!\n");
|
printf("Falló leer Biblia.txt!\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
makexml();
|
make_xml();
|
||||||
|
|
||||||
printf("El achivo %s ha sido generado.\n", config->file);
|
printf("El achivo %s ha sido generado.\n", config->file);
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ void cleanup() {
|
|||||||
* Print information on the program's usage. If the argument is 1, the user
|
* Print information on the program's usage. If the argument is 1, the user
|
||||||
* put something incorrect as an argument.
|
* put something incorrect as an argument.
|
||||||
*/
|
*/
|
||||||
void printusage(int error) {
|
void print_usage(int error) {
|
||||||
if (error == 1) {
|
if (error == 1) {
|
||||||
printf("Opcion desconocido!\n\n");
|
printf("Opcion desconocido!\n\n");
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ struct configuration {
|
|||||||
* verses is the number of verses contained in the verse variable
|
* verses is the number of verses contained in the verse variable
|
||||||
* verse contains the verses
|
* verse contains the verses
|
||||||
*/
|
*/
|
||||||
struct chapterdata {
|
struct chapter_data {
|
||||||
int chapter;
|
int chapter;
|
||||||
int current;
|
int current;
|
||||||
int verses;
|
int verses;
|
||||||
@ -38,7 +38,7 @@ struct chapterdata {
|
|||||||
* chapters is the ammount of chapters that are contained in the chapter variable
|
* chapters is the ammount of chapters that are contained in the chapter variable
|
||||||
* chapter contains all of the chapters
|
* chapter contains all of the chapters
|
||||||
*/
|
*/
|
||||||
struct bookdata {
|
struct book_data {
|
||||||
int current;
|
int current;
|
||||||
int chapters;
|
int chapters;
|
||||||
CHAPTER **chapter;
|
CHAPTER **chapter;
|
||||||
@ -62,4 +62,4 @@ void cleanup();
|
|||||||
* Print information on the program's usage. If the argument is 1, the user
|
* Print information on the program's usage. If the argument is 1, the user
|
||||||
* put something incorrect as an argument.
|
* put something incorrect as an argument.
|
||||||
*/
|
*/
|
||||||
void printusage(int error);
|
void print_usage(int error);
|
||||||
|
@ -8,44 +8,44 @@
|
|||||||
/*
|
/*
|
||||||
* This function generates the xml and saves it to the output file.
|
* This function generates the xml and saves it to the output file.
|
||||||
*/
|
*/
|
||||||
void makexml() {
|
void make_xml() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
int length;
|
int length;
|
||||||
char *temp = NULL;
|
char *temp = NULL;
|
||||||
CHAPTER *chapter = NULL;
|
CHAPTER *chapter = NULL;
|
||||||
xmlDocPtr doc = NULL;
|
xmlDocPtr doc = NULL;
|
||||||
xmlNodePtr bibletag = NULL;
|
xmlNodePtr bible_tag = NULL;
|
||||||
xmlNodePtr booktag = NULL;
|
xmlNodePtr book_tag = NULL;
|
||||||
xmlNodePtr chaptertag = NULL;
|
xmlNodePtr chapter_tag = NULL;
|
||||||
xmlNodePtr versetag = NULL;
|
xmlNodePtr verse_tag = NULL;
|
||||||
xmlNodePtr node = NULL;
|
xmlNodePtr node = NULL;
|
||||||
xmlNodePtr text = NULL;
|
xmlNodePtr text = NULL;
|
||||||
|
|
||||||
LIBXML_TEST_VERSION;
|
LIBXML_TEST_VERSION;
|
||||||
|
|
||||||
doc = xmlNewDoc(BAD_CAST "1.0");
|
doc = xmlNewDoc(BAD_CAST "1.0");
|
||||||
bibletag = xmlNewNode(NULL, BAD_CAST "Biblia");
|
bible_tag = xmlNewNode(NULL, BAD_CAST "Biblia");
|
||||||
xmlDocSetRootElement(doc, bibletag);
|
xmlDocSetRootElement(doc, bible_tag);
|
||||||
|
|
||||||
/* add attribute to bible tag */
|
/* add attribute to bible tag */
|
||||||
xmlNewProp(bibletag, BAD_CAST "nombre", BAD_CAST config->bible);
|
xmlNewProp(bible_tag, BAD_CAST "nombre", BAD_CAST config->bible);
|
||||||
|
|
||||||
/* add dtd */
|
/* add dtd */
|
||||||
xmlCreateIntSubset(doc, BAD_CAST "Biblia", NULL, BAD_CAST "generarxml.dtd");
|
xmlCreateIntSubset(doc, BAD_CAST "Biblia", NULL, BAD_CAST "generarxml.dtd");
|
||||||
|
|
||||||
booktag = xmlNewNode(NULL, BAD_CAST "Libro");
|
book_tag = xmlNewNode(NULL, BAD_CAST "Libro");
|
||||||
xmlAddChild(bibletag, booktag);
|
xmlAddChild(bible_tag, book_tag);
|
||||||
|
|
||||||
node = xmlNewNode(NULL, BAD_CAST "Nombre");
|
node = xmlNewNode(NULL, BAD_CAST "Nombre");
|
||||||
text = xmlNewText(BAD_CAST config->book);
|
text = xmlNewText(BAD_CAST config->book);
|
||||||
xmlAddChild(node, text);
|
xmlAddChild(node, text);
|
||||||
xmlAddChild(booktag, node);
|
xmlAddChild(book_tag, node);
|
||||||
|
|
||||||
/* add the chapters */
|
/* add the chapters */
|
||||||
for (i = 0; i < book->chapters; i++) {
|
for (i = 0; i < book->chapters; i++) {
|
||||||
chaptertag = xmlNewNode(NULL, BAD_CAST "Capitulo");
|
chapter_tag = xmlNewNode(NULL, BAD_CAST "Capitulo");
|
||||||
xmlAddChild(booktag, chaptertag);
|
xmlAddChild(book_tag, chapter_tag);
|
||||||
|
|
||||||
length = snprintf(NULL, 0, "%d", book->chapter[i]->chapter) + strlen(config->chapter);
|
length = snprintf(NULL, 0, "%d", book->chapter[i]->chapter) + strlen(config->chapter);
|
||||||
temp = (char *) malloc((length + 2) * sizeof(char));
|
temp = (char *) malloc((length + 2) * sizeof(char));
|
||||||
@ -54,7 +54,7 @@ void makexml() {
|
|||||||
node = xmlNewNode(NULL, BAD_CAST "Nombre");
|
node = xmlNewNode(NULL, BAD_CAST "Nombre");
|
||||||
text = xmlNewText(BAD_CAST temp);
|
text = xmlNewText(BAD_CAST temp);
|
||||||
xmlAddChild(node, text);
|
xmlAddChild(node, text);
|
||||||
xmlAddChild(chaptertag, node);
|
xmlAddChild(chapter_tag, node);
|
||||||
|
|
||||||
free(temp);
|
free(temp);
|
||||||
|
|
||||||
@ -62,8 +62,8 @@ void makexml() {
|
|||||||
chapter = book->chapter[i];
|
chapter = book->chapter[i];
|
||||||
chapter->current = 0;
|
chapter->current = 0;
|
||||||
for (chapter->current = 0; chapter->current < chapter->verses; chapter->current++) {
|
for (chapter->current = 0; chapter->current < chapter->verses; chapter->current++) {
|
||||||
versetag = xmlNewNode(NULL, BAD_CAST "Versiculo");
|
verse_tag = xmlNewNode(NULL, BAD_CAST "Versiculo");
|
||||||
xmlAddChild(chaptertag, versetag);
|
xmlAddChild(chapter_tag, verse_tag);
|
||||||
|
|
||||||
length = snprintf(NULL, 0, "%d", chapter->current + 1) + strlen("VERSICULO");
|
length = snprintf(NULL, 0, "%d", chapter->current + 1) + strlen("VERSICULO");
|
||||||
temp = (char *) malloc((length + 2) * sizeof(char));
|
temp = (char *) malloc((length + 2) * sizeof(char));
|
||||||
@ -72,14 +72,14 @@ void makexml() {
|
|||||||
node = xmlNewNode(NULL, BAD_CAST "Nombre");
|
node = xmlNewNode(NULL, BAD_CAST "Nombre");
|
||||||
text = xmlNewText(BAD_CAST temp);
|
text = xmlNewText(BAD_CAST temp);
|
||||||
xmlAddChild(node, text);
|
xmlAddChild(node, text);
|
||||||
xmlAddChild(versetag, node);
|
xmlAddChild(verse_tag, node);
|
||||||
|
|
||||||
free(temp);
|
free(temp);
|
||||||
|
|
||||||
node = xmlNewNode(NULL, BAD_CAST "Descripcion");
|
node = xmlNewNode(NULL, BAD_CAST "Descripcion");
|
||||||
text = xmlNewText(BAD_CAST chapter->verse[chapter->current]);
|
text = xmlNewText(BAD_CAST chapter->verse[chapter->current]);
|
||||||
xmlAddChild(node, text);
|
xmlAddChild(node, text);
|
||||||
xmlAddChild(versetag, node);
|
xmlAddChild(verse_tag, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* This function generates the xml and saves it to the output file.
|
* This function generates the xml and saves it to the output file.
|
||||||
*/
|
*/
|
||||||
void makexml();
|
void make_xml();
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* This function reads the designated config file and save into int the
|
* This function reads the designated config file and save into int the
|
||||||
* config struct.
|
* config struct.
|
||||||
*/
|
*/
|
||||||
int readconfig(char *config_file) {
|
int read_config(char *config_file) {
|
||||||
xmlParserCtxtPtr context;
|
xmlParserCtxtPtr context;
|
||||||
xmlDocPtr config_xml = NULL;
|
xmlDocPtr config_xml = NULL;
|
||||||
xmlNodePtr root = NULL;
|
xmlNodePtr root = NULL;
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
* This function reads the designated config file and save into int the
|
* This function reads the designated config file and save into int the
|
||||||
* config struct.
|
* config struct.
|
||||||
*/
|
*/
|
||||||
int readconfig(char *config_file);
|
int read_config(char *config_file);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
* This function reads Biblia.txt, searches for the information in config,
|
* This function reads Biblia.txt, searches for the information in config,
|
||||||
* and stores it into an array of strings to be used later to create the xml.
|
* and stores it into an array of strings to be used later to create the xml.
|
||||||
*/
|
*/
|
||||||
int readfile() {
|
int read_file() {
|
||||||
FILE *file = NULL;
|
FILE *file = NULL;
|
||||||
CHAPTER *chapter = NULL;
|
CHAPTER *chapter = NULL;
|
||||||
int start = 0;
|
int start = 0;
|
||||||
@ -126,7 +126,7 @@ int readfile() {
|
|||||||
|
|
||||||
for (j = 0; j < lines; j++) {
|
for (j = 0; j < lines; j++) {
|
||||||
if (array[j] != NULL) {
|
if (array[j] != NULL) {
|
||||||
line = latin2utf8(array[j]);
|
line = latin_to_utf8(array[j]);
|
||||||
}
|
}
|
||||||
if (line != NULL) {
|
if (line != NULL) {
|
||||||
if (strcmp(line, config->bible) == 0) {
|
if (strcmp(line, config->bible) == 0) {
|
||||||
|
@ -8,4 +8,4 @@
|
|||||||
* This function reads Biblia.txt, searches for the information in config,
|
* This function reads Biblia.txt, searches for the information in config,
|
||||||
* and stores it into an array of strings to be used later to create the xml.
|
* and stores it into an array of strings to be used later to create the xml.
|
||||||
*/
|
*/
|
||||||
int readfile();
|
int read_file();
|
||||||
|
Loading…
Reference in New Issue
Block a user