made hcl immune to an error number/message set in the log_write callback

This commit is contained in:
2018-02-22 04:35:55 +00:00
parent 6e4a8f6081
commit a39e38cc8d
5 changed files with 45 additions and 18 deletions

View File

@ -940,8 +940,8 @@ struct hcl_t
{
hcl_mmgr_t* mmgr;
hcl_cmgr_t* cmgr;
hcl_errnum_t errnum;
hcl_errnum_t errnum;
struct
{
union
@ -953,6 +953,7 @@ struct hcl_t
hcl_ooch_t buf[2048];
hcl_oow_t len;
} errmsg;
int shuterr;
struct
{
@ -1342,11 +1343,11 @@ HCL_EXPORT void hcl_fini (
static HCL_INLINE hcl_mmgr_t* hcl_getmmgr (hcl_t* hcl) { return hcl->mmgr; }
static HCL_INLINE void* hcl_getxtn (hcl_t* hcl) { return (void*)(hcl + 1); }
/*static HCL_INLINE hcl_cmgr_t* hcl_getcmgr (hcl_t* hcl) { return hcl->cmgr; }
static HCL_INLINE void hcl_setcmgr (hcl_t* hcl, hcl_cmgr_t* cmgr) { hcl->cmgr = cmgr; }*/
static HCL_INLINE hcl_cmgr_t* hcl_getcmgr (hcl_t* hcl) { return hcl->cmgr; }
static HCL_INLINE void hcl_setcmgr (hcl_t* hcl, hcl_cmgr_t* cmgr) { hcl->cmgr = cmgr; }
static HCL_INLINE hcl_errnum_t hcl_geterrnum (hcl_t* hcl) { return hcl->errnum; }
static HCL_INLINE void hcl_seterrnum (hcl_t* hcl, hcl_errnum_t errnum) { hcl->errnum = errnum; hcl->errmsg.len = 0; }
#else
# define hcl_getmmgr(hcl) ((hcl)->mmgr)
# define hcl_getxtn(hcl) ((void*)((hcl) + 1))
@ -1355,9 +1356,18 @@ HCL_EXPORT void hcl_fini (
# define hcl_setcmgr(hcl,mgr) ((hcl)->cmgr = (mgr))
# define hcl_geterrnum(hcl) ((hcl)->errnum)
# define hcl_seterrnum(hcl,num) ((hcl)->errmsg.len = 0, (hcl)->errnum = (num))
#endif
HCL_EXPORT void hcl_seterrnum (
hcl_t* hcl,
hcl_errnum_t errnum
);
HCL_EXPORT void hcl_seterrwithsyserr (
hcl_t* hcl,
int syserr
);
HCL_EXPORT void hcl_seterrbfmt (
hcl_t* hcl,
hcl_errnum_t errnum,
@ -1372,11 +1382,6 @@ HCL_EXPORT void hcl_seterrufmt (
...
);
HCL_EXPORT void hcl_seterrwithsyserr (
hcl_t* hcl,
int syserr
);
HCL_EXPORT const hcl_ooch_t* hcl_geterrstr (
hcl_t* hcl
);