… | |
… | |
23 | #include <stdlib.h> |
23 | #include <stdlib.h> |
24 | |
24 | |
25 | #include "generate_routines.h" |
25 | #include "generate_routines.h" |
26 | #include "error.h" |
26 | #include "error.h" |
27 | |
27 | |
28 | int psiconv_generate_word_status_section(psiconv_buffer buf, |
28 | int psiconv_write_word_status_section(psiconv_buffer buf, |
29 | psiconv_word_status_section value) |
29 | psiconv_word_status_section value) |
30 | { |
30 | { |
31 | int res; |
31 | int res; |
32 | |
32 | |
33 | if (!value) { |
33 | if (!value) { |
34 | psiconv_warn(0,psiconv_list_length(buf),"Null word status section"); |
34 | psiconv_warn(0,psiconv_buffer_length(buf),"Null word status section"); |
35 | return -PSICONV_E_GENERATE; |
35 | return -PSICONV_E_GENERATE; |
36 | } |
36 | } |
37 | |
37 | |
38 | if ((res = psiconv_write_u8(buf,0x02))) |
38 | if ((res = psiconv_write_u8(buf,0x02))) |
39 | return res; |
39 | return res; |
… | |
… | |
66 | psiconv_paragraph_layout basepara; |
66 | psiconv_paragraph_layout basepara; |
67 | psiconv_character_layout basechar; |
67 | psiconv_character_layout basechar; |
68 | |
68 | |
69 | |
69 | |
70 | if (!value || !value->normal || !value->styles) { |
70 | if (!value || !value->normal || !value->styles) { |
71 | psiconv_warn(0,psiconv_list_length(buf),"Null word styles section"); |
71 | psiconv_warn(0,psiconv_buffer_length(buf),"Null word styles section"); |
72 | res = -PSICONV_E_GENERATE; |
72 | res = -PSICONV_E_GENERATE; |
73 | goto ERROR1; |
73 | goto ERROR1; |
74 | } |
74 | } |
75 | |
75 | |
76 | if (!(basepara=psiconv_basic_paragraph_layout())) { |
76 | if (!(basepara=psiconv_basic_paragraph_layout())) { |
… | |
… | |
97 | |
97 | |
98 | |
98 | |
99 | |
99 | |
100 | for (i = 0; i < psiconv_list_length(value->styles); i++) { |
100 | for (i = 0; i < psiconv_list_length(value->styles); i++) { |
101 | if (!(style = psiconv_list_get(value->styles,i))) { |
101 | if (!(style = psiconv_list_get(value->styles,i))) { |
102 | psiconv_warn(0,psiconv_list_length(buf),"Massive memory corruption"); |
102 | psiconv_warn(0,psiconv_buffer_length(buf),"Massive memory corruption"); |
103 | res = -PSICONV_E_OTHER; |
103 | res = -PSICONV_E_OTHER; |
104 | goto ERROR3; |
104 | goto ERROR3; |
105 | } |
105 | } |
106 | if ((res = psiconv_write_u32(buf,style->hotkey))) |
106 | if ((res = psiconv_write_u32(buf,style->hotkey))) |
107 | goto ERROR3; |
107 | goto ERROR3; |
108 | } |
108 | } |
109 | if ((res = psiconv_write_u8(buf,psiconv_list_length(value->styles)))) |
109 | if ((res = psiconv_write_u8(buf,psiconv_list_length(value->styles)))) |
110 | goto ERROR3; |
110 | goto ERROR3; |
111 | for (i = 0; i < psiconv_list_length(value->styles); i++) { |
111 | for (i = 0; i < psiconv_list_length(value->styles); i++) { |
112 | if (!(style = psiconv_list_get(value->styles,i))) { |
112 | if (!(style = psiconv_list_get(value->styles,i))) { |
113 | psiconv_warn(0,psiconv_list_length(buf),"Massive memory corruption"); |
113 | psiconv_warn(0,psiconv_buffer_length(buf),"Massive memory corruption"); |
114 | res = -PSICONV_E_OTHER; |
114 | res = -PSICONV_E_OTHER; |
115 | goto ERROR3; |
115 | goto ERROR3; |
116 | } |
116 | } |
117 | if (!style->name) { |
117 | if (!style->name) { |
118 | psiconv_warn(0,psiconv_list_length(buf),"Null style name"); |
118 | psiconv_warn(0,psiconv_buffer_length(buf),"Null style name"); |
119 | res = -PSICONV_E_GENERATE; |
119 | res = -PSICONV_E_GENERATE; |
120 | goto ERROR3; |
120 | goto ERROR3; |
121 | } |
121 | } |
122 | if ((res = psiconv_write_string(buf,style->name))) |
122 | if ((res = psiconv_write_string(buf,style->name))) |
123 | goto ERROR3; |
123 | goto ERROR3; |
… | |
… | |
131 | goto ERROR3; |
131 | goto ERROR3; |
132 | if ((res = psiconv_write_paragraph_layout_list(buf,style->paragraph, |
132 | if ((res = psiconv_write_paragraph_layout_list(buf,style->paragraph, |
133 | value->normal->paragraph))) |
133 | value->normal->paragraph))) |
134 | goto ERROR3; |
134 | goto ERROR3; |
135 | } |
135 | } |
136 | res = -PSICONV_E_OK; |
136 | if ((res = psiconv_write_u8(buf,0xff))) |
|
|
137 | goto ERROR3; |
|
|
138 | if ((res = psiconv_write_u8(buf,0xff))) |
|
|
139 | goto ERROR3; |
|
|
140 | res = psiconv_write_u8(buf,0xff); |
137 | |
141 | |
138 | ERROR3: |
142 | ERROR3: |
139 | psiconv_free_character_layout(basechar); |
143 | psiconv_free_character_layout(basechar); |
140 | ERROR2: |
144 | ERROR2: |
141 | psiconv_free_paragraph_layout(basepara); |
145 | psiconv_free_paragraph_layout(basepara); |