libstdf_internal.h

Go to the documentation of this file.
00001 
00006 /*
00007  * Copyright (C) 2005-2006 Mike Frysinger <vapier@gmail.com>
00008  * Released under the BSD license.  For more information,
00009  * please see: http://opensource.org/licenses/bsd-license.php
00010  *
00011  * $Header: /cvsroot/freestdf/libstdf/include/libstdf_internal.h,v 1.9 2006/01/08 05:39:38 vapier Exp $
00012  */
00013 
00014 #ifndef _LIBSTDF_INTERNAL_H
00015 #define _LIBSTDF_INTERNAL_H
00016 
00017 /* STDF File structure */
00018 #define __STDF_HOST_BYTE_ORDER      BYTE_ORDER
00019 
00020 typedef struct {
00021     int (*open)(void*, int, uint32_t);
00022     int (*read)(void*, void*, long);
00023     int (*close)(void*);
00024 } __stdf_fops;
00025 
00029 typedef struct {
00030     rec_header  header;         
00032     int         fd;             
00033     union {
00034 # if HAVE_ZIP
00035     ZZIP_FILE   *zip;
00036 #  define fd_zip __fd.zip
00037 # endif
00038 # if HAVE_GZIP
00039     gzFile      *gzip;
00040 #  define fd_gzip __fd.gzip
00041 # endif
00042 # if HAVE_BZIP2
00043     BZFILE      *bzip2;
00044 #  define fd_bzip2 __fd.bzip2
00045 # endif
00046 # if HAVE_LZW
00047     lzwFile     *lzw;
00048 #  define fd_lzw __fd.lzw
00049 # endif
00050     uintptr_t   padding[4];
00051     } __fd;
00052 
00053     stdf_format file_format;    
00054     char        *filename;      
00055     __stdf_fops *fops;          
00057     int         byte_order;     
00058     uint32_t    opts;           
00059     dtc_U1      ver;            
00061     byte_t      *__data;
00062     byte_t      *rec_pos;
00063     byte_t      *rec_end;
00064 
00065     byte_t      *__output;
00066     byte_t      *_write_pos;
00067     dtc_U2      _write_chunk_size;
00068 } stdf_file;
00069 
00070 
00071 
00075 #define _warn(fmt, args...)  fprintf(stderr, fmt , ## args)
00076 #define warn(fmt, args...)   _warn(PACKAGE_STRING ": " fmt "\n" , ## args)
00077 #define warnf(fmt, args...)  warn("%s(): " fmt, __FUNCTION__ , ## args)
00078 #define warnp(fmt, args...)  warn(fmt ": %s" , ## args , strerror(errno))
00079 #define warnfp(fmt, args...) warnp("%s(): " fmt, __FUNCTION__ , ## args)
00080 
00081 #define dumphex(buf, cnt) \
00082     do { \
00083         size_t i = 0; \
00084         _warn("dumphex: "); \
00085         while (i < cnt) \
00086             _warn("%2.2X ", buf[i++]); \
00087         _warn("\n"); \
00088     } while (0)
00089 
00090 
00094 #if HAVE_MCHECK_H
00095 # include <mcheck.h>
00096 # define _stdf_mtrace()   mtrace()
00097 # define _stdf_muntrace() muntrace()
00098 #else
00099 # define _stdf_mtrace()
00100 # define _stdf_muntrace()
00101 #endif
00102 
00103 #if HAVE_DMALLOC_H
00104 # include <dmalloc.h>
00105 #endif
00106 
00107 #if HAVE_EFENCE_H
00108 # include <efence.h>
00109 #endif
00110 
00111 
00115 #ifndef __GNUC_PREREQ
00116 # define __GNUC_PREREQ(maj, min) 0
00117 #endif
00118 #if __GNUC_PREREQ(3,3) && defined(__ELF__)
00119 # define attribute_unused __attribute__ ((unused))
00120 # if !defined(weak_alias)
00121 #  define weak_alias(name, aliasname) \
00122     extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)))
00123 # endif
00124 # if !defined(strong_alias)
00125 #  define strong_alias(name, aliasname) \
00126     extern __typeof (name) aliasname __attribute__ ((alias (#name)))
00127 # endif
00128 # if !defined(attribute_hidden)
00129 #  define attribute_hidden __attribute__ ((visibility ("hidden")))
00130 # endif
00131 #else
00132 # define attribute_unused
00133 # if !defined(attribute_hidden)
00134 #  define attribute_hidden
00135 # endif
00136 #endif
00137 
00138 #endif /* _LIBSTDF_INTERNAL_H */

Generated on Thu Jun 8 14:05:35 2006 for libstdf by  doxygen 1.4.6