#include #include AplwcRc aplwc_new(Aplwc **p) { *p = malloc_zero(sizeof(Aplwc)); if(*p == NULL) RETURN_ERROR(*p, MALLOC_FAILED, ""); return APLWC_OK; } AplwcRc aplwc_destroy(Aplwc *p) { if(p) free(p); return APLWC_OK; } const char * aplwc_errstr(Aplwc *aplwc) { static char buf[256]; buf[0] = 0; const char *err = NULL; const char *msg = NULL; if(aplwc){ err = rc_to_string(aplwc->last_error); msg = aplwc->last_error_msg; } if(!err) err = "(unable to produce error string)"; if(msg && (strlen(msg) > 0)) snprintf(buf, sizeof(buf), "%s: %s", err, msg); else snprintf(buf, sizeof(buf), "%s", err); return buf; }