00001
00003 #ifndef _das2_util_h_
00004 #define _das2_util_h_
00005
00006 #include <das2/das1.h>
00007
00008
00009 #define DAS_STREAM_VERSION "2.2"
00010
00011 #include <stdbool.h>
00012 #include <stdlib.h>
00013 #include <stdarg.h>
00014 #include <limits.h>
00015
00016
00017
00018
00019
00020
00021 #ifdef __sun
00022 #ifndef NAME_MAX
00023 #define NAME_MAX 255
00024 #endif
00025 #endif
00026
00027
00028
00029
00030
00034 typedef int ErrorCode;
00035
00037 #define DAS_OKAY 0
00038
00039 ErrorCode das2_error_func(
00040 const char* sFile, const char* sFunc, int nLine, ErrorCode nCode,
00041 const char* sFmt, ...
00042 );
00043
00044 #define DAS2ERR_BUF 12
00045 #define DAS2ERR_UTIL 13
00046 #define DAS2ERR_ENC 14
00047 #define DAS2ERR_UNITS 15
00048 #define DAS2ERR_DESC 16
00049 #define DAS2ERR_PLANE 17
00050 #define DAS2ERR_PKT 18
00051 #define DAS2ERR_STREAM 19
00052 #define DAS2ERR_OOB 20
00053 #define DAS2ERR_IO 22
00054 #define DAS2ERR_DSDF 23
00055 #define DAS2ERR_DFT 24
00056
00057 #define DAS2ERR_NOTIMP 99
00058
00088 #define das2_error(nErrCode, ...)\
00089 das2_error_func(__FILE__, __func__, __LINE__, nErrCode, __VA_ARGS__ )
00090
00091
00100 void das2_abort_on_error(void);
00101
00106 void das2_exit_on_error(void);
00107
00113 void das2_return_on_error(void);
00114
00128 bool das2_str2double(const char* str, double* pRes);
00129
00130
00142 bool das2_str2int(const char* str, int* pRes);
00143
00159 bool das2_str2baseint(const char* str, int base, int* pRes);
00160
00179 bool das2_strn2baseint(const char* str, int nLen, int base, int* pRes);
00180
00188 double* das2_csv2doubles(const char * s, int* nitems);
00189
00190
00205 char* das2_doubles2csv( char * buf, const double * value, int nitems );
00206
00207
00209 #define XML_MAXPROPERTIES 100
00210
00212 #define XML_BUFFER_LENGTH 1000000
00213
00215 #define XML_ELEMENT_NAME_LENGTH 256
00216
00218 #define MAX_ARRAY_SIZE 1000
00219
00225 const char* das2_lib_version( void );
00226
00233 void das2_store_str(char** psDest, size_t* puLen, const char* sSrc);
00234
00235
00240 bool das2_isdir(const char* path);
00241
00246 bool das2_isfile(const char* path);
00247
00268 int das2_dirlist(
00269 const char* sPath, char ppDirList[][NAME_MAX], size_t uMaxDirs, char cType
00270 );
00271
00272
00273
00274
00275
00276 #endif