wsfe.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*write sequential formatted external*/
  2. #include "f2c.h"
  3. #include "fio.h"
  4. #include "fmt.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. int
  9. x_wSL(Void)
  10. {
  11. int n = f__putbuf('\n');
  12. f__hiwater = f__recpos = f__cursor = 0;
  13. return(n == 0);
  14. }
  15. static int
  16. xw_end(Void)
  17. {
  18. int n;
  19. if(f__nonl) {
  20. f__putbuf(n = 0);
  21. fflush(f__cf);
  22. }
  23. else
  24. n = f__putbuf('\n');
  25. f__hiwater = f__recpos = f__cursor = 0;
  26. return n;
  27. }
  28. static int
  29. xw_rev(Void)
  30. {
  31. int n = 0;
  32. if(f__workdone) {
  33. n = f__putbuf('\n');
  34. f__workdone = 0;
  35. }
  36. f__hiwater = f__recpos = f__cursor = 0;
  37. return n;
  38. }
  39. #ifdef KR_headers
  40. integer s_wsfe(a) cilist *a; /*start*/
  41. #else
  42. integer s_wsfe(cilist *a) /*start*/
  43. #endif
  44. { int n;
  45. if(!f__init) f_init();
  46. f__reading=0;
  47. f__sequential=1;
  48. f__formatted=1;
  49. f__external=1;
  50. if(n=c_sfe(a)) return(n);
  51. f__elist=a;
  52. f__hiwater = f__cursor=f__recpos=0;
  53. f__nonl = 0;
  54. f__scale=0;
  55. f__fmtbuf=a->cifmt;
  56. f__cf=f__curunit->ufd;
  57. if(pars_f(f__fmtbuf)<0) err(a->cierr,100,"startio");
  58. f__putn= x_putc;
  59. f__doed= w_ed;
  60. f__doned= w_ned;
  61. f__doend=xw_end;
  62. f__dorevert=xw_rev;
  63. f__donewrec=x_wSL;
  64. fmt_bg();
  65. f__cplus=0;
  66. f__cblank=f__curunit->ublnk;
  67. if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
  68. err(a->cierr,errno,"write start");
  69. return(0);
  70. }
  71. #ifdef __cplusplus
  72. }
  73. #endif