Subversion Repositories filter_foundry

Rev

Rev 255 | Rev 268 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 255 Rev 259
1
/*
1
/*
2
    This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
2
    This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
3
    Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.com.au
3
    Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.com.au
4
    Copyright (C) 2018-2021 Daniel Marschall, ViaThinkSoft
4
    Copyright (C) 2018-2021 Daniel Marschall, ViaThinkSoft
5
 
5
 
6
    This program is free software; you can redistribute it and/or modify
6
    This program is free software; you can redistribute it and/or modify
7
    it under the terms of the GNU General Public License as published by
7
    it under the terms of the GNU General Public License as published by
8
    the Free Software Foundation; either version 2 of the License, or
8
    the Free Software Foundation; either version 2 of the License, or
9
    (at your option) any later version.
9
    (at your option) any later version.
10
 
10
 
11
    This program is distributed in the hope that it will be useful,
11
    This program is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU General Public License for more details.
14
    GNU General Public License for more details.
15
 
15
 
16
    You should have received a copy of the GNU General Public License
16
    You should have received a copy of the GNU General Public License
17
    along with this program; if not, write to the Free Software
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
18
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
*/
19
*/
20
 
20
 
21
#include <plstringfuncs.h>
21
#include <plstringfuncs.h>
22
#include <ASRegistry.h>
22
#include <ASRegistry.h>
23
#include <ctype.h>
23
#include <ctype.h>
24
 
24
 
25
#include "ff.h"
25
#include "ff.h"
26
 
26
 
27
#include "file_compat.h"
27
#include "file_compat.h"
28
 
28
 
29
// MoreFiles headers
29
// MoreFiles headers
30
#include "FileCopy.h"
30
#include "FileCopy.h"
31
#include "MoreFilesExtras.h"
31
#include "MoreFilesExtras.h"
32
 
32
 
33
// prototype for a function included in Carbon's stdlib and declared in /usr/include/string.h
33
// prototype for a function included in Carbon's stdlib and declared in /usr/include/string.h
34
// but missing from MPW Universal header string.h
34
// but missing from MPW Universal header string.h
35
#ifndef _STRING_H_
35
#ifndef _STRING_H_
36
        char    *strnstr(const char *, const char *, size_t);
36
        char    *strnstr(const char *, const char *, size_t);
37
#endif
37
#endif
38
 
38
 
