Subversion Repositories filter_foundry

Compare Revisions

Regard whitespace Rev 552 → Rev 553

/trunk/ff.h
134,7 → 134,7
void parm_cleanup();
 
// from read.c
FFLoadingResult readparams_afs_pff(Handle h);
FFLoadingResult readparams_afs_pff(Handle h, Boolean premiereOrder);
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,6 → 275,7
// 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)))) ){
if( (bUninitializedParams = !(params && (0 == readparams_afs_pff(params, false)))) ){
/* 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){
FFLoadingResult readparams_afs_pff(Handle h, Boolean premiereOrder){
FFLoadingResult res = MSG_LOADFILE_UNKNOWN_FORMAT_ID;
char linebuf[MAXLINE] = { 0 };
char curexpr[MAXEXPR] = { 0 };
67,8 → 67,7
/* process complete line */
if(linecnt==0){
if(strcmp(linebuf,"%RGB-1.0") != 0){
// 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.
res = MSG_INVALID_FILE_SIGNATURE_ID;
break;
}
}else if(linecnt<=8){
88,7 → 87,15
}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;
854,23 → 861,15
if ((h = readfileintohandle(refnum))) {
FILECOUNT count = (FILECOUNT)PIGETHANDLESIZE(h);
char* q = PILOCKHANDLE(h, false);
char protocol[256];
 
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;
if (!_gufReadProperty(q, count, "GUF", "Protocol", protocol, sizeof(protocol))) {
res = MSG_INVALID_FILE_SIGNATURE_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;
946,14 → 945,12
 
if(FSpOpenDF(&sfr->sfFile,fsRdPerm,&r) == noErr){
if( (h = readfileintohandle(r)) ){
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);
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;
}
}
 
970,12 → 967,14
FFLoadingResult readfile_ffl(StandardFileReply* sfr) {
FILEREF rTmp, refnum;
Handle h, hTmp;
FFLoadingResult res = MSG_LOADFILE_UNKNOWN_FORMAT_ID;
FFLoadingResult res = 0;
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) {
990,11 → 989,9
// This is required to make strtok work, because q is not zero-terminated...
q2 = (char*)malloc(count + 1/*NUL byte*/);
if (q2 == NULL) {
PIUNLOCKHANDLE(h);
PIDISPOSEHANDLE(h);
FSClose(refnum);
return MSG_OUT_OF_MEMORY_ID;
res = MSG_OUT_OF_MEMORY_ID;
}
else {
memcpy(q2, q, count);
q2[count] = '\0';
 
1007,11 → 1004,8
}
if (lineNumber == 0) {
if (strcmp(token2,"FFL1.0") != 0) {
free(q2);
PIUNLOCKHANDLE(h);
PIDISPOSEHANDLE(h);
FSClose(refnum);
return MSG_INVALID_FILE_SIGNATURE_ID;
res = MSG_INVALID_FILE_SIGNATURE_ID;
break;
}
}
else if (lineNumber == 1) {
1150,6 → 1144,7
lineNumber++;
token = strtok(NULL, "\n");
}
}
 
free(q2);
 
1159,6 → 1154,8
FSClose(refnum);
}
 
// TODO: show a different message when no filters were processed for some reason...
return MSG_FFL_CONVERTED_ID;
if (res == 0) {
res = foundFilters == 0 ? MSG_FFL_NO_FILTERS_DETECTED_ID : MSG_FFL_CONVERTED_ID;
}
return res;
}
/trunk/ui.c
341,6 → 341,8
TCHAR* filters, *title;
Boolean loadDlgRet;
 
showDialogAgain:
 
title = (TCHAR*)malloc(1024);
if (title == NULL) return false;
 
425,6 → 427,8
 
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);