Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

niml_private.h

Go to the documentation of this file.
00001 #ifndef _NIML_PRIVATE_HEADER_FILE_
00002 #define _NIML_PRIVATE_HEADER_FILE_
00003 
00004 #include "niml.h"
00005 
00006 #define USE_NEW_IOFUN      /* 13 Feb 2003 */
00007 
00008 /****************************************************************************/
00009 /********* NIML private definitions, not needed by user programs ************/
00010 /****************************************************************************/
00011 
00012 /************************** Debugging stuff (duh) ***************************/
00013 
00014 /*** Debug printout will only be enable if NIML_DEBUG
00015      is defined here, AND if environment variable NIML_DEBUG
00016      is also set to a filename (special case: or to the string "stderr"). ***/
00017 
00018 #define NIML_DEBUG
00019 
00020 #include <stdarg.h>
00021 
00022 extern FILE *dfp ;                     /* debug file pointer */
00023 extern void NI_dpr( char * , ... ) ;   /* print debug stuff */
00024 
00025 /******************** typedefs used only internally *************************/
00026 
00027 /*! Holds strings from the <header and=attributes> */
00028 
00029 typedef struct {
00030    int nattr ;            /*!< Number of attributes. */
00031    int empty ;            /*!< Did header end in '/>'? */
00032    char *name ;           /*!< Header name string. */
00033    char **lhs ;           /*!< Left-hand-sides of attributes. */
00034    char **rhs ;           /*!< Right-hand-sides of attributes (may be NULL). */
00035 } header_stuff ;
00036 
00037 /*! A pair of integers (what did you think it was?). */
00038 
00039 typedef struct { int i,j ; } intpair ;
00040 
00041 /*! An array of integers. */
00042 
00043 typedef struct { int num; int *ar; } int_array ;
00044 
00045 /****************************************************************************/
00046 
00047 extern void NI_stream_close_keep( NI_stream_type * ,int ) ;
00048 
00049 extern int string_index( char *targ, int nstr, char *str[] ) ;
00050 extern int unescape_inplace( char *str ) ;
00051 extern char * quotize_string( char *str ) ;
00052 extern char * quotize_string_vector( int num , char **str , char sep ) ;
00053 extern char * quotize_int_vector( int num , int *vec , char sep ) ;
00054 extern char * quotize_float_vector( int num , float *vec , char sep ) ;
00055 extern int NI_is_name( char *str ) ;
00056 extern char * trailname( char *fname , int lev ) ;
00057 
00058 /****************************************************************************/
00059 
00060 extern int  dtable_mode ;
00061 extern byte dtable[256] ;
00062 extern int  linelen ;
00063 extern int  ncrlf   ;
00064 extern int  nocrlf  ;
00065 
00066 #define B64_goodchar(c) (dtable[c] != 0x80)  /* for decode only */
00067 
00068 #define B64_EOL1 '\r'   /* CR */
00069 #define B64_EOL2 '\n'   /* LF */
00070 
00071 /*! Encode 3 bytes (a,b,c) into 4 bytes (w,x,y,z) */
00072 
00073 #define B64_encode3(a,b,c,w,x,y,z)                 \
00074      ( w = dtable[(a)>>2]                      ,   \
00075        x = dtable[((a & 3) << 4) | (b >> 4)]   ,   \
00076        y = dtable[((b & 0xF) << 2) | (c >> 6)] ,   \
00077        z = dtable[c & 0x3F]                     )
00078 
00079 /*! Encode 2 bytes (a,b) into 4 bytes (w,x,y,z) */
00080 
00081 #define B64_encode2(a,b,w,x,y,z)                   \
00082      ( B64_encode3(a,b,0,w,x,y,z) , z = '=' )
00083 
00084 /*! Encode 1 byte (a) into 4 bytes (w,x,y,z) */
00085 
00086 #define B64_encode1(a,w,x,y,z)                     \
00087      ( B64_encode3(a,0,0,w,x,y,z) , y=z = '=' )
00088 
00089 /*! Decode 4 bytes (w,x,y,z) into 3 bytes (a,b,c) */
00090 
00091 #define B64_decode4(w,x,y,z,a,b,c)                 \
00092      ( a = (dtable[w] << 2) | (dtable[x] >> 4) ,   \
00093        b = (dtable[x] << 4) | (dtable[y] >> 2) ,   \
00094        c = (dtable[y] << 6) | dtable[z]         )
00095 
00096 /*! Determine how many output bytes are encoded in a quad (w,x,y,z) */
00097 
00098 #define B64_decode_count(w,x,y,z)                  \
00099      ( ((w)=='='||(x)=='=') ? 0                    \
00100                             : ((y)=='=') ? 1       \
00101                             : ((z)=='=') ? 2 : 3 )
00102 
00103 extern void load_encode_table(void) ;
00104 extern void load_decode_table(void) ;
00105 
00106 /****************************************************************************/
00107 
00108 typedef unsigned char *POINTER;   /* POINTER defines a generic pointer type */
00109 typedef unsigned short int UINT2; /* UINT2 defines a two byte word */
00110 typedef unsigned long int UINT4;  /* UINT4 defines a four byte word */
00111 
00112 /* MD5 context data type */
00113 
00114 typedef struct {
00115   UINT4 state[4];                                        /* state (ABCD) */
00116   UINT4 count[2];             /* number of bits, modulo 2^64 (lsb first) */
00117   unsigned char buffer[64];                              /* input buffer */
00118 } MD5_CTX;
00119 
00120 /* prototypes for some internal functions */
00121 
00122 extern void MD5Init (MD5_CTX *);
00123 extern void MD5Update (MD5_CTX *, unsigned char *, unsigned int);
00124 extern void MD5Final (unsigned char [16], MD5_CTX *);
00125 
00126 /****************************************************************************/
00127 
00128 extern int     typedef_nib ;
00129 extern int     typedef_num ;
00130 extern char ** typedef_nam ;
00131 extern char ** typedef_typ ;
00132 extern char ** typedef_dim ;
00133 
00134 /*! Characters allowed inside unquoted strings. */
00135 
00136 #define IS_STRING_CHAR(c) ( isgraph(c) && !isspace(c) &&  \
00137                             (c) != '>' && (c) != '/'  &&  \
00138                             (c) != '=' && (c) != '<'    )
00139 
00140 /*! Defines what we consider a quoting character. */
00141 
00142 #define IS_QUOTE_CHAR(c)  ( (c) == '"' || (c) == '\'' )
00143 
00144 /*! Defines characters allowed inside a "name". */
00145 
00146 #define IS_NAME_CHAR(c) \
00147   (isalnum(c) || (c)=='_' || (c)=='.' || (c)=='-' || (c)==':')
00148 
00149 extern void destroy_header_stuff( header_stuff *hs ) ;
00150 extern intpair find_string( int nst, int nch, char *ch ) ;
00151 extern header_stuff * parse_header_stuff( int ndat, char *dat, int *nused ) ;
00152 extern intpair decode_type_field( char *tf ) ;
00153 extern int_array * decode_dimen_string( char *ds ) ;
00154 extern int_array * decode_type_string( char *ts ) ;
00155 extern char NI_type_char( int typ ) ;
00156 extern void enhance_header_stuff( header_stuff *hs ) ;
00157 extern char * get_header_attribute( header_stuff *hs , char *attname ) ;
00158 
00159 /****************************************************************************/
00160 
00161 extern NI_element * make_empty_data_element ( header_stuff *hs ) ;
00162 extern NI_group   * make_empty_group_element( header_stuff *hs ) ;
00163 extern void NI_fill_vector_row( NI_element *nel , int row , char *buf ) ;
00164 
00165 extern int NI_stream_writestring( NI_stream_type *ns , char *str ) ;
00166 extern int NI_stream_fillbuf( NI_stream_type *ns, int minread, int msec ) ;
00167 
00168 extern void NI_reset_buffer( NI_stream_type * ) ;
00169 extern int  NI_decode_one_double( NI_stream_type *, double *, int ) ;
00170 extern int  NI_decode_one_string( NI_stream_type *, char ** , int ) ;
00171 
00172 #endif
 

Powered by Plone

This site conforms to the following standards: