home *** CD-ROM | disk | FTP | other *** search
- /* This wrapper prog starts cdrecord/2 to retrieve multisession information
- */
- /*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- */
- #define INCL_DOS
- #define INCL_WIN
-
- #include <os2.h>
- #include <time.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <io.h>
-
- void main(int argc, char * argv[])
- {
- int i;
- char cmdLine[CCHMAXPATH*4]={0};
- char * chrPtr;
- char * chrPtr2;
- HWND hwndNotify;
- char exeName[CCHMAXPATH];//="g:\\projects_working\\audiocpy\\cdrecord.exe";
- char chrError[CCHMAXPATH];
- RESULTCODES resultCodes;
- ULONG rc,ulAction;
-
-
- HFILE SaveStdOut;
- HFILE NewStdOut;
- HPIPE readPipe;
- HPIPE writePipe;
- char puffer[1024];
- ULONG ulBytesRead;
- LONG lValue1=0;
- LONG lValue2=0;
-
- hwndNotify=atol(argv[1]);
- /* Error: no cdrecord options given */
- if(argc<4) {
- WinPostMsg(hwndNotify,WM_APPTERMINATENOTIFY,MPFROMLONG(lValue1),MPFROMLONG(lValue2));
- return;
- }
-
- /* Get input */
- sprintf(exeName,"%s",argv[2]);// cdrecord/2 path
-
- for(i=3;i<argc;i++) {
- /* Find 'dev=' in option string */
- chrPtr=strstr(argv[i],"dev=");
- if(chrPtr!=NULL)i=argc;
- }
-
- /* Error: dev not found */
- if(chrPtr==NULL) {
- WinPostMsg(hwndNotify,WM_APPTERMINATENOTIFY,MPFROMLONG(lValue1),MPFROMLONG(lValue2));
- return;
- }
- /* Build cdrecord/2 cmd-line */
- sprintf(cmdLine,"%s",exeName);
- chrPtr2=strrchr(cmdLine,0)+1;
- sprintf(chrPtr2,"%s -msinfo",chrPtr);
- *(strrchr(chrPtr2,0)+1)=0;
-
- if(DosCreatePipe(&readPipe,&writePipe,1024)) {
- WinPostMsg(hwndNotify,WM_APPTERMINATENOTIFY,MPFROMLONG(lValue1),MPFROMLONG(lValue2));
- return;
- }
-
- /* Save stdout */
- SaveStdOut=-1;
- DosDupHandle(1,&SaveStdOut);
-
- /* Redirect stdout */
- NewStdOut=1;
- DosDupHandle(writePipe,&NewStdOut);
-
- /* start cdrecord/2 */
- DosExecPgm(chrError,sizeof(chrError),EXEC_SYNC,cmdLine,0,&resultCodes,exeName);
-
- /* Retrieve output */
- rc=DosRead(readPipe,puffer,sizeof(puffer),&ulBytesRead);
-
- if(ulBytesRead>2) {
- lValue1=atol(puffer);// Previous session start sector
- puffer[1023]=0; //Make sure we have a terminating zero!
- chrPtr=strchr(puffer,',');
- chrPtr++;
- lValue2=atol(chrPtr);
- }
-
- DosClose(readPipe);
- DosClose(writePipe);
- // sprintf(options,"Wert1: %d Wert2: %d\n",lValue1,lValue2);
- // DosWrite(2,options,strlen(options),&ulBytesRead);
-
-
- /* Send the two values to our notification window */
- WinPostMsg(hwndNotify,WM_APPTERMINATENOTIFY,MPFROMLONG(lValue1),MPFROMLONG(lValue2));
- }
-
-
-
-
-
-
-
-
-
-