Removed the comments about RMS being an asshole communist. I don't want anyone to...
[citadel.git] / webcit-ng / util.c
index 9fdf58a644ee0c3e6bb2ef7018bae54127708e3a..a6a0fc76815ff08e092e1d965f3c27f1f9e138ef 100644 (file)
@@ -1,16 +1,17 @@
-/*
- * Utility functions
- *
- * Copyright (c) 1996-2016 by the citadel.org team
- *
- * This program is open source software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+//
+// Utility functions
+//
+// Copyright (c) 1996-2018 by the citadel.org team
+//
+// This program is open source software.  It runs great on the
+// Linux operating system (and probably elsewhere).  You can use,
+// copy, and run it under the terms of the GNU General Public
+// License version 3.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 
 #include "webcit.h"
 
@@ -27,12 +28,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 +42,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 +52,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 +66,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 +85,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 +94,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);
 }