Beispiel #1
0
int main(int argc, char **argv)
{
	unsigned char rotated[256];
	unsigned char buffer[1024];
    unsigned char r, t, b;
    
	int length, i, bytesread;

    FILE *fi, *fo;

    if(argc < 3) {
        printf("Usage: promgen <infile> <outfile>\n");
        exit(1);
    }

    fi = fopen(argv[1], "rb");
    if(!fi) {
	    printf("Couldn't open file '%s' for reading.\n", argv[1]);
	    exit(2);
	}

    fo = fopen(argv[2], "wb");
    if(!fo) {
	    printf("Couldn't open file '%s' for writing.\n", argv[2]);
        fclose(fi);
	    exit(3);
	}

    // create rotate table
    for(i=0;i<256;i++) {
        r = 0;
        t = (unsigned char) i;
        for(b=0;b<8;b++) {
            r <<= 1;
            r |= (t & 1);
            t >>= 1;
        }
        rotated[i] = r;
    }

    // parse header of bitfile
    if((length = readhead(fi)) < 0) {
        printf("Parsing of header unsuccessful. Invalid bitfile?\n");
        exit(11);        
    }

    do {
        bytesread = fread(buffer, 1, 1024, fi);
        for(i=0;i<bytesread;i++) {
            buffer[i] = rotated[buffer[i]];
        }
        fwrite(buffer, 1, bytesread, fo);
        length -= bytesread;
    } while(length && bytesread);

    fclose(fo);
    fclose(fi);
    
    return 0;
}
Beispiel #2
0
/* read a bit file from stdin */
int main(void)
{
	int t;
	struct bithead bh;
	
	initbh(&bh);
	
	/* read header */
	t = readhead(&bh, stdin);
	if (t)
	{
		printf("Invalid bit file header.\n");
		exit(1);
	}
	
	/* output header info */
	printf("\n");
	printf("Bit file created on %s at %s.\n", bh.date, bh.time);
	printf("Created from file %s for Xilinx part %s.\n", bh.filename, 
	       bh.part);
	printf("Bitstream length is %d bytes.\n", bh.length);
	printf("\n");
	
	freebh(&bh);
	
	return 0;
}
Beispiel #3
0
int open_file_and_test_props(int filecnt,char *filename,int *srate,int chans,int lineno,dataptr dz)
{
	int exit_status;
	double maxamp, maxloc;
	int maxrep;
	int getmax = 0, getmaxinfo = 0;
	infileptr ifp;
	if((ifp = (infileptr)malloc(sizeof(struct filedata)))==NULL) {
		sprintf(errstr,"INSUFFICIENT MEMORY to store data on files.\n");
		return(MEMORY_ERROR);
	}
	if((dz->ifd[0] = sndopenEx(filename,0,CDP_OPEN_RDONLY)) < 0) {
		sprintf(errstr,"Failed to open sndfile %s: line %d\n",filename,lineno+1);
		return(FINISHED);
	}
	if((exit_status = readhead(ifp,dz->ifd[0],filename,&maxamp,&maxloc,&maxrep,getmax,getmaxinfo))<0)
		return(exit_status);
	copy_to_fileptr(ifp,dz->infile);
	if(dz->infile->filetype!=SNDFILE) {
		sprintf(errstr,"%s is not a soundfile: line %d\n",filename,lineno+1);
		return(FINISHED);
	}
	if(dz->infile->channels!=chans) {
		sprintf(errstr,"channel-cnt in file '%s' different to channel value given: line %d\n",filename,lineno+1);
		return(FINISHED);
	}
	if(filecnt==0)
		*srate = dz->infile->srate;
	else if(dz->infile->srate != *srate) {
		sprintf(errstr,"incompatible srate: file %s: line %d\n",filename,lineno+1);
		return(FINISHED);
	}
	if((dz->insams[0] = sndsizeEx(dz->ifd[0]))<0) {	    			
		sprintf(errstr, "Can't read size of input file %s: line %d\n",filename,lineno+1);
		return(PROGRAM_ERROR);
	}
	if(dz->insams[0] <=0) {
		sprintf(errstr, "Zero size for input file %s: line %d\n",filename,lineno+1);
		return(FINISHED);
	}			
	if(sndcloseEx(dz->ifd[0])<0) {
		sprintf(errstr, "Failed to close input file %s: line %d\n",filename,lineno+1);
		return(SYSTEM_ERROR);
	}
	dz->ifd[0] = -1;
	return(CONTINUE);
}
Beispiel #4
0
cv::Mat IpCapture::load_jpeg( const char * host,  const char * uri, int port )
{
	if ( IpCapture::open(host,uri,port) )
	{
		// make a copy of uri and clean of start '/' as of '?' and trailing
		char scpy[400];
		int sstart=0;
		if ( uri[0]=='/')
			sstart=1;
		strcpy(scpy,uri+sstart);
		char * ask = strchr(scpy,'?');
		if ( ask != 0 )
		{
			*ask = 0;
		}
		readhead();

		int finished = 0;
		//std::cerr << scpy << std::endl;
		//std::ofstream img(scpy, std::ios_base::binary );
		// read bytes until the jpeg end sequence ff d9 is hit
		std::vector<char> bytes;
		while ( true )
		{
			char c = Birds::ReadByte(sock);

			//img << c;
			bytes.push_back(c);

			if ( c == char(0xff) ) 	finished = 1;
			else if ( c == char(0xd9) && finished == 1 ) 	break;
			else finished = 0;

			const char * err = Birds::Error();
			if ( err && err[0] )
			{
				printf("%s\n", err );
				return cv::Mat();
			}
		}
		//img.close();
		return cv::imdecode(bytes,1);
	}
	return cv::Mat();
}
Beispiel #5
0
PICTURE *readpic(char *filename)
{
PICTURE *pic = newpic();
FILE *fp;

if (filename == NULL) { filename = (char *)"stdin"; fp = stdin; }
else
	if ((fp = fopen(filename,"rb")) == NULL )
		{
		(void)fprintf(stderr,"%s: readpic: failed to open input file %s\n",
		PROGNAME,filename);
		return(NULL);
		}
(void)fprintf(stderr,"Reading %s from disk: ",filename);
if ((readhead(pic,fp)) == -1) return(NULL);
if (readdata(pic,fp)) return(NULL);
fclose(fp);
return(pic); 
}
Beispiel #6
0
int read_and_sort_properties(char *infilename,dataptr dz)
{
	int ttype = IS_MONO, exit_status;
	double maxamp, maxloc;
	int maxrep;
	int getmax = 0, getmaxinfo = 0;
	infileptr ifp;
	if((ifp = (infileptr)malloc(sizeof(struct filedata)))==NULL) {
		sprintf(errstr,"INSUFFICIENT MEMORY to store data on files.\n");
		return(MEMORY_ERROR);
	}
	if((exit_status = readhead(ifp,dz->ifd[0],infilename,&maxamp,&maxloc,&maxrep,getmax,getmaxinfo))<0)
		return(exit_status);
	copy_to_fileptr(ifp,dz->infile);

	if(dz->infile->filetype != SNDFILE)	{
		switch(dz->infile->filetype) {
		case(PITCHFILE):	return(IS_PITCH);
		case(TRANSPOSFILE):	return(IS_TRANSPOS);
		case(FORMANTFILE):	return(IS_FMNT);
		case(ENVFILE):		return(IS_ENV);
		case(ANALFILE):		return(IS_ANAL);
		default:
			sprintf(errstr,"This program only works with sound files or CDP-derived files.\n");
			return(DATA_ERROR);
		}
    }
	if(dz->infile->channels==2)
		ttype = IS_STEREO;
	else if(dz->infile->channels==4)
		ttype = IS_QUAD;
 	else if(dz->infile->channels != 1) {
		sprintf(errstr,"Program accepts sndfiles which are mono, stereo or quad, only.\n");
		return(DATA_ERROR);
    }
    return(ttype);
}
Beispiel #7
0
int addtomix(dataptr dz)
{
	int    exit_status;
	int	   total_wordcnt, *chans;												
	int    n, m, sndfiles_in = dz->infilecnt - 1;
	char	temp[200], temp2[200];
	infileptr fq;
	double maxamp, maxloc;
	int maxrep;
	int getmax = 0, getmaxinfo = 0;
	if(sndfiles_in <= 0) {
		sprintf(errstr,"No new sound files remembered.\n");
		return(PROGRAM_ERROR);
	}
	if(dz->linecnt <= 0) {
		sprintf(errstr,"None of original mixdata remembered.\n");
		return(PROGRAM_ERROR);
	}
	if((fq = (infileptr)malloc(sizeof(struct filedata)))==NULL) {
		sprintf(errstr,"INSUFFICIENT MEMORY to store data on files.\n");
		return(MEMORY_ERROR);
	}
	if ((chans = (int *)malloc(sndfiles_in * sizeof(int)))==NULL) {
		sprintf(errstr,"INSUFFICIENT MEMORY to store channel count information.\n");
		return(MEMORY_ERROR);
	}
	for(n = sndfiles_in,m = dz->all_words - 1; n>=1; n--,m--) {
		if((exit_status = readhead(fq,dz->ifd[n],dz->wordstor[m],&maxamp,&maxloc,&maxrep,getmax,getmaxinfo))<0) {
			sprintf(errstr,"Cannot read header of soundfile %s\n",dz->wordstor[m]);
			return(USER_ERROR);
		}
		if(((chans[n-1] = fq->channels) < 1) || (chans[n-1] > 2)) {
			sprintf(errstr,"Soundfile %s has wrong number of channels [%d] for this process.\n",dz->wordstor[m],chans[n-1]);
			return(DATA_ERROR);
		}
    }
	
	total_wordcnt = 0;
	for(n=0;n< dz->linecnt;n++) {
		for(m=0;m<dz->wordcnt[n];m++) {
			if(m==0)
				strcpy(temp,dz->wordstor[total_wordcnt++]);
			else {
				strcat(temp," ");
				strcat(temp,dz->wordstor[total_wordcnt++]);
			}
			if(total_wordcnt >= dz->all_words) {
				sprintf(errstr,"Word Count error.\n");
				return(PROGRAM_ERROR);
			}
		}
		strcat(temp,"\n");
		if(fputs(temp,dz->fp)<0) {
			sprintf(errstr,"Failed to write mixfile line %d to output file.\n",n+1);
			return(SYSTEM_ERROR);
		}
	}
	m = 0;
	while(total_wordcnt < dz->all_words) {
		strcpy(temp,dz->wordstor[total_wordcnt]);
		sprintf(temp2,"%lf",dz->duration);
		strcat(temp," ");
		strcat(temp,temp2);

		if(chans[m] == 1)
			strcat(temp,"  1 1.0 C\n");
		else
			strcat(temp," 2 1.0 L 1.0 R\n");
		if(fputs(temp,dz->fp)<0) {
			sprintf(errstr,"Failed to write mixfile line %d to output file.\n",n+1);
			return(SYSTEM_ERROR);
		}
		if(++total_wordcnt > dz->all_words) {
			sprintf(errstr,"Word Count error.\n");
			return(PROGRAM_ERROR);
		}
		m++;
		n++;
	}
	return(FINISHED);
}
Beispiel #8
0
int main(int argc,char *argv[])
{
  if (argc != 3)
    {
      fprintf(stderr,"usage: %s filein fileout\n",argv[0]);
      exit(1);
    }
  dofiles(argc,argv);
  if ((fp = fopen(FILEIN,"rb")) == NULL )
      {
        fprintf(stderr,"%s: wrong input file %s\n",PROGNAME,FILEIN);
        exit(1);
      }
  pic = newpic();
  
while (1) 
 {
  printf("k keeps the existing header\n");
  printf("d deletes the header (translates into raw data format)\n");
  printf("p prepends new header (translates from raw data format)\n");
  printf("c changes to new header (d+p)\t>");
  answer = getchar(); getchar();
  printf("%c it is!\n\n",answer); 
  if ((answer == 'd') || (answer == 'k') || (answer == 'c'))
		{ if (readhead(pic,fp) == -1) exit(1); 
		  break; }
  if (answer == 'p') 
	{  
    /* request new header - no header to be read anymore */
	 printf("Fileid int, as defined in vis.h (0 for unsigned char image): ");
    scanf("%d",&(pic->fileid));
	 printf("New image width (x pixels): ");
    scanf("%d",&(pic->x));
    printf("New image height (y pixels): ");
    scanf("%d",&(pic->y));
    printf("Window x origin (float): ");
    scanf("%f",&(pic->xorigin));
    printf("Window y origin (float): ");
    scanf("%f",&(pic->yorigin));
    printf("Number of items (0 for x*y): ");
    scanf("%d",&(pic->items)); 
    if (pic->items == 0) pic->items = (pic->x)*(pic->y);
    printf("Number of samples for each item: ");
    scanf("%d",&(pic->samples));
	 printf("New image history: ");
    scanf("%[^\n]",pic->history);
    getchar();
    pic->magic = VIS_MAGIC;
    break;
	}
  printf("Unexpected response, please try again\n"); 
 }
 
 while (1)
 {
  printf("d for diagonal reflection (rows into columns)\n");
  printf("r rotate 90 deg anti-clockwise (diagonal & horizontal reflections)\n");
  printf("n for no reflection or endian byte swapping: ");
  reverse = getchar(); getchar();
  printf("%c it is!\n\n",reverse);
  if ((reverse=='d') || (reverse=='r') || (reverse=='n')) break;
  printf("Unexpected response - please try again or control-C\n");
 }
 
 while (1)
 {
  printf("v for Libor Spacek's LVL format output\n");
  printf("p for Jef Poskanzer's PGM or PPM output \t>");
  wout = getchar(); getchar();
  printf("%c it is!\n",wout);
  if (wout == 'v') break;
  if (wout == 'p') break;
  (void) printf("Unexpected response - please try again or control-C\n");
 }
  /* no more user input 
     the desired header must be known by now and be in *pic */
  if ((reverse == 'd')||(reverse == 'r'))   /* swap rows and columns */
    { 
      newdata(pic);
      chbufin = (unsigned char *)pic->data;
      swapping = pic->y;
      pic->y = pic->x;
      pic->x = swapping;
		sz = (pic->samples)*sizeofidtype(pic->fileid);
      for (count=0;count<pic->x;count++)
			if (reverse == 'r')
	  			for (county=(pic->y)-1;county>=0;county--)
	    			fread(&(chbufin[sz*(county*(pic->x)+count)]),sz,1,fp);
			else
	  			for (county=0;county<pic->y;county++)
	   			 fread(&(chbufin[sz*(county*pic->x+count)]),sz,1,fp);
    }
  else readdata(pic,fp);
  fclose(fp);

  if (answer != 'd') 
    switch (wout)
     {
    	case 'v': writepic(pic,FILEOUT); break;
		case 'p': writepmpic(pic,FILEOUT); break;
    	default: exit(1);
     }
  else
    {
      if ((fp = fopen(FILEOUT,"wb")) == NULL )
			{
	  		fprintf(stderr,"%s: wrong output file %s\n",PROGNAME,FILEOUT);
	  		exit(1);
			}
      if (fwrite(pic->data,sizeofdata(pic),1,fp) == 0)
			{
	  		fprintf(stderr,"%s: failed to write data\n",PROGNAME);
	  		exit(1);
			}
    }
  exit(0);
}
Beispiel #9
0
main(int argc, char **argv)
{
	int nt,it;
	float dt;
	FILE *pxfp, *pyfp, *infp, *outfp=stdout;
	char *datain,*pxfile, *pyfile;
	int iy, ix;
	int ipow;
	int nx,ny,lt,lx,ly;
	int nxo,nyo,ixo,iyo,dxo,dyo,nto;
	int ii1, ii2, iyy, ntxo;
	float tmp, tmp1, tmp2;
	int nsegy;
	float *data, *pxo, *pyo, *work, *stack;
	float to0, dto;
	int hy, i2, i22, iy0, ierr, ht, hx;
	float *tt, *tx, *ty;
	int nycore, mlimit, n1, n2, n3,jy,ixx;
	float o1,o2,o3,d1,d2,d3,t0;

	long ltmp;

	segychdr ch;
    	segybhdr bh;
	usghed usgh;


	/* hook up getpar */
	initargs(argc, argv);
	askdoc(1);

/* open input data */
	if (!getparstring("datain",&datain)) err(" must specify datain ");
	if((infp = fopen(datain,"r"))==NULL)
             	err("datain %s open failed \n",datain);
	file2g(infp);
	fgethdr(infp,&ch,&bh);
	

	/* get information from the first header */
	if (!fgettr(infp,&tr)) err("can't get first trace");
	nt = tr.ns;
	dt = (float)tr.dt * 0.001;
	t0 = (float)tr.delrt;

	/* get required parameters */
	if (!getparstring("pxfile",&pxfile)) err(" must specify pxfile ");
	if (!getparstring("pyfile",&pyfile)) err(" must specify pyfile ");

	if (!getparint("nx",&nx)) err(" must specify nx");
	if (!getparint("ny",&ny)) err(" must specify ny");

	/* get optional parameters */
	if (!getparint("lt",&lt)) lt = 11;
	if (!getparint("ipow",&ipow)) ipow = 2;
	if (!getparint("lx",&lx)) lx = 11;
	if (!getparint("ly",&ly)) ly = 5;
	if(ny<ly) ly = (ny-1)/2*2+1;

	if (!getparint("ixo",&ixo)) ixo = 1;
	if (!getparint("dxo",&dxo)) dxo = 1;
	if (!getparint("nxo",&nxo)) nxo = nx;
	if (!getparint("iyo",&iyo)) iyo = 1;
	if (!getparint("dyo",&dyo)) dyo = 1;
	if (!getparint("nyo",&nyo)) nyo = ny;
	if (!getparfloat("to0",&to0)) to0 = tr.delrt;
	if (!getparfloat("dto",&dto)) dto = (float)tr.dt*0.001;
	if (!getparint("nto",&nto)) nto = nt;

	if (!getparint("mlimit",&mlimit)) mlimit = 256;



	if((pxfp = fopen(pxfile,"r"))==NULL)
             	err("pxfile %s open failed \n",pxfile);
	if((pyfp = fopen(pyfile,"r"))==NULL)
             	err("pyfile %s open failed \n",pyfile);

	pxo = (float*) emalloc(n1*sizeof(float));
	pyo = (float*) emalloc(n1*sizeof(float));
	work = (float*) emalloc(nt*sizeof(float));

	tmp = mlimit*1024*1024./(4.*nt*nx);
	nycore = (int) tmp;
	if(nycore<ly) err(" increase mlimit to %d \n",ly*nt*nx*4/1024/1024+1);
	if(dyo>=ly) nycore = ly;
	data = (float*) emalloc(nx*nycore*nt*sizeof(float));
	stack = (float*) emalloc(nto*sizeof(float));

	file2g(pxfp);
	file2g(pyfp);

	hy = (ly-1)/2;
	hx = (lx-1)/2;
	ht = (lt-1)/2;
	tt = (float*) emalloc(lt*sizeof(float));
	tx = (float*) emalloc(lx*sizeof(float));
	ty = (float*) emalloc(ly*sizeof(float));

	for(it=0;it<lt;it++) {
		tmp = it - ht;
		if(tmp<0) tmp = - tmp;
		tt[it]  = 2./(lt+1) * (1.-2.*tmp/(lt+1));
	}
	for(ix=0;ix<lx;ix++) {
		tmp = ix - hx;
		if(tmp<0) tmp = - tmp;
		tx[ix]  = 2./(lx+1) * (1.-2.*tmp/(lx+1));
	}
	for(iy=0;iy<ly;iy++) {
		tmp = iy - hy;
		if(tmp<0) tmp = - tmp;
		ty[iy]  = 2./(ly+1) * (1.-2.*tmp/(ly+1));
	}

	nsegy = 240+nt*sizeof(float);


	ierr = fgetusghdr(pxfp,&usgh);
		if(ierr!=0) err("error in input gridheader for pxfile ");
	fseek2g(pxfp,0,0);

	o1 = usgh.o1;
	d1 = usgh.d1;
	n1 = usgh.n1;
	o2 = usgh.o2;
	d2 = usgh.d2;
	n2 = usgh.n2;
	o3 = usgh.o3;
	d3 = usgh.d3;
	n3 = usgh.n3;

	jy  = -1;

	bh.hns = nto;
    	bh.hdt = dto*1000.;

        fputhdr(outfp,&ch,&bh);

	
	/* loop over output traces  */
	for(iy=0;iy<nyo;iy++) {

		iyy = iy*dyo + iyo;
		readdata(infp,data,tr1,&jy,iyy-1,ny,nt,nx,hy,nycore);

		for(ix=0;ix<nxo;ix++) {
			ixx = ix*dxo+ixo;
			readpxpy(pxfp,pyfp,o1,o2,o3,d1,d2,d3,n1,n2,n3,
				pxo,pyo,iyy,ixx);


			readhead(infp,tr1,ixx,iyy,nx,ny,nsegy);


			tr1.ns  = nto;
			tr1.delrt = to0;
			tr1.dt = dto*1000.;


			sstack_(data,pxo,pyo,stack,work,
				&iyy,&ixx,&jy,&nycore,&nx,
				&d1,&o1,&n1,
				&dt,&t0,&nt,
				&dto,&to0,&nto,
				&ipow,&hy,&hx,&ht,ty,tx,tt);


			for(it=0;it<nto;it++) {
				tr1.data[it] = stack[it]; 
			}

			fputtr(outfp,&tr1);
		}	

	}
	
	free(pxo);
	free(pyo);
	free(data);
	free(stack);
	free(tt);
	free(tx);
	free(ty);

	return EXIT_SUCCESS;
}
Beispiel #10
0
int do_bundle(dataptr dz)
{
	int exit_status;
	int got_sndfile = FALSE, n, OK;
	int filetype = dz->infile->filetype;
	fileptr fp1 = dz->infile;
	double maxamp, maxloc;
	int maxrep;
	int getmax = 0, getmaxinfo = 0;
	infileptr ifp;
	if((ifp = (infileptr)malloc(sizeof(struct filedata)))==NULL) {
		sprintf(errstr,"INSUFFICIENT MEMORY to store data on files.\n");
		return(MEMORY_ERROR);
	}

	for(n=0;n<dz->infilecnt;n++) {
		if(!strcmp(dz->wordstor[n],dz->wordstor[dz->all_words-1])) {
			sprintf(errstr,"Name of out-listfile [%s] cannot be included in the listing!!\n",dz->wordstor[n]);
			return(DATA_ERROR);
		}
	}
	if(!is_a_text_input_filetype(filetype))
		got_sndfile = TRUE;
	if(got_sndfile || dz->mode==BUNDLE_ALL) {
		sprintf(errstr,"BUNDLED %s\n",dz->wordstor[0]);
		print_outmessage(errstr);
		fprintf(dz->fp,"%s\n",dz->wordstor[0]);
	}
	for(n=1;n<dz->infilecnt;n++) {
		for(;;) {
			OK = FALSE;
			if(dz->mode==BUNDLE_ALL) {
				OK = TRUE;					  /* list any file */
				break;
			} else if((dz->ifd[n] = sndopenEx(dz->wordstor[n],0,CDP_OPEN_RDONLY)) < 0)
				break;						  /* else if non-text file, break */
			if(dz->mode==BUNDLE_NONTEXT) {
				OK = TRUE;					  /* if any non-text file OK, break */
				break;				
			}
			if(!got_sndfile) {
				got_sndfile = TRUE;
				if((exit_status = readhead(ifp,dz->ifd[n],dz->wordstor[n],&maxamp,&maxloc,&maxrep,getmax,getmaxinfo))<0)
					return(exit_status);
				filetype = ifp->filetype;
				copy_to_fileptr(ifp,fp1);
				OK = TRUE;					  /* 1st non-text file is always OK, break */
				break;
			}
			if((exit_status = readhead(ifp,dz->ifd[n],dz->wordstor[n],&maxamp,&maxloc,&maxrep,getmax,getmaxinfo))<0)
				return(exit_status);
			if(ifp->filetype!=filetype) /* If files NOT of same type, break */
				break;	
			if(dz->mode==BUNDLE_TYPE) {
				OK = TRUE;					  /* if any file of same type OK, break */
				break;
			}
			if(compare_properties_for_bundling(fp1,ifp)==CONTINUE)
				break;					  	/* if properties incompatible, break */
			if(dz->mode==BUNDLE_SRATE) {
				OK = TRUE;					/* if any file with same props OK, break */
				break;
			}								/* if files have same chancnt, set OK for BUNDLE_CHAN */
			if(fp1->channels==ifp->channels)
				OK = TRUE;				
			break;	
		}
		if(OK) {
			sprintf(errstr,"BUNDLED %s\n",dz->wordstor[n]);
			print_outmessage(errstr);
			fprintf(dz->fp,"%s\n",dz->wordstor[n]);
		}
	}
	fflush(stdout);
	free(ifp);
	return(FINISHED);
}
Beispiel #11
0
int handle_the_extra_infile(char ***cmdline,int *cmdlinecnt,dataptr dz)
{
					/* OPEN ONE EXTRA ANALFILE, CHECK COMPATIBILITY */
	int  exit_status;
	char *filename;
	fileptr fp2;
	int fileno = 1;
	double maxamp, maxloc;
	int maxrep;
	int getmax = 0, getmaxinfo = 0;
	infileptr ifp;
	fileptr fp1 = dz->infile; 
	filename = (*cmdline)[0];
	if((dz->ifd[fileno] = sndopenEx(filename,0,CDP_OPEN_RDONLY)) < 0) {
		sprintf(errstr,"cannot open input file %s to read data.\n",filename);
		return(DATA_ERROR);
	}	
	if((ifp = (infileptr)malloc(sizeof(struct filedata)))==NULL) {
		sprintf(errstr,"INSUFFICIENT MEMORY to store data on later infile. (1)\n");
		return(MEMORY_ERROR);
	}
	if((fp2 = (fileptr)malloc(sizeof(struct fileprops)))==NULL) {
		sprintf(errstr,"INSUFFICIENT MEMORY to store data on later infile. (2)\n");
		return(MEMORY_ERROR);
	}
	if((exit_status = readhead(ifp,dz->ifd[1],filename,&maxamp,&maxloc,&maxrep,getmax,getmaxinfo))<0)
		return(exit_status);
	copy_to_fileptr(ifp,fp2);
	if(fp2->filetype != ANALFILE) {
		sprintf(errstr,"%s is not an analysis file.\n",filename);
		return(DATA_ERROR);
	}
	if(fp2->origstype != fp1->origstype) {
		sprintf(errstr,"Incompatible original-sample-type in input file %s.\n",filename);
		return(DATA_ERROR);
	}
	if(fp2->origrate != fp1->origrate) {
		sprintf(errstr,"Incompatible original-sample-rate in input file %s.\n",filename);
		return(DATA_ERROR);
	}
	if(fp2->arate != fp1->arate) {
		sprintf(errstr,"Incompatible analysis-sample-rate in input file %s.\n",filename);
		return(DATA_ERROR);
	}
	if(fp2->Mlen != fp1->Mlen) {
		sprintf(errstr,"Incompatible analysis-window-length in input file %s.\n",filename);
		return(DATA_ERROR);
	}
	if(fp2->Dfac != fp1->Dfac) {
		sprintf(errstr,"Incompatible decimation factor in input file %s.\n",filename);
		return(DATA_ERROR);
	}
	if(fp2->channels != fp1->channels) {
		sprintf(errstr,"Incompatible channel-count in input file %s.\n",filename);
		return(DATA_ERROR);
	}
	if((dz->insams[fileno] = sndsizeEx(dz->ifd[fileno]))<0) {	    /* FIND SIZE OF FILE */
		sprintf(errstr, "Can't read size of input file %s.\n"
		"open_checktype_getsize_and_compareheader()\n",filename);
		return(PROGRAM_ERROR);
	}
	if(dz->insams[fileno]==0) {
		sprintf(errstr, "File %s contains no data.\n",filename);
		return(DATA_ERROR);
	}
	(*cmdline)++;
	(*cmdlinecnt)--;
	return(FINISHED);
}