34#define DASERR_DIS_EXIT 0
37#define DASERR_DIS_RET 1
40#define DASERR_DIS_ABORT 43
118 const char* sProgName,
int nErrDis,
int nErrBufSz,
int nLevel,
129 const char* sFile,
const char* sFunc,
int nLine,
DasErrCode nCode,
130 const char* sFmt, ...
131) _das_fmt_check(5, 6);
134 const
char* sFile, const
char* sFunc,
int nLine,
DasErrCode nCode,
196#define das_error(nErrCode, ...) \
197 das_error_func(__FILE__, __func__, __LINE__, nErrCode, __VA_ARGS__ )
205#define das_error_str(nErrCode, sMsg) \
206 das_error_func_fixed(__FILE__, __func__, __LINE__, nErrCode, sMsg)
218#define das_error_false(nErrCode, ...) \
219 (das_error_func(__FILE__, __func__, __LINE__, nErrCode, __VA_ARGS__), false)
223#define das_error_null(nErrCode, ...) \
224 (das_error_func(__FILE__, __func__, __LINE__, nErrCode, __VA_ARGS__), NULL)
305typedef struct das_error_message {
333#define das_within(A, B, E) (fabs((A) - (B)) < (E) ? true : false)
336#define DAS_XML_BUF_LEN 1000000
339#define DAS_XML_NODE_NAME_LEN 256
349#define DAS_MAX_ID_BUFSZ 64
458 uint8_t* pDest,
const uint8_t* pSrc,
size_t uElemSz,
size_t uCount
522DAS_API
bool das_copyfile(
const char* src,
const char* dest);
524DAS_API
bool das_copyfile(
const char* src,
const char* dest, mode_t mode);
555 const char* sPath,
char ppDirList[][256],
size_t uMaxDirs,
char cType
584 const unsigned char* data,
size_t input_length,
size_t* output_length
601 const char* data,
size_t input_length,
unsigned char* out,
size_t out_cap,
602 size_t* output_length
612 const char* data,
size_t input_length,
size_t* output_length
634bool dascmd_isArg(
const char* sArg,
const char* sShort,
const char* sLong,
bool* pLong);
667 char* sDest,
size_t uDest,
char** argv,
int argc,
int* pArgIdx,
668 const char* sShort,
const char* sLong
Minimal definitions for das2 utilities that can safely be run without calling das_init().
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition defs.h:184
Structure returned from das_get_error().
Definition util.h:305
DAS_API das_error_msg * das_get_error(void)
Return the saved das2 error message buffer.
DAS_API void das_error_free(das_error_msg *pMsg)
Free an error message structure allocated on the heap.
DAS_API const char * das_xml_escape(char *dest, const char *src, size_t uOutLen)
Translate unsafe characters for XML string output.
bool dascmd_getArgVal(char *sDest, size_t uDest, char **argv, int argc, int *pArgIdx, const char *sShort, const char *sLong)
Get the value of an argument if the current entry in argv matches either the short or long form of an...
DAS_API DasErrCode das_mkdirsto(const char *path)
Insure directories to a specific location exist.
void(* das_log_handler_t)(int nLevel, const char *sMsg, bool bPrnTime)
Definition of a message handler function pointer.
Definition util.h:58
DAS_API bool das_isfile(const char *path)
Is the path a file.
DAS_API size_t das_tokncpy(char *dest, const char *src, size_t n)
Copy string as an XML token.
DAS_API void das_errdisp_get_lock(void)
Used for co-operative locking of time-limited error disposition changes.
DAS_API int das_error_disposition(void)
Error handling: get the library's error disposition.
DAS_API void das_return_on_error(void)
Error handling: Normal Return Set the library to return normally to the calling function with a retur...
DAS_API void das_errdisp_release_lock(void)
Used for co-operative locking of time-limited error disposition changes.
DAS_API uint8_t * das_memset(uint8_t *pDest, const uint8_t *pSrc, size_t uElemSz, size_t uCount)
A memset that handles multi-byte items
DAS_API char * das_string(const char *fmt,...)
Allocate a new string on the heap and format it.
DAS_API char * das_strdup(const char *sIn)
Copy a string into a new buffer allocated on the heap.
DAS_API bool das_isdir(const char *path)
Is the path a directory.
DAS_API int das_dirlist(const char *sPath, char ppDirList[][256], size_t uMaxDirs, char cType)
Get a sorted directory listing.
DAS_API void das_finish(void)
A do nothing function on Unix, closes network sockets on windows.
DAS_API bool das_assert_valid_id(const char *sId)
Check that a string is suitable for use as an object ID.
DAS_API void das_print_error(void)
Error handling: Print formatted error to standard error stream Set the library to output formatted er...
DAS_API void das_store_str(char **psDest, size_t *puLen, const char *sSrc)
Store string in a buffer that is reallocated if need be.
DAS_API void das_abort_on_error(void)
Error handling: Trigger Core Dumps.
DAS_API const char * das_userhome(void)
Get the home directory for the current account.
DAS_API char * das_b64_encode(const unsigned char *data, size_t input_length, size_t *output_length)
Encode binary data as base64 (RFC 4648) characters in a new buffer.
DAS_API const char * das_version(void)
Return the version of this library.
DAS_API void das_init(const char *sProgName, int nErrDis, int nErrBufSz, int nLevel, das_log_handler_t logfunc)
Initialize any global structures in the Das2 library.
DAS_API bool das_save_error(int maxmsg)
Error handling: Save formatted error in a message buffer.
DAS_API double das_strtod_c(const char *nptr, char **endptr)
A C locale string to double converter.
DAS_API const char * das_lib_version(void)
Get the library version.
DAS_API void das_error_setdisp(int nDisp)
The inverse of das_error_disposition.
DAS_API unsigned char * das_b64_decode(const char *data, size_t input_length, size_t *output_length)
Decode base64 (RFC 4648) into a newly allocated buffer, symmetric with das_b64_encode.
DAS_API char * das_vstring(const char *fmt, va_list ap)
Store a formatted string in a newly allocated buffer.
DAS_API bool das_copyfile(const char *src, const char *dest, mode_t mode)
Copy a file to a destination creating directories as needed.
bool dascmd_isArg(const char *sArg, const char *sShort, const char *sLong, bool *pLong)
See a given string matches the short or long form of an option.
DAS_API char * das_strip(char *sLine, char cComment)
Strip whitespace from a string.
DAS_API void das_exit_on_error(void)
Error handling: Normal Exit Set the library to call exit(ErrorCode) when a problem is detected.
DAS_API int das_b64_decode_buf(const char *data, size_t input_length, unsigned char *out, size_t out_cap, size_t *output_length)
Decode base64 (RFC 4648) into a caller-provided buffer, no allocation.