… | |
… | |
78 | int psiconv_parse_font(const psiconv_config config, |
78 | int 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; |
|
|
84 | int len=0; |
85 | int len; |
85 | int leng; |
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); |
|
|
92 | if (res) |
|
|
93 | goto ERROR2; |
|
|
94 | if (!((*result)->name = malloc(strlength))) { |
|
|
95 | goto ERROR2; |
|
|
96 | } |
|
|
97 | for (i = 0; (i < strlength-1) && !res; i++) |
|
|
98 | (*result)->name[i] = psiconv_read_u8(config,buf,lev+2,off + 1 + i,&res); |
91 | (*result)->name = psiconv_read_short_string(config,buf,lev+2,off+len, |
|
|
92 | &leng,&res); |
99 | if (res) |
93 | if (res) |
100 | goto ERROR3; |
94 | goto ERROR2; |
101 | (*result)->name[strlength-1] = 0; |
95 | len += leng; |
|
|
96 | |
102 | (*result)->screenfont = psiconv_read_u8(config,buf,lev+2,off + strlength,&res); |
97 | (*result)->screenfont = psiconv_read_u8(config,buf,lev+2,off+len,&res); |
103 | if (res) |
98 | if (res) |
104 | goto ERROR3; |
99 | goto ERROR3; |
105 | |
100 | |
106 | if (!(str_copy = psiconv_make_printable((*result)->name))) |
101 | if (!(str_copy = psiconv_make_printable((*result)->name))) |
107 | goto ERROR3; |
102 | goto ERROR3; |
108 | |
103 | |
109 | psiconv_debug(config,lev+2,off+1,"Found font `%s', displayed with screen font %02x", |
104 | psiconv_debug(config,lev+2,off+len, |
|
|
105 | "Found font `%s', displayed with screen font %02x", |
110 | str_copy,(*result)->screenfont); |
106 | str_copy,(*result)->screenfont); |
111 | free(str_copy); |
107 | free(str_copy); |
112 | len = strlength + 1; |
108 | len ++; |
|
|
109 | |
113 | if (length) |
110 | if (length) |
114 | *length = len; |
111 | *length = len; |
115 | |
112 | |
116 | psiconv_progress(config,lev+1,off + len - 1,"End of font (total length: %08x)",len); |
113 | psiconv_progress(config,lev+1,off + len - 1, |
|
|
114 | "End of font (total length: %08x)",len); |
117 | return 0; |
115 | return 0; |
118 | |
116 | |
119 | ERROR3: |
117 | ERROR3: |
120 | free ((*result)->name); |
118 | free ((*result)->name); |
121 | ERROR2: |
119 | ERROR2: |