33 lines
780 B
C
33 lines
780 B
C
#include <stdio.h>
|
|
#include <time.h>
|
|
#include <string.h>
|
|
|
|
#define NUM_SUPPORTED_VERSIONS 2
|
|
static char supportedHTTPVersions[NUM_SUPPORTED_VERSIONS][16] = {
|
|
"HTTP/1.1",
|
|
"HTTP/1.0"
|
|
};
|
|
|
|
int PrintLog(unsigned char *message) {
|
|
time_t UTCTime;
|
|
// Setting time in EPOC
|
|
time(&UTCTime);
|
|
struct tm *now = localtime(&UTCTime);
|
|
|
|
printf("[Log] %02d/%02d/%d %02d:%02d:%02d - %s\n", (now->tm_mon + 1), now->tm_mday,
|
|
(now->tm_year + 1900), now->tm_hour, now->tm_min, now->tm_sec, message);
|
|
return 0;
|
|
}
|
|
|
|
int checkHTTPVersion(char *version) {
|
|
int supported = -1; // Default fail state
|
|
char testVer[16];
|
|
strcpy(testVer, version);
|
|
for (int i = 0; i < NUM_SUPPORTED_VERSIONS; i++) {
|
|
if (!strcmp(testVer, supportedHTTPVersions[i])) {
|
|
supported = 0;
|
|
}
|
|
}
|
|
return supported;
|
|
}
|