#ident "@(#) err_msg.c 1.1 05/08/19 SwRI" #include #include #include "vidf_codes.h" #include "SDDAS_types.h" /***************************************************************************** * * * VIDF_ERROR_MESSAGE_STR SUBROUTINE * * * * DESCRIPTION * * This routine is called to compose the error string encountered from * * the generic utility software, both libbase_idfs and libtrec_idfs. * * * * INPUT VARIABLES * * SDDAS_SHORT error_code the error code to be processed * * char *e_str ptr to area where string is to be returned * * int length max length of output string * * * * USAGE * * x = vidf_error_message_str (error_code, e_str) * * * * NECESSARY SUBPROGRAMS * * sprintf() creates a string based upon arguments and * * conversion characters * * * * EXTERNAL VARIABLES * * None * * * * INTERNAL VARIABLES * * None * * * * SUBSYSTEM * * Display Level * * * *****************************************************************************/ void vidf_error_message_str (SDDAS_SHORT error_code, char *e_str, size_t length) { /************************************************************************/ /* Error code generated by generic software? */ /************************************************************************/ switch (error_code) { case VIDF_CREATE_MALLOC: strncpy (e_str, "CREATE_VIDF_STRUCTURE: NO MEMORY FOR VIDF_INFO STRUCTURE.", length); break; case INIT_VIDF_BAD_VERSION: strncpy (e_str, "INIT_VIDF: BAD VERSION NUMBER FOR THE VIDF FILE.", length); break; case INIT_VIDF_TBL_MALLOC: strncpy (e_str, "INIT_VIDF: NO MEMORY FOR TABLES.", length); break; case INIT_VIDF_CONST_MALLOC: strncpy (e_str, "INIT_VIDF: NO MEMORY FOR CONSTANTS.", length); break; case IDF_MANY_BYTES: strncpy (e_str, "READ_IDF: NUMBER OF ELEMENTS BEING REQUESTED IS TOO LARGE FOR DATA FIELD.", length); break; case IDF_NO_ENTRY: strncpy (e_str, "READ_IDF: THE FIELD BEING REQUESTED IS NOT DEFINED.", length); break; case IDF_TBL_NUM: strncpy (e_str, "READ_IDF: THE TABLE NUMBER BEING REQUESTED IS LARGER THAN THE NUMBER OF TABLES.", length); break; case IDF_CON_NUM: strncpy (e_str, "READ_IDF: THE CONSTANT BEING REQUESTED EXCEEDS THE NUMBER OF DEFINED CONSTANTS.", length); break; case VIDF_NOT_READABLE: strncpy (e_str, "ParseOldVIDF: CAN NOT OPEN THE VIDF FILE.", length); break; /* these are for the new VIDF */ case VIDF_ELEMENT_NOT_FOUND: strncpy (e_str, "GetFromNewVIDF: REQUESTED ELEMENT IS NOT IN THE VIDF.", length); break; case VIDF_DATABASE_CORRUPT: strncpy (e_str, "THE VIDF DATABASE IS CORRUPT.", length); break; default: snprintf (e_str, length, "ERROR CODE %d NOT RECOGNIZED BY VIDF LIBRARY.", error_code); break; } }