Rev 385 | Rev 440 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 385 | Rev 408 | ||
---|---|---|---|
Line 71... | Line 71... | ||
71 | 71 | ||
72 | Boolean loadfile(StandardFileReply *sfr,char **reason){ |
72 | Boolean loadfile(StandardFileReply *sfr,char **reason){ |
73 | Boolean readok = false; |
73 | Boolean readok = false; |
74 | FInfo fndrInfo; |
74 | FInfo fndrInfo; |
75 | 75 | ||
- | 76 | // The different read-functions will return true if the resource was successfully loaded, |
|
- | 77 | // or false otherwise. If *reason is set, then the answer is clearly "No". If the result |
|
- | 78 | // is just false, it means that the program should continue with the next read-function. |
|
- | 79 | *reason = NULL; |
|
- | 80 | ||
76 | if(FSpGetFInfo(&sfr->sfFile,&fndrInfo) == noErr){ |
81 | if(FSpGetFInfo(&sfr->sfFile,&fndrInfo) == noErr){ |
77 | // first try to read text parameters (AFS, TXT, PFF) |
82 | // first try to read text parameters (AFS, TXT, PFF) |
- | 83 | if (*reason == NULL) { |
|
78 | if( (readok = readfile_afs_pff(sfr,reason)) ) { |
84 | if (readfile_afs_pff(sfr,reason)) { |
79 | gdata->parmloaded = false; |
85 | gdata->parmloaded = false; |
80 | gdata->obfusc = false; |
86 | gdata->obfusc = false; |
- | 87 | return true; |
|
- | 88 | } |
|
- | 89 | } |
|
81 | 90 | ||
82 | } // then try "Filters Unlimited" file (FFX) |
91 | // then try "Filters Unlimited" file (FFX) |
- | 92 | if (*reason == NULL) { |
|
83 | else if( (readok = readfile_ffx(sfr,reason)) ) { |
93 | if (readfile_ffx(sfr,reason)) { |
84 | gdata->parmloaded = true; |
94 | gdata->parmloaded = true; |
85 | gdata->obfusc = false; |
95 | gdata->obfusc = false; |
- | 96 | return true; |
|
- | 97 | } |
|
- | 98 | } |
|
86 | 99 | ||
87 | } // then try "PluginCommander TXT" file (TXT) |
100 | // then try "PluginCommander TXT" file (TXT) |
- | 101 | if (*reason == NULL) { |
|
88 | else if( (readok = readfile_picotxt(sfr,reason)) ) { |
102 | if (readfile_picotxt(sfr,reason)) { |
89 | gdata->parmloaded = true; |
103 | gdata->parmloaded = true; |
90 | gdata->obfusc = false; |
104 | gdata->obfusc = false; |
- | 105 | return true; |
|
- | 106 | } |
|
- | 107 | } |
|
91 | 108 | ||
92 | } // then try plugin formats (Mac first, then Windows .8bf or .prm DLL) |
- | |
93 | else if( (readok = readmacplugin(sfr,reason) || readfile_8bf(sfr,reason)) ){ |
- | |
94 | if ((gdata->parm.cbSize != PARM_SIZE) && (gdata->parm.cbSize != PARM_SIZE_PREMIERE) && (gdata->parm.cbSize != PARM_SIG_MAC)) { |
- | |
95 | *reason = "Incompatible obfuscation."; |
109 | // Try Mac plugin resource |
96 | //gdata->parmloaded = false; |
110 | if (*reason == NULL) { |
97 | return false; // Stop! We know the issue now. |
111 | if (readmacplugin(sfr,reason)) { |
98 | }else if(gdata->parm.iProtected){ |
112 | if (gdata->parm.iProtected) { |
99 | *reason = "The filter is protected."; |
113 | *reason = "The filter is protected."; |
- | 114 | } else { |
|
100 | //gdata->parmloaded = false; |
115 | gdata->parmloaded = true; |
101 | return false; |
116 | return true; |
- | 117 | } |
|
- | 118 | } |
|
- | 119 | } |
|
- | 120 | ||
- | 121 | // Try Windows resources (we need to do a binary scan) |
|
- | 122 | // Note that we cannot detect obfuscated filters here! |
|
- | 123 | if (*reason == NULL) { |
|
- | 124 | if (readfile_8bf(sfr,reason)) { |
|
- | 125 | if (gdata->parm.iProtected) { |
|
- | 126 | *reason = "The filter is protected."; |
|
102 | }else |
127 | } else { |
103 | gdata->parmloaded = true; |
128 | gdata->parmloaded = true; |
- | 129 | return true; |
|
104 | }else |
130 | } |
105 | *reason = "It is not a text parameter (AFS) file, nor a standalone Mac/PC filter made by Filter Factory/Filter Foundry."; |
- | |
- | 131 | } |
|
106 | } |
132 | } |
107 | 133 | ||
- | 134 | // We didn't had success. If we have a clear reason, return false and the reason. |
|
- | 135 | // If we don't have a clear reason, set a generic reason and return false. |
|
- | 136 | if (*reason == NULL) { |
|
- | 137 | *reason = "It is not a text parameter file, nor a standalone Mac/PC filter created by Filter Factory/Filter Foundry."; |
|
- | 138 | } |
|
108 | return readok; |
139 | return false; |
- | 140 | } else { |
|
- | 141 | *reason = "File cannot be opened"; |
|
- | 142 | return false; |
|
- | 143 | } |
|
109 | } |
144 | } |