GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
lib/gis/error.c File Reference
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <stdarg.h>
#include <sys/types.h>
#include <grass/glocale.h>
#include <grass/gis.h>
Include dependency graph for lib/gis/error.c:

Go to the source code of this file.

Macros

#define MSG   0
 A message. More...
 
#define WARN   1
 A warning message. More...
 
#define ERR   2
 A fatal error message. More...
 

Functions

void G_message (const char *msg,...)
 Print a message to stderr. More...
 
void G_verbose_message (const char *msg,...)
 Print a message to stderr but only if module is in verbose mode. More...
 
void G_important_message (const char *msg,...)
 Print a message to stderr even in brief mode (verbosity=1) More...
 
int G_fatal_error (const char *msg,...)
 Print a fatal error message to stderr. More...
 
int G_warning (const char *msg,...)
 Print a warning message to stderr. More...
 
int G_suppress_warnings (int flag)
 Suppress printing a warning message to stderr. More...
 
int G_sleep_on_error (int flag)
 Turn on/off no_sleep flag. More...
 
int 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. More...
 
int G_unset_error_routine (void)
 After this call subsequent error messages will be handled in the default method. More...
 
int G_info_format (void)
 Get current message format. More...
 

Macro Definition Documentation

#define ERR   2

A fatal error message.

Definition at line 41 of file lib/gis/error.c.

Referenced by G_fatal_error(), and V_call().

#define MSG   0

A message.

Definition at line 29 of file lib/gis/error.c.

Referenced by G_important_message(), G_message(), and G_verbose_message().

#define WARN   1

A warning message.

Definition at line 35 of file lib/gis/error.c.

Referenced by G_warning().

Function Documentation

int G_fatal_error ( const char *  msg,
  ... 
)

Print a fatal error message to stderr.

The output format depends on environment variable GRASS_MESSAGE_FORMAT

By default, the message is handled by an internal routine which prints the message to the screen. Using G_set_error_routine() the programmer can have the message handled by another routine. This is especially useful if the message should go to a particular location on the screen when using curses or to a location on a graphics device (monitor).

Parameters
msgstring (cannot be NULL)
Returns
Terminates with an exit status of EXIT_FAILURE if no external routine is specified by G_set_error_routine()

Definition at line 150 of file lib/gis/error.c.

References ERR.

Referenced by Cairo_begin_scaled_raster(), Cairo_draw_bitmap(), Cairo_Graph_set(), class_apply_algorithm(), class_equiprob(), clean_dir(), D_cell_draw_setup(), D_parse_color(), D_popup(), D_setup(), db__copy_table(), db_set_default_connection(), dig__read_head(), dig_area_add_isle(), dig_area_del_isle(), dig_del_area(), dig_del_isle(), dig_fwrite(), dig_load_plus(), dig_node_line_angle(), dig_Rd_Plus_head(), dig_Rd_spindx_head(), dig_read_cidx_head(), dig_spidx_del_area(), dig_spidx_del_isle(), dig_spidx_del_line(), dig_spidx_del_node(), dig_write_frmt_ascii(), E_edit_fp_cats(), F_open(), G3d_adjustRegion(), G3d_adjustRegionRes(), G3d_fatalError(), G3d_fatalError_noargs(), G__calloc(), G__gisinit(), G__ls(), G__make_mapset_element(), G__malloc(), G__no_gisinit(), G__realloc(), G_ask_ellipse_name(), G_ask_proj_name(), G_check_input_output_name(), G_fseek(), G_get_default_window(), G_get_ellipsoid_parameters(), G_get_raster_sample(), G_get_site(), G_get_window(), G_getenv(), G_getenv2(), G_home(), G_list(), G_location_path(), G_make_location(), G_make_mapset(), G_mapset(), G_put_map_row(), G_put_reclass(), G_put_site(), G_read_color_rule(), G_site_get_head(), G_site_new_struct(), G_site_put(), G_site_put_head(), G_sites_get_fields(), G_sites_open_old(), GK_print_keys(), Gp_load_sites(), GPJ__get_ellipsoid_params(), GS_load_att_map(), Gs_loadmap_as_bitmap(), Gs_loadmap_as_char(), Gs_loadmap_as_float(), Gs_loadmap_as_int(), Gs_loadmap_as_short(), I_list_groups(), I_list_subgroups(), IL_check_at_points_2d(), IL_create_bitmask(), IL_vector_input_data_2d(), LIB_main(), main(), make_mapset(), N_alloc_array_2d(), N_alloc_array_3d(), N_assemble_les_2d_param(), N_assemble_les_3d_param(), N_compute_gradient_field_2d(), N_compute_gradient_field_3d(), N_compute_gradient_field_components_2d(), N_compute_gradient_field_components_3d(), N_copy_array_2d(), N_copy_array_3d(), N_math_array_2d(), N_math_array_3d(), N_norm_array_2d(), N_norm_array_3d(), N_read_rast3d_to_array_3d(), N_read_rast_to_array_2d(), N_write_array_2d_to_rast(), N_write_array_3d_to_rast3d(), NetA_allpairs(), NetA_articulation_points(), NetA_betweenness_closeness(), NetA_compute_bridges(), NetA_eigenvector_centrality(), NetA_find_path(), NetA_flow(), NetA_get_node_costs(), NetA_init_timetable_from_db(), NetA_initialise_varray(), NetA_min_cut(), NetA_spanning_tree(), NetA_split_vertices(), NetA_strongly_connected_components(), NetA_weakly_connected_components(), Nviz_create_render_window(), pg_addedge(), pj_get_kv(), pj_get_string(), port_init(), PS_Graph_set(), R_parse_monitorcap(), read_bmp(), read_ellipsoid_table(), read_image(), read_pgm(), read_png(), read_ppm(), V1_open_old_ogr(), V2_delete_line_nat(), V2_open_old_ogr(), V2_read_line_nat(), V2_read_line_ogr(), V2_restore_line_nat(), Vect__open_old(), Vect_build_line_area(), Vect_build_ogr(), Vect_build_sidx_from_topo(), Vect_build_spatial_index(), Vect_cat_set(), Vect_check_input_output_name(), Vect_cidx_find_next(), Vect_cidx_get_cat_by_index(), Vect_cidx_get_field_number(), Vect_cidx_get_num_cats_by_index(), Vect_cidx_get_num_types_by_index(), Vect_cidx_get_num_unique_cats_by_index(), Vect_cidx_get_type_count_by_index(), Vect_copy(), Vect_copy_map_lines(), Vect_default_field_info(), Vect_delete_line(), Vect_get_area_boundaries(), Vect_get_area_centroid(), Vect_get_area_isle(), Vect_get_area_num_isles(), Vect_get_area_points(), Vect_get_centroid_area(), Vect_get_isle_area(), Vect_get_isle_boundaries(), Vect_get_isle_points(), Vect_get_line_areas(), Vect_get_line_nodes(), Vect_get_node_line(), Vect_get_node_line_angle(), Vect_get_node_n_lines(), Vect_graph_add_edge(), Vect_graph_build(), Vect_line_delete_point(), Vect_line_insert_point(), Vect_net_build_graph(), Vect_net_get_line_cost(), Vect_new_cats_struct(), Vect_new_line_struct(), Vect_overlay(), Vect_read_area_geos(), Vect_read_dblinks(), Vect_read_line(), Vect_read_line_geos(), Vect_remove_small_areas(), Vect_rename(), Vect_restore_line(), Vect_rewrite_line(), Vect_set_db_updated(), Vect_spatial_index_del_item(), Vect_write_line(), write_bmp(), write_image(), write_pgm(), write_png(), and write_ppm().

