tekfile.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Kevin McBride                                   *
00003  *   kevin@planetsaphire.com                                               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Library General Public License as       *
00007  *   published by the Free Software Foundation; either version 2 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU Library General Public     *
00016  *   License along with this program; if not, write to the                 *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef TEKFILE_H_AF7D74D2_DB02_11D9_9782_000BDBC434D9
00022 #define TEKFILE_H_AF7D74D2_DB02_11D9_9782_000BDBC434D9
00023 
00024 #ifndef     TEKLTI_H_C35A2A4C_D475_11D9_90BC_000BDBC434D9
00025 #error      This file must be included from <teklti.h>
00026 #endif      /* TEKLTI_H_C35A2A4C_D475_11D9_90BC_000BDBC434D9 */
00027 
00028 
00029 TEKUUIDIMPORT(UTekFile);
00030 
00031 
00032 enum TekFileType
00033 {
00034       TekFileType_Binary = 0x0000,
00035       TekFileType_ASCII = 0x0001,
00036       TekFileType_ConfigASCII = 0x0002,
00037       TekFileType_UNICODE = 0x0004,
00038       TekFileType_ConfigUNICODE = 0x0008,
00039       TekFileType_BinaryPipe = 0x0010,
00040       TekFileType_ASCIIPipe = 0x0020,
00041       TekFileType_UnicodePipe = 0x0040,
00042       TekFileType_BZIP2 = 0x0100,
00043       TekFileType_BZIP2_ASCII = 0x0200
00044       
00045 };
00046 
00047 #define TekFileType_UserDefined     TekFileType_Binary
00048 
00049 enum TekFileMode
00050 {
00051       TekFileMode_ReadOnly = 0x0000,
00052       TekFileMode_WriteOnly = 0x0001,
00053       TekFileMode_Append = 0x0002,
00054       TekFileMode_ReadWrite = 0x0004,
00055       TekFileMode_ReadWriteTrunc = 0x0008,
00056       TekFileMode_ReadAppend = 0x0010
00057 };
00058 
00059 /*
00060 For those compiling on a platform utilizing Intel processors:
00061 
00062 WARNING!!!  If you decide to change values starting with
00063 TekFileSeek (in any case), TEKFILESEEK_ must contain a
00064 numeric value, and TekFileSeek_ must contain the equivalent
00065 value in hexadecimal format.  The reason for this is because
00066 these values are also used in preprocessing #if...#endif
00067 statements to further optimize the assembly code, not just
00068 the ordinary code.
00069 
00070 ex.: If TEKFILESEEK_END = 2, then TekFileSeek_End = 0x0002
00071 */
00072 
00073 #define     TEKFILESEEK_BEGIN 0
00074 #define     TEKFILESEEK_CURRENT     1
00075 #define     TEKFILESEEK_END   2
00076 
00077 enum TekFileSeek
00078 {
00079       TekFileSeek_Begin = 0x0000,
00080       TekFileSeek_Current = 0x0001,
00081       TekFileSeek_End = 0x0002
00082 };
00083 
00084 /*
00085    The below external variables are inserted for the
00086    sole purpose of satisfying the GNU Assembler.
00087 */
00088 
00089 #ifdef      USE_386_ASM
00090 extern const char TekFileBinary_ReadOnly[];
00091 extern const char TekFileBinary_WriteOnly[];
00092 extern const char TekFileBinary_Append[];
00093 extern const char TekFileBinary_ReadWrite[];
00094 extern const char TekFileBinary_ReadWriteTrunc[];
00095 extern const char TekFileBinary_ReadAppend[];
00096 #endif      /* USE_386_ASM */
00097 
00098 
00099 
00108 class TekFile : public TekStd
00109 {
00110 public:
00114 TekFile();
00115 
00119 ~TekFile();
00120 
00121 #ifndef     TEKFILE_INTERNAL
00122 virtual TEKERR get_FILE(FILE ** FileDescriptor) = 0;
00123 virtual TEKERR get_Filename(uchar_t ** Name) = 0;
00124 virtual TEKERR get_Mode(TekFileMode * ModeID) = 0;
00125 virtual TEKERR get_Type(TekFileType * FileTypePointer) = 0;
00126 virtual TEKERR put_FILE(FILE * FileDescriptor) = 0;
00127 virtual TEKERR put_Filename(uchar_t * Name) = 0;
00128 virtual TEKERR put_Mode(TekFileMode ModeID) = 0;
00129 
00130 virtual TEKERR Close() = 0;
00131 virtual TEKERR Flush() = 0;
00132 virtual TEKERR Open() = 0;
00133 virtual TEKERR Open64() = 0;
00134 virtual TEKERR Read64(
00135       void * Buffer,
00136       uint64_t BytesToRead,
00137       uint64_t * BytesRead
00138 ) = 0;
00139 virtual TEKERR Read(
00140       void * Buffer,
00141       unsigned long BytesToRead,
00142       unsigned long * BytesRead
00143 ) = 0;
00144 virtual TEKERR Seek64(TekFileSeek SeekWhere, int64_t NewLocation) = 0;
00145 virtual TEKERR Seek(TekFileSeek SeekWhere, signed long NewLocation) = 0;
00146 virtual TEKERR Write64(
00147       void * Buffer,
00148       uint64_t BytesToWrite,
00149       uint64_t * BytesWrote
00150 ) = 0;
00151 virtual TEKERR Write(
00152       void * Buffer,
00153       unsigned long BytesToWrite,
00154       unsigned long * BytesWrote
00155 ) = 0;
00156 virtual TEKERR get_Location(unsigned long * Location) = 0;
00157 virtual TEKERR get_Location64(uint64_t * Location) = 0;
00158 #endif      /* not TEKFILE_INTERNAL */
00159 
00165 //TEKSTD_HEADER_VARSANDFUNC(TekFile);
00166 TEKSTD_HEADER_VARS;
00167 };
00168 
00169 
00170 /*
00171     \fn TEKLTI_DECLSPEC TEKERR TekFileCreate(TekFileType FileType, TekFile ** RetVal, uchar_t * FileName = (uchar_t *)NULL)
00172     
00173     Creates an instance to an appropriate TekFileType.
00174  */
00175 
00176 TEKLTI_DECLSPEC TEKERR TekFileCreate(TekFileType FileType, TekFile ** RetVal, uchar_t * FileName = (uchar_t *)NULL);
00177 
00178 #endif      /* not TEKFILE_H_AF7D74D2_DB02_11D9_9782_000BDBC434D9 */
00179 
00180 
SourceForge.net Logo  Technical Library Template Interface Project Page