1 | /*
|
---|
2 | * This file is (C) Chris Wohlgemuth 2001/2002
|
---|
3 | */
|
---|
4 | /*
|
---|
5 | * This program is free software; you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation; either version 2, or (at your option)
|
---|
8 | * any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program; see the file COPYING. If not, write to
|
---|
17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
18 | */
|
---|
19 | #define INCL_WIN
|
---|
20 | #define INCL_DOS
|
---|
21 | #define INCL_DOSERRORS
|
---|
22 |
|
---|
23 | #include <os2.h>
|
---|
24 | #include <sys/types.h>
|
---|
25 | #include <sys/stat.h>
|
---|
26 |
|
---|
27 | #include <stdio.h>
|
---|
28 | #include <string.h>
|
---|
29 | //#include "audiofolder.h"
|
---|
30 | //#include "audiofolderres.h"
|
---|
31 |
|
---|
32 | #define INSTALLDIR 1
|
---|
33 |
|
---|
34 | /* The subdirectory in the installation directory where to put the log files */
|
---|
35 | #define LOGFILE_SUBDIR "Logfiles"
|
---|
36 |
|
---|
37 | extern char* params[];
|
---|
38 | extern HMODULE RESSOURCEHANDLE;
|
---|
39 | extern char logName[];
|
---|
40 |
|
---|
41 | char chrInstallDir[CCHMAXPATH];
|
---|
42 | char chrCDRecord[CCHMAXPATH];/* Path to cdrecord */
|
---|
43 | char chrCDROptions[CCHMAXPATH];
|
---|
44 | char chrAudioCDROptions[CCHMAXPATH];
|
---|
45 | LONG lCDROptions=0;
|
---|
46 |
|
---|
47 | char chrMkisofs[CCHMAXPATH];/* Path to mkisofs */
|
---|
48 | char chrMkisofsOptions[CCHMAXPATH];
|
---|
49 | LONG lMKOptions;
|
---|
50 |
|
---|
51 | char chrGrabberPath[CCHMAXPATH];
|
---|
52 | char chrGrabberOptions[CCHMAXPATH];
|
---|
53 | int bTrackNumbers;
|
---|
54 | int iGrabberID;
|
---|
55 | char chosenCD[3];
|
---|
56 |
|
---|
57 | char chrMpg123Path[CCHMAXPATH];
|
---|
58 | BOOL bMpg123SwabBytes;
|
---|
59 | int iMp3Decoder;
|
---|
60 |
|
---|
61 | char chrMntIsoFS[CCHMAXPATH];
|
---|
62 | char chrUmntIso[CCHMAXPATH];
|
---|
63 |
|
---|
64 | char chrCdrdaoPath[CCHMAXPATH]={0};
|
---|
65 | char chrCdrdaoDriver[100]={0};
|
---|
66 | int iBus=0;
|
---|
67 | int iTarget=0;
|
---|
68 | int iLun=0;
|
---|
69 | int iSpeed=1;
|
---|
70 | int iFifo=4;
|
---|
71 |
|
---|
72 | BOOL bUseCDDB;
|
---|
73 | BOOL bTipsEnabled;
|
---|
74 |
|
---|
75 | SWP swpWindow;
|
---|
76 |
|
---|
77 | HMODULE queryResModuleHandle2(char *installDir, char * chrBaseName);
|
---|
78 |
|
---|
79 |
|
---|
80 | BOOL HlpQueryTempDir(char * chrInstallationDir, char * chrBuffer, int iBufferSize)
|
---|
81 | {
|
---|
82 | int iLeft=iBufferSize;
|
---|
83 |
|
---|
84 | strncpy(chrBuffer, chrInstallationDir, iBufferSize);
|
---|
85 | chrBuffer[iBufferSize-1]=0;
|
---|
86 | iLeft=iBufferSize-strlen(chrBuffer);
|
---|
87 | strncat(chrBuffer, "\\temp", iLeft);
|
---|
88 | chrBuffer[iBufferSize-1]=0;
|
---|
89 |
|
---|
90 | return TRUE;
|
---|
91 | }
|
---|
92 |
|
---|
93 | /****************************************************
|
---|
94 | * *
|
---|
95 | * This funktion returns the running OS version: *
|
---|
96 | * *
|
---|
97 | * 30: Warp 3, 40 Warp 4 *
|
---|
98 | * *
|
---|
99 | ****************************************************/
|
---|
100 | ULONG cwQueryOSRelease()
|
---|
101 | {
|
---|
102 | static ULONG ulVersionMinor=0;
|
---|
103 |
|
---|
104 | if(!ulVersionMinor)
|
---|
105 | if(DosQuerySysInfo(QSV_VERSION_MINOR, QSV_VERSION_MINOR, &ulVersionMinor, sizeof(ulVersionMinor)))
|
---|
106 | ulVersionMinor=30;/* Default Warp 3 */
|
---|
107 |
|
---|
108 | return ulVersionMinor;
|
---|
109 |
|
---|
110 | }
|
---|
111 | void writeLog(char* logText);
|
---|
112 | void removeLog(void)
|
---|
113 | {
|
---|
114 | char logNameLocal[CCHMAXPATH];
|
---|
115 |
|
---|
116 | sprintf(logNameLocal,"%s\\%s\\%s",params[1],LOGFILE_SUBDIR,logName);
|
---|
117 | //WinMessageBox(HWND_DESKTOP,HWND_DESKTOP, logNameLocal,"",1234,MB_MOVEABLE|MB_OK);
|
---|
118 | //writeLog(logNameLocal);
|
---|
119 |
|
---|
120 | remove(logNameLocal);
|
---|
121 | //DosBeep(500,100);
|
---|
122 | }
|
---|
123 |
|
---|
124 | void removeLog2(char * installDir, char * logName)
|
---|
125 | {
|
---|
126 | char logNameLocal[CCHMAXPATH];
|
---|
127 |
|
---|
128 | sprintf(logNameLocal,"%s\\%s\\%s",installDir,LOGFILE_SUBDIR,logName);
|
---|
129 | remove(logNameLocal);
|
---|
130 | }
|
---|
131 |
|
---|
132 | void writeLog(char* logText)
|
---|
133 | {
|
---|
134 | char logNameLocal[CCHMAXPATH];
|
---|
135 | FILE *fHandle;
|
---|
136 |
|
---|
137 | sprintf(logNameLocal,"%s\\%s\\%s",params[1],LOGFILE_SUBDIR,logName);
|
---|
138 | fHandle=fopen(logNameLocal,"a");
|
---|
139 | if(fHandle) {
|
---|
140 | fprintf(fHandle,logText);
|
---|
141 | fclose(fHandle);
|
---|
142 | }
|
---|
143 | }
|
---|
144 |
|
---|
145 | void writeLog2(char * installDir, char * logName, char* logText)
|
---|
146 | {
|
---|
147 | char logNameLocal[CCHMAXPATH];
|
---|
148 | FILE *fHandle;
|
---|
149 |
|
---|
150 | sprintf(logNameLocal,"%s\\%s\\%s",installDir, LOGFILE_SUBDIR, logName);
|
---|
151 | fHandle=fopen(logNameLocal,"a");
|
---|
152 | if(fHandle) {
|
---|
153 | fprintf(fHandle,logText);
|
---|
154 | fclose(fHandle);
|
---|
155 | }
|
---|
156 | }
|
---|
157 |
|
---|
158 | BOOL buildLogName( char * outBuf, char * logName,ULONG ulSize)
|
---|
159 | {
|
---|
160 | if(snprintf(outBuf, ulSize,"logfiles\\%s",logName)==EOF)
|
---|
161 | return FALSE;
|
---|
162 | return TRUE;
|
---|
163 | }
|
---|
164 |
|
---|
165 |
|
---|
166 | /* This function launches the wrapper <wrapperExe> */
|
---|
167 | /* with the params given as a PM-session */
|
---|
168 | /* in PSZ parameter. PSZ folderPath is the path to put the */
|
---|
169 | /* write.log. HWND hwnd is the window waiting for the */
|
---|
170 | /* WM_APPTERMINATE message */
|
---|
171 | ULONG launchPMWrapper(PSZ chrInstallDir, PSZ parameter, PSZ folderPath, PSZ wrapperExe, PSZ pszTitle)
|
---|
172 | {
|
---|
173 | STARTDATA startData={0};
|
---|
174 | APIRET rc;
|
---|
175 | PID pid;
|
---|
176 | ULONG ulSessionID=0;
|
---|
177 | char chrLoadError[CCHMAXPATH];
|
---|
178 | char startParams[CCHMAXPATH*4];
|
---|
179 | char exename[CCHMAXPATH]={0};
|
---|
180 | char chrFolderPath[CCHMAXPATH+10];
|
---|
181 |
|
---|
182 | memset(&startData,0,sizeof(startData));
|
---|
183 | startData.Length=sizeof(startData);
|
---|
184 | startData.Related=SSF_RELATED_INDEPENDENT;
|
---|
185 | startData.FgBg=SSF_FGBG_FORE;
|
---|
186 | startData.TraceOpt=SSF_TRACEOPT_NONE;
|
---|
187 | startData.PgmTitle=pszTitle;
|
---|
188 |
|
---|
189 | /* sprintf(exename,"%s",buildWrapName(wrapperExe));*/
|
---|
190 | sprintf(exename,"%s\\bin\\%s",params[1],wrapperExe);
|
---|
191 | /*
|
---|
192 | if(!checkHelper(exename))
|
---|
193 | return -1;
|
---|
194 | */
|
---|
195 |
|
---|
196 | startData.PgmName=exename;
|
---|
197 | startData.InheritOpt=SSF_INHERTOPT_SHELL;
|
---|
198 | startData.SessionType=SSF_TYPE_PM;
|
---|
199 | startData.PgmControl=0;
|
---|
200 | startData.InitXPos=30;
|
---|
201 | startData.InitYPos=30;
|
---|
202 | startData.InitXSize=500;
|
---|
203 | startData.InitYSize=400;
|
---|
204 | startData.ObjectBuffer=chrLoadError;
|
---|
205 | startData.ObjectBuffLen=(ULONG)sizeof(chrLoadError);
|
---|
206 |
|
---|
207 | /* Put the exe-path between " " to make sure, spaces are handled correctly */
|
---|
208 | strcpy(chrFolderPath,folderPath);
|
---|
209 | sprintf(startParams,"\"%s\" \"%s\" %s",
|
---|
210 | chrInstallDir,chrFolderPath, parameter);
|
---|
211 | startData.PgmInputs=startParams;
|
---|
212 |
|
---|
213 | rc=DosStartSession(&startData,&ulSessionID,&pid);
|
---|
214 | return 0;
|
---|
215 | }
|
---|
216 |
|
---|
217 |
|
---|
218 | ULONG launchCmdExe( PSZ wrapperExe, PSZ parameter, PSZ folderPath, PSZ pszTitle)
|
---|
219 | {
|
---|
220 | STARTDATA startData={0};
|
---|
221 | APIRET rc;
|
---|
222 | PID pid;
|
---|
223 | ULONG ulSessionID=0;
|
---|
224 | char chrLoadError[CCHMAXPATH];
|
---|
225 | char startParams[CCHMAXPATH*4];
|
---|
226 | char exename[CCHMAXPATH]={0};
|
---|
227 | char chrCDRexe[CCHMAXPATH+10];
|
---|
228 | struct stat statBuf;
|
---|
229 |
|
---|
230 | strcpy(exename,wrapperExe);
|
---|
231 |
|
---|
232 | writeLog("\nStarting '");
|
---|
233 | writeLog(exename);
|
---|
234 | writeLog("' with the following parameters:\n");
|
---|
235 |
|
---|
236 |
|
---|
237 | memset(&startData,0,sizeof(startData));
|
---|
238 | startData.Length=sizeof(startData);
|
---|
239 | startData.Related=SSF_RELATED_INDEPENDENT;
|
---|
240 | startData.FgBg=SSF_FGBG_BACK;
|
---|
241 | startData.TraceOpt=SSF_TRACEOPT_NONE;
|
---|
242 | startData.PgmTitle=pszTitle;
|
---|
243 | startData.PgmName=exename;
|
---|
244 | startData.InheritOpt=SSF_INHERTOPT_SHELL;
|
---|
245 | startData.SessionType=SSF_TYPE_WINDOWABLEVIO;
|
---|
246 | startData.PgmControl=0;
|
---|
247 | // if(lCDROptions&IDCDR_HIDEWINDOW)
|
---|
248 | startData.PgmControl|=SSF_CONTROL_INVISIBLE;//|SSF_CONTROL_MAXIMIZE|SSF_CONTROL_NOAUTOCLOSE;
|
---|
249 | // if(!(lCDROptions&IDCDR_CLOSEWINDOW))
|
---|
250 | //startData.PgmControl|=SSF_CONTROL_NOAUTOCLOSE;
|
---|
251 | startData.InitXPos=30;
|
---|
252 | startData.InitYPos=30;
|
---|
253 | startData.InitXSize=500;
|
---|
254 | startData.InitYSize=400;
|
---|
255 | startData.ObjectBuffer=chrLoadError;
|
---|
256 | startData.ObjectBuffLen=(ULONG)sizeof(chrLoadError);
|
---|
257 |
|
---|
258 | startData.PgmInputs=parameter;
|
---|
259 |
|
---|
260 | writeLog("\n\n");
|
---|
261 |
|
---|
262 | rc=DosStartSession(&startData,&ulSessionID,&pid);
|
---|
263 | if(rc!=NO_ERROR) {
|
---|
264 | writeLog("Error while starting: ");
|
---|
265 | sprintf(chrLoadError,"%d\n",rc);
|
---|
266 | writeLog(chrLoadError);
|
---|
267 | return -1;
|
---|
268 | }
|
---|
269 | return 0;
|
---|
270 | }
|
---|
271 |
|
---|
272 | #if 0
|
---|
273 | BOOL readWindowPosFromIni(char * installDir, char *chrKey)
|
---|
274 | {
|
---|
275 | char profileName[CCHMAXPATH];
|
---|
276 | char moduleName[CCHMAXPATH];
|
---|
277 | HINI hini=0;
|
---|
278 | ULONG ulSize;
|
---|
279 | BOOL bError=FALSE;
|
---|
280 | HWND hwnd;
|
---|
281 |
|
---|
282 | hwnd=HWND_DESKTOP;
|
---|
283 |
|
---|
284 | strncpy(chrInstallDir, installDir,sizeof(chrInstallDir));
|
---|
285 | /* Build full path for cdrecord.ini file */
|
---|
286 | sprintf(profileName,"%s\\cdrecord.ini", installDir);
|
---|
287 | /* Insert message in Logfile */
|
---|
288 | writeLog("Reading Window position from ");
|
---|
289 | writeLog(profileName);
|
---|
290 | writeLog("\n");
|
---|
291 |
|
---|
292 | /* Open ini-file */
|
---|
293 | hini=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),(unsigned char *)profileName);
|
---|
294 | do{
|
---|
295 | if(!hini) {
|
---|
296 | /* profileName: "Warning! Cannot open Ini-file!"
|
---|
297 | moduleName: "Data-CD-Creator"
|
---|
298 | */
|
---|
299 | messageBox( profileName, IDSTR_INIFILEOPENWARNING , sizeof(profileName),
|
---|
300 | moduleName, IDSTRD_DATACDCREATOR, sizeof(moduleName),
|
---|
301 | RESSOURCEHANDLE, HWND_DESKTOP, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE);
|
---|
302 | break;
|
---|
303 | }/* end of if(!hini) */
|
---|
304 |
|
---|
305 | ulSize=sizeof(swpWindow);
|
---|
306 | if(!PrfQueryProfileData(hini,"windowposition", chrKey, &swpWindow, &ulSize))
|
---|
307 | bError=TRUE;
|
---|
308 |
|
---|
309 | if(hini)
|
---|
310 | PrfCloseProfile(hini);
|
---|
311 |
|
---|
312 | if(bError)
|
---|
313 | break;
|
---|
314 | return TRUE;
|
---|
315 | } while(TRUE);
|
---|
316 | writeLog("Error while reading cdrecord.ini\n");
|
---|
317 | return FALSE;
|
---|
318 | }
|
---|
319 |
|
---|
320 | BOOL writeWindowPosToIni(char * installDir, char *chrKey)
|
---|
321 | {
|
---|
322 | char profileName[CCHMAXPATH];
|
---|
323 | char moduleName[CCHMAXPATH];
|
---|
324 | HINI hini=0;
|
---|
325 | ULONG ulSize;
|
---|
326 | BOOL bError=FALSE;
|
---|
327 | HWND hwnd;
|
---|
328 |
|
---|
329 | hwnd=HWND_DESKTOP;
|
---|
330 |
|
---|
331 | strncpy(chrInstallDir, installDir,sizeof(chrInstallDir));
|
---|
332 | /* Build full path for cdrecord.ini file */
|
---|
333 | sprintf(profileName,"%s\\cdrecord.ini", installDir);
|
---|
334 | /* Insert message in Logfile */
|
---|
335 | writeLog("Writing Window position to ");
|
---|
336 | writeLog(profileName);
|
---|
337 | writeLog("\n");
|
---|
338 |
|
---|
339 | /* Open ini-file */
|
---|
340 | hini=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),(unsigned char *)profileName);
|
---|
341 | do{
|
---|
342 | if(!hini) {
|
---|
343 | /* profileName: "Warning! Cannot open Ini-file!"
|
---|
344 | moduleName: "Data-CD-Creator"
|
---|
345 | */
|
---|
346 | messageBox( profileName, IDSTR_INIFILEOPENWARNING , sizeof(profileName),
|
---|
347 | moduleName, IDSTRD_DATACDCREATOR, sizeof(moduleName),
|
---|
348 | RESSOURCEHANDLE, HWND_DESKTOP, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE);
|
---|
349 | break;
|
---|
350 | }/* end of if(!hini) */
|
---|
351 |
|
---|
352 | if(!PrfWriteProfileData(hini,"windowposition", chrKey, &swpWindow, sizeof(swpWindow)))
|
---|
353 | bError=TRUE;
|
---|
354 |
|
---|
355 | if(hini)
|
---|
356 | PrfCloseProfile(hini);
|
---|
357 |
|
---|
358 | if(bError)
|
---|
359 | break;
|
---|
360 | return TRUE;
|
---|
361 | } while(TRUE);
|
---|
362 | writeLog("Error while writing cdrecord.ini\n");
|
---|
363 | return FALSE;
|
---|
364 | }
|
---|
365 |
|
---|
366 |
|
---|
367 | BOOL readIni2(char * installDir)
|
---|
368 | {
|
---|
369 | ULONG keyLength;
|
---|
370 | char profileName[CCHMAXPATH];
|
---|
371 | char moduleName[CCHMAXPATH];
|
---|
372 | char *chrPtr;
|
---|
373 | char *chrPtr2;
|
---|
374 | HINI hini=0;
|
---|
375 | char text[200];
|
---|
376 | ULONG ulSize;
|
---|
377 | int a;
|
---|
378 | char chrCD[4];
|
---|
379 | BOOL bError=FALSE;
|
---|
380 | HWND hwnd;
|
---|
381 |
|
---|
382 | hwnd=HWND_DESKTOP;
|
---|
383 |
|
---|
384 | strncpy(chrInstallDir, installDir,sizeof(chrInstallDir));
|
---|
385 | /* Build full path for cdrecord.ini file */
|
---|
386 | sprintf(profileName,"%s\\cdrecord.ini", installDir);
|
---|
387 | /* Insert message in Logfile */
|
---|
388 | writeLog("Reading values from ");
|
---|
389 | writeLog(profileName);
|
---|
390 | writeLog("\n");
|
---|
391 |
|
---|
392 | /* Open ini-file */
|
---|
393 | hini=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),(unsigned char *)profileName);
|
---|
394 | do{
|
---|
395 | if(!hini) {
|
---|
396 | /* profileName: "Warning! Cannot open Ini-file!"
|
---|
397 | moduleName: "Data-CD-Creator"
|
---|
398 | */
|
---|
399 | messageBox( profileName, IDSTR_INIFILEOPENWARNING , sizeof(profileName),
|
---|
400 | moduleName, IDSTRD_DATACDCREATOR, sizeof(moduleName),
|
---|
401 | RESSOURCEHANDLE, HWND_DESKTOP, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE);
|
---|
402 | break;
|
---|
403 | }/* end of if(!hini) */
|
---|
404 |
|
---|
405 | keyLength=PrfQueryProfileString(hini,"CDWriter","cdrecord","",chrCDRecord,sizeof(chrCDRecord));
|
---|
406 | if(keyLength==1){
|
---|
407 | /* Text: "No CDRecord/2 path in cdrecord.ini found!\n" */
|
---|
408 | getMessage(text, IDSTRLOG_NOCDRECORD, sizeof(text), RESSOURCEHANDLE , hwnd);
|
---|
409 | writeLog(text);
|
---|
410 | writeLog("\n");
|
---|
411 | bError=TRUE;
|
---|
412 | // break;/* First opening. We havn't got entries yet */
|
---|
413 | }
|
---|
414 |
|
---|
415 | ulSize=sizeof(lCDROptions);
|
---|
416 | PrfQueryProfileData(hini,"CDWriter","options",&lCDROptions,&ulSize);
|
---|
417 |
|
---|
418 | PrfQueryProfileString(hini,"CDWriter","audiocdroptions","",chrAudioCDROptions,sizeof(chrAudioCDROptions));
|
---|
419 | PrfQueryProfileString(hini,"CDWriter","cdroptions","",chrCDROptions,sizeof(chrCDROptions));
|
---|
420 |
|
---|
421 | ulSize=sizeof(lCDROptions);
|
---|
422 | PrfQueryProfileData(hini,"CDWriter","options",&lCDROptions,&ulSize);
|
---|
423 | keyLength=PrfQueryProfileString(hini,"Mkisofs","mkisofs","",chrMkisofs,sizeof(chrMkisofs));
|
---|
424 | if(keyLength==1){
|
---|
425 | /* Text: "No mkisofs path in cdrecord.ini found!\n" */
|
---|
426 | getMessage(text, IDSTRLOG_NOMKISOFS, sizeof(text), RESSOURCEHANDLE , hwnd);
|
---|
427 | writeLog(text);
|
---|
428 | writeLog("\n");
|
---|
429 | bError=TRUE;
|
---|
430 | //break;/* First opening. We havn't got entries yet */
|
---|
431 | }
|
---|
432 |
|
---|
433 | PrfQueryProfileString(hini,"Mkisofs","mkisofsoptions","",chrMkisofsOptions,sizeof(chrMkisofsOptions));
|
---|
434 | //lMKOptions=PrfQueryProfileInt(hini,"Mkisofs","options",IDMK_HIDEWINDOW|IDMK_CLOSEWINDOW);
|
---|
435 | ulSize=sizeof(lMKOptions);
|
---|
436 | PrfQueryProfileData(hini,"Mkisofs","options",&lMKOptions,&ulSize);
|
---|
437 |
|
---|
438 | keyLength=PrfQueryProfileString(hini,"CDGrabber","grabber","",chrGrabberPath,sizeof(chrGrabberPath));
|
---|
439 | if(keyLength==1){
|
---|
440 | /* Text: "No grabber path in cdrecord.ini found!\n" */
|
---|
441 | getMessage(text, IDSTRLOG_NOGRABBER, sizeof(text), RESSOURCEHANDLE , hwnd);
|
---|
442 | writeLog(text);
|
---|
443 | writeLog("\n");
|
---|
444 | bError=TRUE;
|
---|
445 | //break;/* We havn't got entries yet */
|
---|
446 | }
|
---|
447 | PrfQueryProfileString(hini,"CDGrabber","graboptions","",chrGrabberOptions,sizeof(chrGrabberOptions));
|
---|
448 | PrfQueryProfileString(hini,"CDGrabber","grabdrive","",chosenCD,sizeof(chosenCD));
|
---|
449 | bTrackNumbers=PrfQueryProfileInt(hini,"CDGrabber","tracknumbers",1);
|
---|
450 | iGrabberID=PrfQueryProfileInt(hini,"CDGrabber","ID", IDGRABBER_UNKNOWN);/* 99: unknown */
|
---|
451 |
|
---|
452 | keyLength=PrfQueryProfileString(hini,"mpg123","path","",chrMpg123Path,sizeof(chrMpg123Path));
|
---|
453 | if(keyLength==1){
|
---|
454 | /* Text: "No mpg123 path in cdrecord.ini found!\n" */
|
---|
455 | getMessage(text, IDSTRLOG_NOMPG123, sizeof(text), RESSOURCEHANDLE , hwnd);
|
---|
456 | writeLog(text);
|
---|
457 | writeLog("\n");
|
---|
458 | bError=TRUE;
|
---|
459 | // break;/* We havn't got entries yet */
|
---|
460 | }
|
---|
461 | bMpg123SwabBytes=PrfQueryProfileInt(hini,"mpg123","swabbytes",1);
|
---|
462 | iMp3Decoder=PrfQueryProfileInt(hini,"mpg123","decoder",IDKEY_USEMPG123);/* Which decoder to use */
|
---|
463 |
|
---|
464 | keyLength=PrfQueryProfileString(hini,"cdrdao","path","",chrCdrdaoPath,sizeof(chrCdrdaoPath));
|
---|
465 | if(keyLength==1){
|
---|
466 | /* Text: "No cdrdao/2 path in cdrecord.ini found!\n" */
|
---|
467 | getMessage(text, IDSTRLOG_NOCDRDAO, sizeof(text), RESSOURCEHANDLE , hwnd);
|
---|
468 | writeLog(text);
|
---|
469 | writeLog("\n");
|
---|
470 | bError=TRUE;
|
---|
471 | // break; /* We havn't got entries yet */
|
---|
472 | }
|
---|
473 |
|
---|
474 | keyLength=PrfQueryProfileString(hini,"cdrdao","driver","",chrCdrdaoDriver,sizeof(chrCdrdaoDriver));
|
---|
475 | if(keyLength==1){
|
---|
476 | /* Text: "No driver for cdrdao/2 found in cdrecord.ini!\n" */
|
---|
477 | getMessage(text, IDSTRLOG_NOCDRDAODRIVER, sizeof(text), RESSOURCEHANDLE , hwnd);
|
---|
478 | writeLog(text);
|
---|
479 | writeLog("\n");
|
---|
480 | bError=TRUE;
|
---|
481 | /* We havn't got entries yet */
|
---|
482 | //break;
|
---|
483 | }
|
---|
484 |
|
---|
485 | PrfQueryProfileString(hini,"isofs","mountpath","",chrMntIsoFS,sizeof(chrMntIsoFS));
|
---|
486 | PrfQueryProfileString(hini,"isofs","unmountpath","",chrUmntIso, sizeof(chrUmntIso));
|
---|
487 |
|
---|
488 | iBus=PrfQueryProfileInt(hini,"device","bus",0);
|
---|
489 | iTarget=PrfQueryProfileInt(hini,"device","target",0);
|
---|
490 | iLun=PrfQueryProfileInt(hini,"device","lun",0);
|
---|
491 | iSpeed=PrfQueryProfileInt(hini,"device","speed",1);
|
---|
492 | iFifo=PrfQueryProfileInt(hini,"device","fifo",4);
|
---|
493 |
|
---|
494 | bUseCDDB=PrfQueryProfileInt(hini,"cddb","usecddb",0);
|
---|
495 | bTipsEnabled=PrfQueryProfileInt(hini,"tips","enable",1);
|
---|
496 |
|
---|
497 | if(hini)
|
---|
498 | PrfCloseProfile(hini);
|
---|
499 |
|
---|
500 | if(bError)
|
---|
501 | break;
|
---|
502 | return TRUE;
|
---|
503 | } while(TRUE);
|
---|
504 | writeLog("Error while reading cdrecord.ini\n");
|
---|
505 | return FALSE;
|
---|
506 | }
|
---|
507 |
|
---|
508 |
|
---|
509 | static void _HlpBuildProfileName(char* chrBuffer, int iBufferSize)
|
---|
510 | {
|
---|
511 | /* Build full path for cdrecord.ini file */
|
---|
512 | snprintf(chrBuffer, iBufferSize, "%s\\cdrecord.ini", chrInstallDir);
|
---|
513 | chrBuffer[iBufferSize-1]=0; /* Always terminate with zero */
|
---|
514 | }
|
---|
515 |
|
---|
516 | HINI HlpOpenIni()
|
---|
517 | {
|
---|
518 | char profileName[CCHMAXPATH];
|
---|
519 |
|
---|
520 | /* Build full path for cdrecord.ini file */
|
---|
521 | _HlpBuildProfileName(profileName, sizeof(profileName));
|
---|
522 |
|
---|
523 | /* Open ini-file */
|
---|
524 | return PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),(unsigned char *)profileName);
|
---|
525 | }
|
---|
526 |
|
---|
527 | void HlpCloseIni(HINI hini)
|
---|
528 | {
|
---|
529 | if(hini)
|
---|
530 | PrfCloseProfile(hini);
|
---|
531 | }
|
---|
532 | #endif
|
---|
533 |
|
---|
534 | /* This function returns the module handle of our ressource dll */
|
---|
535 | HMODULE queryResModuleHandle2(char *installDir, char * chrBaseName)
|
---|
536 | {
|
---|
537 | COUNTRYCODE country= {0};
|
---|
538 | COUNTRYINFO countryInfo= {0};
|
---|
539 | char path[CCHMAXPATH];
|
---|
540 | char buf[CCHMAXPATH];
|
---|
541 | char* found;
|
---|
542 | APIRET rc;
|
---|
543 | ULONG ulInfoLen;
|
---|
544 |
|
---|
545 | if(!RESSOURCEHANDLE) {
|
---|
546 | writeLog("Trying to load ressource DLL.\n");
|
---|
547 |
|
---|
548 | /* Get the country code of our system and load the
|
---|
549 | resource DLL with the right language */
|
---|
550 | do {
|
---|
551 | rc=DosQueryCtryInfo(sizeof(countryInfo),&country,&countryInfo,&ulInfoLen);
|
---|
552 | if(rc!=NO_ERROR) {
|
---|
553 | /* Insert message in Logfile */
|
---|
554 | writeLog(__FUNCTION__);
|
---|
555 | writeLog(": Can't get country info. Ressource-DLL will not be loaded.\n");
|
---|
556 | break;
|
---|
557 | }
|
---|
558 | sprintf(path,"%s", installDir);
|
---|
559 |
|
---|
560 | sprintf(buf,"\\%s%03d.dll", chrBaseName, countryInfo.country);
|
---|
561 | strcat(path,buf);
|
---|
562 | /* Insert message in Logfile */
|
---|
563 | writeLog("Using the following DLL path: ");
|
---|
564 | writeLog(path);
|
---|
565 | writeLog("\n");
|
---|
566 |
|
---|
567 | //WinMessageBox( HWND_DESKTOP,0, path, "Search DLL...", 0UL, MB_YESNO | MB_ICONEXCLAMATION|MB_MOVEABLE );
|
---|
568 | rc=DosLoadModule(buf,sizeof(buf),path, &RESSOURCEHANDLE);
|
---|
569 | if(rc==NO_ERROR)
|
---|
570 | break;
|
---|
571 |
|
---|
572 | /* Insert message in Logfile */
|
---|
573 | writeLog("Ressource-DLL for the current countrycode not found. Trying to load default one (nnnnn001.DLL).\n");
|
---|
574 |
|
---|
575 | /* NLS DLL not found. Try to load default */
|
---|
576 | found=strrchr(path,'\\');
|
---|
577 | if(!found)
|
---|
578 | break;
|
---|
579 |
|
---|
580 | *found=0;
|
---|
581 | sprintf(buf,"\\%s001.dll", chrBaseName);
|
---|
582 | strcat(path,buf);
|
---|
583 | writeLog("Using the following DLL path: ");
|
---|
584 | writeLog(path);
|
---|
585 | writeLog("\n");
|
---|
586 |
|
---|
587 | rc=DosLoadModule(buf,sizeof(buf),path, &RESSOURCEHANDLE);
|
---|
588 | if(rc!=NO_ERROR) {
|
---|
589 | writeLog("Can't load DLL!\n");
|
---|
590 | RESSOURCEHANDLE=NULLHANDLE;
|
---|
591 | }
|
---|
592 | else {
|
---|
593 | writeLog("Ressource DLL loaded.\n");
|
---|
594 | }
|
---|
595 | break;
|
---|
596 | }while(TRUE);
|
---|
597 | }
|
---|
598 | return RESSOURCEHANDLE;
|
---|
599 | }
|
---|
600 |
|
---|
601 | void freeResHandle()
|
---|
602 | {
|
---|
603 | if(RESSOURCEHANDLE)
|
---|
604 | DosFreeModule(RESSOURCEHANDLE);
|
---|
605 | }
|
---|
606 |
|
---|
607 | #if 0
|
---|
608 | void sendCommand(char* command)
|
---|
609 | {
|
---|
610 | HOBJECT hObject;
|
---|
611 | char chrCommand[CCHMAXPATH];
|
---|
612 |
|
---|
613 | hObject=WinQueryObject(params[2]);
|
---|
614 | sprintf(chrCommand,"Querying object pointer for: %s\n",params[2]);
|
---|
615 | writeLog(chrCommand);
|
---|
616 | if(hObject!=NULLHANDLE) {
|
---|
617 | strcpy(chrCommand,command);
|
---|
618 | WinSetObjectData(hObject,chrCommand);
|
---|
619 | writeLog("Sending command to folder: ");
|
---|
620 | writeLog(command);
|
---|
621 | writeLog("\n");
|
---|
622 | }
|
---|
623 | else {
|
---|
624 | sprintf(chrCommand,"Can't query object pointer for: %s\n",params[2]);
|
---|
625 | writeLog(chrCommand);
|
---|
626 | }
|
---|
627 | }
|
---|
628 | #endif
|
---|
629 |
|
---|
630 | void HlpSendCommandToObject(char* chrObject, char* command)
|
---|
631 | {
|
---|
632 | HOBJECT hObject;
|
---|
633 | char chrCommand[CCHMAXPATH];
|
---|
634 |
|
---|
635 | hObject=WinQueryObject(chrObject);
|
---|
636 | sprintf(chrCommand,"Querying object pointer for: %s\n", chrObject);
|
---|
637 | writeLog(chrCommand);
|
---|
638 | if(hObject!=NULLHANDLE) {
|
---|
639 | strcpy(chrCommand,command);
|
---|
640 | WinSetObjectData(hObject,chrCommand);
|
---|
641 | writeLog("Sending command to object: ");
|
---|
642 | writeLog(command);
|
---|
643 | writeLog("\n");
|
---|
644 | }
|
---|
645 | else {
|
---|
646 | sprintf(chrCommand,"Can't query object pointer for: %s\n", chrObject);
|
---|
647 | writeLog(chrCommand);
|
---|
648 | }
|
---|
649 | }
|
---|