- sprintf(err,"101:Unsupported format, id0=0x81\n");\r
- return 101;\r
- }\r
- FFH=new FontFileHeader;\r
- if(!FFH)\r
- {\r
- sprintf(err,"116:Not enough memory for FFH\n");\r
- fclose(CPI);\r
- remove("tempcpi");\r
- return 116;\r
+ status=spawnlp(P_WAIT,"cpx2cpi","cpx2cpi",nazwap,"__TEMP__.com","q",NULL);\r
+ if(status==-1)//and there is no cpx2cpi\r
+ {\r
+ sprintf(err,"150:CPX not supported, install cpx2cpi\n");\r
+ return 150;\r
+ }\r
+ if(status)//not converted\r
+ {\r
+ sprintf(err,"151:CPX decompression failed");\r
+ if (status<3)//but file is created\r
+ remove("__TEMP__.com");\r
+ return 151;\r
+ }\r
+ CPX=true;\r
+ CPI=fopen("__TEMP__.com","rb");\r
+ if(CPI==NULL)//converted to an unopenable file\r
+ {\r
+ sprintf(err,"152:Cannot open decompressed file");\r
+ return 152;\r
+ }\r
+ FFH=new FontFileHeader;\r
+ if(!FFH)\r
+ {\r
+ sprintf(err,"116:Not enough memory for FFH\n");\r
+ fclose(CPI);\r
+ remove("__TEMP__.com");\r
+ return 116;\r
+ }\r
+ fread(FFH,0x19,1,CPI);\r
+ if(FFH->id0!=0xff)\r
+ //converted to cpi but it's not a cpi\r
+ {\r
+ sprintf(err,"101:Unsupported format, id0=0x%02x\n",(short)(FFH->id0&0xff));\r
+ fclose(CPI);\r
+ remove("__TEMP__.com");\r
+ deleteCPI(0);\r
+ return 101;\r
+ }\r