home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / f2c / i77lib / iio.c < prev    next >
C/C++ Source or Header  |  2000-06-22  |  2KB  |  133 lines

  1. #include "f2c.h"
  2. #include "fio.h"
  3. #include "fmt.h"
  4. extern char *f__icptr;
  5. char *f__icend;
  6. extern icilist *f__svic;
  7. int f__icnum;
  8. extern int f__hiwater;
  9. z_getc(Void)
  10. {
  11.     if(f__recpos++ < f__svic->icirlen) {
  12.         if(f__icptr >= f__icend) err(f__svic->iciend,(EOF),"endfile");
  13.         return(*f__icptr++);
  14.         }
  15.     err(f__svic->icierr,110,"recend");
  16. }
  17. #ifdef KR_headers
  18. z_putc(c)
  19. #else
  20. z_putc(int c)
  21. #endif
  22. {
  23.     if(f__icptr >= f__icend) err(f__svic->icierr,110,"inwrite");
  24.     if(f__recpos++ < f__svic->icirlen)
  25.         *f__icptr++ = c;
  26.     else    err(f__svic->icierr,110,"recend");
  27.     return 0;
  28. }
  29. z_rnew(Void)
  30. {
  31.     f__icptr = f__svic->iciunit + (++f__icnum)*f__svic->icirlen;
  32.     f__recpos = 0;
  33.     f__cursor = 0;
  34.     f__hiwater = 0;
  35.     return 1;
  36. }
  37.  
  38.  static int
  39. z_endp(Void)
  40. {
  41.     (*f__donewrec)();
  42.     return 0;
  43.     }
  44.  
  45. #ifdef KR_headers
  46. c_si(a) icilist *a;
  47. #else
  48. c_si(icilist *a)
  49. #endif
  50. {
  51.     f__elist = (cilist *)a;
  52.     f__fmtbuf=a->icifmt;
  53.     if(pars_f(f__fmtbuf)<0)
  54.         err(a->icierr,100,"startint");
  55.     fmt_bg();
  56.     f__sequential=f__formatted=1;
  57.     f__external=0;
  58.     f__cblank=f__cplus=f__scale=0;
  59.     f__svic=a;
  60.     f__icnum=f__recpos=0;
  61.     f__cursor = 0;
  62.     f__hiwater = 0;
  63.     f__icptr = a->iciunit;
  64.     f__icend = f__icptr + a->icirlen*a->icirnum;
  65.     f__curunit = 0;
  66.     f__cf = 0;
  67.     return(0);
  68. }
  69. y_ierr(Void)
  70. {
  71.     err(f__elist->cierr, 110, "iio");
  72. }
  73. #ifdef KR_headers
  74. integer s_rsfi(a) icilist *a;
  75. #else
  76. integer s_rsfi(icilist *a)
  77. #endif
  78. {    int n;
  79.     if(n=c_si(a)) return(n);
  80.     f__reading=1;
  81.     f__doed=rd_ed;
  82.     f__doned=rd_ned;
  83.     f__getn=z_getc;
  84.     f__dorevert = y_ierr;
  85.     f__donewrec = z_rnew;
  86.     f__doend = z_endp;
  87.     return(0);
  88. }
  89.  
  90. z_wnew(Void)
  91. {
  92.     while(f__recpos++ < f__svic->icirlen)
  93.         *f__icptr++ = ' ';
  94.     f__recpos = 0;
  95.     f__cursor = 0;
  96.     f__hiwater = 0;
  97.     f__icnum++;
  98.     return 1;
  99. }
  100. #ifdef KR_headers
  101. integer s_wsfi(a) icilist *a;
  102. #else
  103. integer s_wsfi(icilist *a)
  104. #endif
  105. {    int n;
  106.     if(n=c_si(a)) return(n);
  107.     f__reading=0;
  108.     f__doed=w_ed;
  109.     f__doned=w_ned;
  110.     f__putn=z_putc;
  111.     f__dorevert = y_ierr;
  112.     f__donewrec = z_wnew;
  113.     f__doend = z_endp;
  114.     return(0);
  115. }
  116. integer e_rsfi(Void)
  117. {    int n;
  118.     n = en_fio();
  119.     f__fmtbuf = NULL;
  120.     return(n);
  121. }
  122. integer e_wsfi(Void)
  123. {
  124.     int n;
  125.     n = en_fio();
  126.     f__fmtbuf = NULL;
  127.     if(f__icnum >= f__svic->icirnum)
  128.         return(n);
  129.     while(f__recpos++ < f__svic->icirlen)
  130.         *f__icptr++ = ' ';
  131.     return(n);
  132. }
  133.