From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 18-JUN-1992 13:04:26.12
To:	info-vax@kl.sri.com
CC:	
Subj:	Re: Split & Fsplit on VMS? Archie for VMS?

In article <1992Jun16.103933.1@woods.ulowell.edu>, bhuttam@woods.ulowell.edu 
 (Bilal A. Bhutta  aka The Nukeman) writes:
> Hello Netters,
>     Is there a port of the Unix commands split and fsplit to VMS? Also when one 
 [rest of message deleted]

I am not sure if this is what you are looking for.  I was in need of a utility
to break up a very large file (over 3Mbytes) into several smaller chunks to be
downloaded to PC floppies (DOS backup was to technical for the user it was to
be given to).

Robert Smith  -- smith@leeca.oecn.ohio.gov
Lorain County Board of Education
Elyria, Ohio
(216) 324-2931

/************* cut here *****************************************************
   split.c 

   This program will split a file into smaller chunks.  Split require three
   parameters: the input file, the output file, and the number of lines
   to split the input file into.  The output files will have a version/part
   number appended to the extention (actually, a letter).  Split will 
   breakup the input file into up to 26 parts of 65,000 lines each
   (theoretically, anyway).

   NO WARRANTY OR GARUANTEE IS IMPLIED OR PROMISED.  USE AT YOUR RISK.  While
   I have made every effort to ensure this program works as stated, I will
   not be held liable for any damages that may occur.

   Robert Smith
   April 1992.
*****************************************************************************/

#include <stdio.h>

#define BUFFSIZE 132

int main (int argc, char **argv)
{
    FILE *fp, *fout;
    char buffer[BUFFSIZE];
    char outFile[BUFFSIZE];
    char extArray[27] = { "ABCDEFGHIJKLMNOPQRSTUVWXYZ" };
    char extention;
    int x = 0;
    int i=0;
    int lines = 1;

    if (argc < 4) {
       printf ("\n\r Usage: Split Inputfile Outputfile Number of lines \n\r");
       exit (-1);
    }

    if ((fp = fopen (argv[1], "r")) == NULL ) {
         printf ("\n\r %s not found \n\r", argv[1]);
         exit (-1);
    }


    strcpy (outFile, argv[2]);
    outFile[strlen(outFile)] = extArray[x];
    outFile[strlen(outFile)] = '\0';

    if ((fout = fopen ( outFile, "w")) == NULL ) {
         printf ("\n\r %s cannot be opened for output! \n\r", argv[2]);
         exit (-2);
    }

    i = atoi(argv[3]);

    while (fgets (buffer, BUFFSIZE, fp) != NULL) {
         fprintf (fout, "%s", buffer);
         lines++;
         if (lines > i) {
           fclose (fout);
           strcpy (outFile, argv[2]);
           x++;
           if (x > 25) {
              fprintf (stderr, "\n\rError Occurred -- Input File needs to be");
              fprintf (stderr, " split into larger pieces!\n\r");
              exit (-3);
           }
           outFile[strlen(outFile)] = extArray[x];
           outFile[strlen(outFile)] = '\0';
           if ((fout = fopen ( outFile, "w")) == NULL ) {
               printf ("\n\r %s cannot be opened for output! \n\r", argv[2]);
               exit (-2);
           }
          lines = 1;
          }
    }

    fclose (fp);
    fclose (fout);

    return (0);
}

/*************** end split.c ******************************************/

