Subversion Repositories filter_foundry

Rev

Rev 556 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 556 Rev 557
Line 96... Line 96...
96
                                        else {
96
                                        else {
97
                                                strcpy(gdata->parm.szFormula[exprcnt], curexpr);
97
                                                strcpy(gdata->parm.szFormula[exprcnt], curexpr);
98
                                        }
98
                                        }
99
 
99
 
100
                                        if(++exprcnt == 4){
100
                                        if(++exprcnt == 4){
101
                                                res = 0;
101
                                                res = LOADING_OK;
102
                                                break; /* got everything we want */
102
                                                break; /* got everything we want */
103
                                        }
103
                                        }
104
 
104
 
105
                                        q = curexpr; /* empty current expr, ready for next one */
105
                                        q = curexpr; /* empty current expr, ready for next one */
106
                                }
106
                                }
Line 322... Line 322...
322
                                        strcpy(gdata->parm.szMap[0], "Map 0:");
322
                                        strcpy(gdata->parm.szMap[0], "Map 0:");
323
                                        strcpy(gdata->parm.szMap[1], "Map 1:");
323
                                        strcpy(gdata->parm.szMap[1], "Map 1:");
324
                                        strcpy(gdata->parm.szMap[2], "Map 2:");
324
                                        strcpy(gdata->parm.szMap[2], "Map 2:");
325
                                        strcpy(gdata->parm.szMap[3], "Map 3:");
325
                                        strcpy(gdata->parm.szMap[3], "Map 3:");
326
 
326
 
327
                                        res = 0;
327
                                        res = LOADING_OK;
328
                                }
328
                                }
329
                        }
329
                        }
330
                        PIDISPOSEHANDLE(h);
330
                        PIDISPOSEHANDLE(h);
331
                }
331
                }
332
                FSClose(refnum);
332
                FSClose(refnum);
333
        }
333
        }
334
 
334
 
335
        if (res == 0) gdata->obfusc = false;
335
        if (res == LOADING_OK) gdata->obfusc = false;
336
        return res;
336
        return res;
337
}
337
}
338
 
338
 
339
FFLoadingResult readfile_8bf(StandardFileReply *sfr){
339
FFLoadingResult readfile_8bf(StandardFileReply *sfr){
340
        unsigned char magic[2];
340
        unsigned char magic[2];
Line 354... Line 354...
354
                                        // look for signature at start of valid PARM resource
354
                                        // look for signature at start of valid PARM resource
355
                                        // This signature is observed in Filter Factory standalones.
355
                                        // This signature is observed in Filter Factory standalones.
356
                                        for( count /= 4 ; count >= PARM_SIZE/4 ; --count, ++q )
356
                                        for( count /= 4 ; count >= PARM_SIZE/4 ; --count, ++q )
357
                                        {
357
                                        {
358
                                                res = readPARM(&gdata->parm, (Ptr)q);
358
                                                res = readPARM(&gdata->parm, (Ptr)q);
359
                                                if (res == 0) break;
359
                                                if (res == LOADING_OK) break;
360
                                        }
360
                                        }
361
 
361
 
362
                                        PIDISPOSEHANDLE(h);
362
                                        PIDISPOSEHANDLE(h);
363
                                }
363
                                }
364
                        }
364
                        }
365
                } // else no point in proceeding
365
                } // else no point in proceeding
366
                FSClose(refnum);
366
                FSClose(refnum);
367
        }else
367
        }else
368
                res = MSG_CANNOT_OPEN_FILE_ID;
368
                res = MSG_CANNOT_OPEN_FILE_ID;
369
 
369
 
370
        if (res == 0) gdata->obfusc = false;
370
        if (res == LOADING_OK) gdata->obfusc = false;
371
        return res;
371
        return res;
372
}
372
}
373
 
373
 
374
FFLoadingResult readPARM(PARM_T* pparm, Ptr p){
374
FFLoadingResult readPARM(PARM_T* pparm, Ptr p){
375
        Boolean towin, tomac, fromwin, frommac;
375
        Boolean towin, tomac, fromwin, frommac;
Line 758... Line 758...
758
                                                sprintf(keyname, "map[%d]", i);
758
                                                sprintf(keyname, "map[%d]", i);
759
                                                _picoReadProperty(q, count, keyname, gdata->parm.szMap[i], sizeof(gdata->parm.szMap[i]), false);
759
                                                _picoReadProperty(q, count, keyname, gdata->parm.szMap[i], sizeof(gdata->parm.szMap[i]), false);
760
                                        }
760
                                        }
761
                                }
761
                                }
762
 
762
 
763
                                res = 0;
763
                                res = LOADING_OK;
764
                        }
764
                        }
765
 
765
 
766
                        PIUNLOCKHANDLE(h);
766
                        PIUNLOCKHANDLE(h);
767
                        PIDISPOSEHANDLE(h);
767
                        PIDISPOSEHANDLE(h);
768
                }
768
                }
Line 791... Line 791...
791
        iTmp = strlen(inputwork) + strlen("\n\n[");
