Annotation of researchv10dc/libI77/old1/close.c, revision 1.1.1.1

1.1       root        1: #include "f2c.h"
                      2: #include "fio.h"
                      3: #ifdef KR_headers
                      4: integer f_clos(a) cllist *a;
                      5: #else
                      6: #undef abs
                      7: #undef min
                      8: #undef max
                      9: #include "stdlib.h"
                     10: #ifdef MSDOS
                     11: #include "io.h"
                     12: #else
                     13: #ifdef __cplusplus
                     14: extern "C" int unlink(const char*);
                     15: #else
                     16: extern int unlink(const char*);
                     17: #endif
                     18: #endif
                     19: 
                     20: integer f_clos(cllist *a)
                     21: #endif
                     22: {      unit *b;
                     23: 
                     24:        if(a->cunit >= MXUNIT) return(0);
                     25:        b= &f__units[a->cunit];
                     26:        if(b->ufd==NULL)
                     27:                goto done;
                     28:        if (!a->csta)
                     29:                if (b->uscrtch == 1)
                     30:                        goto Delete;
                     31:                else
                     32:                        goto Keep;
                     33:        switch(*a->csta) {
                     34:                default:
                     35:                Keep:
                     36:                case 'k':
                     37:                case 'K':
                     38:                        if(b->uwrt == 1)
                     39:                                (void) t_runc((alist *)a);
                     40:                        if(b->ufnm) {
                     41:                                (void) fclose(b->ufd);
                     42:                                free(b->ufnm);
                     43:                                }
                     44:                        break;
                     45:                case 'd':
                     46:                case 'D':
                     47:                Delete:
                     48:                        if(b->ufnm) {
                     49:                                (void) fclose(b->ufd);
                     50:                                (void) unlink(b->ufnm); /*SYSDEP*/
                     51:                                free(b->ufnm);
                     52:                                }
                     53:                }
                     54:        b->ufd=NULL;
                     55:  done:
                     56:        b->uend=0;
                     57:        b->ufnm=NULL;
                     58:        return(0);
                     59:        }
                     60:  void
                     61: #ifdef KR_headers
                     62: f_exit()
                     63: #else
                     64: f_exit(void)
                     65: #endif
                     66: {      int i;
                     67:        static cllist xx;
                     68:        if (!xx.cerr) {
                     69:                xx.cerr=1;
                     70:                xx.csta=NULL;
                     71:                for(i=0;i<MXUNIT;i++)
                     72:                {
                     73:                        xx.cunit=i;
                     74:                        (void) f_clos(&xx);
                     75:                }
                     76:        }
                     77: }
                     78:  void
                     79: #ifdef KR_headers
                     80: flush_()
                     81: #else
                     82: flush_(void)
                     83: #endif
                     84: {      int i;
                     85:        for(i=0;i<MXUNIT;i++)
                     86:                if(f__units[i].ufd != NULL && f__units[i].uwrt)
                     87:                        fflush(f__units[i].ufd);
                     88: }

unix.superglobalmegacorp.com

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