Annotation of researchv9/X11/src/X.V11R1/server/os/4.2bsd/fileio.c, revision 1.1.1.1

1.1       root        1: /***********************************************************
                      2: Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
                      3: and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
                      4: 
                      5:                         All Rights Reserved
                      6: 
                      7: Permission to use, copy, modify, and distribute this software and its 
                      8: documentation for any purpose and without fee is hereby granted, 
                      9: provided that the above copyright notice appear in all copies and that
                     10: both that copyright notice and this permission notice appear in 
                     11: supporting documentation, and that the names of Digital or MIT not be
                     12: used in advertising or publicity pertaining to distribution of the
                     13: software without specific, written prior permission.  
                     14: 
                     15: DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
                     16: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
                     17: DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
                     18: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
                     19: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
                     20: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
                     21: SOFTWARE.
                     22: 
                     23: ******************************************************************/
                     24: /* $Header: fileio.c,v 1.8 87/09/11 07:50:51 toddb Exp $ */
                     25: #include <stdio.h>
                     26: #include "os.h"
                     27: #include "osdep.h"
                     28: 
                     29: /*
                     30:  *   FiOpenForRead, FiRead, FiClose,
                     31:  */
                     32: 
                     33: FID
                     34: FiOpenForRead( lenn, name)
                     35:     int                lenn;
                     36:     char       *name;
                     37: {
                     38:     FID                fid;
                     39:     char       *unixfname = name;
                     40: 
                     41: 
                     42:     if ( name[lenn-1] != '\0')
                     43:     {
                     44:        unixfname = (char *) ALLOCATE_LOCAL( lenn+1);
                     45:        strncpy( unixfname, name, lenn);
                     46:        unixfname[lenn] = '\0';
                     47:     }
                     48:     else
                     49:        unixfname = name;
                     50: 
                     51:     fid = (FID)fopen( unixfname, "r");
                     52:     if(unixfname != name)
                     53:         DEALLOCATE_LOCAL(unixfname);
                     54:     return fid;
                     55: }
                     56: 
                     57: 
                     58: /*
                     59:  * returns 0 on error
                     60:  */
                     61: int
                     62: FiRead( buf, itemsize, nitems, fid)
                     63:     char       *buf;
                     64:     unsigned   itemsize;
                     65:     unsigned   nitems;
                     66:     FID                fid;
                     67: {
                     68:     return fread( buf, itemsize, nitems, (FILE *)fid);
                     69: }
                     70: 
                     71: int
                     72: FiClose(fid)
                     73:     FID                fid;
                     74: {
                     75:     return fclose( (FILE *)fid);
                     76: }
                     77: 

unix.superglobalmegacorp.com

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