| 8201 | /*! ===> Error message reporting */ |
| 8202 | |
| 8203 | int gmtlib_report_error (void *V_API, int error) { |
| 8204 | /* Write error message to log or stderr, then return error code back. |
| 8205 | * All functions can call this, even if API has not been initialized. */ |
| 8206 | FILE *fp = NULL; |
| 8207 | bool report; |
| 8208 | char message[GMT_LEN256]; |
| 8209 | struct GMTAPI_CTRL *API = gmtapi_get_api_ptr (V_API); |
| 8210 | |
| 8211 | report = (API) ? API->error != API->last_error : true; |
| 8212 | if (report && error != GMT_NOERROR) { /* Report error */ |
| 8213 | if (!API || !API->GMT || (fp = API->GMT->session.std[GMT_ERR]) == NULL) fp = stderr; |
| 8214 | if (API && API->session_tag) { |
| 8215 | snprintf (message, GMT_LEN256, "[Session %s (%d)]: Error returned from GMT API: %s (%d)\n", |
| 8216 | API->session_tag, API->session_ID, gmt_api_error_string[error], error); |
| 8217 | GMT_Message (API, GMT_TIME_NONE, message); |
| 8218 | if (API->log_level) fflush (fp); /* Flush the latest message to file in case of crash */ |
| 8219 | } |
| 8220 | else |
| 8221 | fprintf (fp, "Error returned from GMT API: %s (%d)\n", gmt_api_error_string[error], error); |
| 8222 | } |
| 8223 | if (API) API->last_error = API->error, API->error = error; /* Update API error value if API exists */ |
| 8224 | return (error); |
| 8225 | } |
| 8226 | |
| 8227 | /*! . */ |
| 8228 | int gmtlib_validate_id (struct GMTAPI_CTRL *API, int family, int object_ID, int direction, int module_input) { |
no test coverage detected