BYTE SIGN::getDay() { time_t now = time(nullptr); struct tm tmNow; LOCAL_TIME(now, tmNow); return BYTE(tmNow.tm_mday); }
BYTE SIGN::getMonth() { time_t now = time(nullptr); struct tm tmNow; LOCAL_TIME(now, tmNow); return BYTE(tmNow.tm_mon + 1); }
ERROR_CODE log_http_request(char *host, char *identity, char *user, char *method, char *uri, enum http_version_e version, int error_code, size_t content_length) { /* allocates space for the buffer to hild the date and time information to be logged */ char date_buffer[1024]; /* allocates space for the internal date structures to be used for the retrieval of the time information and retrieves the current time to be used converting it then to the local time*/ struct tm *_local_time; time_t _time = time(NULL); LOCAL_TIME(_local_time, &_time); /* checks if the converted local time is invalid and in case it is raises the apropriate runtime error to be caught */ if(_local_time == NULL) { RAISE_ERROR_M( RUNTIME_EXCEPTION_ERROR_CODE, (unsigned char *) "Problem retrieving local time" ); } /* formats the local time into the data buffer and then uses it and the other (sent) variables to format the output buffer */ strftime(date_buffer, 1024, "%d/%b/%Y %H:%M:%S", _local_time); PRINTF_F( "%s %s %s [%s] \"%s %s %s\" %d %lu\n", host, identity, user, date_buffer, method, uri, http_version_codes[version - 1], error_code, (long unsigned int) content_length ); /* raises no error */ RAISE_NO_ERROR; }
BYTE SIGN::getMonthBytime(time_t now) { struct tm tmNow; LOCAL_TIME(now, tmNow); return BYTE(tmNow.tm_mon + 1); }
BYTE SIGN::getDayByTime(time_t now) { struct tm tmNow; LOCAL_TIME(now, tmNow); return BYTE(tmNow.tm_mday); }