39
static OSErr doresources(FSSpec *srcplug, FSSpec *rsrccopy){
39
static OSErr doresources(FSSpec *srcplug, FSSpec *rsrccopy){
40
        short srcrn,dstrn;
40
        short srcrn,dstrn;
41
        Handle hpipl,h;
41
        Handle hpipl,h;
42
        long origsize,newsize,parm_type,parm_id;
42
        long origsize,newsize,parm_type,parm_id;
43
        OSErr e = noErr;
43
        OSErr e = noErr;
44
        Str255 title;
44
        Str255 title;
45
        long event_id;
45
        long event_id;
46
 
46
 
47
#ifdef MACMACHO
47
#ifdef MACMACHO
48
        FSRef inref,outref;
48
        FSRef inref,outref;
49
        // work with resources in data fork
49
        // work with resources in data fork
50
        if( !(e = FSpMakeFSRef(srcplug,&inref))
50
        if( !(e = FSpMakeFSRef(srcplug,&inref))
51
         && !(e = FSOpenResourceFile(&inref,0/*forkNameLength*/,NULL/*forkName*/,fsRdPerm,&srcrn))
51
         && !(e = FSOpenResourceFile(&inref,0/*forkNameLength*/,NULL/*forkName*/,fsRdPerm,&srcrn))
52
         && ((e = FSpMakeFSRef(rsrccopy,&outref))
52
         && ((e = FSpMakeFSRef(rsrccopy,&outref))
53
                 || (e = FSOpenResourceFile(&outref,0/*forkNameLength*/,NULL/*forkName*/,fsWrPerm,&dstrn))) )
53
                 || (e = FSOpenResourceFile(&outref,0/*forkNameLength*/,NULL/*forkName*/,fsWrPerm,&dstrn))) )
54
                CloseResFile(srcrn);
54
                CloseResFile(srcrn);
55
#else
55
#else
56
        // ordinary resource fork files
56
        // ordinary resource fork files
57
        srcrn = FSpOpenResFile(srcplug,fsRdPerm);
57
        srcrn = FSpOpenResFile(srcplug,fsRdPerm);
58
        if(srcrn != -1){
58
        if(srcrn != -1){
59
                dstrn = FSpOpenResFile(rsrccopy,fsWrPerm);
59
                dstrn = FSpOpenResFile(rsrccopy,fsWrPerm);
60
                if(dstrn == -1){
60
                if(dstrn == -1){
61
                        e = ResError();
61
                        e = ResError();
62
                        CloseResFile(srcrn);
62
                        CloseResFile(srcrn);
63
                }
63
                }
64
        }else e = ResError();
64
        }else e = ResError();
65
#endif
65
#endif
66
 
66
 
67
        if(!e){
67
        if(!e){
68
                /* create a new PiPL resource for the standalone plugin,
68
                /* create a new PiPL resource for the standalone plugin,
69
                   with updated title and category strings */
69
                   with updated title and category strings */
70
 
70
 
71
                if( (hpipl = Get1Resource('TpLT',16000))
71
                if( (hpipl = Get1Resource('TpLT',16000))
72
                 && (h = Get1Resource('PiPL',16000)) )
72
                 && (h = Get1Resource('PiPL',16000)) )
73
                {
73
                {
74
                        RemoveResource(h);
74
                        RemoveResource(h);
75
 
75
 
76
                        DetachResource(hpipl);
76
                        DetachResource(hpipl);
77
 
77
 
78
                        PLstrcpy(title,gdata->parm.title);
78
                        PLstrcpy(title,gdata->parm.title);
79
                        if(gdata->parm.popDialog)
79
                        if(gdata->parm.popDialog)
80
                                PLstrcat(title,"\pÉ");
80
                                PLstrcat(title,"\pÉ");
81
 
81
 
82
                        origsize = GetHandleSize(hpipl);
82
                        origsize = GetHandleSize(hpipl);
83
                        SetHandleSize(hpipl,origsize+0x300); /* some slop for fixup to work with */
83
                        SetHandleSize(hpipl,origsize+0x300); /* some slop for fixup to work with */
84
                        HLock(hpipl);
84
                        HLock(hpipl);
85
                        newsize = fixpipl((PIPropertyList*) *hpipl,origsize,title,&event_id);
85
                        newsize = fixpipl((PIPropertyList*) *hpipl,origsize,title,&event_id);
86
                        HUnlock(hpipl);
86
                        HUnlock(hpipl);
87
                        SetHandleSize(hpipl,newsize);
87
                        SetHandleSize(hpipl,newsize);
88
 
88
 
89
                        AddResource(hpipl,'PiPL',16000,"\p");
89
                        AddResource(hpipl,'PiPL',16000,"\p");
90
 
90
 
91
                        if( !(e = ResError()) ){
91
                        if( !(e = ResError()) ){
92
                                /* do a similar trick with the terminology resource,
92
                                /* do a similar trick with the terminology resource,
93
                                   so the scripting system can distinguish the standalone plugin */
93
                                   so the scripting system can distinguish the standalone plugin */
94
 
94
 
95
                                if( (h = Get1Resource(typeAETE,AETE_ID)) ){
95
                                if( (h = Get1Resource(typeAETE,AETE_ID)) ){
96
                                        SetHandleSize(h,4096);
96
                                        SetHandleSize(h,4096);
97
                                        HLock(h);
97
                                        HLock(h);
98
                                        newsize = aete_generate((unsigned char*)*h, &gdata->parm, event_id);
98
                                        newsize = aete_generate((unsigned char*)*h, &gdata->parm, event_id);
99
                                        HUnlock(h);
99
                                        HUnlock(h);
100
                                        SetHandleSize(h,newsize);
100
                                        SetHandleSize(h,newsize);
101
 
101
 
102
                                        ChangedResource(h);
102
                                        ChangedResource(h);
103
 
103
 
104
                                        if( !(e = ResError()) ){
104
                                        if( !(e = ResError()) ){
105
                                                /* add PARM resource */
105
                                                /* add PARM resource */
106
                                                if( !(e = PtrToHand(&gdata->parm,&h,sizeof(PARM_T))) ){
106
                                                if( !(e = PtrToHand(&gdata->parm,&h,sizeof(PARM_T))) ){
107
                                                        if(gdata->obfusc){
107
                                                        if(gdata->obfusc){
108
                                                                HLock(h);
108
                                                                HLock(h);
109
                                                                obfusc((unsigned char*)*h,sizeof(PARM_T),OBFUSC_SEED_POS);
109
                                                                obfusc((unsigned char*)*h,sizeof(PARM_T),OBFUSC_SEED_POS);
110
                                                                HUnlock(h);
110
                                                                HUnlock(h);
111
                                                                parm_type = 'DATA';
111
                                                                parm_type = 'DATA';
112
                                                                parm_id = OBFUSCDATA_ID;
112
                                                                parm_id = OBFUSCDATA_ID;
113
                                                        }else{
113
                                                        }else{
114
                                                                parm_type = 'PARM';
114
                                                                parm_type = 'PARM';
115
                                                                parm_id = PARM_ID;
115
                                                                parm_id = PARM_ID;
116
                                                        }
116
                                                        }
117
                                                        AddResource(h,parm_type,parm_id,"\p");
117
                                                        AddResource(h,parm_type,parm_id,"\p");
118
                                                }
118
                                                }
119
                                        }
119
                                        }
120
                                }
120
                                }
121
 
121
 
122
                        }
122
                        }
123
 
123
 
124
                }
124
                }
125
                if(!e)
125
                if(!e)
126
                        e = ResError();
126
                        e = ResError();
127
 
127
 
128
                CloseResFile(dstrn);
128
                CloseResFile(dstrn);
129
                CloseResFile(srcrn);
129
                CloseResFile(srcrn);
130
        }
130
        }
131
 
131
 
132
        return e;
132
        return e;
133
}
133
}
134
 
