Main Page   Compound List   File List   Compound Members   File Members   Related Pages  

library_file.h

Go to the documentation of this file.
00001 /*
00002      library_file.h: header file for library_file.c
00003      Copyright (C) 2001  CCLRC, Charles Ballard
00004 
00005      This library is free software and is distributed under the terms and
00006      conditions of the CCP4 licence agreement as `Part 0' (Annex 2)
00007      software, which is version 2.1 of the GNU Lesser General Public
00008      Licence (LGPL) with the following additional clause:
00009 
00010         `You may also combine or link a "work that uses the Library" to
00011         produce a work containing portions of the Library, and distribute
00012         that work under terms of your choice, provided that you give
00013         prominent notice with each copy of the work that the specified
00014         version of the Library is used in it, and that you include or
00015         provide public access to the complete corresponding
00016         machine-readable source code for the Library including whatever
00017         changes were used in the work. (i.e. If you make changes to the
00018         Library you must distribute those, but you do not need to
00019         distribute source or object code to those portions of the work
00020         not covered by this licence.)'
00021 
00022      Note that this clause grants an additional right and does not impose
00023      any additional restriction, and so does not affect compatibility
00024      with the GNU General Public Licence (GPL). If you wish to negotiate
00025      other terms, please contact the maintainer.
00026 
00027      You can redistribute it and/or modify the library under the terms of
00028      the GNU Lesser General Public License as published by the Free Software
00029      Foundation; either version 2.1 of the License, or (at your option) any
00030      later version.
00031 
00032      This library is distributed in the hope that it will be useful, but
00033      WITHOUT ANY WARRANTY; without even the implied warranty of
00034      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00035      Lesser General Public License for more details.
00036 
00037      You should have received a copy of the CCP4 licence and/or GNU
00038      Lesser General Public License along with this library; if not, write
00039      to the CCP4 Secretary, Daresbury Laboratory, Warrington WA4 4AD, UK.
00040      The GNU Lesser General Public can also be obtained by writing to the
00041      Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00042      MA 02111-1307 USA
00043 */
00044 
00050 #ifndef __CCP4_LIB_FILE
00051 #define __CCP4_LIB_FILE
00052 
00053 #include "ccp4_sysdep.h"
00054 #include "ccp4_types.h"
00055 
00056 #ifdef __cplusplus
00057 namespace CCP4 {
00058 extern "C" {
00059 #endif
00060 
00062 typedef struct _CFileStruct CCP4File;
00063 
00064 struct _CFileStruct {
00065   char *name;
00066   FILE *stream;
00067   int fd;
00068   unsigned int read : 1;
00069   unsigned int write : 1;
00070   unsigned int append : 1;
00071   unsigned int binary : 1;
00072   unsigned int scratch : 1 , : 3;
00073   unsigned int buffered : 1;
00074   unsigned int sync : 1, : 6;
00075   unsigned int direct : 1, : 7;
00076   unsigned int open : 1;
00077   unsigned int own : 1;
00078   unsigned int last_op : 2;
00079   unsigned int getbuff : 1, : 4;
00080   int iostat;
00081   unsigned int mode : 8;
00082   unsigned int itemsize : 8;
00083   unsigned int iconvert : 8;
00084   unsigned int fconvert: 8;
00085   off_t length;
00086   off_t loc;
00087   size_t stamp_loc;
00088   int (*_read) (CCP4File *, uint8 *, size_t);
00089   int (*_write) (CCP4File *, const uint8 *, size_t);
00090   char buff[8];
00091   void *priv;
00092 };
00093 
00094 
00095 CCP4File *ccp4_file_open (const char *, const int);
00096 
00097 CCP4File *ccp4_file_open_file (const FILE *, const int);
00098 
00099 CCP4File *ccp4_file_open_fd (const int, const int);
00100 
00101 int ccp4_file_rarch ( CCP4File*);
00102 
00103 int ccp4_file_warch ( CCP4File*);
00104 
00105 int ccp4_file_close ( CCP4File*);
00106 
00107 int ccp4_file_mode ( const CCP4File*);
00108 
00109 int ccp4_file_setmode ( CCP4File*, const int);
00110 
00111 int ccp4_file_setstamp( CCP4File *, const size_t);
00112 
00113 int ccp4_file_itemsize( const CCP4File*);
00114 
00115 int ccp4_file_setbyte( CCP4File *, const int);
00116 
00117 int ccp4_file_byteorder( CCP4File *);
00118 
00119 int ccp4_file_is_write(const CCP4File *);
00120 
00121 int ccp4_file_is_read(const CCP4File *);
00122 
00123 int ccp4_file_is_append(const CCP4File *);
00124 
00125 int ccp4_file_is_scratch(const CCP4File *);
00126 
00127 int ccp4_file_is_buffered(const CCP4File *);
00128 
00129 int ccp4_file_status(const CCP4File *);
00130 
00131 const char *ccp4_file_name( CCP4File *);
00132 
00133 int ccp4_file_read ( CCP4File*, uint8 *, size_t);
00134 
00135 int ccp4_file_readcomp ( CCP4File*, uint8 *, size_t);
00136 
00137 int ccp4_file_readshortcomp ( CCP4File*, uint8 *, size_t);
00138 
00139 int ccp4_file_readfloat ( CCP4File*, uint8 *, size_t);
00140 
00141 int ccp4_file_readint ( CCP4File*, uint8 *, size_t);
00142 
00143 int ccp4_file_readshort ( CCP4File*, uint8 *, size_t);
00144 
00145 int ccp4_file_readchar ( CCP4File*, uint8 *, size_t);
00146 
00147 int ccp4_file_write ( CCP4File*, const uint8 *, size_t);
00148 
00149 int ccp4_file_writecomp ( CCP4File*, const uint8 *, size_t);
00150 
00151 int ccp4_file_writeshortcomp ( CCP4File*, const uint8 *, size_t);
00152 
00153 int ccp4_file_writefloat ( CCP4File*, const uint8 *, size_t);
00154 
00155 int ccp4_file_writeint ( CCP4File*, const uint8 *, size_t);
00156 
00157 int ccp4_file_writeshort ( CCP4File*, const uint8 *, size_t);
00158 
00159 int ccp4_file_writechar ( CCP4File*, const uint8 *, size_t);
00160 
00161 int ccp4_file_seek ( CCP4File*, long, int);
00162 
00163 void ccp4_file_rewind ( CCP4File*);
00164 
00165 void ccp4_file_flush (CCP4File *);
00166 
00167 long ccp4_file_length ( CCP4File*);
00168 
00169 long ccp4_file_tell ( CCP4File*);
00170 
00171 int ccp4_file_feof(CCP4File *);
00172 
00173 void ccp4_file_clearerr(CCP4File *);
00174 
00175 void ccp4_file_fatal (CCP4File *, char *);
00176 
00177 char *ccp4_file_print(CCP4File *, char *, char *);
00178 
00179 int ccp4_file_raw_seek( CCP4File *, long, int);
00180 int ccp4_file_raw_read ( CCP4File*, char *, size_t);
00181 int ccp4_file_raw_write ( CCP4File*, const char *, size_t);
00182 int ccp4_file_raw_setstamp( CCP4File *, const size_t);
00183 #ifdef __cplusplus
00184 }
00185 }
00186 #endif
00187 
00188 #endif  /* __CCP4_LIB_FILE */