25#include "gis_local_proto.h"
47static int (*ext_error)(
const char *,
int);
48static int no_warn =
FALSE;
49static int no_sleep =
TRUE;
51static int grass_info_format;
53static char *prefix_std[3];
54static struct Counter message_id;
56static int print_word(
FILE *,
char **,
int *,
const int);
57static void print_sentence(
FILE *,
const int,
const char *);
58static void print_error(
const char *,
const int);
59static void mail_msg(
const char *,
int);
60static int write_error(
const char *,
int,
time_t,
const char *);
61static void log_error(
const char *,
int);
63static int fatal_longjmp;
69 return &fatal_jmp_buf;
72static void vfprint_error(
int type,
const char *
template,
va_list ap)
78 print_error(buffer, type);
185 if (
getenv(
"GRASS_ABORT_ON_ERROR"))
280static void print_error(
const char *
msg,
const int type)
289 if ((type ==
MSG || type ==
WARN || type ==
ERR) &&
297 if (type ==
WARN || type ==
ERR)
326 else if ((type ==
WARN || type ==
ERR) &&
327 getenv(
"GRASS_ERROR_MAIL")) {
337static void log_error(
const char *
msg,
int fatal)
357 static int initialized;
366 prefix_std[1] =
_(
"WARNING: ");
367 prefix_std[2] =
_(
"ERROR: ");
369 logfile =
getenv(
"GIS_ERROR_LOG");
409 fprintf(
log,
"-------------------------------------\n");
415 fprintf(
log,
"-------------------------------------\n");
423static void mail_msg(
const char *
msg,
int fatal)
435static int print_word(
FILE *fd,
char **
word,
int *len,
const int lead)
445 while (*w ==
' ' || *w ==
'\t' || *w ==
'\n')
450 for (
b = w; *
b != 0 && *
b !=
' ' && *
b !=
'\t' && *
b !=
'\n';
b++)
488static void print_sentence(
FILE *fd,
const int type,
const char *
msg)
497 "GRASS_INFO_MESSAGE(%d,%d): ",
getpid(),
id);
501 "GRASS_INFO_WARNING(%d,%d): ",
getpid(),
id);
512 while (*start !=
'\0') {
513 const char *next = start;
517 while (*next !=
'\0') {
526 fwrite(start, 1, next - start, fd);
544 return grass_info_format;
const char * G_program_name(void)
Return module name.
void G_free(void *)
Free allocated memory.
const char * G_gisbase(void)
Get full path name of the top level module directory.
void G_close_mail(struct Popen *)
const char * G_whoami(void)
Gets user's name.
int G_verbose(void)
Get current verbosity level.
int G_verbose_min(void)
Get min verbosity level.
void G_sleep(unsigned int)
int G_is_initialized(int *)
void G_initialize_done(int *)
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
char * G_store(const char *)
Copy string to allocated memory.
int G_counter_next(struct Counter *)
FILE * G_open_mail(struct Popen *)
void G_init_counter(struct Counter *, int)
int G_verbose_std(void)
Get standard verbosity level.
int G_vasprintf(char **, const char *, va_list)
Safe replacement for asprintf().
void G_verbose_message(const char *msg,...)
Print a message to stderr but only if module is in verbose mode.
int G_sleep_on_error(int flag)
Turn on/off no_sleep flag.
void G_set_error_routine(int(*error_routine)(const char *, int))
Establishes error_routine as the routine that will handle the printing of subsequent error messages.
#define WARN
A warning message.
void G_important_message(const char *msg,...)
Print a message to stderr even in brief mode (verbosity=1)
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
#define ERR
A fatal error message.
void G_message(const char *msg,...)
Print a message to stderr.
int G_suppress_warnings(int flag)
Suppress printing a warning message to stderr.
jmp_buf * G_fatal_longjmp(int enable)
void G_unset_error_routine(void)
After this call subsequent error messages will be handled in the default method.
void G_warning(const char *msg,...)
Print a warning message to stderr.
int G_info_format(void)
Get current message format.
void G_init_logging(void)
void G__call_error_handlers(void)
Call available error handlers (internal use only)
#define G_INFO_FORMAT_GUI
#define G_INFO_FORMAT_PLAIN
#define G_INFO_FORMAT_STANDARD
#define G_INFO_FORMAT_SILENT
const char * G__home(void)
Get user's home directory (internal use only)