134
 
135
static int copyletters(char *dst,StringPtr src){
135
static int copyletters(char *dst,StringPtr src){
136
        int i, n;
136
        int i, n;
137
 
137
 
138
        for(i = src[0], n = 0; i--;)
138
        for(i = src[0], n = 0; i--;)
139
                if(isalpha(*++src)){
139
                if(isalpha(*++src)){
140
                        *dst++ = *src;
140
                        *dst++ = *src;
141
                        ++n;
141
                        ++n;
142
                }
142
                }
143
        return n;
143
        return n;
144
}
144
}
145
 
145
 
146
// Info.plist in new standalone copy needs to be edited -
146
// Info.plist in new standalone copy needs to be edited -
147
// at least the CFBundleIdentifier property must be unique
147
// at least the CFBundleIdentifier property must be unique
148
 
148
 
149
static OSErr copyplist(FSSpec *fss, short dstvol, long dstdir){
149
static OSErr copyplist(FSSpec *fss, short dstvol, long dstdir){
150
        static char *key = "com.telegraphics.FilterFoundry";
150
        static char *key = "com.telegraphics.FilterFoundry";
151
        static unsigned char *fname="\pInfo.plist";
151
        static unsigned char *fname="\pInfo.plist";
152
        char *buf,*save,*p;
152
        char *buf,*save,*p;
153
        short rn,dstrn,i,n,m;
153
        short rn,dstrn,i,n,m;
154
        FILEPOS eof;
154
        FILEPOS eof;
155
        FILECOUNT count;
155
        FILECOUNT count;
156
        OSErr e;
156
        OSErr e;
157
 
157
 
158
        if( !(e = HCreate(dstvol,dstdir,fname,'pled','TEXT')) ){
158
        if( !(e = HCreate(dstvol,dstdir,fname,'pled','TEXT')) ){
159
                if( !(e = HOpenDF(dstvol,dstdir,fname,fsWrPerm,&dstrn)) ){
159
                if( !(e = HOpenDF(dstvol,dstdir,fname,fsWrPerm,&dstrn)) ){
160
                        if( !(e = FSpOpenDF(fss,fsRdPerm,&rn)) ){
160
                        if( !(e = FSpOpenDF(fss,fsRdPerm,&rn)) ){
161
                                if( !(e = GetEOF(rn,&eof)) && (buf = malloc(eof+1024)) ){
161
                                if( !(e = GetEOF(rn,&eof)) && (buf = malloc(eof+1024)) ){
162
                                        if( !(e = FSRead(rn,&eof,buf)) ){
162
                                        if( !(e = FSRead(rn,&eof,buf)) ){
163
                                                buf[eof] = 0;
163
                                                buf[eof] = 0;
164
                                                if( (p = strnstr(buf,key,eof)) && (save = malloc(eof-(p-buf)+1)) ){
164
                                                if( (p = strnstr(buf,key,eof)) && (save = malloc(eof-(p-buf)+1)) ){
165
                                                        p += strlen(key);
165
                                                        p += strlen(key);
166
                                                        // store text after matched string
166
                                                        // store text after matched string
167
                                                        strcpy(save,p);
167
                                                        strcpy(save,p);
168
 
168
 
169
                                                        *p++ = '.';
169
                                                        *p++ = '.';
170
                                                        n = copyletters(p,gdata->parm.category);
170
                                                        n = copyletters(p,gdata->parm.category);
171
                                                        p += n;
171
                                                        p += n;
172
                                                        if(n) *p++ = '.';
172
                                                        if(n) *p++ = '.';
173
                                                        m = copyletters(p,gdata->parm.title);
173
                                                        m = copyletters(p,gdata->parm.title);
174
                                                        p += m;
174
                                                        p += m;
175
                                                        if(!m){
175
                                                        if(!m){
176
                                                                // generate a random ASCII identifier
176
                                                                // generate a random ASCII identifier
177
                                                                srand(TICKCOUNT());
177
                                                                srand(TICKCOUNT());
178
                                                                for(i = 8; i--;)
178
                                                                for(i = 8; i--;)
179
                                                                        *p++ = 'a' + (rand() % 26);
179
                                                                        *p++ = 'a' + (rand() % 26);
180
                                                        }
180
                                                        }
181
                                                        strcpy(p,save);
181
                                                        strcpy(p,save);
182
 
182
 
183
                                                        count = strlen(buf);
183
                                                        count = strlen(buf);
184
                                                        e = FSWrite(dstrn,&count,buf);
184
                                                        e = FSWrite(dstrn,&count,buf);
185
 
185
 
186
                                                        free(save);
186
                                                        free(save);
187
                                                }else e = paramErr; // not found?? shouldn't happen
187
                                                }else e = paramErr; // not found?? shouldn't happen
188
                                        }
188
                                        }
189
                                        free(buf);
189
                                        free(buf);
190
                                }
190
                                }
191
                                FSClose(rn);
191
                                FSClose(rn);
192
                        }
192
                        }
193
                        FSClose(dstrn);
193
                        FSClose(dstrn);
194
                }
194
                }
195
                if(e) HDelete(dstvol,dstdir,fname);
195
                if(e) HDelete(dstvol,dstdir,fname);
196
        }
196
        }
197
        return e;
197
        return e;
198
}
198
}
199
 
