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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 142 - (show annotations)
Tue Jan 29 18:38:38 2002 UTC (22 years, 2 months ago) by frodo
File MIME type: text/plain
File size: 2844 byte(s)
(Frodo) DMALLOC support

1 /*
2 generate_texted.c - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 2000 Frodo Looijaard <frodol@dds.nl>
4
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
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include "config.h"
21 #include "compat.h"
22
23 #include <stdlib.h>
24
25 #include "generate_routines.h"
26 #include "error.h"
27
28 #ifdef DMALLOC
29 #include <dmalloc.h>
30 #endif
31
32
33
34 int psiconv_write_texted_section(psiconv_buffer buf,
35 const psiconv_texted_section value,
36 const psiconv_character_layout base_char,
37 const psiconv_paragraph_layout base_para,
38 psiconv_buffer *extra_buf)
39 {
40 int res,with_layout_section=0;
41 psiconv_u32 layout_id;
42
43 if (!value) {
44 psiconv_warn(0,psiconv_buffer_length(buf),"Null TextEd section");
45 res = -PSICONV_E_GENERATE;
46 goto ERROR1;
47 }
48
49 if (!(*extra_buf = psiconv_buffer_new())) {
50 res = -PSICONV_E_NOMEM;
51 goto ERROR1;
52 }
53
54 layout_id = psiconv_buffer_unique_id();
55 psiconv_buffer_add_target(*extra_buf,layout_id);
56
57 if (psiconv_list_length(value->paragraphs)) {
58 with_layout_section = 1;
59 if ((res = psiconv_write_styleless_layout_section(*extra_buf,
60 value->paragraphs,
61 base_char,base_para)))
62 goto ERROR2;
63 }
64
65 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_BODY)))
66 goto ERROR2;
67
68 /* Partly dummy TextEd Jumptable */
69 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_REPLACEMENT)))
70 goto ERROR2;
71 if ((res = psiconv_write_u32(buf,0)))
72 goto ERROR2;
73 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_UNKNOWN)))
74 goto ERROR2;
75 if ((res = psiconv_write_u32(buf,0)))
76 goto ERROR2;
77 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_LAYOUT)))
78 goto ERROR2;
79 if (with_layout_section) {
80 if ((res = psiconv_write_offset(buf,layout_id)))
81 goto ERROR2;
82 } else {
83 if ((res = psiconv_write_u32(buf,0)))
84 goto ERROR2;
85 }
86
87 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_TEXT)))
88 goto ERROR2;
89
90 return psiconv_write_text_section(buf,value->paragraphs);
91
92 ERROR2:
93 psiconv_buffer_free(*extra_buf);
94 ERROR1:
95 return res;
96 }

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