DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T m

⟦8c15d840e⟧ TextFile

    Length: 1370 (0x55a)
    Types: TextFile
    Names: »main.c++«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec1/image/truncate/main.c++« 

TextFile

/*
    Main routine for calling the trunc routine
*/

#include <stream.h>
#include <stdio.h>
#include <vartools.h++>

int
main ( int argc , char *argv[] )
    {
    switch(argc)
	{
	// with no arguments it acts as a pipe
    case 1:
	trunc(stdin,stdout,"Truncating file from stdin\n");
    break;
	// with 1 argument it reads from specified file and writes to stdout
    case 2:
	FILE *input;
	if(NULL == (input = fopen(argv[1],"r")))
	    {
	    perror("trunc:");
	    return 5;
	    }
	trunc(input,stdout,form("Truncating file %s\n",argv[1]));
    break;
	// with 2 arguments it reads from specified file and writes to 
	// specified file
    case 3:
	FILE *input;
	FILE *output;
	if(NULL == (input = fopen(argv[1],"r")))
	    {
	    perror("trunc:");
	    return 5;
	    }
	if(NULL == (output = fopen(argv[2],"w")))
	    {
	    perror("trunc:");
	    return 6;
	    }
	trunc(input,output,form("Truncating file %s to file %s\n",argv[1],argv[2]));
    break;
	// otherwise wrong number of arguments failure!
    default:
	cerr << "Syntax is: trunc [input.var [output.var]]";
	return 1;
    break;
	}
    return 0;
    }
/*
Copyright (C) 1986, David Sher in the University of Rochester
Permission is granted to any individual or institution to use, copy, or
redistribute this software so long as it is not sold for profit, provided
this copyright notice is retained.
*/