199
 
200
static OSErr make_bundle(StandardFileReply *sfr, short plugvol,
200
static OSErr make_bundle(StandardFileReply *sfr, short plugvol,
201
                                                 long plugdir, StringPtr plugname, char *reason)
201
                                                 long plugdir, StringPtr plugname, char *reason)
202
{
202
{
203
        short dstvol = sfr->sfFile.vRefNum;
203
        short dstvol = sfr->sfFile.vRefNum;
204
        long bundledir,contentsdir,macosdir,rsrcdir;
204
        long bundledir,contentsdir,macosdir,rsrcdir;
205
        DInfo fndrInfo;
205
        DInfo fndrInfo;
206
        OSErr e;
206
        OSErr e;
207
        FSSpec fss,macosfss,rsrcfss,rsrccopyfss;
207
        FSSpec fss,macosfss,rsrcfss,rsrccopyfss;
208
        char *why;
208
        char *why;
209
 
209
 
210
        if( !(e = FSpDirCreate(&sfr->sfFile,sfr->sfScript,&bundledir)) ){
210
        if( !(e = FSpDirCreate(&sfr->sfFile,sfr->sfScript,&bundledir)) ){
211
                if(!(e = FSpGetDInfo(&sfr->sfFile,&fndrInfo)) ){
211
                if(!(e = FSpGetDInfo(&sfr->sfFile,&fndrInfo)) ){
212
                        fndrInfo.frFlags |= kHasBundle;
212
                        fndrInfo.frFlags |= kHasBundle;
213
                        FSpSetDInfo(&sfr->sfFile,&fndrInfo);
213
                        FSpSetDInfo(&sfr->sfFile,&fndrInfo);
214
                }
214
                }
215
                if( !(e = DirCreate(dstvol,bundledir,"\pContents",&contentsdir)) ){
215
                if( !(e = DirCreate(dstvol,bundledir,"\pContents",&contentsdir)) ){
216
                        if( !(e = DirCreate(dstvol,contentsdir,"\pMacOS",&macosdir)) ){
216
                        if( !(e = DirCreate(dstvol,contentsdir,"\pMacOS",&macosdir)) ){
217
                                if( !(e = DirCreate(dstvol,contentsdir,"\pResources",&rsrcdir)) ){
217
                                if( !(e = DirCreate(dstvol,contentsdir,"\pResources",&rsrcdir)) ){
218
                                        /* copy the Info.plist file, resource file, and executable */
218
                                        /* copy the Info.plist file, resource file, and executable */
219
                                        if( !(e = FSMakeFSSpec(plugvol,plugdir,"\p::MacOS:FilterFoundry",&macosfss))
219
                                        if( !(e = FSMakeFSSpec(plugvol,plugdir,"\p::MacOS:FilterFoundry",&macosfss))
220
                                         && !(e = FileCopy(macosfss.vRefNum,macosfss.parID,macosfss.name, dstvol,macosdir,NULL, NULL,NULL,0,false)) )
220
                                         && !(e = FileCopy(macosfss.vRefNum,macosfss.parID,macosfss.name, dstvol,macosdir,NULL, NULL,NULL,0,false)) )
221
                                        {
221
                                        {
222
                                                /* add PARM resources to each binary, and edit PiPLs */
222
                                                /* add PARM resources to each binary, and edit PiPLs */
223
                                                if( !(e = FSMakeFSSpec(plugvol,plugdir,"\p::Resources:FilterFoundry.rsrc",&rsrcfss))
223
                                                if( !(e = FSMakeFSSpec(plugvol,plugdir,"\p::Resources:FilterFoundry.rsrc",&rsrcfss))
224
                                                 && !(e = FileCopy(rsrcfss.vRefNum,rsrcfss.parID,rsrcfss.name, dstvol,rsrcdir,NULL, NULL,NULL,0,false))
224
                                                 && !(e = FileCopy(rsrcfss.vRefNum,rsrcfss.parID,rsrcfss.name, dstvol,rsrcdir,NULL, NULL,NULL,0,false))
225
                                                 && !(e = FSMakeFSSpec(dstvol,rsrcdir,"\pFilterFoundry.rsrc",&rsrccopyfss)) )
225
                                                 && !(e = FSMakeFSSpec(dstvol,rsrcdir,"\pFilterFoundry.rsrc",&rsrccopyfss)) )
226
                                                {
226
                                                {
227
                                                        if( !(e = doresources(&rsrcfss, &rsrccopyfss))
227
                                                        if( !(e = doresources(&rsrcfss, &rsrccopyfss))
228
                                                         && !(e = FSMakeFSSpec(plugvol,plugdir,"\p::Info.plist",&fss)) )
228
                                                         && !(e = FSMakeFSSpec(plugvol,plugdir,"\p::Info.plist",&fss)) )
229
                                                        {
229
                                                        {
230
                                                                e = copyplist(&fss,dstvol,contentsdir);
230
                                                                e = copyplist(&fss,dstvol,contentsdir);
231
                                                                if(e){
231
                                                                if(e){
232
                                                                        FSpDelete(&rsrccopyfss);
232
                                                                        FSpDelete(&rsrccopyfss);
233
                                                                        why = "Can't copy Info.plist file.";
233
                                                                        why = "Can't copy Info.plist file.";
234
                                                                }
234
                                                                }
235
                                                        }else why = "Can't copy resources.";
235
                                                        }else why = "Can't copy resources.";
236
                                                        if(e) HDelete(dstvol,macosdir,"\pFilterFoundry");
236
                                                        if(e) HDelete(dstvol,macosdir,"\pFilterFoundry");
237
                                                }else why = "Can't copy FilterFoundry.rsrc file.";
237
                                                }else why = "Can't copy FilterFoundry.rsrc file.";
238
                                                if(e) HDelete(dstvol,rsrcdir,plugname);
238
                                                if(e) HDelete(dstvol,rsrcdir,plugname);
239
                                        }else why = "Can't copy FilterFoundry executable.";
239
                                        }else why = "Can't copy FilterFoundry executable.";
240
                                        if(e) HDelete(dstvol,contentsdir,"\pResources");
240
                                        if(e) HDelete(dstvol,contentsdir,"\pResources");
241
                                }else why = "Can't create bundle Contents/Resources directory.";
241
                                }else why = "Can't create bundle Contents/Resources directory.";
242
                                if(e) HDelete(dstvol,contentsdir,"\pMacOS");
242
                                if(e) HDelete(dstvol,contentsdir,"\pMacOS");
243
                        }else why = "Can't create bundle Contents/MacOS directory.";
243
                        }else why = "Can't create bundle Contents/MacOS directory.";
244
                        if(e) HDelete(dstvol,bundledir,"\pContents");
244
                        if(e) HDelete(dstvol,bundledir,"\pContents");
245
                }else why = "Can't create bundle Contents directory.";
245
                }else why = "Can't create bundle Contents directory.";
246
                if(e) FSpDelete(&sfr->sfFile);
246
                if(e) FSpDelete(&sfr->sfFile);
247
        }else why = "Can't create new bundle directory.";
247
        }else why = "Can't create new bundle directory.";
248
 
248
 
249
        if(e)
249
        if(e)
250
                sprintf(reason, "%s (%d)", why, e);
250
                sprintf(reason, "%s (%d)", why, e);
251
        else
251
        else
252
                reason[0] = 0;
252
                reason[0] = 0;
253
 
253
 
254
        return e;
254
        return e;
255
}
255
}
256
 
