Annotation of researchv10dc/libI77/d/endfile.c, revision 1.1.1.1

1.1       root        1: 4d3
                      2: < #include "fcntl.h"
                      3: 6,8d4
                      4: < #ifndef O_RDONLY
                      5: < #define O_RDONLY 0
                      6: < #endif
                      7: 19a16,24
                      8: > #ifdef NON_UNIX_STDIO
                      9: > #ifndef unlink
                     10: > #define unlink remove
                     11: > #endif
                     12: > #else
                     13: > #ifdef MSDOS
                     14: > #include "io.h"
                     15: > #endif
                     16: > #endif
                     17: 20a26,29
                     18: > #ifdef NON_UNIX_STDIO
                     19: > extern char *f__r_mode[], *f__w_mode[];
                     20: > #endif
                     21: > 
                     22: 32a42,47
                     23: > #ifdef NON_UNIX_STDIO
                     24: >              { FILE *tf;
                     25: >                      if (tf = fopen(nbuf, f__w_mode[0]))
                     26: >                              fclose(tf);
                     27: >                      }
                     28: > #else
                     29: 33a49
                     30: > #endif
                     31: 40a57
                     32: > #ifdef NON_UNIX_STDIO
                     33: 43a61,78
                     34: > copy(FILE *from, register long len, FILE *to)
                     35: > #endif
                     36: > {
                     37: >      int k, len1;
                     38: >      char buf[BUFSIZ];
                     39: > 
                     40: >      while(fread(buf, len1 = len > BUFSIZ ? BUFSIZ : (int)len, 1, from)) {
                     41: >              if (!fwrite(buf, len1, 1, to))
                     42: >                      return 1;
                     43: >              if ((len -= len1) <= 0)
                     44: >                      break;
                     45: >              }
                     46: >      return 0;
                     47: >      }
                     48: > #else
                     49: > #ifdef KR_headers
                     50: > copy(from, len, to) char *from, *to; register long len;
                     51: > #else
                     52: 64a100
                     53: > #endif
                     54: 79a116,120
                     55: > #ifdef NON_UNIX_STDIO
                     56: >      FILE *bf, *tf;
                     57: > #else
                     58: >      FILE *bf;
                     59: > #endif
                     60: 83,86c124,128
                     61: <      if(b->url) return(0);   /*don't truncate direct files*/
                     62: <      loc=ftell(b->ufd);
                     63: <      (void) fseek(b->ufd,0L,SEEK_END);
                     64: <      len=ftell(b->ufd);
                     65: ---
                     66: >      if(b->url)
                     67: >              return(0);      /*don't truncate direct files*/
                     68: >      loc=ftell(bf = b->ufd);
                     69: >      fseek(bf,0L,SEEK_END);
                     70: >      len=ftell(bf);
                     71: 89c131
                     72: < #ifdef MSDOS
                     73: ---
                     74: > #ifdef NON_UNIX_STDIO
                     75: 94a137,139
                     76: > #ifdef NON_UNIX_STDIO
                     77: >              if (!(bf = fopen(b->ufnm, f__w_mode[b->ufmt])))
                     78: > #else
                     79: 96c141
                     80: < #ifdef MSDOS
                     81: ---
                     82: > #endif
                     83: 98,100d142
                     84: <              goto done;
                     85: < #else
                     86: <                      { rc = 1; goto done; }
                     87: 103,104c145
                     88: <              return 0;
                     89: < #endif
                     90: ---
                     91: >              goto done;
                     92: 109,110c150,151
                     93: <      (void) strcpy(nm,"tmp.FXXXXXX");
                     94: <      (void) mktemp(nm);
                     95: ---
                     96: >      strcpy(nm,"tmp.FXXXXXX");
                     97: >      mktemp(nm);
                     98: 111a153,182
                     99: > #ifdef NON_UNIX_STDIO
                    100: >      if (!(bf = fopen(b->ufnm, f__r_mode[0]))) {
                    101: >  bad:
                    102: >              rc = 1;
                    103: >              goto done;
                    104: >              }
                    105: >      if (!(tf = fopen(nm, f__w_mode[0])))
                    106: >              goto bad;
                    107: >      if (copy(bf, loc, tf)) {
                    108: >  bad1:
                    109: >              rc = 1;
                    110: >              goto done1;
                    111: >              }
                    112: >      if (!(bf = freopen(b->ufnm, f__w_mode[0], bf)))
                    113: >              goto bad1;
                    114: >      if (!(tf = freopen(nm, f__r_mode[0], tf)))
                    115: >              goto bad1;
                    116: >      if (copy(tf, loc, bf))
                    117: >              goto bad1;
                    118: >      if (f__w_mode[0] != f__w_mode[b->ufmt]) {
                    119: >              if (!(bf = freopen(b->ufnm, f__w_mode[b->ufmt+2], bf)))
                    120: >                      goto bad1;
                    121: >              fseek(bf, loc, SEEK_SET);
                    122: >              }
                    123: > done1:
                    124: >      fclose(tf);
                    125: >      unlink(nm);
                    126: > done:
                    127: >      f__cf = b->ufd = bf;
                    128: > #else
                    129: 115a187
                    130: >      fseek(b->ufd, loc, SEEK_SET);
                    131: 117,124d188
                    132: < #ifdef MSDOS
                    133: <      {
                    134: <      extern char *f__r_mode[];
                    135: <      b->uwrt = 0;
                    136: <      if (!(b->ufd = fopen(b->ufnm, f__r_mode[b->ufmt])))
                    137: <              rc = 1;
                    138: <      }
                    139: <      if (loc)
                    140: 126d189
                    141: <      fseek(b->ufd, loc, SEEK_SET);

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.