Annotation of researchv10no/cmd/basic/bite/src/copen.c, revision 1.1.1.1

1.1       root        1: /* Copyright Bell Telephone Laboratories Whippany, N.J.
                      2: 
                      3:  *     /////////////////////////////////////
                      4:  *     /////////////////////////////////////
                      5:  *     ////////////// copen.c //////////////
                      6:  *     /// J. P. Hawkins WH X4610 8C-001 ///
                      7:  *     ///// Fri Aug 24 17:35:10 1979 //////
                      8:  *     /////////////////////////////////////
                      9:  *     /////////////////////////////////////
                     10: 
                     11:  * FILE OPEN ROUTINES FOR BITE
                     12:  * if LSX not defined, compiles for TS system calls
                     13:  * call format:        fd = copen(filename,mode)
                     14:  *
                     15:  *     where:  fd is returned file descriptor
                     16:  *             filename is string pointer to filename
                     17:  *             mode = 0 for input, 1 for output and 2 for append
                     18:  */
                     19: /*   "@(#) copen.c:  V 1.1  12/21/80" */
                     20: #include       "bas.h"
                     21: 
                     22: copen(s,mode)
                     23: char   s[];
                     24: int    mode;
                     25: {
                     26:        int     fd;
                     27:        switch(mode)
                     28:        {
                     29:                case 0: /* OPEN FOR INPUT */
                     30:                        fd = open(s, 0);
                     31:                        break;
                     32:                case 1: /* OPEN FOR OUTPUT */
                     33:                        fd = creat(s, 0666);
                     34:                        break;
                     35:                case 2: /* OPEN FOR APPEND */
                     36:                        if((fd = open(s, 1)) < 0) /* try to open */
                     37:                                fd = creat(s, 0666); /* create new file
                     38:                                                        if one doesn't exist */
                     39:                        else
                     40:                        {
                     41:                                /*
                     42:                                 * SEEK TO END OF FILE FOR APPEND
                     43:                                 */
                     44:                                lseek(fd, 0L, 2);
                     45:                        }
                     46:                default:
                     47:                        break;
                     48:        }
                     49:        return(fd);
                     50: }

unix.superglobalmegacorp.com

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