#ifndef CORE_MACROS_H #define CORE_MACROS_H #include #define M_STRLEN(s) ((sizeof(s)/sizeof(s[0])) - sizeof(s[0])) #define M_RESPONSE_TEXT_STATIC(logger_func, response, code, content) do { logger_func("%s\n", content); endpoint_response_text(response, code, content, M_STRLEN(content)); } while(0) #define M_RESPONSE_400_NO_VALID_JSON(response) M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 400, "the request is not valid json") #define M_RESPONSE_400_NO_VALID_ID(response) M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 400, "the request does not contain valid id (uuid)") #define M_RESPONSE_400_NO_NAME(response) M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 400, "the request does not contain a name") #define M_RESPONSE_403_PROTECTED_SCHEDULE(response) M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 403, "the target schedule is protected") #define M_RESPONSE_404_NO_CONTROLLER_FOUND_FOR_ID(response) M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 404, "no controller was found for the requested id") #define M_RESPONSE_404_NO_SCHEDULE_FOUND_FOR_ID(response) M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 404, "no schedule was found for the requested id") #define M_RESPONSE_404_NO_MACRO_FOUND_FOR_ID(response) M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 404, "no schedule was found for the requested id") #define M_RESPONSE_404_NO_TAG_FOUND(response) M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 404, "the requested tag was not found") #define M_RESPONSE_500_FAILED_TO_SAVE_TO_DATABASE(response) M_RESPONSE_TEXT_STATIC(LOGGER_ERR, response, 500, "the server failed to save to the database") #define M_RESPONSE_500_FAILED_TO_READ_FROM_DATABASE(response) M_RESPONSE_TEXT_STATIC(LOGGER_ERR, response, 500, "the server failed to read from the database") #define M_RESPONSE_500_FAILED_TO_DELETE_FROM_DATABASE(response) M_RESPONSE_TEXT_STATIC(LOGGER_ERR, response, 500, "the server failed to delete from the database") #endif /* CORE_MACROS_H */