X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit-ng%2Futil.c;h=825786f7e0efa72cce393acc1ac42094b94f13b8;hb=03d5df9a4e11ce16fbfeac4ad03f2825591fa4ae;hp=6d0c69d6223139459cc9e9a249a760f875499e5d;hpb=52b6f96d74b3faf7e25f87618493c1ffd8cc3571;p=citadel.git diff --git a/webcit-ng/util.c b/webcit-ng/util.c index 6d0c69d62..825786f7e 100644 --- a/webcit-ng/util.c +++ b/webcit-ng/util.c @@ -27,12 +27,12 @@ int unescape_input(char *buf) buflen = strlen(buf); - while ((buflen > 0) && (isspace(buf[buflen - 1]))){ + while ((buflen > 0) && (isspace(buf[buflen - 1]))) { buf[buflen - 1] = 0; - buflen --; + buflen--; } - a = 0; + a = 0; while (a < buflen) { if (buf[a] == '+') buf[a] = ' '; @@ -41,8 +41,7 @@ int unescape_input(char *buf) if (a + 2 > buflen) { buf[a] = '\0'; buflen = a; - } - else { + } else { hex[0] = buf[a + 1]; hex[1] = buf[a + 2]; hex[2] = 0; @@ -52,8 +51,8 @@ int unescape_input(char *buf) len = buflen - a - 2; if (len > 0) memmove(&buf[a + 1], &buf[a + 3], len); - - buflen -=2; + + buflen -= 2; } } a++; @@ -66,14 +65,15 @@ int unescape_input(char *buf) * Supplied with a unix timestamp, generate a textual time/date stamp. * Caller owns the returned memory. */ -char *http_datestring(time_t xtime) { +char *http_datestring(time_t xtime) +{ /* HTTP Months - do not translate - these are not for human consumption */ static char *httpdate_months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - + /* HTTP Weekdays - do not translate - these are not for human consumption */ static char *httpdate_weekdays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" @@ -84,7 +84,8 @@ char *http_datestring(time_t xtime) { char offsign; int n = 40; char *buf = malloc(n); - if (!buf) return(NULL); + if (!buf) + return (NULL); localtime_r(&xtime, &t); @@ -92,22 +93,14 @@ char *http_datestring(time_t xtime) { offset = t.tm_gmtoff; if (offset > 0) { offsign = '+'; - } - else { + } else { offset = 0L - offset; offsign = '-'; } - offset = ( (offset / 3600) * 100 ) + ( offset % 60 ); + offset = ((offset / 3600) * 100) + (offset % 60); snprintf(buf, n, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld", - httpdate_weekdays[t.tm_wday], - t.tm_mday, - httpdate_months[t.tm_mon], - t.tm_year + 1900, - t.tm_hour, - t.tm_min, - t.tm_sec, - offsign, offset - ); - return(buf); + httpdate_weekdays[t.tm_wday], + t.tm_mday, httpdate_months[t.tm_mon], t.tm_year + 1900, t.tm_hour, t.tm_min, t.tm_sec, offsign, offset); + return (buf); }