abyss_file.h

Go to the documentation of this file.
00001 #ifndef FILE_H_INCLUDED
00002 #define FILE_H_INCLUDED
00003 
00004 #include <fcntl.h>
00005 #include <sys/types.h>
00006 #include <sys/stat.h>
00007 #include <limits.h>
00008 
00009 #include <xmlrpc-c/abyss.h>
00010 
00011 #ifndef NAME_MAX
00012 #define NAME_MAX    1024
00013 #endif
00014 
00015 #ifdef WIN32
00016 #ifndef __BORLANDC__
00017 #define O_APPEND    _O_APPEND
00018 #define O_CREAT     _O_CREAT 
00019 #define O_EXCL      _O_EXCL
00020 #define O_RDONLY    _O_RDONLY
00021 #define O_RDWR      _O_RDWR 
00022 #define O_TRUNC _O_TRUNC
00023 #define O_WRONLY    _O_WRONLY
00024 #define O_TEXT      _O_TEXT
00025 #define O_BINARY    _O_BINARY
00026 #endif
00027 
00028 #define A_HIDDEN    _A_HIDDEN
00029 #define A_NORMAL    _A_NORMAL
00030 #define A_RDONLY    _A_RDONLY
00031 #define A_SUBDIR    _A_SUBDIR
00032 #else
00033 #define A_SUBDIR    1
00034 #define O_BINARY    0
00035 #define O_TEXT      0
00036 #endif  /* WIN32 */
00037 
00038 #ifdef WIN32
00039 
00040 #ifndef __BORLANDC__
00041 typedef struct _stati64 TFileStat;
00042 typedef struct _finddata_t TFileInfo;
00043 typedef long TFileFind;
00044 
00045 #else  /* WIN32 */
00046 
00047 typedef struct stat TFileStat;
00048 typedef struct finddata_t {
00049     char name[NAME_MAX+1];
00050     int attrib;
00051     uint64_t size;
00052     time_t time_write;
00053     WIN32_FIND_DATA data;
00054 } TFileInfo;
00055 
00056 typedef HANDLE TFileFind;
00057 
00058 #endif /* WIN32 */
00059 
00060 #else
00061 
00062 #include <unistd.h>
00063 #include <dirent.h>
00064 
00065 typedef struct stat TFileStat;
00066 
00067 typedef struct finddata_t {
00068     char name[NAME_MAX+1];
00069     int attrib;
00070     uint64_t size;
00071     time_t time_write;
00072 } TFileInfo;
00073 
00074 typedef struct {
00075     char path[NAME_MAX+1];
00076     DIR *handle;
00077 } TFileFind;
00078 
00079 #endif
00080 
00081 typedef int TFile;
00082 
00083 abyss_bool
00084 FileOpen(TFile *      const f,
00085          const char * const name,
00086          uint32_t     const attrib);
00087 
00088 abyss_bool
00089 FileOpenCreate(TFile *      const f,
00090                const char * const name,
00091                uint32_t     const attrib);
00092 
00093 abyss_bool
00094 FileClose(TFile * const f);
00095 
00096 abyss_bool
00097 FileWrite(TFile *      const f,
00098           const void * const buffer,
00099           uint32_t     const len);
00100 
00101 int32_t
00102 FileRead(TFile *  const f,
00103          void *   const buffer,
00104          uint32_t const len);
00105 
00106 abyss_bool
00107 FileSeek(TFile *  const f,
00108          uint64_t const pos,
00109          uint32_t const attrib);
00110 
00111 uint64_t
00112 FileSize(TFile * const f);
00113 
00114 abyss_bool
00115 FileStat(const char * const filename,
00116          TFileStat *  const filestat);
00117 
00118 abyss_bool
00119 FileFindFirst(TFileFind *  const filefind,
00120               const char * const path,
00121               TFileInfo *  const fileinfo);
00122 
00123 abyss_bool
00124 FileFindNext(TFileFind * const filefind,
00125              TFileInfo * const fileinfo);
00126 
00127 void
00128 FileFindClose(TFileFind * const filefind);
00129 
00130 #endif

Generated on Thu May 17 10:00:23 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6