Subversion Repositories filter_foundry

Rev

Rev 194 | Rev 206 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 194 Rev 198
Line 23... Line 23...
23
#include "file_compat.h"
23
#include "file_compat.h"
24
#include "compat_string.h"
24
#include "compat_string.h"
25
#include "versioninfo_modify_win.h"
25
#include "versioninfo_modify_win.h"
26
#include "version.h"
26
#include "version.h"
27
 
27
 
28
extern HANDLE hDllInstance;
28
extern HINSTANCE hDllInstance;
29
 
29
 
30
Boolean doresources(HMODULE srcmod,char *dstname);
30
Boolean doresources(HMODULE srcmod,char *dstname);
31
 
31
 
32
void dbglasterror(char *func){
32
void dbglasterror(char *func){
33
        char s[0x100];
33
        char s[0x100];
Line 48... Line 48...
48
}
48
}
49
*/
49
*/
50
 
50
 
51
Boolean doresources(HMODULE srcmod,char *dstname){
51
Boolean doresources(HMODULE srcmod,char *dstname){
52
        HRSRC datarsrc,aetersrc;
52
        HRSRC datarsrc,aetersrc;
53
        HANDLE datah,aeteh,hupdate;
53
        HGLOBAL datah,aeteh,hupdate;
54
        Ptr newpipl = NULL,newaete = NULL,datap,aetep;
54
        Ptr newpipl = NULL, newaete = NULL;
-
 
55
        LPVOID datap, aetep;
55
        PARM_T *pparm = NULL;
56
        PARM_T *pparm = NULL;
56
        size_t piplsize,aetesize,origsize;
57
        size_t piplsize,aetesize,origsize;
57
        Str255 title;
58
        Str255 title;
58
        LPCTSTR parm_type;
59
        LPCTSTR parm_type;
59
        int i,parm_id;
60
        int i,parm_id;
Line 68... Line 69...
68
                if (!hLib) {
69
                if (!hLib) {
69
                        char* sysdir;
70
                        char* sysdir;
70
 
71
 
71
                        sysdir = (char*)malloc(MAX_PATH);
72
                        sysdir = (char*)malloc(MAX_PATH);
72
                        GetSystemDirectoryA(sysdir, MAX_PATH);
73
                        GetSystemDirectoryA(sysdir, MAX_PATH);
73
                        alertuser(my_strdup("To build standalone plugins using this version of\nWindows, you need to install UNICOWS.DLL\n\nPlease download it from the Internet\nand place it into following directory:"),sysdir);
74
                        alertuser(_strdup("To build standalone plugins using this version of\nWindows, you need to install UNICOWS.DLL\n\nPlease download it from the Internet\nand place it into following directory:"),sysdir);
74
                        free(sysdir);
75
                        free(sysdir);
75
 
76
 
76
                        return false;
77
                        return false;
77
                } else {
78
                } else {
78
                        FreeLibrary(hLib);
79
                        FreeLibrary(hLib);
Line 84... Line 85...
84
 
85
 
85
        if( (hupdate = _BeginUpdateResource(dstname,false)) ){
86
        if( (hupdate = _BeginUpdateResource(dstname,false)) ){
86
                DBG("BeginUpdateResource OK");
87
                DBG("BeginUpdateResource OK");
87
                if( (datarsrc = FindResource(srcmod,MAKEINTRESOURCE(16000),RT_RCDATA))
88
                if( (datarsrc = FindResource(srcmod,MAKEINTRESOURCE(16000),RT_RCDATA))
88
                        && (datah = LoadResource(srcmod,datarsrc))
89
                        && (datah = LoadResource(srcmod,datarsrc))
89
                        && (datap = LockResource(datah))
90
                        && (datap = (Ptr)LockResource(datah))
90
                        && (aetersrc = FindResource(srcmod,MAKEINTRESOURCE(16000),"AETE"))
91
                        && (aetersrc = FindResource(srcmod,MAKEINTRESOURCE(16000),"AETE"))
91
                        && (aeteh = LoadResource(srcmod,aetersrc))
92
                        && (aeteh = LoadResource(srcmod,aetersrc))
92
                        && (aetep = LockResource(aeteh)) )
93
                        && (aetep = (Ptr)LockResource(aeteh)) )
93
                {
94
                {
94
                        DBG("loaded DATA, PiPL");
95
                        DBG("loaded DATA, PiPL");
95
 
96
 
96
                        PLstrcpy(title,gdata->parm.title);
97
                        PLstrcpy(title,gdata->parm.title);
97
                        if(gdata->parm.popDialog)
98
                        if(gdata->parm.popDialog)
98
                                PLstrcat(title,(StringPtr)"\003...");
99
                                PLstrcat(title,(StringPtr)"\003...");
99
 
100
 
100
                        origsize = SizeofResource(srcmod,datarsrc);
101
                        origsize = SizeofResource(srcmod,datarsrc);
101
 
102
 
102
                        if( (newpipl = malloc(origsize+0x300))
103
                        if( (newpipl = (Ptr)malloc(origsize+0x300))
103
                         && (newaete = malloc(4096))
104
                         && (newaete = (Ptr)malloc(4096))
104
                         && (pparm = malloc(sizeof(PARM_T))) )
105
                         && (pparm = (PARM_T*)malloc(sizeof(PARM_T))) )
105
                        {
106
                        {
106
                                /* add user-specified title and category to new PiPL */
107
                                /* add user-specified title and category to new PiPL */
107
                                memcpy(newpipl,datap,origsize);
108
                                memcpy(newpipl,datap,origsize);
108
                                /* note that Windows PiPLs have 2 byte version datum in front
109
                                /* note that Windows PiPLs have 2 byte version datum in front
109
                                   that isn't reflected in struct definition or Mac resource template: */
110
                                   that isn't reflected in struct definition or Mac resource template: */
Line 144... Line 145...
144
                                                                   MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),newaete,(DWORD)aetesize)
145
                                                                   MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),newaete,(DWORD)aetesize)
145
                                 && _UpdateResource(hupdate,parm_type,MAKEINTRESOURCE(parm_id),
146
                                 && _UpdateResource(hupdate,parm_type,MAKEINTRESOURCE(parm_id),
146
                                                                   MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),pparm,sizeof(PARM_T)) )
147
                                                                   MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),pparm,sizeof(PARM_T)) )
147
                                        discard = false;
148
                                        discard = false;
148
                                else
149
                                else
149
                                        dbglasterror("UpdateResource");
150
                                        dbglasterror(_strdup("UpdateResource"));
150
 
151
 
151
                                if (soleFilename = strrchr(dstname, '\\')) {
152
                                if (soleFilename = strrchr(dstname, '\\')) {
152
                                    ++soleFilename;
153
                                    ++soleFilename;
153
                                } else {
154
                                } else {
154
                                    soleFilename = dstname;
155
                                    soleFilename = dstname;
Line 193... Line 194...
193
                                tmp++;
194
                                tmp++;
194
 
195
 
195
                                tmp += mbstowcs(tmp, "", 1);
196
                                tmp += mbstowcs(tmp, "", 1);
196
 
197
 
197
                                if (UpdateVersionInfoWithHandle(dstname, hupdate, changeRequestStr) != NOERROR) {
198
                                if (UpdateVersionInfoWithHandle(dstname, hupdate, changeRequestStr) != NOERROR) {
198
                                        alertuser(my_strdup("UpdateVersionInfoWithHandle failed"),my_strdup(""));
199
                                        alertuser(_strdup("UpdateVersionInfoWithHandle failed"),_strdup(""));
199
                                }
200
                                }
200
 
201
 
201
                                free(changeRequestStr);
202
                                free(changeRequestStr);
202
                        }
203
                        }
203
 
204
 
204
                }else dbglasterror("Find-, Load- or LockResource");
205
                }else dbglasterror(_strdup("Find-, Load- or LockResource"));
