5
#include "scim-bridge-exception.h"
7
static const char EMPTY_MESSAGE[] = "\0";
9
void scim_bridge_exception_initialize (ScimBridgeException *except)
11
memset (except, 0, sizeof (ScimBridgeException));
15
void scim_bridge_exception_finalize (ScimBridgeException *except)
17
if (except->message != NULL) {
18
free (except->message);
19
except->message = NULL;
24
void scim_bridge_exception_copy (ScimBridgeException *dest, const ScimBridgeException *except)
26
scim_bridge_exception_set_message (dest, except->message);
27
scim_bridge_exception_set_errno (dest, except->err_no);
31
void scim_bridge_exception_set_message (ScimBridgeException *except, const char *new_message)
33
if (new_message != NULL) {
34
const size_t str_len = strlen (new_message);
35
except->message = malloc (sizeof (char) * (str_len + 1));
36
strcpy (except->message, new_message);
38
free (except->message);
39
except->message = NULL;
44
const char *scim_bridge_exception_get_message (const ScimBridgeException *except)
46
if (except->message) {
47
return except->message;
54
void scim_bridge_exception_set_errno (ScimBridgeException *except, const int new_errno)
56
except->err_no = new_errno;
60
int scim_bridge_exception_get_errno (const ScimBridgeException *except)
62
return except->err_no;
66
const char *scim_bridge_exception_get_strerror (const ScimBridgeException *except)
68
return strerror (except->err_no);