Subversion Repositories filter_foundry

Compare Revisions

Regard whitespace Rev 553 → Rev 554

/trunk/load_mac.c
91,6 → 91,7
gdata->obfusc = false;
return 0;
}
if (res == MSG_INVALID_FILE_SIGNATURE_ID) res = MSG_LOADFILE_UNKNOWN_FORMAT_ID;
}
 
// Try to read the file as FFL file
100,6 → 101,7
gdata->obfusc = false;
return 0;
}
if (res == MSG_INVALID_FILE_SIGNATURE_ID) res = MSG_LOADFILE_UNKNOWN_FORMAT_ID;
}
 
// then try "Filters Unlimited" file (FFX)
108,6 → 110,7
gdata->obfusc = false;
return 0;
}
if (res == MSG_INVALID_FILE_SIGNATURE_ID) res = MSG_LOADFILE_UNKNOWN_FORMAT_ID;
}
 
// then try "PluginCommander TXT" file (TXT)
/trunk/load_win.c
93,7 → 93,13
parm_reset(true, false, true, false);
return 0;
}
if (!fileHasExtension(sfr, TEXT(".afs")) && !fileHasExtension(sfr, TEXT(".pff"))) {
// If .afs and .pff files have an invalid signature, then it is a hard error.
// If any other file has no "%RGB1.0" signature, then it is OK and
// we will return MSG_LOADFILE_UNKNOWN_FORMAT_ID and continue with trying other formats
if (res == MSG_INVALID_FILE_SIGNATURE_ID) res = MSG_LOADFILE_UNKNOWN_FORMAT_ID;
}
}
 
// Try to read the file as FFL file
if (res == MSG_LOADFILE_UNKNOWN_FORMAT_ID) {
102,8 → 108,27
parm_reset(true, true, true, true);
return 0;
}
if (!fileHasExtension(sfr, TEXT(".ffl"))) {
// If .ffl files have an invalid signature, then it is a hard error.
// If any other file has no "FFL1.0" signature, then it is OK and
// we will return MSG_LOADFILE_UNKNOWN_FORMAT_ID and continue with trying other formats
if (res == MSG_INVALID_FILE_SIGNATURE_ID) res = MSG_LOADFILE_UNKNOWN_FORMAT_ID;
}
}
 
// Is it a "Filters Unlimited" FFX filter? (Only partially compatible with Filter Factory!!!)
if (res == MSG_LOADFILE_UNKNOWN_FORMAT_ID) {
if (0 == (res = readfile_ffx(sfr))) {
return 0;
}
if (!fileHasExtension(sfr, TEXT(".ffx"))) {
// If .ffx files have an invalid signature, then it is a hard error.
// If any other file has no "FFX1.0", "FFX1.1", or "FFX1.2" signature, then it is OK and
// we will return MSG_LOADFILE_UNKNOWN_FORMAT_ID and continue with trying other formats
if (res == MSG_INVALID_FILE_SIGNATURE_ID) res = MSG_LOADFILE_UNKNOWN_FORMAT_ID;
}
}
 
// If that didn't work, try to load as Windows image file (Resource API for 8BF/PRM files)
if (res == MSG_LOADFILE_UNKNOWN_FORMAT_ID) {
if (hm = LoadLibraryEx(sfr->sfFile.szName, NULL, LOAD_LIBRARY_AS_DATAFILE)) {
122,26 → 147,23
}
}
 
// Is it a "Filters Unlimited" FFX filter? (Only partially compatible with Filter Factory!!!)
if (res == MSG_LOADFILE_UNKNOWN_FORMAT_ID) {
if (0 == (res = readfile_ffx(sfr))) {
return 0;
}
}
 
// Is it a "Filters Unlimited" TXT filter? (Only partially compatible with Filter Factory!!!)
if (res == MSG_LOADFILE_UNKNOWN_FORMAT_ID) {
if (fileHasExtension(sfr, TEXT(".txt"))) {
if (0 == (res = readfile_picotxt_or_ffdecomp(sfr))) {
return 0;
}
}
}
 
// Is it a "GIMP UserFilter (GUF)" file? (Only partially compatible with Filter Factory!!!)
if (res == MSG_LOADFILE_UNKNOWN_FORMAT_ID) {
if (fileHasExtension(sfr, TEXT(".guf"))) {
if (0 == (res = readfile_guf(sfr))) {
return 0;
}
}
}
 
// If nothing worked, we will try to find a PARM resource (MacOS plugin, or 64 bit 8BF on Win32 OS)
// Note that we cannot detect obfuscated filters here!
/trunk/read.c
208,13 → 208,17
char* q = (char*)PILOCKHANDLE(h, false);
 
