blob: 1458bf80905391b451a0c5ebc90460516d01015a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include <aplwc.h>
#include <aplwc_internal.h>
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;
}
|