205
 
206
 
206
                if(!_EndUpdateResource(hupdate,discard))
207
                if(!_EndUpdateResource(hupdate,discard))
207
                        dbglasterror("EndUpdateResource");
208
                        dbglasterror(_strdup("EndUpdateResource"));
208
 
209
 
209
                if(pparm) free(pparm);
210
                if(pparm) free(pparm);
210
                if(newpipl) free(newpipl);
211
                if(newpipl) free(newpipl);
211
                if(newaete) free(newaete);
212
                if(newaete) free(newaete);
212
        }else
213
        }else
213
                dbglasterror("BeginUpdateResource");
214
                dbglasterror(_strdup("BeginUpdateResource"));
214
        return !discard;
215
        return !discard;
215
}
216
}
216
 
217
 
217
OSErr make_standalone(StandardFileReply *sfr){
218
OSErr make_standalone(StandardFileReply *sfr){
218
        Boolean res;
219
        Boolean res;
Line 223... Line 224...
223
        res = GetModuleFileName(hDllInstance,srcname,MAX_PATH)
224
        res = GetModuleFileName(hDllInstance,srcname,MAX_PATH)
224
                  && CopyFile(srcname,dstname,false)
225
                  && CopyFile(srcname,dstname,false)
225
                  && doresources(hDllInstance,dstname);
226
                  && doresources(hDllInstance,dstname);
226
 
227
 
227
        if(!res) {
228
        if(!res) {
228
                alertuser(my_strdup("Could not create standalone plugin."),my_strdup(""));
229
                alertuser(_strdup("Could not create standalone plugin."),_strdup(""));
229
        } else {
230
        } else {
230
                showmessage(my_strdup("Filter was sucessfully created"));
231
                showmessage(_strdup("Filter was sucessfully created"));
231
        }
232
        }
232
 
233
 
233
        return res ? ioErr : noErr;
234
        return res ? ioErr : noErr;
234
}
235
}