Rev 192 | Rev 211 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | toby | 1 | /* |
18 | toby | 2 | This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop |
192 | daniel-mar | 3 | Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.com.au |
206 | daniel-mar | 4 | Copyright (C) 2018-2021 Daniel Marschall, ViaThinkSoft |
2 | toby | 5 | |
6 | This program is free software; you can redistribute it and/or modify |
||
145 | dmarschall | 7 | it under the terms of the GNU General Public License as published by |
2 | toby | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. |
||
10 | |||
11 | This program is distributed in the hope that it will be useful, |
||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
14 | GNU General Public License for more details. |
||
15 | |||
145 | dmarschall | 16 | You should have received a copy of the GNU General Public License |
2 | toby | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
19 | */ |
||
20 | |||
21 | #include "ff.h" |
||
22 | |||
85 | toby | 23 | #include <Resources.h> |
45 | toby | 24 | |
2 | toby | 25 | #include "file_compat.h" |
26 | |||
87 | toby | 27 | Boolean readPARMresource(HMODULE hm,char **reason,int readobfusc){ |
2 | toby | 28 | Boolean res = false; |
85 | toby | 29 | Handle h; |
30 | |||
31 | if( !(h = Get1Resource(PARM_TYPE,PARM_ID)) |
||
87 | toby | 32 | && readobfusc |
85 | toby | 33 | && (h = Get1Resource('DATA',OBFUSCDATA_ID)) ){ |
34 | HLock(h); |
||
35 | obfusc((unsigned char*)*h,GetHandleSize(h)); |
||
36 | } |
||
23 | toby | 37 | if(h){ |
2 | toby | 38 | HLock(h); |
45 | toby | 39 | res = readPARM(*h, &gdata->parm, reason, 0 /*Mac format resource*/); |
2 | toby | 40 | ReleaseResource(h); |
41 | } |
||
42 | return res; |
||
43 | } |
||
44 | |||
85 | toby | 45 | static Boolean readmacplugin(StandardFileReply *sfr,char **reason){ |
45 | toby | 46 | Boolean res = false; |
47 | short rrn = FSpOpenResFile(&sfr->sfFile,fsRdPerm); |
||
145 | dmarschall | 48 | |
85 | toby | 49 | if(rrn != -1){ |
87 | toby | 50 | if(readPARMresource(NULL,reason,0)) |
45 | toby | 51 | res = true; |
52 | CloseResFile(rrn); |
||
53 | }else |
||
54 | *reason = "Could not open file."; |
||
55 | return res; |
||
56 | } |
||
57 | |||
2 | toby | 58 | Boolean loadfile(StandardFileReply *sfr,char **reason){ |
59 | Boolean readok = false; |
||
60 | FInfo fndrInfo; |
||
61 | |||
188 | dmarschall | 62 | if(FSpGetFInfo(&sfr->sfFile,&fndrInfo) == noErr){ |
145 | dmarschall | 63 | // first try to read text parameters (AFS, TXT, PFF) |
45 | toby | 64 | if( (readok = readfile(sfr,reason)) ) |
65 | gdata->parmloaded = false; |
||
147 | dmarschall | 66 | // then try plugin formats (Mac first, then Windows .8bf or .prm DLL) |
45 | toby | 67 | else if( (readok = readmacplugin(sfr,reason) || read8bfplugin(sfr,reason)) ){ |
68 | if(gdata->parm.iProtected){ |
||
69 | *reason = "The filter is protected."; |
||
70 | return false; |
||
71 | }else |
||
72 | gdata->parmloaded = true; |
||
85 | toby | 73 | }else |
74 | *reason = "It is not a text parameter (AFS) file, nor a standalone Mac/PC filter made by Filter Factory/Filter Foundry."; |
||
45 | toby | 75 | } |
2 | toby | 76 | |
77 | return readok; |
||
78 | } |