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] = ' ';
if (a + 2 > buflen) {
buf[a] = '\0';
buflen = a;
- }
- else {
+ } else {
hex[0] = buf[a + 1];
hex[1] = buf[a + 2];
hex[2] = 0;
len = buflen - a - 2;
if (len > 0)
memmove(&buf[a + 1], &buf[a + 3], len);
-
- buflen -=2;
+
+ buflen -= 2;
}
}
a++;
* 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"
char offsign;
int n = 40;
char *buf = malloc(n);
- if (!buf) return(NULL);
+ if (!buf)
+ return (NULL);
localtime_r(&xtime, &t);
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);
}