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;
113 sprintf(lead,
"%s: ", who);
116 sprintf(msg,
"%s%s: %s", lead, strerror(errno), s);
128 return err_flag ? err_code :
DB_OK;
149 sprintf(msg,
_(
"dbmi: %s() not implemented"), name);
163 sprintf(msg,
_(
"dbmi: Invalid procedure %d"), procnum);
192 sprintf(lead,
"%s: ", who);
194 if (user_print_function) {
197 sprintf(buf,
"%s%s\n", lead, err_msg);
198 user_print_function(buf);
201 fprintf(stderr,
"%s%s\n", lead, err_msg);
205 static int debug_on = 0;
231 fprintf(stderr,
"debug(%s): %s\n", who ? who :
"", s ? s :
"<NULL>");
241 return err_flag ? err_msg : (
const char *)
NULL;
251 auto_print_errors = flag;
252 auto_print_protocol_errors = flag;
262 auto_print_protocol_errors = flag;
void db_on_error(void(*f)(const char *))
User defined error procedure.
char * db_store(const char *)
Make a copy of string buffer.
void db_syserror(const char *s)
Report system error.
void db_auto_print_protocol_errors(int flag)
Set auto print protocol error.
void db_debug_on(void)
Turn on debugging.
void db_debug_off(void)
Turn off debugging.
void db_clear_error(void)
Clear error status.
void db_free(void *)
Free allocated memory.
void db_set_error_who(const char *me)
Set 'who' for error messages.
int db_get_error_code(void)
Get error code.
void db_auto_print_errors(int flag)
Toggles printing of DBMI error messages.
void db_print_error(void)
Print error.
void db_procedure_not_implemented(const char *name)
Report 'not implemented' error.
void db_protocol_error(void)
Report protocol error.
const char * db_get_error_who(void)
const char * db_get_error_msg(void)
Get error message.
void db_debug(const char *s)
Print debug message.
void db_noproc_error(int procnum)
Report no procedure error.
void db_memory_error(void)
Report memory error.
void db_error(const char *s)
Report error message.