void G_important_message ( const char *  msg,
  ... 
)

Print a message to stderr even in brief mode (verbosity=1)

Ususally just G_percent()/G_clicker() would be shown at this level. This allows important non-error/warning messages to display as well.

The output format depends on environment variables GRASS_MESSAGE_FORMAT and GRASS_VERBOSE

Parameters
msgstring (cannot be NULL)

Definition at line 119 of file lib/gis/error.c.

References G_verbose(), G_verbose_min(), and MSG.

Referenced by G__calloc(), G__malloc(), G__realloc(), G_parser(), IL_vector_input_data_2d(), and Vect_build_nat().

int G_info_format ( void  )

Get current message format.

Maybe set to either "standard" or "gui" (normally GRASS takes care)

Returns
grass_info_format value

Definition at line 499 of file lib/gis/error.c.

References G_strcasecmp(), and getenv().

Referenced by G_clicker(), G_percent2(), and Vect_build_nat().

int G_set_error_routine ( int(*)(const char *, int error_routine)

Establishes error_routine as the routine that will handle the printing of subsequent error messages.

Parameters
error_routineroutine will be called like this: error_routine(msg, fatal)
Returns
0

Definition at line 233 of file lib/gis/error.c.

Referenced by wxdisplay.DisplayDriver::__init__(), and wxnviz.Nviz::__init__().

int G_sleep_on_error ( int  flag)

Turn on/off no_sleep flag.

Parameters
flagif non-zero/zero value is given G_sleep() will be activated/deactivated
Returns
previous flag

Definition at line 215 of file lib/gis/error.c.

References tools::flag.

int G_suppress_warnings ( int  flag)

Suppress printing a warning message to stderr.

Parameters
flaga warning message will be suppressed if non-zero value is given
Returns
previous flag

Definition at line 199 of file lib/gis/error.c.

References tools::flag.

Referenced by I_get_group(), I_get_group_title(), I_get_subgroup(), and I_get_target().

int G_unset_error_routine ( void  )

After this call subsequent error messages will be handled in the default method.

Error messages are printed directly to the screen: ERROR: message or WARNING: message

Returns
0

Definition at line 247 of file lib/gis/error.c.

Referenced by wxnviz.Nviz::__del__(), and wxdisplay.DisplayDriver::__del__().

void G_verbose_message ( const char *  msg,
  ... 
)

Print a message to stderr but only if module is in verbose mode.

The output format depends on environment variables GRASS_MESSAGE_FORMAT and GRASS_VERBOSE

Parameters
msgstring (cannot be NULL)

Definition at line 95 of file lib/gis/error.c.

References G_verbose(), G_verbose_std(), and MSG.

Referenced by gsd_init_mpeg(), IL_vector_input_data_2d(), Vect_break_lines_list(), Vect_break_polygons(), Vect_build_ogr(), Vect_build_partial(), Vect_merge_lines(), Vect_remove_duplicates(), and Vect_snap_lines_list().

int G_warning ( const char *  msg,
  ... 
)

Print a warning message to stderr.

The output format depends on environment variable GRASS_MESSAGE_FORMAT

A warning message can be suppressed by G_suppress_warnings()

Parameters
msgstring (cannot be NULL)
Returns
0

Definition at line 178 of file lib/gis/error.c.

References WARN.