791
        iTmp = strlen(inputwork) + strlen("\n\n[");
792
        tmpFileContents = (char*)malloc(iTmp + 1/*NUL byte*/);
792
        tmpFileContents = (char*)malloc(iTmp + 1/*NUL byte*/);
793
        if (tmpFileContents == NULL) return false;
793
        if (tmpFileContents == NULL) return false;
794
        sprintf(tmpFileContents, "\n%s\n[", inputwork);
794
        sprintf(tmpFileContents, "\n%s\n[", inputwork);
795
        for (iTmp = 0; iTmp < strlen(tmpFileContents); iTmp++) {
795
        for (iTmp = 0; iTmp < strlen(tmpFileContents); iTmp++) {
796
                if (tmpFileContents[iTmp] == '\r') tmpFileContents[iTmp] = '\n';
796
                if (tmpFileContents[iTmp] == CR) tmpFileContents[iTmp] = LF;
797
        }
797
        }
798
 
798
 
799
        // Find the section begin
799
        // Find the section begin
800
        iTmp = strlen(section) + strlen("\n[]\n");
800
        iTmp = strlen(section) + strlen("\n[]\n");
801
        tmpSection = (char*)malloc(iTmp + 1/*NUL byte*/);
801
        tmpSection = (char*)malloc(iTmp + 1/*NUL byte*/);
Line 924... Line 924...
924
                                                sprintf(keyname, "Map %d", i);
924
                                                sprintf(keyname, "Map %d", i);
925
                                                _gufReadProperty(q, count, keyname, "Label", gdata->parm.szMap[i], sizeof(gdata->parm.szMap[i]));
925
                                                _gufReadProperty(q, count, keyname, "Label", gdata->parm.szMap[i], sizeof(gdata->parm.szMap[i]));
926
                                        }
926
                                        }
927
                                }
927
                                }
928
 
928
 
929
                                res = 0;
929
                                res = LOADING_OK;
930
                        }
930
                        }
931
 
931
 
932
                        PIUNLOCKHANDLE(h);
932
                        PIUNLOCKHANDLE(h);
933
                        PIDISPOSEHANDLE(h);
933
                        PIDISPOSEHANDLE(h);
934
                }
934
                }
Line 960... Line 960...
960
}
960
}
961
 
961
 
962
FFLoadingResult readfile_ffl(StandardFileReply* sfr) {
962
FFLoadingResult readfile_ffl(StandardFileReply* sfr) {
963
        FILEREF rTmp, refnum;
963
        FILEREF rTmp, refnum;
964
        Handle h, hTmp;
964
        Handle h, hTmp;
965
        FFLoadingResult res = 0;
965
        FFLoadingResult res = LOADING_OK;
966
        StandardFileReply sfrTmp;
966
        StandardFileReply sfrTmp;
967
        OSErr e;
967
        OSErr e;
968
        char* p, * start;
968
        char* p, * start;
969
        size_t est;
969
        size_t est;
970
        int foundFilters = 0;
970
        int foundFilters = 0;
Line 1000... Line 1000...
1000
                                                token = strtok(q2, "\n");
1000
                                                token = strtok(q2, "\n");
1001
                                                while (token != NULL) {
1001
                                                while (token != NULL) {
1002
                                                        size_t i;
1002
                                                        size_t i;
1003
                                                        char* token2 = my_strdup(token);
1003
                                                        char* token2 = my_strdup(token);
1004
                                                        for (i = 0; i < strlen(token2); i++) {
1004
                                                        for (i = 0; i < strlen(token2); i++) {
1005
                                                                if (token2[i] == '\r') token2[i] = '\0';
1005
                                                                if (token2[i] == CR) token2[i] = '\0';
1006
                                                        }
1006
                                                        }
1007
                                                        if (lineNumber == 0) {
1007
                                                        if (lineNumber == 0) {
1008
                                                                // We already checked it above (in order to avoid an unnecessary memory copy)
1008
                                                                // We already checked it above (in order to avoid an unnecessary memory copy)
1009
                                                                /*
1009
                                                                /*
1010
                                                                if (strcmp(token2, "FFL1.0") != 0) {
1010
                                                                if (strcmp(token2, "FFL1.0") != 0) {
Line 1175... Line 1175...
1175
                        PIDISPOSEHANDLE(h);
1175
                        PIDISPOSEHANDLE(h);
1176
                }
1176
                }
1177
                FSClose(refnum);
1177
                FSClose(refnum);
1178
        }
1178
        }
1179
 
1179
 
1180
        if (res == 0) {
1180
        if (res == LOADING_OK) {
1181
                res = foundFilters == 0 ? MSG_FFL_NO_FILTERS_DETECTED_ID : MSG_FFL_CONVERTED_ID;
1181
                res = foundFilters == 0 ? MSG_FFL_NO_FILTERS_DETECTED_ID : MSG_FFL_CONVERTED_ID;
1182
        }
1182
        }
1183
        return res;
1183
        return res;
1184
}
1184
}
1185
1185