26 #include <sys/types.h>
37 #define ALPHAVAL(x) (tolower((x)) - 'a' + 0xa)
38 #define DIGITVAL(x) ((x) - '0')
39 #define ALNUMVAL(x) (isdigit((x))?DIGITVAL((x)):ALPHAVAL((x)))
43 "Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat" };
45 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
46 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec" };
53 rfc1123Gmt(
char * buffer,
size_t _nbuf,
const time_t * t)
55 struct tm * tmp = gmtime(t);
58 nbuf = strftime(buffer, _nbuf,
"---, %d --- %Y %T GMT", tmp);
59 memcpy(buffer,
DAY_NAMES[tmp->tm_wday], 3);
71 time_t t = time(NULL);
86 char * buf_ptr = buffer;
87 char * res_ptr = buffer;
89 for(; 0 < nbuffer; nbuffer--, buf_ptr++, res_ptr++) {
108 return res_ptr - buffer;
120 if (0 != memcmp(
"HTTP/", str,
sizeof(
"HTTP/")-1))
128 const char * part1,
size_t len1,
129 const char * part2,
size_t len2,
130 const char * part3,
size_t len3)
133 return new(HttpResponse,
135 strtoul(part2, NULL, 10),
140 return new(HttpRequest,
size_t urldecode(char *buffer, size_t nbuffer)
static const char * MONTH_NAMES[]
char isHttpVersion(const char *str, size_t len)
HttpMessage httpGetMessage(const char *part1, size_t len1, const char *part2, size_t len2, const char *part3, size_t len3)
size_t rfc1123GmtNow(char *buffer, size_t _nbuf)
static const char * DAY_NAMES[]
size_t rfc1123Gmt(char *buffer, size_t _nbuf, const time_t *t)