Category : Recently Uploaded Files
Archive   : SNIP9503.ZIP
Filename : SPLIT.C

 
Output of file : SPLIT.C contained in archive : SNIP9503.ZIP
/*
** SPLIT.C - A utility to split large text files into smaller files
**
** public domain by Bob Stout
**
** uses PSPLIT.C from SNIPPETS
*/

#include
#include
#include

#ifdef __TURBOC__
#define FAR far
#else
#define FAR _far
#endif

void psplit(char *, char *, char *, char *, char *);

int main(int argc, char *argv[])
{
long newsize = 32L * 1024L;
size_t seq = 0;
char fname[FILENAME_MAX];
FILE *from;

if (2 > argc)
{
puts("SPLIT big_file [size_in_K]\n");
puts("creates files of the same name, "
"but with numeric extensions");
puts("a maximum file size may be specified for new files");
return EXIT_SUCCESS;
}
if (2 < argc)
{
newsize = atol(argv[2]);
newsize <<= 10;
}
if (NULL == (from = fopen(argv[1], "r")))
{
printf("\aSPLIT: error - can't open %s\n", argv[1]);
return EXIT_FAILURE;
}
psplit(argv[1], NULL, NULL, fname, NULL);
while (!feof(from))
{
char newname[FILENAME_MAX], buf[1024];
FILE *to;
long bytes;

sprintf(newname, "%s.%03d", fname, seq++);
if (NULL == (to = fopen(newname, "w")))
{
printf("\aSPLIT: error - can't write %s\n", newname);
return EXIT_FAILURE;
}
for (bytes = 0L; !feof(from) && (bytes < newsize); )
{
if (fgets(buf, 1023, from))
{
fputs(buf, to);
bytes += (long)strlen(buf);
}
}
fclose(to);
printf("%s written\n", newname);
}
return EXIT_SUCCESS;
}


  3 Responses to “Category : Recently Uploaded Files
Archive   : SNIP9503.ZIP
Filename : SPLIT.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/