256
 
257
static OSErr make_singlefile(StandardFileReply *sfr, short plugvol, long plugdir, StringPtr plugname){
257
static OSErr make_singlefile(StandardFileReply *sfr, short plugvol, long plugdir, StringPtr plugname){
258
        OSErr e;
258
        OSErr e;
259
        FSSpec origfss;
259
        FSSpec origfss;
260
 
260
 
261
        e = FSpDelete(&sfr->sfFile);
261
        e = FSpDelete(&sfr->sfFile);
262
        if(e && e != fnfErr){
262
        if(e && e != fnfErr){
263
                alertuser(_strdup("Can't replace the existing file. Try a different name or location."),_strdup(""));
263
                alertuser(_strdup("Can't replace the existing file. Try a different name or location."),_strdup(""));
264
                return userCanceledErr;
264
                return userCanceledErr;
265
        }
265
        }
266
 
266
 
267
        if( !(e = FileCopy(plugvol,plugdir,plugname, sfr->sfFile.vRefNum,sfr->sfFile.parID,NULL, sfr->sfFile.name,NULL,0,false))
267
        if( !(e = FileCopy(plugvol,plugdir,plugname, sfr->sfFile.vRefNum,sfr->sfFile.parID,NULL, sfr->sfFile.name,NULL,0,false))
268
         && !(e = FSMakeFSSpec(plugvol,plugdir,plugname,&origfss)) )
268
         && !(e = FSMakeFSSpec(plugvol,plugdir,plugname,&origfss)) )
269
                /* add PARM resources, and edit PiPL */
269
                /* add PARM resources, and edit PiPL */
270
                e = doresources(&origfss, &sfr->sfFile);
270
                e = doresources(&origfss, &sfr->sfFile);
271
 
271
 
272
        return e;
272
        return e;
273
}
273
}
274
 
