22 static int err_flag = 0;
23 static int err_code =
DB_OK;
24 static char *err_msg = 0;
25 static int auto_print_errors = 1;
26 static int auto_print_protocol_errors = 1;
27 static void (*user_print_function)(
const char *);
29 static char *who =
NULL;
38 user_print_function = f;
61 return who ? who :
"";
72 s =
_(
"<NULL error message>");
77 if (auto_print_errors)
89 flag = auto_print_errors;
90 auto_print_errors = auto_print_protocol_errors;
92 auto_print_errors = flag;
112 sprintf(lead,
"%s: ", who);
115 sprintf(msg,
"%s%s: %s", lead, strerror(errno), s);
127 return err_flag ? err_code :
DB_OK;
148 sprintf(msg,
_(
"dbmi: %s() not implemented"),
name);
162 sprintf(msg,
_(
"dbmi: Invalid procedure %d"),
procnum);
191 sprintf(lead,
"%s: ", who);
193 if (user_print_function) {
196 sprintf(buf,
"%s%s\n", lead, err_msg);
197 user_print_function(buf);
200 fprintf(stderr,
"%s%s\n", lead, err_msg);
203 static int debug_on = 0;
229 fprintf(stderr,
"debug(%s): %s\n", who ? who :
"", s ? s :
"<NULL>");
239 return err_flag ? err_msg : (
const char *)
NULL;
249 auto_print_errors = flag;
250 auto_print_protocol_errors = flag;
260 auto_print_protocol_errors = flag;
const char * db_get_error_who(void)
void db_error(const char *s)
Report error message.
void db_debug_off(void)
Turn off debugging.
void db_debug(const char *s)
Print debug message.
void db_on_error(void(*f)(const char *))
User defined error procedure.
void db_print_error(void)
Print error.
void db_debug_on(void)
Turn on debugging.
void db_set_error_who(const char *me)
Set 'who' for error messages.
void db_auto_print_protocol_errors(int flag)
Set auto print protocol error.
void db_procedure_not_implemented(const char *name)
Report 'not implemented' error.
void db_syserror(const char *s)
Report system error.
void db_clear_error(void)
Clear error status.
int db_get_error_code(void)
Get error code.
const char * db_get_error_msg(void)
Get error message.
void db_auto_print_errors(int flag)
Toggles printing of DBMI error messages.
void db_protocol_error(void)
Report protocol error.
void db_noproc_error(int procnum)
Report no procedure error.
void db_memory_error(void)
Report memory error.
void db_free(void *)
Free allocated memory.
char * db_store(const char *)
Make a copy of string buffer.