home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / ZIPCOMNT.ZIP / ZIPCOMNT.C < prev    next >
Text File  |  1989-10-15  |  3KB  |  149 lines

  1. #define INCL_BASE
  2. #include <os2.h>
  3.  
  4.    USHORT selEnvironment;
  5.    USHORT offCommand;
  6.    PSZ pszCommandLine;
  7.    USHORT cbWritten;
  8.    USHORT cch, i, i2;
  9.    char achFailName[128];
  10.    RESULTCODES rescResults;
  11.    char readbuf[85];
  12.    char *p;
  13.    HDIR hdir = 0xFFFF;
  14.    FILEFINDBUF findbuf;
  15.    USHORT usSearchCount = 1;
  16.    int code;
  17.    char *path;   
  18.    char *temp_path;
  19.    char *zipstring;    
  20.  
  21. main()
  22.  
  23. {
  24.    VioWrtTTy("\r\nZIPCOMNT - version 1.00 - OS/2\r\n",34,0);
  25.  
  26.    DosGetEnv(&selEnvironment, &offCommand);
  27.    pszCommandLine = MAKEP(selEnvironment, offCommand);
  28.  
  29.    for (i = 0; pszCommandLine[i]; i++);
  30.  
  31.    path = (char *) malloc(64);   
  32.    memset(path,0,64);
  33.    for (i++, cch = 0; pszCommandLine[cch + i]; cch++);
  34.    i++;
  35.    for (i2 = 0; i2 < cch; i2++) 
  36.      {
  37.      path[i2] = pszCommandLine[i + i2];
  38.      }
  39.  
  40.    memset(readbuf,0,sizeof(readbuf));
  41.    strcpy(readbuf, "CMD.EXE");
  42.  
  43.    temp_path = (char *) malloc(64);
  44.    memset(temp_path,0,64);
  45.    strcpy(temp_path, strupr(path));
  46.  
  47.    zipstring = (char *) malloc(64);
  48.    memset(zipstring,0,64);
  49.  
  50.    p = (&readbuf[strlen(readbuf)]+1);
  51.  
  52.    strcpy(zipstring, "0<COMMENT.FIL");
  53.  
  54.    findfirstzip();
  55.    if (code == 0)
  56.      findrestzip();            
  57.    else
  58.      usage();
  59.  
  60.    VioWrtTTy("\r\n",2,0);
  61.    DosExit(EXIT_PROCESS,0);
  62. }
  63.  
  64. findfirstzip()
  65. {
  66.    code = DosFindFirst(path,&hdir,0x00,&findbuf,sizeof(findbuf),
  67.                        &usSearchCount,0L);
  68.  
  69.    if (code == 0)
  70.      {
  71.      justpathname(temp_path);
  72.      strcpy(p, "/C PKZIP.EXE -Z ");
  73.      strcat(p, temp_path);
  74.      strcat(p,findbuf.achName,strlen(findbuf.achName));
  75.      strcat(p, " ");
  76.      strcat(p, zipstring);
  77.      code = DosExecPgm(achFailName, sizeof(achFailName), EXEC_SYNC,
  78.             readbuf, 0, &rescResults, readbuf);
  79.      }
  80. }
  81.  
  82. findrestzip()
  83. {
  84.    while (DosFindNext(hdir,&findbuf,sizeof(findbuf),&usSearchCount) == 0)
  85.      {
  86.      VioWrtTTy("\r\n",2,0);
  87.      strcpy(p, "/C PKZIP.EXE -Z ");
  88.      strcat(p, temp_path);
  89.      strcat(p,findbuf.achName,strlen(findbuf.achName));
  90.      strcat(p, " ");
  91.      strcat(p, zipstring);
  92.      code = DosExecPgm(achFailName, sizeof(achFailName), EXEC_SYNC,
  93.             readbuf, 0, &rescResults, readbuf);
  94.      }
  95. }
  96.  
  97. usage()
  98. {
  99.    VioWrtTTy("\r\n",2,0);
  100.    VioWrtTTy("Usage:",6,0);
  101.    VioWrtTTy("\r\n\r\n",4,0);
  102.    VioWrtTTy("ZIPCOMNT n",10,0);
  103.    VioWrtTTy("\r\n\r\n",4,0);
  104.    VioWrtTTy("Where n is ZIP file to comment",30,0);
  105.    VioWrtTTy("\r\n\r\n",4,0);
  106.    VioWrtTTy("Ex: ZIPCOMNT C:\\FILES\\SOME*.ZIP",33,0);
  107.    VioWrtTTy("\r\n\r\n",4,0);
  108.    VioWrtTTy("A file titled COMMENT.FIL *must* exist on DPATH",47,0);
  109.    VioWrtTTy("\r\n\r\n",4,0);
  110.    VioWrtTTy("This comment.fil contains your desired comment to add to .ZIP",61,0);
  111. }
  112.  
  113. justpathname(temp_path)
  114.  
  115. char temp_path[];
  116.  
  117. {
  118.    char *path;
  119.    char *drive;
  120.    char *dir;
  121.    char *fname;
  122.    char *ext;
  123.    
  124.    path = (char *) malloc(64);  
  125.    drive = (char *) malloc(64);
  126.    dir = (char *) malloc(64);
  127.    fname = (char *) malloc(64);
  128.    ext = (char *) malloc(64);
  129.  
  130.    memset(path,0,64);
  131.    memset(drive,0,64);
  132.    memset(dir,0,64);
  133.    memset(fname,0,64);
  134.    memset(ext,0,64);
  135.  
  136.    strcpy(path,temp_path);
  137.    _splitpath(temp_path,drive,dir,fname,ext);
  138.    strcpy(path,drive);
  139.    strcat(path,dir);
  140.    strcpy(temp_path,path);
  141.  
  142.    free(path);
  143.    free(drive);
  144.    free(dir);
  145.    free(fname);
  146.    free(ext);
  147. }
  148. 
  149.