home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!stanford.edu!rutgers!cbmvax!cbmehq!cbmger!imart.franken.de!hcast.franken.de!jow
- From: jow@hcast.franken.de (Juergen Weinelt)
- Newsgroups: comp.sys.amiga.datacomm
- Subject: Re: Splitting .lha files on UNIX
- Message-ID: <jow.02rl@hcast.franken.de>
- Date: 7 Nov 92 00:50:23 GMT
- References: <Bwn9s8.H58@news.cso.uiuc.edu>
- Organization: None at all
- Lines: 110
-
- In article <Bwn9s8.H58@news.cso.uiuc.edu> djs55750@ih-nxt01.cso.uiuc.edu (David John Schulz) writes:
- >For instance, I have a 2 meg lharc file I'd love to break down to several
- >~700k files so I could put then on an MS-DOS disk.
-
- Well, since I've seen no replies so far, I'm going to post my own
- solution to this problem. It should be quite generic. Sorry for
- posting source code to a discussion group, but it's short and
- it may be useful for many readers.
-
- BTW, the language this was written in is actually C. You might
- notice though that I'm usually doing M2 programming :-) So there
- could be several 1000's of bugs in there ( I'm not that familiar
- with C :)
-
- The usual disclaimer applies: this software works fine for me.
- Your mileage may vary. Use at your own risk.
-
-
- --snip--snip--snip--snip--snip--snip--snip--snip--snip--snip--snip--
- #include <stdio.h>
- #include <ctype.h>
- #include <strings.h>
-
-
-
- #define TRUE 1
- #define FALSE 0
- #define NOT(a) (!(a))
- #define AND &&
- #define OR ||
- #define REPEAT do {
- #define UNTIL(a) } while(!(a))
- #define WHILE while (
- #define FOR for(
- #define TO ;
- #define BY ;
- #define DO ) {
- #define IF if(
- #define THEN ) {
- #define ELSE } else {
- #define ELSIF } else if(
- #define END }
- #define BEGIN {
- #define INC(a) a++
- #define DEC(a) a--
-
-
-
- int main(argc,argv)
- int argc;
- char *argv[];
- BEGIN
- FILE *outfile;
- int c;
- int chars;
- int blocksize;
- char ext[50];
- char nam[50];
-
- strcpy(ext,".000");
- IF (argc<2) THEN
- printf("%s outname [blocksize]\n",argv[0]);
- printf(" copy from stdin to a sequence of files named\n");
- printf(" 'outname.xxx' (000<=xxx<=999) with size 'blocksize'\n");
- printf(" (or smaller). default blocksize is 728,000 bytes.\n");
- exit(10);
- END;
- IF (argc>3) THEN
- printf("%s outname [blocksize]\n",argv[0]);
- printf("ERROR: too many parameters\n");
- exit(10);
- END;
- IF (argc==3) THEN
- blocksize=atoi(argv[2]);
- ELSE
- blocksize=728000;
- END;
- REPEAT
- chars=0;
- strcpy(nam,argv[1]);
- strcat(nam,ext);
- outfile=fopen(nam,"w");
- REPEAT
- c=getchar();
- IF (c!=EOF) THEN
- putc(c,outfile);
- END;
- INC(chars);
- UNTIL ((chars==blocksize) OR (c==EOF));
- INC(ext[3]);
- IF (ext[3]>'9') THEN
- ext[3]='0';
- INC(ext[2]);
- IF (ext[2]>'9') THEN
- ext[2]='0';
- INC(ext[1]);
- END;
- END;
- fclose(outfile);
- UNTIL (c==EOF);
- exit(0);
- END
- --snip--snip--snip--snip--snip--snip--snip--snip--snip--snip--snip--
-
-
- -- Juergen Weinelt, Germany
-
- o _ 1) jow@sun.rz.uni-wuerzburg.de (preferred)
- | (_) \/\/ 2) jow@hcast.adsp.sub.org
- ' 3) jow@hcast.franken.de
-