home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CBM Funet Archive
/
cbm-funet-archive-2003.iso
/
cbm
/
crossplatform
/
converters
/
unix
/
unkar.c
< prev
Wrap
C/C++ Source or Header
|
1994-05-12
|
1KB
|
57 lines
#INCLUDE <STDIO.H>
INT GETLINE();
INT ATOI();
MAIN(ARGC, ARGV)
INT ARGC;
CHAR *ARGV[];
{$7b}
file *FIN, *FOUT;
CHAR LINE[1000];
INT NFILES, NLINES, IFILE, ILINE;
IF (ARGC != 2) {$7b}
FPRINTF(STDERR, "USAGE: %S FILENAME\N", ARGV[0]);
EXIT( 1 );
{$7d}
FIN = FOPEN( ARGV[1], "R" );
IF (FIN == null) {$7b}
FPRINTF(STDERR, "eRROR OPENING FILE \"%S\".\N", ARGV[1]);
EXIT( 1 );
{$7d}
GETLINE( FIN, LINE );
NFILES = ATOI( LINE );
PRINTF("fILES TO EXTRACT = %D\N", NFILES);
FOR (IFILE=1; IFILE <= NFILES; IFILE++) {$7b}
GETLINE( FIN, LINE );
PRINTF("%D. eXTRACTING \"%S\"", IFILE, LINE);
FOUT = FOPEN( LINE, "W" );
IF (FOUT == null) {$7b}
FPRINTF(STDERR, "\NuNABLE TO OPEN \"%S\" FOR OUTPUT\N",
LINE);
EXIT(1);
{$7d}
GETLINE( FIN, LINE );
NLINES = ATOI( LINE );
PRINTF(", LINES=%D\N", NLINES);
FOR (ILINE=1; ILINE <= NLINES; ILINE++) {$7b}
GETLINE( FIN, LINE );
FPRINTF(FOUT, "%S\N", LINE);
{$7d}
FCLOSE( FOUT );
{$7d}
{$7d}
INT GETLINE( FILE, LINE )
REGISTER file *FILE;
REGISTER CHAR *LINE;
{$7b}
REGISTER INT C;
WHILE ((C=GETC(FILE)) != '\N') {$7b}
*LINE++ = C;
{$7d}
*LINE = '\0';
{$7d}