2 // Copyright (c) 1996-2022 by the citadel.org team
3 // This program is open source software. Use, duplication, or disclosure are subject to the GNU General Public License v3.
8 // remove escaped strings from i.e. the url string (like %20 for blanks)
9 int unescape_input(char *buf) {
17 while ((buflen > 0) && (isspace(buf[buflen - 1]))) {
28 // don't let % chars through - instead truncate the input.
42 memmove(&buf[a + 1], &buf[a + 3], len);
53 // Supplied with a unix timestamp, generate a textual time/date stamp.
54 // Caller owns the returned memory.
55 char *http_datestring(time_t xtime) {
57 // HTTP Months - do not translate - these are not for human consumption
58 static char *httpdate_months[] = {
59 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
60 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
63 // HTTP Weekdays - do not translate - these are not for human consumption
64 static char *httpdate_weekdays[] = {
65 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
72 char *buf = malloc(n);
77 localtime_r(&xtime, &t);
79 // Convert "seconds west of GMT" to "hours/minutes offset"
88 offset = ((offset / 3600) * 100) + (offset % 60);
90 snprintf(buf, n, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
91 httpdate_weekdays[t.tm_wday],
92 t.tm_mday, httpdate_months[t.tm_mon], t.tm_year + 1900, t.tm_hour, t.tm_min, t.tm_sec, offsign, offset);