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

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

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

Revision 160 Revision 161
938 int res=0; 938 int res=0;
939 int len=0; 939 int len=0;
940 int leng,i; 940 int leng,i;
941 psiconv_section_table_section table; 941 psiconv_section_table_section table;
942 psiconv_section_table_entry entry; 942 psiconv_section_table_entry entry;
943 psiconv_u32 icon_sec,display_sec,table_sec; 943 psiconv_u32 icon_sec=0,display_sec=0,table_sec=0;
944 944
945 psiconv_progress(lev+1,off+len,"Going to read an Embedded Object"); 945 psiconv_progress(lev+1,off+len,"Going to read an Embedded Object");
946 if (!(*result = malloc(sizeof(**result)))) 946 if (!(*result = malloc(sizeof(**result))))
947 goto ERROR1; 947 goto ERROR1;
948 948
973 psiconv_debug(lev+3,off+len,"Section ID %08x, offset %08x", 973 psiconv_debug(lev+3,off+len,"Section ID %08x, offset %08x",
974 entry->id, entry->offset); 974 entry->id, entry->offset);
975 } 975 }
976 } 976 }
977 977
978 psiconv_progress(lev+2,off+len,"Looking for the Object Display Section");
979 if (!icon_sec) {
980 psiconv_warn(lev+2,off+len,"Object Display Section not found");
981 (*result)->display = NULL;
982 } else {
983 psiconv_debug(lev+2,off+len,"Object Display Section at offset %08x",
984 display_sec);
985 if ((res = psiconv_parse_object_display_section(buf,lev+2,display_sec,NULL,
986 &(*result)->display)))
987 goto ERROR2;
988 }
989
990 psiconv_progress(lev+2,off+len,"Looking for the Object Icon Section");
991 if (!icon_sec) {
992 psiconv_warn(lev+2,off+len,"Object Icon Section not found");
993 (*result)->icon = NULL;
994 } else {
995 psiconv_debug(lev+2,off+len,"Object Icon Section at offset %08x",icon_sec);
996 if ((res = psiconv_parse_object_icon_section(buf,lev+2,icon_sec,NULL,
997 &(*result)->icon)))
998 goto ERROR2;
999 }
1000
1001 if (length)
1002 *length = len;
1003
978 psiconv_progress(lev+1,off+len-1,"End of Embedded Object Section " 1004 psiconv_progress(lev+1,off+len-1,"End of Embedded Object Section "
979 "(total length: %08x)",len); 1005 "(total length: %08x)",len);
1006
980 return res; 1007 return res;
981 1008
982 1009
983ERROR2: 1010ERROR2:
984 psiconv_free_section_table_section(table); 1011 psiconv_free_section_table_section(table);
985ERROR1: 1012ERROR1:
986 psiconv_warn(lev+1,off,"Reading Embedded Object failed"); 1013 psiconv_warn(lev+1,off,"Reading Embedded Object failed");
1014
987 if (length) 1015 if (length)
988 *length = 0; 1016 *length = 0;
1017
989 if (res == 0) 1018 if (res == 0)
990 return -PSICONV_E_NOMEM; 1019 return -PSICONV_E_NOMEM;
991 else 1020 else
992 return res; 1021 return res;
993} 1022}
1023
1024int psiconv_parse_object_display_section(const psiconv_buffer buf,int lev,
1025 psiconv_u32 off, int *length,
1026 psiconv_object_display_section *result)
1027{
1028 int res = 0;
1029 int len = 0;
1030 int leng;
1031 psiconv_u32 temp;
1032
1033 psiconv_progress(lev+1,off,"Going to read the Object Display Section");
1034 if (!(*result = malloc(sizeof(**result))))
1035 goto ERROR1;
1036
1037 psiconv_progress(lev+2,off+len,"Going to read the display as icon flag "
1038 "(expecting 0x00 or 0x01)");
1039 temp = psiconv_read_u8(buf,lev+2,off+len,&res);
1040 if (res)
1041 goto ERROR2;
1042 if (temp == 0x00) {
1043 (*result)->show_icon = psiconv_bool_true;
1044 psiconv_debug(lev+2,off+len,"Displayed as full document");
1045 } else if (temp == 0x01) {
1046 (*result)->show_icon = psiconv_bool_false;
1047 psiconv_debug(lev+2,off+len,"Displayed as icon");
1048 } else {
1049 psiconv_warn(lev+2,off+len,"Unknown Object Display Section Icon Flag");
1050 psiconv_debug(lev+2,off+len,"Icon flag found: %02x",temp);
1051 /* Improvise */
1052 (*result)->show_icon = (temp & 0x01?psiconv_bool_false:psiconv_bool_true);
1053 }
1054 len ++;
1055
1056 psiconv_progress(lev+2,off+len,"Going to read the icon width");
1057 (*result)->width = psiconv_read_length(buf,lev+2,off+len,&leng,&res);
1058 if (res)
1059 goto ERROR2;
1060 psiconv_debug(lev+2,off+len,"Icon width: %f cm",(*result)->width);
1061 len += leng;
1062
1063 psiconv_progress(lev+2,off+len,"Going to read the icon height");
1064 (*result)->height = psiconv_read_length(buf,lev+2,off+len,&leng,&res);
1065 if (res)
1066 goto ERROR2;
1067 psiconv_debug(lev+2,off+len,"Icon length: %f cm",(*result)->height);
1068 len += leng;
1069
1070 psiconv_progress(lev+2,off+len,"Going to read unknown long (%08x expected)",
1071 0);
1072 temp = psiconv_read_u32(buf,lev+2,off+len,&res);
1073 if (temp != 0) {
1074 psiconv_warn(lev+2,off+len,"Unknown Object Display Section final long");
1075 psiconv_debug(lev+2,off+len,"Long read: %08x",temp);
1076 }
1077 len += 4;
1078
1079 if (length)
1080 *length = len;
1081
1082 psiconv_progress(lev+1,off+len-1,"End of Object Display Section"
1083 "(total length: %08x",len);
1084 return res;
1085
1086ERROR2:
1087 free(*result);
1088ERROR1:
1089 psiconv_warn(lev+1,off+len,"Reading of Object Display Section failed");
1090 if (length)
1091 *length=0;
1092 if (!res)
1093 return -PSICONV_E_NOMEM;
1094 else
1095 return res;
1096}
1097
1098int psiconv_parse_object_icon_section(const psiconv_buffer buf,int lev,
1099 psiconv_u32 off, int *length,
1100 psiconv_object_icon_section *result)
1101{
1102 int res = 0;
1103 int len = 0;
1104 int leng;
1105
1106 psiconv_progress(lev+1,off,"Going to read the Object Icon Section");
1107 if (!(*result = malloc(sizeof(**result))))
1108 goto ERROR1;
1109
1110 psiconv_progress(lev+2,off+len,"Going to read the icon name");
1111 (*result)->icon_name = psiconv_read_string(buf,lev+2,off+len,&leng,&res);
1112 if (res)
1113 goto ERROR2;
1114 psiconv_debug(lev+2,off+len,"Icon name: %s",(*result)->icon_name);
1115 len += leng;
1116
1117 psiconv_progress(lev+2,off+len,"Going to read the icon width");
1118 (*result)->icon_width = psiconv_read_length(buf,lev+2,off+len,&leng,&res);
1119 if (res)
1120 goto ERROR3;
1121 psiconv_debug(lev+2,off+len,"Icon width: %f cm",(*result)->icon_width);
1122 len += leng;
1123
1124 psiconv_progress(lev+2,off+len,"Going to read the icon height");
1125 (*result)->icon_height = psiconv_read_length(buf,lev+2,off+len,&leng,&res);
1126 if (res)
1127 goto ERROR3;
1128 psiconv_debug(lev+2,off+len,"Icon length: %f cm",(*result)->icon_height);
1129 len += leng;
1130
1131 if (length)
1132 *length = len;
1133
1134 psiconv_progress(lev+1,off+len-1,"End of Object Icon Section"
1135 "(total length: %08x",len);
1136 return res;
1137
1138ERROR3:
1139 free((*result)->icon_name);
1140ERROR2:
1141 free(*result);
1142ERROR1:
1143 psiconv_warn(lev+1,off+len,"Reading of Object Icon Section failed");
1144 if (length)
1145 *length=0;
1146 if (!res)
1147 return -PSICONV_E_NOMEM;
1148 else
1149 return res;
1150}

Legend:
Removed from v.160  
changed lines
  Added in v.161

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