Category : Utilities for DOS and Windows Machines
Archive   : BLDZIP.ZIP
Filename : BLDZIP.C

 
Output of file : BLDZIP.C contained in archive : BLDZIP.ZIP
/*****************************

bldzip [ ]

this program takes the file(s) specified in the filespec list and
builds one or more zip files named .zip, such that
each resulting zip file will fit on a floppy disk.

Compile: cl bldzip.c -link /exepack /CP:1
******************************/

#include
#include
#include
#include
#include
#include
#include
#include
#include
main(argc,argv)

int argc;
char *argv[];

{
int ret;
int argidx; // index to current filespec argv
int first = -1; // first file in a given search?
long floppy_size; // size in bytes of target file

char sysname[60]; // base file name for zip files
static char filetag[2] = "A"; // extension for zip file name
int filetagidx; // index of filetag in file name
struct find_t findbuf; // buffer for DOS dir search
struct stat statbuf; // DOS fileinfo buffer

char zipfilename[66]; // path & name of zip program

long thisfile, // size of current file to be zip'd
thiszip = 0L; // size of current zip file

printf("BLDzip (%s)\n",__DATE__);
printf("Copyright 1989, Steven D. Stern\n");
strcpy(zipfilename,"pkzip.exe");

if (argc < 4) // at least three parameters are required
{
fprintf(stderr,
"Usage is BLDzip ... \n");
exit(1);
}

floppy_size = atoi(argv[1]);
floppy_size *= 1024;

filetagidx = strlen(argv[2]);
if (filetagidx > 7) // system name cannot exceed 7 char
{
fprintf(stderr,
"System name %s is too long.",argv[1]);
argv[2][7] = '\0';
filetagidx = 7;
fprintf(stderr,
" Truncating to %s\n",argv[2]);
}

testzip:
ret = access(zipfilename,0);
if (ret)
{
fprintf(stderr,
"Can't find %s.\nWhat's the fully qualified name of the zip program? ",
zipfilename);
scanf("%s",zipfilename);
goto testzip;
}

strcpy(sysname,argv[2]);
strcat(sysname,filetag);
strcat(sysname,".zip");

argidx = 2;
while (argidx <= argc) // work through each filespec
{
if (first)
{
ret = _dos_findfirst(argv[argidx],_A_NORMAL,&findbuf);
if (ret) // no more files
{
first = -1;
argidx++;
continue;
}
first = 0;
}
else
{
ret = _dos_findnext(&findbuf);
if (ret) // no more files
{
first = -1;
argidx++;
continue;
}
}

if (!strnicmp(sysname,findbuf.name,filetagidx))
continue; // skip the .zip file(s) being built

thisfile = 0.6 * findbuf.size; // assume 40% compression
if (thisfile + thiszip > floppy_size) // too big for floppy
{
*filetag = sysname[filetagidx];
if (*filetag < 'Z') // can the tag be bumped?
{
*filetag = (*filetag) + 1;
sysname[filetagidx] = *filetag;
thiszip = 0L;
}
else
{
fprintf(stderr,
"\nOut of legal file names for the zip files - Program Abort\n");
exit(1);
}
}

add_zip(zipfilename,sysname,findbuf.name);

stat(sysname,&statbuf);
thiszip = statbuf.st_size;

} // while

}


add_zip( char *program, // name of ziphive program
char *zipname, // name of target zip file
char *filename) // name of file to be zip'd

{
int ret;


ret = spawnle(P_WAIT,program,program,zipname,"-a",filename,NULL);
if (ret != 0)
{
perror("Zip server failed");
exit(1);
}
}


  3 Responses to “Category : Utilities for DOS and Windows Machines
Archive   : BLDZIP.ZIP
Filename : BLDZIP.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/