home *** CD-ROM | disk | FTP | other *** search
- /* ATKINSON - HOME COMPUTER - 414-543-8929 */
-
- #define INCL_DOS
- #include <os2.h>
-
- USHORT cbWritten;
- char achFailName[128];
- RESULTCODES rescResults;
- char readbuf[85];
- char *p;
- HDIR hdir = 0xFFFF;
- FILEFINDBUF findbuf;
- USHORT usSearchCount = 1;
- int code;
- int find_result;
- int exec_result;
- char *exec_path;
- char *path;
- char *temp_path;
- char *zipstring;
- char *error_log;
- char *error_message;
- ULONG ulFilePointer = 0;
- HFILE open_fh;
- USHORT usAction;
- int open_result;
- char *zip_file;
- char msg_buf[100];
- FILESTATUS fstsFile;
- int get_info;
- int set_info;
- int dos_close;
- USHORT usAttribute;
- int mode_result;
- char szFoundFile[128];
- int search_result = 0;
- int error_check = 0;
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- DosWrite(1,"\r\nZIPCOMNT - version 1.10 - OS/2\r\n",34,&cbWritten);
-
- exec_path = (char *) malloc(128);
- memset(exec_path,0,128);
- strcpy(exec_path, argv[0]);
- justpathname(exec_path);
- path = (char *) malloc(128);
- memset(path,0,128);
- strcpy(path, argv[1]);
- memset(readbuf,0,sizeof(readbuf));
- strcpy(readbuf, "CMD.EXE");
- temp_path = (char *) malloc(128);
- memset(temp_path,0,128);
- strcpy(temp_path, strupr(path));
- zipstring = (char *) malloc(128);
- memset(zipstring,0,128);
- error_log = (char *) malloc(128);
- memset(error_log,0,128);
- error_message = (char *) malloc(128);
- memset(error_message,0,128);
- zip_file = (char *) malloc(128);
- memset(zip_file,0,128);
-
- p = (&readbuf[strlen(readbuf)]+1);
-
- strcpy(zipstring, "0<COMMENT.FIL");
-
- if (DosSearchPath(SEARCH_ENVIRONMENT,"PATH","PKZIP.EXE",szFoundFile,
- sizeof(szFoundFile)) == 0)
- {
- }
- else
- {
- DosWrite(1, "\r\nPKZIP.EXE not found on PATH\r\n",31,&cbWritten);
- search_result = 1;
- }
-
- if (DosSearchPath(SEARCH_ENVIRONMENT, "DPATH", "COMMENT.FIL", szFoundFile,
- sizeof(szFoundFile)) ==0)
- {
- }
- else
- {
- DosWrite(1, "\r\nCOMMENT.FIL not found on DPATH\r\n",34, &cbWritten);
- search_result = 1;
- }
-
- if (DosSearchPath(SEARCH_ENVIRONMENT, "PATH", "ZIPCOMNT.EXE", szFoundFile,
- sizeof(szFoundFile)) == 0)
- {
- justpathname(szFoundFile);
- }
- else
- {
- DosWrite(1, "\r\nZIPCOMNT.EXE not found on PATH\r\n",34,&cbWritten);
- search_result = 1;
- }
-
- if (search_result == 1)
- {
- DosExit(EXIT_THREAD, 0);
- }
-
- findfirstzip();
-
- if (find_result == 0)
- findrestzip();
- else
- usage();
-
- if (error_check != 0)
- {
- memset(error_message, 0, 128);
- strcpy(error_message, "\r\nSee ");
- strcat(error_message, szFoundFile);
- strcat(error_message, "PKERRORS.LOG\r\n");
- DosWrite(1,error_message,strlen(error_message),&cbWritten);
- }
-
- DosExit(EXIT_THREAD,0);
- }
-
- findfirstzip()
- {
- find_result = DosFindFirst(path,&hdir,0x00,&findbuf,sizeof(findbuf),
- &usSearchCount,0L);
-
- if (find_result == 0)
- {
- justpathname(temp_path);
- strcpy(zip_file, temp_path);
- strcat(zip_file, findbuf.achName);
- mode_result = DosQFileMode(zip_file,&usAttribute,0L);
- open_result = DosOpen(zip_file, &open_fh, &usAction, 0L, 0x00, FILE_OPEN,
- OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, 0L);
- if (open_result == 0)
- {
- get_info = DosQFileInfo(open_fh, 1, &fstsFile, sizeof(fstsFile));
- dos_close = DosClose(open_fh);
- strcpy(p, "/C PKZIP.EXE -Z ");
- strcat(p, temp_path);
- strcat(p,findbuf.achName,strlen(findbuf.achName));
- strcat(p, " ");
- strcat(p, zipstring);
- exec_result = DosExecPgm(achFailName, sizeof(achFailName), EXEC_SYNC,
- readbuf, 0, &rescResults, readbuf);
- if ((open_result == 0) && (get_info == 0) && (dos_close == 0))
- {
- open_result = DosOpen(zip_file, &open_fh, &usAction, 0L, 0x00,
- FILE_OPEN, OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE,
- 0L);
- set_info = DosSetFileInfo(open_fh, 1, &fstsFile, sizeof(fstsFile));
- dos_close = DosClose(open_fh);
- mode_result = DosSetFileMode(zip_file,usAttribute,0L);
- }
- if (rescResults.codeResult != 0)
- {
- memset(error_message,0,128);
- strcpy(error_message, temp_path);
- strcat(error_message, findbuf.achName);
- strcat(error_message, "\r\n");
- memset(error_log,0,128);
- strcpy(error_log, szFoundFile);
- strcat(error_log, "PKERRORS.LOG");
- open_result = DosOpen(error_log, &open_fh, &usAction,0L, 0x00,
- FILE_OPEN | FILE_CREATE,
- OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, 0L);
- DosChgFilePtr(open_fh, 0L, FILE_END, &ulFilePointer);
- DosWrite(open_fh,error_message,strlen(error_message),&cbWritten);
- dos_close = DosClose(open_fh);
- error_check = 1;
- }
- else
- {
- DosWrite(1,"\r\n",2,&cbWritten);
- }
- }
- }
- }
-
- findrestzip()
- {
- while (DosFindNext(hdir,&findbuf,sizeof(findbuf),&usSearchCount) == 0)
- {
- strcpy(zip_file, temp_path);
- strcat(zip_file, findbuf.achName);
- mode_result = DosQFileMode(zip_file,&usAttribute,0L);
- open_result = DosOpen(zip_file, &open_fh, &usAction, 0L, 0x00, FILE_OPEN,
- OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, 0L);
- if (open_result == 0)
- {
- get_info = DosQFileInfo(open_fh, 1, &fstsFile, sizeof(fstsFile));
- dos_close = DosClose(open_fh);
- strcpy(p, "/C PKZIP.EXE -Z ");
- strcat(p, temp_path);
- strcat(p,findbuf.achName,strlen(findbuf.achName));
- strcat(p, " ");
- strcat(p, zipstring);
- exec_result = DosExecPgm(achFailName, sizeof(achFailName), EXEC_SYNC,
- readbuf, 0, &rescResults, readbuf);
- if ((open_result == 0) && (get_info == 0) && (dos_close == 0))
- {
- open_result = DosOpen(zip_file, &open_fh, &usAction, 0L, 0x00,
- FILE_OPEN, OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE,
- 0L);
- set_info = DosSetFileInfo(open_fh, 1, &fstsFile, sizeof(fstsFile));
- dos_close = DosClose(open_fh);
- mode_result = DosSetFileMode(zip_file,usAttribute,0L);
- }
- if (rescResults.codeResult != 0)
- {
- memset(error_message,0,128);
- strcpy(error_message, temp_path);
- strcat(error_message, findbuf.achName);
- strcat(error_message, "\r\n");
- memset(error_log,0,128);
- strcpy(error_log, szFoundFile);
- strcat(error_log, "PKERRORS.LOG");
- open_result = DosOpen(error_log, &open_fh, &usAction,0L, 0x00,
- FILE_OPEN | FILE_CREATE,
- OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, 0L);
- DosChgFilePtr(open_fh,0L,FILE_END,&ulFilePointer);
- DosWrite(open_fh,error_message,strlen(error_message),&cbWritten);
- dos_close = DosClose(open_fh);
- error_check = 1;
- }
- else
- {
- DosWrite(1,"\r\n",2,&cbWritten);
- }
- }
- }
- }
-
- usage()
- {
- DosWrite(1,"\r\n",2,&cbWritten);
- DosWrite(1,"Usage:",6,&cbWritten);
- DosWrite(1,"\r\n\r\n",4,&cbWritten);
- DosWrite(1,"ZIPCOMNT n",10,&cbWritten);
- DosWrite(1,"\r\n\r\n",4,&cbWritten);
- DosWrite(1,"Where n is full path to ZIP file/s to comment",45,&cbWritten);
- DosWrite(1,"\r\n\r\n",4,&cbWritten);
- DosWrite(1,"Ex: ZIPCOMNT C:\\FILES\\SOME*.ZIP",33,&cbWritten);
- DosWrite(1,"\r\n\r\n",4,&cbWritten);
- DosWrite(1,"Ex: ZIPCOMNT D:\\SOME*.ZIP",25,&cbWritten);
- DosWrite(1,"\r\n\r\n",4,&cbWritten);
- DosWrite(1,"A file titled COMMENT.FIL *must* exist on DPATH",47,&cbWritten);
- DosWrite(1,"\r\n\r\n",4,&cbWritten);
- DosWrite(1,"This comment.fil contains your desired comment to add to .ZIP",
- 61,&cbWritten);
- DosWrite(1,"\r\n",2,&cbWritten);
- }
-
- justpathname(temp_path)
-
- char temp_path[];
-
- {
- char *path;
- char *drive;
- char *dir;
- char *fname;
- char *ext;
-
- path = (char *) malloc(128);
- drive = (char *) malloc(128);
- dir = (char *) malloc(128);
- fname = (char *) malloc(128);
- ext = (char *) malloc(128);
-
- memset(path,0,128);
- memset(drive,0,128);
- memset(dir,0,128);
- memset(fname,0,128);
- memset(ext,0,128);
-
- 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);
- }
-