use heim_error_t
This commit is contained in:
@@ -45,17 +45,6 @@ struct hx509_error_data {
|
||||
char *msg;
|
||||
};
|
||||
|
||||
static void
|
||||
free_error_string(hx509_error msg)
|
||||
{
|
||||
while(msg) {
|
||||
hx509_error m2 = msg->next;
|
||||
free(msg->msg);
|
||||
free(msg);
|
||||
msg = m2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the error strings the hx509 context.
|
||||
*
|
||||
@@ -68,7 +57,7 @@ void
|
||||
hx509_clear_error_string(hx509_context context)
|
||||
{
|
||||
if (context) {
|
||||
free_error_string(context->error);
|
||||
heim_release(context->error);
|
||||
context->error = NULL;
|
||||
}
|
||||
}
|
||||
@@ -91,31 +80,18 @@ void
|
||||
hx509_set_error_stringv(hx509_context context, int flags, int code,
|
||||
const char *fmt, va_list ap)
|
||||
{
|
||||
hx509_error msg;
|
||||
heim_error_t msg;
|
||||
|
||||
if (context == NULL)
|
||||
return;
|
||||
|
||||
msg = calloc(1, sizeof(*msg));
|
||||
if (msg == NULL) {
|
||||
hx509_clear_error_string(context);
|
||||
return;
|
||||
}
|
||||
|
||||
if (vasprintf(&msg->msg, fmt, ap) == -1) {
|
||||
hx509_clear_error_string(context);
|
||||
free(msg);
|
||||
return;
|
||||
}
|
||||
msg->code = code;
|
||||
|
||||
if (flags & HX509_ERROR_APPEND) {
|
||||
msg->next = context->error;
|
||||
context->error = msg;
|
||||
} else {
|
||||
free_error_string(context->error);
|
||||
context->error = msg;
|
||||
msg = heim_error_createv(code, fmt, ap);
|
||||
if (msg) {
|
||||
if (flags & HX509_ERROR_APPEND)
|
||||
heim_error_append(msg, context->error);
|
||||
heim_release(context->error);
|
||||
}
|
||||
context->error = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,12 +133,12 @@ hx509_set_error_string(hx509_context context, int flags, int code,
|
||||
char *
|
||||
hx509_get_error_string(hx509_context context, int error_code)
|
||||
{
|
||||
struct rk_strpool *p = NULL;
|
||||
hx509_error msg = context->error;
|
||||
heim_error_t msg = context->error;
|
||||
heim_string_t s;
|
||||
char *str = NULL;
|
||||
|
||||
if (msg == NULL || msg->code != error_code) {
|
||||
if (msg == NULL || heim_error_get_code(msg) != error_code) {
|
||||
const char *cstr;
|
||||
char *str;
|
||||
|
||||
cstr = com_right(context->et_list, error_code);
|
||||
if (cstr)
|
||||
@@ -175,11 +151,14 @@ hx509_get_error_string(hx509_context context, int error_code)
|
||||
return str;
|
||||
}
|
||||
|
||||
for (msg = context->error; msg; msg = msg->next)
|
||||
p = rk_strpoolprintf(p, "%s%s", msg->msg,
|
||||
msg->next != NULL ? "; " : "");
|
||||
|
||||
return rk_strpoolcollect(p);
|
||||
s = heim_error_copy_string(msg);
|
||||
if (s) {
|
||||
str = heim_string_get_utf8(s);
|
||||
if (str)
|
||||
str = strdup(str);
|
||||
heim_release(s);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user