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]))) {
27 // don't let % chars through, rather truncate the input.
41 memmove(&buf[a + 1], &buf[a + 3], len);
52 // Supplied with a unix timestamp, generate a textual time/date stamp.
53 // Caller owns the returned memory.
54 char *http_datestring(time_t xtime) {
56 // HTTP Months - do not translate - these are not for human consumption
57 static char *httpdate_months[] = {
58 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
59 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
62 // HTTP Weekdays - do not translate - these are not for human consumption
63 static char *httpdate_weekdays[] = {
64 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
71 char *buf = malloc(n);
76 localtime_r(&xtime, &t);
78 // Convert "seconds west of GMT" to "hours/minutes offset"
87 offset = ((offset / 3600) * 100) + (offset % 60);
89 snprintf(buf, n, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
90 httpdate_weekdays[t.tm_wday],
91 t.tm_mday, httpdate_months[t.tm_mon], t.tm_year + 1900, t.tm_hour, t.tm_min, t.tm_sec, offsign, offset);