00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00034 #include "config.h"
00035 #include "shared/status.h"
00036
00037 #include <stdlib.h>
00038
00039 ods_lookup_table ods_status_str[] = {
00040 { ODS_STATUS_OK, "All OK" },
00041 { ODS_STATUS_ASSERT_ERR, "Assertion error"},
00042 { ODS_STATUS_CFG_ERR, "Configuration error"},
00043 { ODS_STATUS_CHDIR_ERR, "Change directory failed"},
00044 { ODS_STATUS_CHROOT_ERR, "Change root failed"},
00045 { ODS_STATUS_CMDHANDLER_ERR, "Command handler error"},
00046 { ODS_STATUS_CONFLICT_ERR, "Conflict detected"},
00047 { ODS_STATUS_ERR, "General error"},
00048 { ODS_STATUS_FOPEN_ERR, "Unable to open file"},
00049 { ODS_STATUS_FORK_ERR, "fork() failed"},
00050 { ODS_STATUS_FREAD_ERR, "Unable to read file"},
00051 { ODS_STATUS_FWRITE_ERR, "Unable to write file"},
00052 { ODS_STATUS_HSM_ERR, "HSM error"},
00053 { ODS_STATUS_INSECURE, "Insecure"},
00054 { ODS_STATUS_MALLOC_ERR, "Memory allocation error"},
00055 { ODS_STATUS_PARSE_ERR, "Parse error"},
00056 { ODS_STATUS_PRIVDROP_ERR, "Unable to drop privileges"},
00057 { ODS_STATUS_RNG_ERR, "RelaxNG error"},
00058 { ODS_STATUS_SETSID_ERR, "setsid() failed"},
00059 { ODS_STATUS_UNCHANGED, "Status unchanged"},
00060 { ODS_STATUS_WRITE_PIDFILE_ERR, "Unable to write process id to pidfile"},
00061 { ODS_STATUS_XML_ERR, "XML error"},
00062 { 0, NULL }
00063 };
00064
00065 ods_lookup_table*
00066 ods_lookup_by_id(ods_lookup_table *table, int id)
00067 {
00068 while (table->name != NULL) {
00069 if (table->id == id) {
00070 return table;
00071 }
00072 table++;
00073 }
00074 return NULL;
00075 }
00076
00077
00082 const char *
00083 ods_status2str(ods_status status)
00084 {
00085 ods_lookup_table *lt;
00086 lt = ods_lookup_by_id(ods_status_str, status);
00087 if (lt) {
00088 return lt->name;
00089 }
00090 return NULL;
00091 }
00092