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

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

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

Revision 168 Revision 184
62 return 0; 62 return 0;
63 63
64ERROR2: 64ERROR2:
65 free(*result); 65 free(*result);
66ERROR1: 66ERROR1:
67 psiconv_warn(config,lev+1,off,"Reading of Color failed"); 67 psiconv_error(config,lev+1,off,"Reading of Color failed");
68 if (length) 68 if (length)
69 *length = 0; 69 *length = 0;
70 if (res == 0) 70 if (res == 0)
71 return -PSICONV_E_NOMEM; 71 return -PSICONV_E_NOMEM;
72 else 72 else
78int psiconv_parse_font(const psiconv_config config, 78int psiconv_parse_font(const psiconv_config config,
79 const psiconv_buffer buf, int lev, psiconv_u32 off, 79 const psiconv_buffer buf, int lev, psiconv_u32 off,
80 int *length, psiconv_font *result) 80 int *length, psiconv_font *result)
81{ 81{
82 int res = 0; 82 int res = 0;
83 int strlength,i;
84 char *str_copy; 83 char *str_copy;
85 int len; 84 int len=0;
85 int fontlen;
86 86
87 psiconv_progress(config,lev+1,off,"Going to parse font"); 87 psiconv_progress(config,lev+1,off,"Going to parse font");
88 if (!(*result = malloc(sizeof(**result)))) 88 if (!(*result = malloc(sizeof(**result))))
89 goto ERROR1; 89 goto ERROR1;
90 90
91 strlength = psiconv_read_u8(config,buf,lev+2,off,&res); 91 fontlen = psiconv_read_u8(config,buf,lev+2,off,&res);
92 if (res) 92 if (res)
93 goto ERROR2; 93 goto ERROR2;
94 if (!((*result)->name = malloc(strlength))) { 94 len = 1;
95
96 (*result)->name = psiconv_read_charlist(config,buf,lev+2,off, fontlen-1,&res);
97 if (res)
95 goto ERROR2; 98 goto ERROR2;
96 } 99 len += fontlen - 1;
97 for (i = 0; (i < strlength-1) && !res; i++) 100
98 (*result)->name[i] = psiconv_read_u8(config,buf,lev+2,off + 1 + i,&res); 101 (*result)->screenfont = psiconv_read_u8(config,buf,lev+2,off+len,&res);
99 if (res) 102 if (res)
100 goto ERROR3; 103 goto ERROR3;
101 (*result)->name[strlength-1] = 0; 104
102 (*result)->screenfont = psiconv_read_u8(config,buf,lev+2,off + strlength,&res); 105 if (!(str_copy = psiconv_make_printable(config,(*result)->name)))
103 if (res)
104 goto ERROR3; 106 goto ERROR3;
105 107
106 if (!(str_copy = psiconv_make_printable((*result)->name))) 108 psiconv_debug(config,lev+2,off+len,
107 goto ERROR3; 109 "Found font `%s', displayed with screen font %02x",
108
109 psiconv_debug(config,lev+2,off+1,"Found font `%s', displayed with screen font %02x",
110 str_copy,(*result)->screenfont); 110 str_copy,(*result)->screenfont);
111 free(str_copy); 111 free(str_copy);
112 len = strlength + 1; 112 len ++;
113
113 if (length) 114 if (length)
114 *length = len; 115 *length = len;
115 116
116 psiconv_progress(config,lev+1,off + len - 1,"End of font (total length: %08x)",len); 117 psiconv_progress(config,lev+1,off + len - 1,
118 "End of font (total length: %08x)",len);
117 return 0; 119 return 0;
118 120
119ERROR3: 121ERROR3:
120 free ((*result)->name); 122 free ((*result)->name);
121ERROR2: 123ERROR2:
122 free (*result); 124 free (*result);
123ERROR1: 125ERROR1:
124 psiconv_warn(config,lev+1,off,"Reading of Font failed"); 126 psiconv_error(config,lev+1,off,"Reading of Font failed");
125 if (length) 127 if (length)
126 *length = 0; 128 *length = 0;
127 if (!res) 129 if (!res)
128 return -PSICONV_E_NOMEM; 130 return -PSICONV_E_NOMEM;
129 else 131 else
214ERROR3: 216ERROR3:
215 psiconv_free_color((*result)->color); 217 psiconv_free_color((*result)->color);
216ERROR2: 218ERROR2:
217 free (result); 219 free (result);
218ERROR1: 220ERROR1:
219 psiconv_warn(config,lev+1,off,"Reading of Border failed"); 221 psiconv_error(config,lev+1,off,"Reading of Border failed");
220 if (length) 222 if (length)
221 *length = 0; 223 *length = 0;
222 if (!res) 224 if (!res)
223 return -PSICONV_E_NOMEM; 225 return -PSICONV_E_NOMEM;
224 else 226 else
231{ 233{
232 int res = 0; 234 int res = 0;
233 int len = 0; 235 int len = 0;
234 int leng; 236 int leng;
235 int bullet_length; 237 int bullet_length;
238 psiconv_u8 temp;
236 239
237 if (!(*result = malloc(sizeof(**result)))) 240 if (!(*result = malloc(sizeof(**result))))
238 goto ERROR1; 241 goto ERROR1;
239 (*result)->on = psiconv_bool_true; 242 (*result)->on = psiconv_bool_true;
240 243
251 if (res) 254 if (res)
252 goto ERROR2; 255 goto ERROR2;
253 len +=leng; 256 len +=leng;
254 257
255 psiconv_progress(config,lev+2,off+len,"Going to read bullet character"); 258 psiconv_progress(config,lev+2,off+len,"Going to read bullet character");
256 (*result)->character = psiconv_read_u8(config,buf,lev+2,off+len,&res); 259 temp = psiconv_read_u8(config,buf,lev+2,off+len,&res);
257 if (res) 260 if (res)
258 goto ERROR2; 261 goto ERROR2;
262 (*result)->character = psiconv_unicode_from_char(config,temp);
259 psiconv_debug(config,lev+2,off+len,"Character: %02x",(*result)->character); 263 psiconv_debug(config,lev+2,off+len,"Character: %02x",(*result)->character);
260 len ++; 264 len ++;
261 265
262 psiconv_progress(config,lev+2,off+len,"Going to read indent on/off"); 266 psiconv_progress(config,lev+2,off+len,"Going to read indent on/off");
263 if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,&(*result)->indent))) 267 if ((res = psiconv_parse_bool(config,buf,lev+2,off+len,&leng,&(*result)->indent)))
291ERROR3: 295ERROR3:
292 psiconv_free_color((*result)->color); 296 psiconv_free_color((*result)->color);
293ERROR2: 297ERROR2:
294 free (result); 298 free (result);
295ERROR1: 299ERROR1:
296 psiconv_warn(config,lev+1,off,"Reading of Bullet failed"); 300 psiconv_error(config,lev+1,off,"Reading of Bullet failed");
297 if (length) 301 if (length)
298 *length = 0; 302 *length = 0;
299 if (!res) 303 if (!res)
300 return -PSICONV_E_NOMEM; 304 return -PSICONV_E_NOMEM;
301 else 305 else
347 return 0; 351 return 0;
348 352
349ERROR2: 353ERROR2:
350 free (result); 354 free (result);
351ERROR1: 355ERROR1:
352 psiconv_warn(config,lev+1,off,"Reading of Tab failed"); 356 psiconv_error(config,lev+1,off,"Reading of Tab failed");
353 if (length) 357 if (length)
354 *length = 0; 358 *length = 0;
355 if (!res) 359 if (!res)
356 return -PSICONV_E_NOMEM; 360 return -PSICONV_E_NOMEM;
357 else 361 else
602 } 606 }
603 nr ++; 607 nr ++;
604 } 608 }
605 609
606 if (len - 4 != list_length) { 610 if (len - 4 != list_length) {
607 psiconv_warn(config,lev+2,off+len, 611 psiconv_error(config,lev+2,off+len,
608 "Read past end of paragraph layout codes list. I probably lost track" 612 "Read past end of paragraph layout codes list. I probably lost track "
609 "somewhere!"); 613 "somewhere!");
610 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d", 614 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
611 len-4,list_length); 615 len-4,list_length);
612 res = PSICONV_E_PARSE; 616 res = PSICONV_E_PARSE;
613 goto ERROR1; 617 goto ERROR1;
621 if (length) 625 if (length)
622 *length = len; 626 *length = len;
623 return 0; 627 return 0;
624 628
625ERROR1: 629ERROR1:
626 psiconv_warn(config,lev+1,off,"Reading of paragraph_layout_list failed"); 630 psiconv_error(config,lev+1,off,"Reading of paragraph_layout_list failed");
627 if (length) 631 if (length)
628 *length = 0; 632 *length = 0;
629 if (!res) 633 if (!res)
630 return -PSICONV_E_NOMEM; 634 return -PSICONV_E_NOMEM;
631 else 635 else
771 } 775 }
772 nr ++; 776 nr ++;
773 } 777 }
774 778
775 if (len - 4 != list_length) { 779 if (len - 4 != list_length) {
776 psiconv_warn(config,lev+2,off+len, 780 psiconv_error(config,lev+2,off+len,
777 "Read past end of character layout codes list. I probably lost track" 781 "Read past end of character layout codes list. I probably lost track "
778 "somewhere!"); 782 "somewhere!");
779 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d", 783 psiconv_debug(config,lev+2,off+len,"Read %d characters instead of %d",
780 len-4,list_length); 784 len-4,list_length);
781 res = PSICONV_E_PARSE; 785 res = PSICONV_E_PARSE;
782 goto ERROR1; 786 goto ERROR1;
790 if (length) 794 if (length)
791 *length = len; 795 *length = len;
792 return res; 796 return res;
793 797
794ERROR1: 798ERROR1:
795 psiconv_warn(config,lev+1,off,"Reading of character_layout_list failed"); 799 psiconv_error(config,lev+1,off,"Reading of character_layout_list failed");
796 if (length) 800 if (length)
797 *length = 0; 801 *length = 0;
798 if (!res) 802 if (!res)
799 return -PSICONV_E_NOMEM; 803 return -PSICONV_E_NOMEM;
800 else 804 else

Legend:
Removed from v.168  
changed lines
  Added in v.184

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