274
 
275
OSErr make_standalone(StandardFileReply *sfr){
275
OSErr make_standalone(StandardFileReply *sfr){
276
        OSErr e;
276
        OSErr e;
277
        short plugvol;
277
        short plugvol;
278
        long plugdir;
278
        long plugdir;
279
        Str255 plugname;
279
        Str255 plugname;
280
        char reason[0x100] = {0};
280
        char reason[0x100] = {0};
281
 
281
 
282
        if(!(e = GetFileLocation(CurResFile(),&plugvol,&plugdir,plugname))){
282
        if(!(e = GetFileLocation(CurResFile(),&plugvol,&plugdir,plugname))){
283
#ifdef MACMACHO
283
#ifdef MACMACHO
284
                e = make_bundle(sfr,plugvol,plugdir,plugname,reason);
284
                e = make_bundle(sfr,plugvol,plugdir,plugname,reason);
285
#else
285
#else
286
                e = make_singlefile(sfr,plugvol,plugdir,plugname);
286
                e = make_singlefile(sfr,plugvol,plugdir,plugname);
287
#endif
287
#endif
288
        }
288
        }
289
 
289
 
290
        if(e && e != userCanceledErr) {
290
        if(e && e != userCanceledErr) {
291
                alertuser(_strdup("Could not create standalone plugin."),reason);
291
                alertuser(_strdup("Could not create standalone plugin."),reason);
292
        } else {
292
        } else {
293
                showmessage(_strdup("Filter was sucessfully created"));
293
                showmessage(_strdup("Filter was sucessfully created"));
294
        }
294
        }
295
 
295
 
296
        return e;
296
        return e;
297
}
297
}
298
 
298