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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 168 - (hide annotations)
Tue Nov 25 17:57:05 2003 UTC (20 years, 5 months ago) by frodo
File MIME type: text/plain
File size: 2990 byte(s)
(Frodo) config stuff and image generation stuff

* All parse and generate functions have a new config parameter
* New files configuration.[ch] in the psiconv lib
* Some image generation stuff (not ready, but won't do any harm)

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

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