/[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 80 - (show annotations)
Wed Dec 27 02:12:23 2000 UTC (23 years, 3 months ago) by frodo
File MIME type: text/plain
File size: 2799 byte(s)
(Frodo) Many changes. Layout sections now work!

* Added list_empty, list_replace
* Added relocation to buffers, removed base address
* Added buffer_resolve, buffer_add_reference, buffer_add_target,
  psiconv_unique_id functions
* Modifified other buffer functions to work with references
* Added comments to buffer.h
* Added write_offset function
* Added reference support in functions where needed
* Corrected extra/rewrite error message
* Corrected numerous bugs to make layouts work.

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
29 int psiconv_write_texted_section(psiconv_buffer buf,
30 const psiconv_texted_section value,
31 const psiconv_character_layout base_char,
32 const psiconv_paragraph_layout base_para,
33 psiconv_buffer *extra_buf)
34 {
35 int res,with_layout_section=0;
36 psiconv_u32 layout_id;
37
38 if (!value) {
39 psiconv_warn(0,psiconv_buffer_length(buf),"Null TextEd section");
40 res = -PSICONV_E_GENERATE;
41 goto ERROR1;
42 }
43
44 if (!(*extra_buf = psiconv_buffer_new())) {
45 res = -PSICONV_E_NOMEM;
46 goto ERROR1;
47 }
48
49 layout_id = psiconv_buffer_unique_id();
50 psiconv_buffer_add_target(*extra_buf,layout_id);
51
52 if (psiconv_list_length(value->paragraphs)) {
53 with_layout_section = 1;
54 if ((res = psiconv_write_styleless_layout_section(*extra_buf,
55 value->paragraphs,
56 base_char,base_para)))
57 goto ERROR2;
58 }
59
60 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_BODY)))
61 goto ERROR2;
62
63 /* Partly dummy TextEd Jumptable */
64 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_REPLACEMENT)))
65 goto ERROR2;
66 if ((res = psiconv_write_u32(buf,0)))
67 goto ERROR2;
68 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_UNKNOWN)))
69 goto ERROR2;
70 if ((res = psiconv_write_u32(buf,0)))
71 goto ERROR2;
72 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_LAYOUT)))
73 goto ERROR2;
74 if (with_layout_section) {
75 if ((res = psiconv_write_offset(buf,layout_id)))
76 goto ERROR2;
77 } else {
78 if ((res = psiconv_write_u32(buf,0)))
79 goto ERROR2;
80 }
81
82 if ((res = psiconv_write_u32(buf,PSICONV_ID_TEXTED_TEXT)))
83 goto ERROR2;
84
85 return psiconv_write_text_section(buf,value->paragraphs);
86
87 ERROR2:
88 psiconv_buffer_free(*extra_buf);
89 ERROR1:
90 return res;
91 }

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