Annotation of sbbs/xpdev/filewrap.h, revision 1.1

1.1     ! root        1: /* filewrap.h */
        !             2: 
        !             3: /* File system-call wrappers */
        !             4: 
        !             5: /* $Id: filewrap.h,v 1.21 2004/08/31 08:21:16 deuce Exp $ */
        !             6: 
        !             7: /****************************************************************************
        !             8:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
        !             9:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
        !            10:  *                                                                                                                                                     *
        !            11:  * Copyright 2004 Rob Swindell - http://www.synchro.net/copyright.html         *
        !            12:  *                                                                                                                                                     *
        !            13:  * This library is free software; you can redistribute it and/or                       *
        !            14:  * modify it under the terms of the GNU Lesser General Public License          *
        !            15:  * as published by the Free Software Foundation; either version 2                      *
        !            16:  * of the License, or (at your option) any later version.                                      *
        !            17:  * See the GNU Lesser General Public License for more details: lgpl.txt or     *
        !            18:  * http://www.fsf.org/copyleft/lesser.html                                                                     *
        !            19:  *                                                                                                                                                     *
        !            20:  * Anonymous FTP access to the most recent released source is available at     *
        !            21:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
        !            22:  *                                                                                                                                                     *
        !            23:  * Anonymous CVS access to the development source and modification history     *
        !            24:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
        !            25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
        !            26:  *     (just hit return, no password is necessary)                                                     *
        !            27:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
        !            28:  *                                                                                                                                                     *
        !            29:  * For Synchronet coding style and modification guidelines, see                                *
        !            30:  * http://www.synchro.net/source.html                                                                          *
        !            31:  *                                                                                                                                                     *
        !            32:  * You are encouraged to submit any modifications (preferably in Unix diff     *
        !            33:  * format) via e-mail to [email protected]                                                                      *
        !            34:  *                                                                                                                                                     *
        !            35:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
        !            36:  ****************************************************************************/
        !            37: 
        !            38: #ifndef _FILEWRAP_H
        !            39: #define _FILEWRAP_H
        !            40: 
        !            41: #include "wrapdll.h"   /* DLLEXPORT and DLLCALL */
        !            42: 
        !            43: #include <sys/stat.h>  /* S_IREAD and S_IWRITE (for use with sopen) */
        !            44: #include <stdio.h>
        !            45: 
        !            46: #if defined(__unix__)
        !            47:        #include <unistd.h>     /* read, write, close, ftruncate, lseek, etc. */
        !            48: #endif
        !            49: 
        !            50: #if defined(_WIN32) || defined(__BORLANDC__)
        !            51:        #include <io.h>
        !            52: #endif
        !            53: 
        !            54: /**********/
        !            55: /* Macros */
        !            56: /**********/
        !            57: 
        !            58: #if defined(_WIN32)
        !            59: 
        !            60:        #include <fcntl.h>                      /* O_BINARY */
        !            61:        #include <windows.h>            /* OF_SHARE_ */
        !            62:        #include <share.h>                      /* SH_DENY */
        !            63: 
        !            64:        #ifndef SH_DENYNO
        !            65:        #define SH_DENYNO                       OF_SHARE_DENY_NONE
        !            66:        #define SH_DENYWR                       OF_SHARE_DENY_WRITE
        !            67:        #define SH_DENYRW                       OF_SHARE_EXCLUSIVE
        !            68:        #endif
        !            69: 
        !            70: #elif defined(__unix__)
        !            71: 
        !            72:        #include <fcntl.h>
        !            73:        #ifdef __solaris__
        !            74:                #define LOCK_NB 1
        !            75:                #define LOCK_SH 2
        !            76:                #define LOCK_EX 4
        !            77:        #endif
        !            78: 
        !            79:        #ifdef __QNX__
        !            80:                #include <share.h>
        !            81:                #define L_SET   SEEK_SET
        !            82:        #else
        !            83:                #define O_TEXT          0               /* all files in binary mode on Unix */
        !            84:                #define O_BINARY        0               /* all files in binary mode on Unix */
        !            85:                #undef  O_DENYNONE
        !            86:                #define O_DENYNONE  (1<<31)     /* req'd for Baja/nopen compatibility */
        !            87: 
        !            88:                #define SH_DENYNO       2          /* no locks */
        !            89:                #ifdef F_SANEWRLCKNO
        !            90:                        #define SH_DENYRW       F_SANEWRLCKNO      /* exclusive lock */
        !            91:                #else
        !            92:                        #define SH_DENYRW       F_WRLCK    /* exclusive lock */
        !            93:                #endif
        !            94:        
        !            95:                #ifdef F_SANERDLCKNO
        !            96:                        #define SH_DENYWR   F_SANERDLCKNO    /* shareable lock */
        !            97:                #else
        !            98:                        #define SH_DENYWR   F_RDLCK    /* shareable lock */
        !            99:                #endif
        !           100:        #endif
        !           101:        #define chsize(fd,size)         ftruncate(fd,size)
        !           102:        #define tell(fd)                        lseek(fd,0,SEEK_CUR)
        !           103: 
        !           104: #elif defined(__OS2__)
        !           105: 
        !           106:        #include <share.h>                      /* SH_DENY */
        !           107: 
        !           108: #endif
        !           109: 
        !           110: /* Standard file descriptors.  */
        !           111: #ifndef STDIN_FILENO
        !           112: #define STDIN_FILENO    0       /* Standard input */
        !           113: #define STDOUT_FILENO   1       /* Standard output */
        !           114: #define STDERR_FILENO   2       /* Standard error output */
        !           115: #endif
        !           116: 
        !           117: #ifndef O_DENYNONE
        !           118: #define O_DENYNONE             SH_DENYNO
        !           119: #endif
        !           120: 
        !           121: /**************/
        !           122: /* Prototypes */
        !           123: /**************/
        !           124: 
        !           125: #if defined(__cplusplus)
        !           126: extern "C" {
        !           127: #endif
        !           128: 
        !           129: #if !defined(__BORLANDC__) && !defined(__WATCOMC__)
        !           130:        DLLEXPORT int   DLLCALL lock(int fd, long pos, long len);
        !           131:        DLLEXPORT int   DLLCALL unlock(int fd, long pos, long len);
        !           132: #endif
        !           133: 
        !           134: #if !defined(__BORLANDC__) && defined(__unix__)
        !           135:        DLLEXPORT int   DLLCALL sopen(const char* fn, int access, int share, ...);
        !           136:        DLLEXPORT long  DLLCALL filelength(int fd);
        !           137: #endif
        !           138: 
        !           139: #if defined(__unix__)
        !           140:        DLLEXPORT FILE * DLLCALL _fsopen(char *pszFilename, char *pszMode, int shmode);
        !           141: #endif
        !           142: 
        !           143: DLLEXPORT time_t       DLLCALL filetime(int fd);
        !           144: 
        !           145: #if defined(__cplusplus)
        !           146: }
        !           147: #endif
        !           148: 
        !           149: #endif /* Don't add anything after this line */

unix.superglobalmegacorp.com

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