00001 00016 #ifndef GRU_STATUS_H 00017 #define GRU_STATUS_H 00018 00019 #include <assert.h> 00020 #include <errno.h> 00021 #include <stdarg.h> 00022 #include <stdbool.h> 00023 #include <stdint.h> 00024 #include <stdio.h> 00025 #include <stdlib.h> 00026 #include <string.h> 00027 00028 #include "common/gru_portable.h" 00029 00030 #ifdef __cplusplus 00031 extern "C" { 00032 #endif 00033 00034 #define GRU_MAX_ERROR_MESSAGE 1024 00035 00036 /* 00037 * Valid status codes 00038 */ 00039 typedef enum gru_status_code_t_ { 00040 GRU_SUCCESS, 00041 GRU_FAILURE, 00042 } gru_status_code_t; 00043 00047 typedef struct gru_status_t_ { 00048 char *message; 00049 gru_status_code_t code; 00050 } gru_status_t; 00051 00056 gru_export gru_status_t gru_status_new(); 00057 00065 gru_export void gru_status_set( 00066 gru_status_t *status, gru_status_code_t code, const char *message, ...); 00067 00074 gru_export void gru_status_strerror( 00075 gru_status_t *status, gru_status_code_t code, int errnum); 00076 00081 gru_export void gru_status_reset(gru_status_t *status); 00082 00087 gru_export void gru_status_set_success(gru_status_t *status); 00088 00094 gru_export bool gru_status_error(const gru_status_t *status); 00095 00101 gru_export bool gru_status_success(const gru_status_t *status); 00102 00103 #ifdef __cplusplus 00104 } 00105 #endif 00106 00107 #endif /* GRU_STATUS_H */