1 /********************************************************************* 2 * Copyright 1993, University Corporation for Atmospheric Research 3 * See netcdf/COPYRIGHT file for copying and redistribution conditions. 4 * $Header: /upc/share/CVS/netcdf-3/ncdump/dumplib.h,v 1.28 2009/08/13 21:06:13 russ Exp $ 5 *********************************************************************/ 6 #ifndef _DUMPLIB_H_ 7 #define _DUMPLIB_H_ 8 9 #include "config.h" 10 11 extern char *progname; /* for error messages */ 12 13 #ifndef NO_NETCDF_2 14 #define NO_NETCDF_2 /* assert we aren't using any netcdf-2 stuff */ 15 #endif 16 17 #ifndef EXIT_FAILURE 18 #ifndef vms 19 #define EXIT_SUCCESS 0 20 #define EXIT_FAILURE 1 21 #else 22 #define EXIT_SUCCESS 1 23 #define EXIT_FAILURE 0 24 #endif 25 #endif 26 27 /* more than enough characters needed to represent any single numeric 28 * primitive value (e.g. int, float, double, long long, ...) using 29 * printf functions */ 30 #define PRIM_LEN 100 31 32 #define FLT_DIGITS 7 /* default sig. digits for float data */ 33 #define DBL_DIGITS 15 /* default sig. digits for double data */ 34 35 extern int float_precision_specified; /* -p option specified float precision */ 36 extern int double_precision_specified; /* -p option specified double precision */ 37 extern char float_var_fmt[]; 38 extern char double_var_fmt[]; 39 extern char float_att_fmt[]; 40 extern char float_attx_fmt[]; 41 extern char double_att_fmt[]; 42 43 /* Display for netCDF-4 and HDF5 string values representing NULL 44 * pointers rather than empty strings. HDF5 distinguishes these two 45 * kinds of string values so NULL pointers can be used as fill values 46 * for lists of strings that might include empty strings. */ 47 #define NIL_STRING "NIL" 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 /* In case different formats specified with -d option, set them here. */ 54 extern void set_formats ( int flt_digs, int dbl_digs ); 55 56 /* Determine print format to use for each value for this variable. */ 57 const char * get_fmt ( int ncid, int varid, nc_type typeid ); 58 59 /* Add type info to type list */ 60 extern void typeadd ( nctype_t *typep ); 61 62 /* From type id, get full type info (in current typlelist context) */ 63 extern nctype_t *get_typeinfo ( int typeid ); 64 65 /* From type id, get type name */ 66 extern void get_type_name(int ncid, nc_type type, char *name); 67 68 /* set tostring member function */ 69 extern void set_tostring_func ( ncvar_t *varp); 70 71 /* helper function for output of opaque attributes */ 72 extern int ncopaque_val_as_hex ( size_t size, char *buf, const void *valp ); 73 74 /* Initialize list of types, only need primitive types for netCDF-3 */ 75 extern void init_types ( int ncid ); 76 77 /* Deallocate type list */ 78 /* extern void xfree_typeinfo ( ); */ 79 80 /* Test if variable is a coordinate variable */ 81 extern int iscoordvar ( int ncid, int varid ); 82 83 /* Test if user-defined type */ 84 extern int is_user_defined_type ( nc_type type ); 85 86 /* Initialize global constants used in slightly fuzzy float comparisons */ 87 extern void init_epsilons ( void ); 88 89 /* Initialize string buffer */ 90 safebuf_t *sbuf_new(); 91 92 /* Copy string s2 to buffer in sbuf, growing if necessary */ 93 void sbuf_cpy(safebuf_t *sbuf, const char *s2); 94 95 /* Concatenate string s2 to end of buffer in sbuf, growing if necessary */ 96 void sbuf_cat(safebuf_t *sbuf, const char *s2); 97 98 /* Concatenate sbuf s2 to end of sbuf s1, growing if necessary */ 99 void sbuf_catb(safebuf_t *s1, const safebuf_t *s2); 100 101 /* Return length of the string in sbuf */ 102 size_t sbuf_len(const safebuf_t *sbuf); 103 104 /* Return the C string inside an sbuf */ 105 char *sbuf_str(const safebuf_t *sbuf); 106 107 /* Free string buffer */ 108 void sbuf_free(safebuf_t *sbuf); 109 110 /* Print simple type name symbol or as absolute path, if necessary. 111 * Escape any special chars. */ 112 void print_type_name(int locid, int typeid); 113 114 int nctime_val_tostring(const ncvar_t *varp, safebuf_t *sfbf, const void *valp); 115 116 /* Return true if dimid is an unlimited dimension */ 117 extern bool_t is_unlim_dim(int ncid, int dimid); 118 119 #ifdef __cplusplus 120 } 121 #endif 122 123 #endif /*_DUMPLIB_H_ */ 124