Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
bread.c
Go to the documentation of this file.
1 /*
2  * bread.c -
3  *
4  * Author: Todd W. Fuqua
5  * Computer Science Dept.
6  * University of Utah
7  * Date: Wed Jul 25 1984
8  * Copyright (c) 1984 Todd W. Fuqua
9  *
10  * $Header: bread.c,v 2.3 86/06/18 11:46:19 thomas Exp $
11  * $Log: bread.c,v $
12  * Revision 2.3 86/06/18 11:46:19 thomas
13  * Add vax ifdef.
14  *
15  * Revision 2.2 85/04/26 15:03:56 thomas
16  * Lint and potential bug fixes.
17  *
18  * Revision 2.1 85/03/05 16:00:22 thomas
19  * *** empty log message ***
20  *
21  */
22 static char rcs_ident[] = "$Header: bread.c,v 2.3 86/06/18 11:46:19 thomas Exp $";
23 
24 
25 #include "stdio.h"
26 bread(ptr, size, iop)
27 unsigned size;
28 register char *ptr;
29 register FILE *iop;
30 {
31  register unsigned ndone, s;
32  register int c;
33 
34  if (!size) return 0;
35 
36  ndone = size;
37  if ( iop->_cnt >= ndone )
38  {
39  switch ( ndone )
40  {
41  /* WARNING -- the first two cases should be
42  * "sizeof(short)" and "sizeof(long)", but the compiler
43  * doesn't like those.
44  */
45  case sizeof(short): *(short *)ptr = *(short *)iop->_ptr;
46  break;
47  case sizeof(long): *(long *)ptr = *(int *)iop->_ptr;
48  break;
49  default: /*bcopy( iop->_ptr, ptr, ndone );*/
50 #ifdef vax
51  asm(" movl 4(r10),r0");
52  asm(" movc3 r9,(r0),(r11)");
53 #else
54  bcopy( iop->_ptr, ptr, ndone );
55 #endif
56  }
57  iop->_cnt -= ndone;
58  iop->_ptr += ndone;
59  }
60  else
61  while ( ndone != 0 )
62  {
63  if ( iop->_cnt == 0 )
64  if ((c = _filbuf(iop)) == EOF)
65  return (size - ndone) ;
66  else
67  {
68  *ptr++ = c;
69  ndone--;
70  }
71 
72  if (s = ndone)
73  {
74  if ( s > iop->_cnt )
75  s = iop->_cnt;
76  iop->_cnt -= s; /* work-around for CC bug */
77 /* bcopy( iop->_ptr, ptr, s );*/
78  asm(" movl 4(r10),r0");
79  asm(" movc3 r8,(r0),(r11)");
80  iop->_ptr += s;
81  ndone -= s;
82  ptr += s;
83  }
84  }
85 
86  return size;
87 }
static char rcs_ident[]
Definition: bread.c:22