# #include /* * IRHEAD inputs a CVL picture header from the specified file descriptor. * The length of the comment field is returned, unless an error occurs, * in which case -1 is returned. * this is exactly IHEAD except that reverse byte order is expected. * Joseph Pallas 9/18/80 cc -O -c ihead.c * Modified by Robert L. Kirby for more distinctive tag1 on Oct 8, 1980. */ int irhead (fdin, oldarea) int fdin; struct cvl_p *oldarea; { register int numread; register int total; register char *p; short flipshort(); p = (char *)oldarea; for(total = 0; total < sizeof *oldarea; total += numread) if((numread = read(fdin, &p[total], sizeof *oldarea - total)) == 0 || numread == -1) return(-1); if(oldarea->cv_tag != 'PICT' + 0x80) return(-1); oldarea->cv_lcom = flipshort(oldarea->cv_lcom); oldarea->cv_type = flipshort(oldarea->cv_type); oldarea->cv_dims = flipshort(oldarea->cv_dims); oldarea->cv_hpls = flipshort(oldarea->cv_hpls); oldarea->cv_plns = flipshort(oldarea->cv_plns); oldarea->cv_rows = flipshort(oldarea->cv_rows); oldarea->cv_cols = flipshort(oldarea->cv_cols); oldarea->cv_bnds = flipshort(oldarea->cv_bnds); oldarea->cv_bp = flipshort(oldarea->cv_bp); oldarea->cv_ebb = flipshort(oldarea->cv_ebb); oldarea->cv_sbb = flipshort(oldarea->cv_sbb); oldarea->cv_bb = flipshort(oldarea->cv_bb); oldarea->cv_sbp = flipshort(oldarea->cv_sbp); oldarea->cv_ebp = flipshort(oldarea->cv_ebp); return(oldarea->cv_lcom); } static short flipshort(invalue) short invalue; { short outvalue; char *in, *out; in = (char *) (&invalue); out = (char *) (&outvalue); in[0] = out[1]; in[1] = out[0]; return(outvalue); }