/build/buildd/nifticlib-0.4/znzlib/znzlib.h

00001 #ifndef _ZNZLIB_H_
00002 #define _ZNZLIB_H_
00003 
00004 /*
00005 znzlib.h  (zipped or non-zipped library)
00006 
00007 *****            This code is released to the public domain.            *****
00008 
00009 *****  Author: Mark Jenkinson, FMRIB Centre, University of Oxford       *****
00010 *****  Date:   September 2004                                           *****
00011 
00012 *****  Neither the FMRIB Centre, the University of Oxford, nor any of   *****
00013 *****  its employees imply any warranty of usefulness of this software  *****
00014 *****  for any purpose, and do not assume any liability for damages,    *****
00015 *****  incidental or otherwise, caused by any use of this document.     *****
00016 
00017 */
00018 
00019 /*
00020 
00021 This library provides an interface to both compressed (gzip/zlib) and
00022 uncompressed (normal) file IO.  The functions are written to have the
00023 same interface as the standard file IO functions.  
00024 
00025 To use this library instead of normal file IO, the following changes
00026 are required:
00027  - replace all instances of FILE* with znzFile
00028  - change the name of all function calls, replacing the initial character
00029    f with the znz  (e.g. fseek becomes znzseek)
00030  - add a third parameter to all calls to znzopen (previously fopen)
00031    that specifies whether to use compression (1) or not (0)
00032  - use znz_isnull rather than any (pointer == NULL) comparisons in the code
00033  
00034 NB: seeks for writable files with compression are quite restricted
00035 
00036 */
00037 
00038 
00039 /*=================*/
00040 #ifdef  __cplusplus
00041 extern "C" {
00042 #endif
00043 /*=================*/
00044 
00045 #include <stdio.h>
00046 #include <stdlib.h>
00047 #include <string.h>
00048 #include <stdarg.h>
00049 
00050 #include "config.h"
00051 
00052 #ifdef HAVE_ZLIB 
00053 #include "zlib.h"
00054 #endif
00055 
00056 
00057 struct znzptr {
00058   int withz;
00059   FILE* nzfptr;
00060 #ifdef HAVE_ZLIB
00061   gzFile zfptr;
00062 #endif
00063 } ;
00064 
00065 /* the type for all file pointers */
00066 typedef struct znzptr * znzFile;
00067 
00068 
00069 /* int znz_isnull(znzFile f); */
00070 /* int znzclose(znzFile f); */
00071 #define znz_isnull(f) ((f) == NULL)
00072 #define znzclose(f)   Xznzclose(&(f))
00073 
00074 /* Note extra argument (use_compression) where 
00075    use_compression==0 is no compression
00076    use_compression!=0 uses zlib (gzip) compression
00077 */
00078 
00079 znzFile znzopen(const char *path, const char *mode, int use_compression);
00080 
00081 znzFile znzdopen(int fd, const char *mode, int use_compression);
00082 
00083 int Xznzclose(znzFile * file);
00084 
00085 size_t znzread(void* buf, size_t size, size_t nmemb, znzFile file);
00086 
00087 size_t znzwrite(const void* buf, size_t size, size_t nmemb, znzFile file);
00088 
00089 long znzseek(znzFile file, long offset, int whence);
00090 
00091 int znzrewind(znzFile stream);
00092 
00093 long znztell(znzFile file);
00094 
00095 int znzputs(const char *str, znzFile file);
00096 
00097 char * znzgets(char* str, int size, znzFile file);
00098 
00099 int znzputc(int c, znzFile file);
00100 
00101 int znzgetc(znzFile file);
00102 
00103 #if !defined(WIN32)
00104 int znzprintf(znzFile stream, const char *format, ...);
00105 #endif
00106 
00107 /*=================*/
00108 #ifdef  __cplusplus
00109 }
00110 #endif
00111 /*=================*/
00112 
00113 #endif

Generated on Fri Nov 17 08:11:48 2006 for nifti1_io by  doxygen 1.5.1