mfs_file.h

Go to the documentation of this file.
00001 /*
00002   --------------------------------------------------------------------------------
00003   -   Module      :   mem_file.h
00004   -   Description :   A general purpose library for manipulating a memory area
00005   -                   as if it were a file.
00006   -                   mfs_ stands for memory file system.
00007   -   Author      :   Mike Johnson - Banctec AB 03/07/96
00008   -                   
00009   --------------------------------------------------------------------------------
00010 */
00011 
00012 /* 
00013 
00014 Copyright (c) 1996 Mike Johnson
00015 Copyright (c) 1996 BancTec AB
00016 
00017 Permission to use, copy, modify, distribute, and sell this software
00018 for any purpose is hereby granted without fee, provided
00019 that (i) the above copyright notices and this permission notice appear in
00020 all copies of the software and related documentation, and (ii) the names of
00021 Mike Johnson and BancTec may not be used in any advertising or
00022 publicity relating to the software.
00023 
00024 THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
00025 EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
00026 WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
00027 
00028 IN NO EVENT SHALL MIKE JOHNSON OR BANCTEC BE LIABLE FOR
00029 ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
00030 OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00031 WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
00032 LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
00033 OF THIS SOFTWARE.
00034 
00035 */
00036 
00037 #ifndef __mfs_file_c
00038 #define __mfs_file_c
00039 
00040 /*
00041   --------------------------------------------------------------------------------
00042   -   Includes
00043   --------------------------------------------------------------------------------
00044 */
00045 
00046 #include    <cstdio>
00047 #include    <cstdlib>
00048 #include    <cstring>
00049 
00050 /*
00051   --------------------------------------------------------------------------------
00052   -   Definitions
00053   --------------------------------------------------------------------------------
00054 */
00055 
00056 static const int MAX_BUFFS  = 20;
00057 
00058 static const int  MFS_EINVAL = 22;
00059 static const int  MFS_EMFILE = 24;
00060 static const int  MFS_EBADF = 77;
00061 static const int  MFS_EDQUOT = 122;
00062 
00063 
00064 /*
00065   --------------------------------------------------------------------------------
00066   -   Function prototypes
00067   --------------------------------------------------------------------------------
00068 */
00069 
00070 int mfs_open (void *ptr, int size, const char *mode);
00071 int mfs_lseek (int fd, int offset, int whence);
00072 int mfs_lseekForTIFFRead (int fd, int offset, int whence);
00073 int mfs_read (int fd, void *buf, int size);
00074 int mfs_write (int fd, void *buf, int size);
00075 int mfs_size (int fd);
00076 int mfs_map (int fd, char **addr, size_t *len);
00077 int mfs_unmap (int fd);
00078 int mfs_close (int fd);
00079 int extend_mem_file (int fd, int size);
00080 void mem_init ();
00081 
00082 /*
00083   --------------------------------------------------------------------------------
00084   -   Function    :   mfs_gets()
00085   -
00086   -   Arguments   :   File descriptor, buffer, size
00087   -
00088   -   Returns     :   as per man gets (2)
00089   -
00090   -   Description :   Does the same as gets (2) except on a memory based file.
00091   -                   Note: An attempt to read past the end of memory currently
00092   -                   allocated to the file will return 0 (End Of File)
00093   -                   
00094   --------------------------------------------------------------------------------
00095 */
00096 
00097 int mfs_gets (int fd, void *clnt_buf, int size);
00098 
00099 #endif

DOCLIB is being developed under contract by a collaboration between:
The Laboratory for Language and Media Processing
Unviersity of Maryland, College Park
and
Booz | Allen | Hamilton

All Rights Reserved, 2003-2007