1 | /* |
1 | /* |
2 | generate_simple.c - Part of psiconv, a PSION 5 file formats converter |
2 | generate_simple.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. |
… | |
… | |
148 | |
148 | |
149 | int psiconv_write_string_aux(const psiconv_config config,psiconv_buffer buf, |
149 | int psiconv_write_string_aux(const psiconv_config config,psiconv_buffer buf, |
150 | int lev, const psiconv_string_t value,int kind) |
150 | int lev, const psiconv_string_t value,int kind) |
151 | { |
151 | { |
152 | int res,i,len; |
152 | int res,i,len; |
153 | psiconv_u8 *output; |
|
|
154 | |
153 | |
155 | psiconv_progress(config,lev,0,"Writing string (auxiliary)"); |
154 | psiconv_progress(config,lev,0,"Writing string (auxiliary)"); |
156 | len = psiconv_unicode_strlen(value); |
155 | len = psiconv_unicode_strlen(value); |
157 | if (!value) { |
156 | if (!value) { |
158 | psiconv_error(config,0,psiconv_buffer_length(buf), |
157 | psiconv_error(config,0,psiconv_buffer_length(buf), |
… | |
… | |
166 | else |
165 | else |
167 | res = 0; |
166 | res = 0; |
168 | if (res) |
167 | if (res) |
169 | return res; |
168 | return res; |
170 | |
169 | |
171 | if ((res = psiconv_unicode_to_chars(config,value,&output))) |
|
|
172 | return res; |
|
|
173 | |
|
|
174 | for (i = 0; i < len; i++) |
170 | for (i = 0; i < len; i++) |
175 | if ((res = psiconv_write_u8(config,buf,lev+1,output[i]))) { |
171 | if ((res = psiconv_unicode_write_char(config,buf,lev+1,value[i]))) |
176 | free(output); |
|
|
177 | return res; |
172 | return res; |
178 | } |
|
|
179 | free(output); |
|
|
180 | return -PSICONV_E_OK; |
173 | return -PSICONV_E_OK; |
181 | } |
174 | } |
182 | |
175 | |
183 | int psiconv_write_offset(const psiconv_config config,psiconv_buffer buf, |
176 | int psiconv_write_offset(const psiconv_config config,psiconv_buffer buf, |
184 | int lev,psiconv_u32 id) |
177 | int lev,psiconv_u32 id) |