home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 9 Archive
/
09-Archive.zip
/
ZIPCOMNT.ZIP
/
ZIPCOMNT.C
< prev
next >
Wrap
Text File
|
1989-10-15
|
3KB
|
149 lines
#define INCL_BASE
#include <os2.h>
USHORT selEnvironment;
USHORT offCommand;
PSZ pszCommandLine;
USHORT cbWritten;
USHORT cch, i, i2;
char achFailName[128];
RESULTCODES rescResults;
char readbuf[85];
char *p;
HDIR hdir = 0xFFFF;
FILEFINDBUF findbuf;
USHORT usSearchCount = 1;
int code;
char *path;
char *temp_path;
char *zipstring;
main()
{
VioWrtTTy("\r\nZIPCOMNT - version 1.00 - OS/2\r\n",34,0);
DosGetEnv(&selEnvironment, &offCommand);
pszCommandLine = MAKEP(selEnvironment, offCommand);
for (i = 0; pszCommandLine[i]; i++);
path = (char *) malloc(64);
memset(path,0,64);
for (i++, cch = 0; pszCommandLine[cch + i]; cch++);
i++;
for (i2 = 0; i2 < cch; i2++)
{
path[i2] = pszCommandLine[i + i2];
}
memset(readbuf,0,sizeof(readbuf));
strcpy(readbuf, "CMD.EXE");
temp_path = (char *) malloc(64);
memset(temp_path,0,64);
strcpy(temp_path, strupr(path));
zipstring = (char *) malloc(64);
memset(zipstring,0,64);
p = (&readbuf[strlen(readbuf)]+1);
strcpy(zipstring, "0<COMMENT.FIL");
findfirstzip();
if (code == 0)
findrestzip();
else
usage();
VioWrtTTy("\r\n",2,0);
DosExit(EXIT_PROCESS,0);
}
findfirstzip()
{
code = DosFindFirst(path,&hdir,0x00,&findbuf,sizeof(findbuf),
&usSearchCount,0L);
if (code == 0)
{
justpathname(temp_path);
strcpy(p, "/C PKZIP.EXE -Z ");
strcat(p, temp_path);
strcat(p,findbuf.achName,strlen(findbuf.achName));
strcat(p, " ");
strcat(p, zipstring);
code = DosExecPgm(achFailName, sizeof(achFailName), EXEC_SYNC,
readbuf, 0, &rescResults, readbuf);
}
}
findrestzip()
{
while (DosFindNext(hdir,&findbuf,sizeof(findbuf),&usSearchCount) == 0)
{
VioWrtTTy("\r\n",2,0);
strcpy(p, "/C PKZIP.EXE -Z ");
strcat(p, temp_path);
strcat(p,findbuf.achName,strlen(findbuf.achName));
strcat(p, " ");
strcat(p, zipstring);
code = DosExecPgm(achFailName, sizeof(achFailName), EXEC_SYNC,
readbuf, 0, &rescResults, readbuf);
}
}
usage()
{
VioWrtTTy("\r\n",2,0);
VioWrtTTy("Usage:",6,0);
VioWrtTTy("\r\n\r\n",4,0);
VioWrtTTy("ZIPCOMNT n",10,0);
VioWrtTTy("\r\n\r\n",4,0);
VioWrtTTy("Where n is ZIP file to comment",30,0);
VioWrtTTy("\r\n\r\n",4,0);
VioWrtTTy("Ex: ZIPCOMNT C:\\FILES\\SOME*.ZIP",33,0);
VioWrtTTy("\r\n\r\n",4,0);
VioWrtTTy("A file titled COMMENT.FIL *must* exist on DPATH",47,0);
VioWrtTTy("\r\n\r\n",4,0);
VioWrtTTy("This comment.fil contains your desired comment to add to .ZIP",61,0);
}
justpathname(temp_path)
char temp_path[];
{
char *path;
char *drive;
char *dir;
char *fname;
char *ext;
path = (char *) malloc(64);
drive = (char *) malloc(64);
dir = (char *) malloc(64);
fname = (char *) malloc(64);
ext = (char *) malloc(64);
memset(path,0,64);
memset(drive,0,64);
memset(dir,0,64);
memset(fname,0,64);
memset(ext,0,64);
strcpy(path,temp_path);
_splitpath(temp_path,drive,dir,fname,ext);
strcpy(path,drive);
strcat(path,dir);
strcpy(temp_path,path);
free(path);
free(drive);
free(dir);
free(fname);
free(ext);
}