--- psiconv/trunk/program/psiconv/gen_txt.c 1999/10/11 19:17:17 14 +++ psiconv/trunk/program/psiconv/gen_txt.c 2002/01/29 18:38:38 142 @@ -21,9 +21,14 @@ #include "config.h" #include #include -#include "data.h" -#include "list.h" +#include "psiconv/data.h" +#include "psiconv/list.h" #include "gen.h" +#include "psiconv.h" + +#ifdef DMALLOC +#include "dmalloc.h" +#endif /* @@ -95,11 +100,13 @@ int i; psiconv_paragraph para; - if (tf->page_sec->header->on_first_page) { - for (i=0; i < psiconv_list_length(tf->page_sec->header->text->paragraphs); i++) { - para = psiconv_list_get(tf->page_sec->header->text->paragraphs, i); - fput_text(of, para->text, strlen(para->text)); - fputs("\n", of); + if (tf->page_sec->header->text) { + if (tf->page_sec->header->on_first_page) { + for (i=0; i < psiconv_list_length(tf->page_sec->header->text->paragraphs); i++) { + para = psiconv_list_get(tf->page_sec->header->text->paragraphs, i); + fput_text(of, para->text, strlen(para->text)); + fputs("\n", of); + } } } fputs("\n",of); @@ -110,10 +117,12 @@ } fputs("\n",of); - for (i=0; i < psiconv_list_length(tf->page_sec->footer->text->paragraphs); i++) { - para = psiconv_list_get(tf->page_sec->footer->text->paragraphs, i); - fput_text(of, para->text, strlen(para->text)); - fputs("\n", of); + if (tf->page_sec->header->text) { + for (i=0; i < psiconv_list_length(tf->page_sec->footer->text->paragraphs); i++) { + para = psiconv_list_get(tf->page_sec->footer->text->paragraphs, i); + fput_text(of, para->text, strlen(para->text)); + fputs("\n", of); + } } } @@ -144,13 +153,33 @@ } } -void psiconv_gen_txt(FILE * of, psiconv_file file) +static int psiconv_gen_txt(const char *filename, const psiconv_file file, + const char *dest) { - if (file->type == psiconv_word_file) + FILE *of = fopen(filename,"w"); + if (! of) + return -1; + + if (file->type == psiconv_word_file) { psiconv_gen_txt_word(of,(psiconv_word_f) file->file); - else if (file->type == psiconv_texted_file) + } else if (file->type == psiconv_texted_file) { psiconv_gen_txt_texted(of,(psiconv_texted_f) file->file); - else - return; + } else { + fclose(of); + return -1; + } + return fclose(of); +} + +static struct psiconv_fileformat_s ff = + { + "ASCII", + "Plain text without much layout", + psiconv_gen_txt + }; + +void init_txt(void) +{ + psiconv_list_add(fileformat_list,&ff); }