Subversion Repositories filter_foundry

Compare Revisions

Regard whitespace Rev 553 → Rev 552

/trunk/ff.h
134,7 → 134,7
void parm_cleanup();
 
// from read.c
FFLoadingResult readparams_afs_pff(Handle h, Boolean premiereOrder);
FFLoadingResult readparams_afs_pff(Handle h);
void convert_premiere_to_photoshop(PARM_T* photoshop, PARM_T_PREMIERE* premiere);
FFLoadingResult readfile_8bf(StandardFileReply *sfr);
Handle readfileintohandle(FILEREF r);
/trunk/language.h
275,7 → 275,6
// TODO: Give own IDs and Translate
#define MSG_OUT_OF_MEMORY_ID 14
#define MSG_INVALID_FILE_SIGNATURE_ID 6
#define MSG_FFL_NO_FILTERS_DETECTED_ID 6
 
void strcpy_advance_id(TCHAR** str, int msgid);
int FF_GetMsg(TCHAR* ret, int MsgId);
/trunk/main.c
608,7 → 608,7
}
}
 
if( (bUninitializedParams = !(params && (0 == readparams_afs_pff(params, false)))) ){
if( (bUninitializedParams = !(params && (0 == readparams_afs_pff(params)))) ){
/* either the parameter handle was uninitialised,
or the parameter data couldn't be read; set default values */
 
/trunk/read.c
36,7 → 36,7
#define BUFSIZE 4L<<10
#define MAXLINE 0x200
 
FFLoadingResult readparams_afs_pff(Handle h, Boolean premiereOrder){
FFLoadingResult readparams_afs_pff(Handle h){
FFLoadingResult res = MSG_LOADFILE_UNKNOWN_FORMAT_ID;
char linebuf[MAXLINE] = { 0 };
char curexpr[MAXEXPR] = { 0 };
67,7 → 67,8
/* process complete line */
if(linecnt==0){
if(strcmp(linebuf,"%RGB-1.0") != 0){
res = MSG_INVALID_FILE_SIGNATURE_ID;
// Note: We don't set res to an error message, because we cannot be sure if it is a valid file in regards to a different data type
// We only set res to an error message, if we are sure that it is an AFS file which is indeed wrong.
break;
}
}else if(linecnt<=8){
87,15 → 88,7
}else{
/* it's an empty line: we've completed the expr string */
*q = '\0';
if (premiereOrder) {
// Premiere has the order BGRA , while Photoshop (and our internal order) is RGBA
if (exprcnt == 0) strcpy(gdata->parm.szFormula[2], curexpr);
else if (exprcnt == 2) strcpy(gdata->parm.szFormula[0], curexpr);
else strcpy(gdata->parm.szFormula[exprcnt], curexpr);
}
else {
strcpy(gdata->parm.szFormula[exprcnt], curexpr);
}
 
if(++exprcnt == 4){
res = 0;
861,15 → 854,23
if ((h = readfileintohandle(refnum))) {
FILECOUNT count = (FILECOUNT)PIGETHANDLESIZE(h);
char* q = PILOCKHANDLE(h, false);
char protocol[256];
 
if (!_gufReadProperty(q, count, "GUF", "Protocol", protocol, sizeof(protocol))) {
res = MSG_INVALID_FILE_SIGNATURE_ID;
char out[256];
if (_gufReadProperty(q, count, "GUF", "Protocol", out, sizeof(out))) {
if (strcmp(out, "1") != 0) {
PIUNLOCKHANDLE(h);
PIDISPOSEHANDLE(h);
FSClose(refnum);
return MSG_INCOMPATIBLE_GUF_FILE_ID;
}
else if (strcmp(protocol, "1") != 0) {
res = MSG_INCOMPATIBLE_GUF_FILE_ID;
}
else {
PIUNLOCKHANDLE(h);
PIDISPOSEHANDLE(h);
FSClose(refnum);
return MSG_INCOMPATIBLE_GUF_FILE_ID;
}
if (_gufReadProperty(q, count, "Info", "Title", out, sizeof(out))) {
int i;
char tmp[256];
char* tmp2;
945,12 → 946,14
 
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;
if( 0 == (res = readparams_afs_pff(h)) ) {
if (fileHasExtension(sfr, TEXT(".pff"))) {
// If it is a Premiere settings file, we need to swap the channels red and blue
// We just swap the pointers!
char tmp[MAXEXPR];
strcpy(tmp, gdata->parm.szFormula[0]);
strcpy(gdata->parm.szFormula[0], gdata->parm.szFormula[2]);
strcpy(gdata->parm.szFormula[2], tmp);
}
}
 
967,14 → 970,12
FFLoadingResult readfile_ffl(StandardFileReply* sfr) {
FILEREF rTmp, refnum;
Handle h, hTmp;
FFLoadingResult res = 0;
FFLoadingResult res = MSG_LOADFILE_UNKNOWN_FORMAT_ID;
StandardFileReply sfrTmp;
OSErr e;
char* p, * start;
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) {
989,9 → 990,11
// This is required to make strtok work, because q is not zero-terminated...
q2 = (char*)malloc(count + 1/*NUL byte*/);
if (q2 == NULL) {
res = MSG_OUT_OF_MEMORY_ID;
PIUNLOCKHANDLE(h);
PIDISPOSEHANDLE(h);
FSClose(refnum);
return MSG_OUT_OF_MEMORY_ID;
}
else {
memcpy(q2, q, count);
q2[count] = '\0';
 
1004,8 → 1007,11
}
if (lineNumber == 0) {
if (strcmp(token2, "FFL1.0") != 0) {
res = MSG_INVALID_FILE_SIGNATURE_ID;
break;
free(q2);
PIUNLOCKHANDLE(h);
PIDISPOSEHANDLE(h);
FSClose(refnum);
return MSG_INVALID_FILE_SIGNATURE_ID;
}
}
else if (lineNumber == 1) {
1144,7 → 1150,6
lineNumber++;
token = strtok(NULL, "\n");
}
}
 
free(q2);
 
1154,8 → 1159,6
FSClose(refnum);
}
 
if (res == 0) {
res = foundFilters == 0 ? MSG_FFL_NO_FILTERS_DETECTED_ID : MSG_FFL_CONVERTED_ID;
}
return res;
// TODO: show a different message when no filters were processed for some reason...
return MSG_FFL_CONVERTED_ID;
}
/trunk/ui.c
341,8 → 341,6
TCHAR* filters, *title;
Boolean loadDlgRet;
 
showDialogAgain:
 
title = (TCHAR*)malloc(1024);
if (title == NULL) return false;
 
427,8 → 425,6
 
if (res == MSG_FFL_CONVERTED_ID) {
showmessage_id(res);
//return maindlgitem(dp, item); // call open Dialog again
goto showDialogAgain;
}
else {
TCHAR* reason = FF_GetMsg_Cpy(res);