ftp.nice.ch/pub/next/developer/objc/appkit/ContourPlot.1.4.NIHS.bs.tar.gz#/ContourPlot/stripCPfile.c

This is stripCPfile.c in view mode; [Download] [Up]

/* stripCPfile.c  -- strips data or header portion of ContourPlot format file

   "stripCPfile infile -h" will keep the header (upto and including ZDATA line)
   "stripCPfile infile -d" will keep the data (after ZDATA line)


   This is for Matlab manipulation of the data portion.

   1996-06-11  Izumi Ohzawa

   cc -Wall -s -o stripCPfile stripCPfile.c
*/

#include <stdio.h>
#include <strings.h>



void usage(void)
{
	printf("Strips data or header portion of ContourPlot format file.\n");
	printf("  stripCPfile infile -h	: will output header (upto and including ZDATA line)\n");
	printf("  stripCPfile infile -d	: will output data only(after ZDATA line)\n");
	exit(0);
}


void main(int argc, char **argv)
{
int keepheader = 0;
int keepdata = 0;
int ch = 0;
FILE *fpin;
char linebuf[1024];

	if(argc != 3) usage();

	if( strncmp(argv[2], "-h", 2) == 0)
	    keepheader = 1;
	else if( strncmp(argv[2], "-d", 2) == 0)
	    keepdata = 1;
	else
	    usage();

	if( (fpin = fopen(argv[1], "r")) == NULL) {
	    fprintf(stderr, "Cant open input file: %s\n", argv[1]);
	    exit(1);
	}

	/* now do header */
	while(fgets(linebuf, 250, fpin) != NULL) {
	    if(keepheader) fputs(linebuf, stdout);
	    if(strncmp(linebuf, "ZDATA", 5) == 0)
		break;
	}

	/* now do data */
	if(keepdata) {
	    while( (ch = fgetc(fpin)) != EOF) {
	    	fputc(ch, stdout);
	    }
	}

	fclose(fpin);
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.