len = *((uint32_t*)q);
if (len == 6) {
if (len != 6) {
res = MSG_INVALID_FILE_SIGNATURE_ID;
} else {
val = _ffx_read_str(&q);
if (strcmp(val, "FFX1.0") == 0) format_version = 10;
else if (strcmp(val, "FFX1.1") == 0) format_version = 11;
else if (strcmp(val, "FFX1.2") == 0) format_version = 12;
free(val);
if (format_version > 0) {
if (format_version < 0) {
res = MSG_INVALID_FILE_SIGNATURE_ID;
} else {
simplewarning_id(MSG_FILTERS_UNLIMITED_WARNING_ID);
 
val = _ffx_read_str(&q);
328,7 → 332,7
FSClose(refnum);
}
 
if (res) gdata->obfusc = false;
if (res == 0) gdata->obfusc = false;
return res;
}
 
352,7 → 356,7
for( count /= 4 ; count >= PARM_SIZE/4 ; --count, ++q )
{
res = readPARM(&gdata->parm, (Ptr)q);
if (res) break;
if (res == 0) break;
}
 
PIDISPOSEHANDLE(h);
363,7 → 367,7
}else
res = MSG_CANNOT_OPEN_FILE_ID;
 
if (res) gdata->obfusc = false;
if (res == 0) gdata->obfusc = false;
return res;
}
 
697,8 → 701,6
FFLoadingResult res = MSG_LOADFILE_UNKNOWN_FORMAT_ID;
FILEREF refnum;
 
if (!fileHasExtension(sfr, TEXT(".txt"))) return MSG_LOADFILE_UNKNOWN_FORMAT_ID;
 
if (FSpOpenDF(&sfr->sfFile, fsRdPerm, &refnum) == noErr) {
if ((h = readfileintohandle(refnum))) {
FILECOUNT count = (FILECOUNT)PIGETHANDLESIZE(h);
855,8 → 857,6
 
// TODO: Decode UTF-8 to ANSI (or "?" for unknown characters)
 
if (!fileHasExtension(sfr, TEXT(".guf"))) return MSG_LOADFILE_UNKNOWN_FORMAT_ID;
 
if (FSpOpenDF(&sfr->sfFile, fsRdPerm, &refnum) == noErr) {
if ((h = readfileintohandle(refnum))) {
FILECOUNT count = (FILECOUNT)PIGETHANDLESIZE(h);
945,15 → 945,10
 
if(FSpOpenDF(&sfr->sfFile,fsRdPerm,&r) == noErr){
if( (h = readfileintohandle(r)) ){
if( 0 != (res = readparams_afs_pff(h, fileHasExtension(sfr, TEXT(".pff")))) ) {
// If .afs and .pff files are not recognized, then it is a hard error.
// If a .txt file has no "%RGB1.0" signature, then it is OK and
// we will return MSG_LOADFILE_UNKNOWN_FORMAT_ID to inform the caller that they shall continue trying formats.
if (!fileHasExtension(sfr, TEXT(".afs")) && !fileHasExtension(sfr, TEXT(".pff"))) {
if (res == MSG_INVALID_FILE_SIGNATURE_ID) res = MSG_LOADFILE_UNKNOWN_FORMAT_ID;
}
}
 
// Note in re fileHasExtension(): Mac does not have file extensions like Windows,
// so, the detection if the channel order is BGRA (Premiere *.pff) or RGBA (Photoshop *.afs)
// is not possible, except if the file has an extension (e.g. when it was copied from a Windows system)
res = readparams_afs_pff(h, fileHasExtension(sfr, TEXT(".pff")));
PIDISPOSEHANDLE(h);
}
FSClose(r);
974,9 → 969,6
size_t est;
int foundFilters = 0;
 
// TODO: sollte von außerhalb gesteuert werden [auch bei anderen]
if (!fileHasExtension(sfr, TEXT(".ffl"))) return MSG_LOADFILE_UNKNOWN_FORMAT_ID;
 
if (FSpOpenDF(&sfr->sfFile, fsRdPerm, &refnum) == noErr) {
if ((h = readfileintohandle(refnum))) {
FILECOUNT count = (FILECOUNT)PIGETHANDLESIZE(h);
984,8 → 976,12
 
char* q2, * tmp_cur_filter_str[29], *token;
int lineNumber = 0;
int countFilters = 0;
 
if (strstr(q, "FFL1.0") != q) {
res = MSG_INVALID_FILE_SIGNATURE_ID;
}
else {
 
// This is required to make strtok work, because q is not zero-terminated...
q2 = (char*)malloc(count + 1/*NUL byte*/);
if (q2 == NULL) {
1003,13 → 999,19
if (token2[i] == '\r') token2[i] = '\0';
}
if (lineNumber == 0) {
// We already checked it above (in order to avoid an unnecessary memory copy)
/*
if (strcmp(token2, "FFL1.0") != 0) {
res = MSG_INVALID_FILE_SIGNATURE_ID;
break;
}
*/
}
else if (lineNumber == 1) {
else if (lineNumber > 1) {
// We don't check that. We just stop at every 28th line of each filter
/*
countFilters = atoi(token2);
*/
}
else
{
1147,6 → 1149,7
}
 
free(q2);
}
 
PIUNLOCKHANDLE(h);
PIDISPOSEHANDLE(h);