git-svn: trunk@3359
Nigel Horne authored on 2007/11/07 02:11:12... | ... |
@@ -917,30 +917,6 @@ typedef struct macro_info_tag { |
917 | 917 |
struct macro_entry_tag *macro_entry; |
918 | 918 |
} macro_info_t; |
919 | 919 |
|
920 |
-#if 0 |
|
921 |
-typedef struct macro_extname_tag { |
|
922 |
- uint8_t length; |
|
923 |
- unsigned char *extname; |
|
924 |
- uint16_t numref; |
|
925 |
-} macro_extname_t; |
|
926 |
- |
|
927 |
-typedef struct macro_extnames_tag { |
|
928 |
- uint16_t count; |
|
929 |
- struct macro_extname_tag *macro_extname; |
|
930 |
-} macro_extnames_t; |
|
931 |
-#endif |
|
932 |
- |
|
933 |
-typedef struct macro_intnames_tag { |
|
934 |
- uint16_t count; |
|
935 |
- struct macro_intname_tag *macro_intname; |
|
936 |
-} macro_intnames_t; |
|
937 |
- |
|
938 |
-typedef struct macro_intname_tag { |
|
939 |
- uint16_t id; |
|
940 |
- uint8_t length; |
|
941 |
- unsigned char *intname; |
|
942 |
-} macro_intname_t; |
|
943 |
- |
|
944 | 920 |
typedef struct menu_entry_tag { |
945 | 921 |
uint16_t context; |
946 | 922 |
uint16_t menu; |
... | ... |
@@ -961,7 +937,6 @@ typedef struct mac_token2_tag { |
961 | 961 |
|
962 | 962 |
} mac_token2_t; |
963 | 963 |
|
964 |
-static void wm_free_intnames(macro_intnames_t *macro_intnames); |
|
965 | 964 |
static void wm_free_macro_info(macro_info_t *macro_info); |
966 | 965 |
|
967 | 966 |
static void wm_print_fib(mso_fib_t *fib) |
... | ... |
@@ -1176,9 +1151,9 @@ wm_skip_macro_extnames(int fd) |
1176 | 1176 |
} |
1177 | 1177 |
|
1178 | 1178 |
if(is_unicode) |
1179 |
- offset = length * 2 + 1; |
|
1179 |
+ offset = (off_t)length * 2 + 1; |
|
1180 | 1180 |
else |
1181 |
- offset = length; |
|
1181 |
+ offset = (off_t)length; |
|
1182 | 1182 |
|
1183 | 1183 |
offset += sizeof(uint16_t); /* numref */ |
1184 | 1184 |
if(lseek(fd, offset, SEEK_CUR) == -1) { |
... | ... |
@@ -1189,78 +1164,39 @@ wm_skip_macro_extnames(int fd) |
1189 | 1189 |
return TRUE; |
1190 | 1190 |
} |
1191 | 1191 |
|
1192 |
-static macro_intnames_t *wm_read_macro_intnames(int fd) |
|
1192 |
+static int |
|
1193 |
+wm_skip_macro_intnames(int fd) |
|
1193 | 1194 |
{ |
1194 |
- uint16_t i, junk; |
|
1195 |
- macro_intnames_t *macro_intnames; |
|
1196 |
- macro_intname_t *macro_intname; |
|
1195 |
+ uint16_t i, count; |
|
1197 | 1196 |
|
1198 |
- macro_intnames = (macro_intnames_t *) cli_malloc(sizeof(macro_intnames_t)); |
|
1199 |
- if (!macro_intnames) { |
|
1200 |
- return NULL; |
|
1201 |
- } |
|
1202 |
- |
|
1203 |
- if (cli_readn(fd, ¯o_intnames->count, 2) != 2) { |
|
1197 |
+ if (cli_readn(fd, &count, sizeof(uint16_t)) != sizeof(uint16_t)) { |
|
1204 | 1198 |
cli_dbgmsg("read macro_intnames failed\n"); |
1205 |
- return NULL; |
|
1199 |
+ return FALSE; |
|
1206 | 1200 |
} |
1207 |
- macro_intnames->count = vba_endian_convert_16(macro_intnames->count, FALSE); |
|
1208 |
- cli_dbgmsg("int names count: %d\n", macro_intnames->count); |
|
1201 |
+ count = vba_endian_convert_16(count, FALSE); |
|
1202 |
+ cli_dbgmsg("int names count: %u\n", count); |
|
1209 | 1203 |
|
1210 |
- macro_intnames->macro_intname = |
|
1211 |
- (macro_intname_t *) cli_malloc(sizeof(macro_intname_t) * macro_intnames->count); |
|
1212 |
- if (!macro_intnames->macro_intname) { |
|
1213 |
- free(macro_intnames); |
|
1214 |
- return NULL; |
|
1215 |
- } |
|
1216 |
- for (i=0 ; i < macro_intnames->count ; i++) { |
|
1217 |
- macro_intname = ¯o_intnames->macro_intname[i]; |
|
1218 |
- if (cli_readn(fd, ¯o_intname->id, 2) != 2) { |
|
1219 |
- cli_dbgmsg("read macro_intnames failed\n"); |
|
1220 |
- macro_intnames->count = i; |
|
1221 |
- goto abort; |
|
1222 |
- } |
|
1223 |
- macro_intname->id = vba_endian_convert_16(macro_intname->id, FALSE); |
|
1224 |
- if (cli_readn(fd, ¯o_intname->length, 1) != 1) { |
|
1225 |
- cli_dbgmsg("read macro_intnames failed\n"); |
|
1226 |
- macro_intnames->count = i; |
|
1227 |
- goto abort; |
|
1228 |
- } |
|
1229 |
- macro_intname->intname = (unsigned char *)cli_malloc(macro_intname->length+1); |
|
1230 |
- if (!macro_intname->intname) { |
|
1231 |
- macro_intnames->count = i; |
|
1232 |
- goto abort; |
|
1233 |
- } |
|
1234 |
- if (cli_readn(fd, macro_intname->intname, macro_intname->length) != macro_intname->length) { |
|
1235 |
- cli_dbgmsg("read macro_intnames failed\n"); |
|
1236 |
- macro_intnames->count = (uint16_t)(i + 1); |
|
1237 |
- goto abort; |
|
1238 |
- } |
|
1239 |
- macro_intname->intname[macro_intname->length] = '\0'; |
|
1240 |
- if (cli_readn(fd, &junk, 1) != 1) { |
|
1241 |
- cli_dbgmsg("read macro_intnames failed\n"); |
|
1242 |
- macro_intnames->count = (uint16_t)(i + 1); |
|
1243 |
- goto abort; |
|
1204 |
+ for(i = 0; i < count; i++) { |
|
1205 |
+ uint8_t length; |
|
1206 |
+ |
|
1207 |
+ /* id */ |
|
1208 |
+ if(lseek(fd, sizeof(uint16_t), SEEK_CUR) == -1) { |
|
1209 |
+ cli_dbgmsg("skip_macro_intnames failed\n"); |
|
1210 |
+ return FALSE; |
|
1244 | 1211 |
} |
1245 |
- cli_dbgmsg("int name: %s\n", (char *)macro_intname->intname); |
|
1246 |
- } |
|
1247 |
- return macro_intnames; |
|
1248 |
-abort: |
|
1249 |
- wm_free_intnames(macro_intnames); |
|
1250 |
- return NULL; |
|
1251 |
-} |
|
1252 | 1212 |
|
1253 |
-static void |
|
1254 |
-wm_free_intnames(macro_intnames_t *macro_intnames) |
|
1255 |
-{ |
|
1256 |
- if (macro_intnames) { |
|
1257 |
- int i; |
|
1213 |
+ if(cli_readn(fd, &length, sizeof(uint8_t)) != sizeof(uint8_t)) { |
|
1214 |
+ cli_dbgmsg("skip_macro_intnames failed\n"); |
|
1215 |
+ return FALSE; |
|
1216 |
+ } |
|
1258 | 1217 |
|
1259 |
- for(i = 0; i < macro_intnames->count; i++) |
|
1260 |
- free(macro_intnames->macro_intname[i].intname); |
|
1261 |
- free(macro_intnames->macro_intname); |
|
1262 |
- free(macro_intnames); |
|
1218 |
+ /* Internal name, plus one byte of unknown data */ |
|
1219 |
+ if(lseek(fd, length + 1, SEEK_CUR) == -1) { |
|
1220 |
+ cli_dbgmsg("skip_macro_intnames failed\n"); |
|
1221 |
+ return FALSE; |
|
1222 |
+ } |
|
1263 | 1223 |
} |
1224 |
+ return TRUE; |
|
1264 | 1225 |
} |
1265 | 1226 |
|
1266 | 1227 |
vba_project_t *wm_dir_read(const char *dir) |
... | ... |
@@ -1303,8 +1239,6 @@ vba_project_t *wm_dir_read(const char *dir) |
1303 | 1303 |
done = FALSE; |
1304 | 1304 |
|
1305 | 1305 |
while ((lseek(fd, 0, SEEK_CUR) < end_offset) && !done) { |
1306 |
- macro_intnames_t *macro_intnames; |
|
1307 |
- |
|
1308 | 1306 |
if (cli_readn(fd, &info_id, 1) != 1) { |
1309 | 1307 |
cli_dbgmsg("read macro_info failed\n"); |
1310 | 1308 |
close(fd); |
... | ... |
@@ -1312,10 +1246,11 @@ vba_project_t *wm_dir_read(const char *dir) |
1312 | 1312 |
} |
1313 | 1313 |
switch (info_id) { |
1314 | 1314 |
case 0x01: |
1315 |
+ if(macro_info) |
|
1316 |
+ wm_free_macro_info(macro_info); |
|
1315 | 1317 |
macro_info = wm_read_macro_info(fd); |
1316 |
- if (macro_info == NULL) { |
|
1318 |
+ if(macro_info == NULL) |
|
1317 | 1319 |
done = TRUE; |
1318 |
- } |
|
1319 | 1320 |
break; |
1320 | 1321 |
case 0x03: |
1321 | 1322 |
if(!wm_read_oxo3(fd)) |
... | ... |
@@ -1330,10 +1265,7 @@ vba_project_t *wm_dir_read(const char *dir) |
1330 | 1330 |
done = TRUE; |
1331 | 1331 |
break; |
1332 | 1332 |
case 0x11: |
1333 |
- macro_intnames = wm_read_macro_intnames(fd); |
|
1334 |
- if(macro_intnames) |
|
1335 |
- wm_free_intnames(macro_intnames); |
|
1336 |
- else |
|
1333 |
+ if(!wm_skip_macro_intnames(fd)) |
|
1337 | 1334 |
done = TRUE; |
1338 | 1335 |
break; |
1339 | 1336 |
case 0x12: |