--- psiconv/trunk/lib/psiconv/parse_driver.c 2004/01/06 20:15:01 184 +++ psiconv/trunk/lib/psiconv/parse_driver.c 2004/02/26 21:33:52 237 @@ -1,6 +1,6 @@ /* parse_driver.c - Part of psiconv, a PSION 5 file formats converter - Copyright (c) 1999, 2000 Frodo Looijaard + Copyright (c) 1999-2004 Frodo Looijaard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,10 +31,21 @@ #include #endif -static psiconv_ucs2 unicode_paint[10] = { 'P','a','i','n','t','.','a','p','p',0 }; -static psiconv_ucs2 unicode_texted[11] ={ 'T','e','x','t','E','d','.','a','p','p',0 }; -static psiconv_ucs2 unicode_word[9] = { 'W','o','r','d','.','a','p','p',0 }; -static psiconv_ucs2 unicode_sheet[10] = { 'S','h','e','e','t','.','a','p','p',0 }; +/* Compare whether application id names match. + Sought must be lower case; the comparison is case insensitive */ +static psiconv_bool_t applid_matches(psiconv_string_t found, + const char *sought) +{ + int i; + if (psiconv_unicode_strlen(found) != strlen(sought)) + return psiconv_bool_false; + for (i = 0; i < strlen(sought); i++) + if ((found[i] != sought[i]) && + ((sought[i] < 'a') || (sought[i] > 'z') || + (found[i] != sought[i] + 'A' - 'a'))) + return psiconv_bool_false; + return psiconv_bool_true; +} psiconv_file_type_t psiconv_file_type(const psiconv_config config, psiconv_buffer buf,int *length, @@ -136,6 +147,7 @@ goto ERROR4; if ((res = psiconv_list_add((*result)->sections,clipart))) goto ERROR5; + free(clipart); } psiconv_free_jumptable_section(table); @@ -146,7 +158,7 @@ ERROR4: for (i = 0; i < psiconv_list_length((*result)->sections); i++) { if (!(clipart = psiconv_list_get((*result)->sections,i))) { - psiconv_error(config,lev+1,off,"Massive memory corruption"); + psiconv_error(config,lev+1,off,"Data structure corruption"); goto ERROR3; } psiconv_free_clipart_section(clipart); @@ -201,6 +213,7 @@ goto ERROR4; if ((res = psiconv_list_add((*result)->sections,paint))) goto ERROR5; + free(paint); } psiconv_free_jumptable_section(table); @@ -211,7 +224,7 @@ ERROR4: for (i = 0; i < psiconv_list_length((*result)->sections); i++) { if (!(paint = psiconv_list_get((*result)->sections,i))) { - psiconv_error(config,lev+1,off,"Massive memory corruption"); + psiconv_error(config,lev+1,off,"Data structure corruption"); goto ERROR3; } psiconv_free_paint_data_section(paint); @@ -293,7 +306,7 @@ goto ERROR3; } if ((appl_id->id != PSICONV_ID_SKETCH) || - psiconv_unicode_strcmp(appl_id->name,unicode_paint)) { + !applid_matches(appl_id->name,"paint.app")) { psiconv_warn(config,lev+2,applid_sec, "Application ID section contains unexpected data"); psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found", @@ -412,7 +425,7 @@ } if ((appl_id->id != PSICONV_ID_TEXTED) || - psiconv_unicode_strcmp(appl_id->name,unicode_texted)) { + !applid_matches(appl_id->name,"texted.app")) { psiconv_warn(config,lev+2,applid_sec, "Application ID section contains unexpected data"); psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found", @@ -595,7 +608,7 @@ goto ERROR4; } if ((appl_id->id != PSICONV_ID_WORD) || - psiconv_unicode_strcmp(appl_id->name,unicode_word)) { + !applid_matches(appl_id->name,"word.app")) { psiconv_warn(config,lev+2,applid_sec, "Application ID section contains unexpected data"); psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found", @@ -791,7 +804,7 @@ goto ERROR4; } if ((appl_id->id != PSICONV_ID_SHEET) || - psiconv_unicode_strcmp(appl_id->name,unicode_sheet)) { + !applid_matches(appl_id->name,"sheet.app")) { psiconv_warn(config,lev+2,applid_sec, "Application ID section contains unexpected data"); psiconv_debug(config,lev+2,applid_sec,"ID: %08x expected, %08x found",