home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fs.zip / octave / f2c / libi77 / rsli.c < prev    next >
C/C++ Source or Header  |  2000-01-15  |  2KB  |  99 lines

  1. #include "f2c.h"
  2. #include "fio.h"
  3. #include "lio.h"
  4. #include "fmt.h" /* for f__doend */
  5.  
  6. extern flag f__lquit;
  7. extern int f__lcount;
  8. extern char *f__icptr;
  9. extern char *f__icend;
  10. extern icilist *f__svic;
  11. extern int f__icnum, f__recpos;
  12.  
  13. static int i_getc(Void)
  14. {
  15.     if(f__recpos >= f__svic->icirlen) {
  16.         if (f__recpos++ == f__svic->icirlen)
  17.             return '\n';
  18.         z_rnew();
  19.         }
  20.     f__recpos++;
  21.     if(f__icptr >= f__icend) err(f__svic->iciend,(EOF),"internal read");
  22.     return(*f__icptr++);
  23.     }
  24.  
  25.  static
  26. #ifdef KR_headers
  27. int i_ungetc(ch, f) int ch; FILE *f;
  28. #else
  29. int i_ungetc(int ch, FILE *f)
  30. #endif
  31. {
  32.     if (--f__recpos == f__svic->icirlen)
  33.         return '\n';
  34.     if (f__recpos < -1)
  35.         err(f__svic->icierr,110,"recend");
  36.     /* *--icptr == ch, and icptr may point to read-only memory */
  37.     return *--f__icptr /* = ch */;
  38.     }
  39.  
  40.  static void
  41. #ifdef KR_headers
  42. c_lir(a) icilist *a;
  43. #else
  44. c_lir(icilist *a)
  45. #endif
  46. {
  47.     extern int l_eof;
  48.     f__reading = 1;
  49.     f__external = 0;
  50.     f__formatted = 1;
  51.     f__svic = a;
  52.     L_len = a->icirlen;
  53.     f__recpos = -1;
  54.     f__icnum = f__recpos = 0;
  55.     f__cursor = 0;
  56.     l_getc = i_getc;
  57.     l_ungetc = i_ungetc;
  58.     l_eof = 0;
  59.     f__icptr = a->iciunit;
  60.     f__icend = f__icptr + a->icirlen*a->icirnum;
  61.     f__cf = 0;
  62.     f__curunit = 0;
  63.     f__elist = (cilist *)a;
  64.     }
  65.  
  66.  
  67. #ifdef KR_headers
  68. integer s_rsli(a) icilist *a;
  69. #else
  70. integer s_rsli(icilist *a)
  71. #endif
  72. {
  73.     f__lioproc = l_read;
  74.     f__lquit = 0;
  75.     f__lcount = 0;
  76.     c_lir(a);
  77.     f__doend = 0;
  78.     return(0);
  79.     }
  80.  
  81. integer e_rsli(Void)
  82. { return 0; }
  83.  
  84. #ifdef KR_headers
  85. integer s_rsni(a) icilist *a;
  86. #else
  87. extern int x_rsne(cilist*);
  88.  
  89. integer s_rsni(icilist *a)
  90. #endif
  91. {
  92.     cilist ca;
  93.     ca.ciend = a->iciend;
  94.     ca.cierr = a->icierr;
  95.     ca.cifmt = a->icifmt;
  96.     c_lir(a);
  97.     return x_rsne(&ca);
  98.     }
  99.