/[public]/psiconv/trunk/lib/psiconv/generate_texted.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/generate_texted.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 142 Revision 233
1/* 1/*
2 generate_texted.c - Part of psiconv, a PSION 5 file formats converter 2 generate_texted.c - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 2000 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 2000-2004 Frodo Looijaard <frodol@dds.nl>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
29#include <dmalloc.h> 29#include <dmalloc.h>
30#endif 30#endif
31 31
32 32
33 33
34int psiconv_write_texted_section(psiconv_buffer buf, 34int psiconv_write_texted_section(const psiconv_config config,
35 psiconv_buffer buf, int lev,
35 const psiconv_texted_section value, 36 const psiconv_texted_section value,
36 const psiconv_character_layout base_char, 37 const psiconv_character_layout base_char,
37 const psiconv_paragraph_layout base_para, 38 const psiconv_paragraph_layout base_para,
38 psiconv_buffer *extra_buf) 39 psiconv_buffer *extra_buf)
39{ 40{
40 int res,with_layout_section=0; 41 int res,with_layout_section=0;
41 psiconv_u32 layout_id; 42 psiconv_u32 layout_id;
42 43
44 psiconv_progress(config,lev,0,"Writing texted section");
45
43 if (!value) { 46 if (!value) {
44 psiconv_warn(0,psiconv_buffer_length(buf),"Null TextEd section"); 47 psiconv_error(config,lev,0,"Null TextEd section");
45 res = -PSICONV_E_GENERATE; 48 res = -PSICONV_E_GENERATE;
46 goto ERROR1; 49 goto ERROR1;
47 } 50 }
48 51
49 if (!(*extra_buf = psiconv_buffer_new())) { 52 if (!(*extra_buf = psiconv_buffer_new())) {
53 psiconv_error(config,lev+1,0,"Out of memory error");
50 res = -PSICONV_E_NOMEM; 54 res = -PSICONV_E_NOMEM;
51 goto ERROR1; 55 goto ERROR1;
52 } 56 }
53 57
54 layout_id = psiconv_buffer_unique_id(); 58 layout_id = psiconv_buffer_unique_id();
55 psiconv_buffer_add_target(*extra_buf,layout_id); 59 if ((res = psiconv_buffer_add_target(*extra_buf,layout_id))) {
60 psiconv_error(config,lev+1,0,"Out of memory error");
61 goto ERROR2;
62 }
56 63
57 if (psiconv_list_length(value->paragraphs)) { 64 if (psiconv_list_length(value->paragraphs)) {
58 with_layout_section = 1; 65 with_layout_section = 1;
59 if ((res = psiconv_write_styleless_layout_section(*extra_buf, 66 if ((res = psiconv_write_styleless_layout_section(config,*extra_buf,lev+1,
60 value->paragraphs, 67 value->paragraphs,
61 base_char,base_para))) 68 base_char,base_para)))
62 goto ERROR2; 69 goto ERROR2;
63 } 70 }
64 71
65 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_BODY))) 72 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_BODY)))
66 goto ERROR2; 73 goto ERROR2;
67 74
68 /* Partly dummy TextEd Jumptable */ 75 /* Partly dummy TextEd Jumptable */
69 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_REPLACEMENT))) 76 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_REPLACEMENT)))
70 goto ERROR2; 77 goto ERROR2;
71 if ((res = psiconv_write_u32(buf,0))) 78 if ((res = psiconv_write_u32(config,buf,lev+1,0)))
72 goto ERROR2; 79 goto ERROR2;
73 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_UNKNOWN))) 80 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_UNKNOWN)))
74 goto ERROR2; 81 goto ERROR2;
75 if ((res = psiconv_write_u32(buf,0))) 82 if ((res = psiconv_write_u32(config,buf,lev+1,0)))
76 goto ERROR2; 83 goto ERROR2;
77 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_LAYOUT))) 84 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_LAYOUT)))
78 goto ERROR2; 85 goto ERROR2;
79 if (with_layout_section) { 86 if (with_layout_section) {
80 if ((res = psiconv_write_offset(buf,layout_id))) 87 if ((res = psiconv_write_offset(config,buf,lev+1,layout_id)))
81 goto ERROR2; 88 goto ERROR2;
82 } else { 89 } else {
83 if ((res = psiconv_write_u32(buf,0))) 90 if ((res = psiconv_write_u32(config,buf,lev+1,0)))
84 goto ERROR2; 91 goto ERROR2;
85 } 92 }
86 93
87 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_TEXT))) 94 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_TEXTED_TEXT)))
88 goto ERROR2; 95 goto ERROR2;
89 96
90 return psiconv_write_text_section(buf,value->paragraphs); 97 if ((res = psiconv_write_text_section(config,buf,lev+1,value->paragraphs)))
98 goto ERROR2;
99 psiconv_progress(config,lev,0,"End of texted section");
100 return 0;
91 101
92ERROR2: 102ERROR2:
93 psiconv_buffer_free(*extra_buf); 103 psiconv_buffer_free(*extra_buf);
94ERROR1: 104ERROR1:
105 psiconv_error(config,lev,0,"Writing of texted section failed");
95 return res; 106 return res;
96} 107}

Legend:
Removed from v.142  
changed lines
  Added in v.233

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26