home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 November / PCONLINE_11_99.ISO / filesbbs / OS2 / ACDCR032.ZIP / source / launchers / wrapper.cpp < prev   
Encoding:
C/C++ Source or Header  |  1999-04-04  |  3.1 KB  |  113 lines

  1. /*
  2.  * This program is free software; you can redistribute it and/or modify
  3.  * it under the terms of the GNU General Public License as published by
  4.  * the Free Software Foundation; either version 2, or (at your option)
  5.  * any later version.
  6.  *
  7.  * This program is distributed in the hope that it will be useful,
  8.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.  * GNU General Public License for more details.
  11.  *
  12.  * You should have received a copy of the GNU General Public License
  13.  * along with this program; see the file COPYING.  If not, write to
  14.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  15.  */
  16. #define INCL_DOS
  17. #define INCL_WIN
  18.  
  19. #include <os2.h>
  20. #include <time.h>
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include <io.h>
  25.  
  26. void main(int argc, char * argv[])
  27. {
  28.     int i;
  29.     char cmdLine[CCHMAXPATH*4]={0};
  30.     char cmdLineBuff[CCHMAXPATH*4];
  31.     char * chrPtr;    
  32.     HWND hwndNotify;
  33.     char exeName[CCHMAXPATH];//"g:\\projects_working\\audiocpy\\show.exe";
  34.     char chrError[CCHMAXPATH];
  35.     char logName[CCHMAXPATH];
  36.     RESULTCODES resultCodes;
  37.     ULONG rc,ulAction;
  38.     HFILE hf,hfNew;
  39.     time_t ltime;
  40.     
  41.     //DosBeep(1000,500);
  42.     
  43.     hwndNotify=atol(argv[1]);
  44.  
  45.     /* Build grabber input */
  46.     sprintf(exeName,"%s",argv[2]);
  47.     sprintf(logName,"%s\\grab.log",argv[3]);
  48.     
  49.     sprintf(cmdLine,exeName);
  50.     chrPtr=strrchr(cmdLine,0);
  51.     chrPtr++;
  52.     /* Build parameters */
  53.     for(i=4;i<argc;i++) {
  54.         sprintf(cmdLineBuff,"%s",chrPtr);
  55.         sprintf(chrPtr,"%s %s",cmdLineBuff,argv[i]);
  56.     }
  57.  
  58.         
  59.     printf("HWND: %d",hwndNotify);
  60.     printf("\n");    
  61.     printf("Grabber-executable: %s",exeName);
  62.     printf("\n");
  63.     printf("Logname: %s\n",logName);
  64.     printf("Grabber parameter: %s",chrPtr);
  65.     printf("\n");
  66.     /* Redirect stderr */
  67.     rc=DosOpen(logName,&hf,&ulAction,0,FILE_NORMAL,OPEN_ACTION_CREATE_IF_NEW|OPEN_ACTION_OPEN_IF_EXISTS,
  68.                          OPEN_ACCESS_WRITEONLY|OPEN_SHARE_DENYWRITE,0);
  69.     if(!rc) {
  70.         DosSetFilePtr(hf,0,FILE_END,&ulAction);
  71.         hfNew=2;
  72.         DosDupHandle(hf,&hfNew);
  73.         
  74.         sprintf(logName,"---------------------------------------------------------------------\n");
  75.         write(2,logName,strlen(logName));
  76.  
  77.         sprintf(logName,"\n");
  78.         write(2,logName,strlen(logName));    
  79.  
  80.         /*    time(<ime);
  81.         
  82.         sprintf(logName,"%s",ctime(<ime));
  83.         write(2,logName,strlen(logName));    
  84.  
  85.         sprintf(logName,"\n");
  86.         write(2,logName,strlen(logName));    */
  87.     
  88.         sprintf(logName,"Starting to grab using %s\n",exeName);
  89.         write(2,logName,strlen(logName));
  90.         
  91.         sprintf(logName,"with the following parameters: %s\n",chrPtr);
  92.         write(2,logName,strlen(logName));
  93.     }
  94.     
  95.     DosExecPgm(chrError,sizeof(chrError),EXEC_SYNC,cmdLine,0,&resultCodes,exeName);
  96.     sprintf(logName,"Return code is: %d\n ",resultCodes.codeResult);
  97.     write(2,logName,strlen(logName));
  98.     /*    sprintf(logName,"---------------------------------------------------------------------\n");
  99.     write(2,logName,strlen(logName));*/
  100.     DosClose(hf);
  101.     
  102.     WinPostMsg(hwndNotify,WM_APPTERMINATENOTIFY,0,MPFROMLONG(resultCodes.codeResult));
  103. }
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.