]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
SourceFormat Enforcement
authorAutomatic source maintenance <squidadm@squid-cache.org>
Mon, 23 Nov 2009 01:16:57 +0000 (18:16 -0700)
committerAutomatic source maintenance <squidadm@squid-cache.org>
Mon, 23 Nov 2009 01:16:57 +0000 (18:16 -0700)
13 files changed:
helpers/log_daemon/file/log_file_daemon.cc
src/cache_cf.cc
src/log/Config.h
src/log/File.cc
src/log/File.h
src/log/ModDaemon.cc
src/log/ModDaemon.h
src/log/ModStdio.cc
src/log/ModStdio.h
src/log/ModSyslog.cc
src/log/ModSyslog.h
src/log/ModUdp.cc
src/log/ModUdp.h

index aaa4e488a7822ab76cc8d27e6c1cb40cdf304dcf..9552d82ef50be9487871d187d55628a37b5ae66d 100644 (file)
@@ -51,25 +51,25 @@ rotate(const char *path, int rotate_count)
     assert(path);
 #ifdef S_ISREG
     if (stat(path, &sb) == 0)
-       if (S_ISREG(sb.st_mode) == 0)
-           return;
+        if (S_ISREG(sb.st_mode) == 0)
+            return;
 #endif
     /* Rotate numbers 0 through N up one */
     for (i = rotate_count; i > 1;) {
-       i--;
-       snprintf(from, MAXPATHLEN, "%s.%d", path, i - 1);
-       snprintf(to, MAXPATHLEN, "%s.%d", path, i);
+        i--;
+        snprintf(from, MAXPATHLEN, "%s.%d", path, i - 1);
+        snprintf(to, MAXPATHLEN, "%s.%d", path, i);
 #if defined(_SQUID_OS2_) || defined(_SQUID_WIN32_)
-       remove(to);
+        remove(to);
 #endif
-       rename(from, to);
+        rename(from, to);
     }
     if (rotate_count > 0) {
-       snprintf(to, MAXPATHLEN, "%s.%d", path, 0);
+        snprintf(to, MAXPATHLEN, "%s.%d", path, 0);
 #if defined(_SQUID_OS2_) || defined(_SQUID_WIN32_)
-       remove(to);
+        remove(to);
 #endif
-       rename(path, to);
+        rename(path, to);
     }
 }
 
@@ -94,13 +94,13 @@ main(int argc, char *argv[])
     int do_buffer = 1;
 
     if (argc < 2) {
-       printf("Error: usage: %s <logfile>\n", argv[0]);
-       exit(1);
+        printf("Error: usage: %s <logfile>\n", argv[0]);
+        exit(1);
     }
     fp = fopen(argv[1], "a");
     if (fp == NULL) {
-       perror("fopen");
-       exit(1);
+        perror("fopen");
+        exit(1);
     }
     setbuf(stdout, NULL);
     close(2);
@@ -109,44 +109,44 @@ main(int argc, char *argv[])
     dup2(t, 2);
 
     while (fgets(buf, LOGFILE_BUF_LEN, stdin)) {
-       /* First byte indicates what we're logging! */
-       switch (buf[0]) {
-       case 'L':
-           if (buf[1] != '\0') {
-               fprintf(fp, "%s", buf + 1);
-           }
-           if (!do_buffer)
-               fflush(fp);
-           break;
-       case 'R':
-           fclose(fp);
-           rotate(argv[1], rotate_count);
-           fp = fopen(argv[1], "a");
-           if (fp == NULL) {
-               perror("fopen");
-               exit(1);
-           }
-           break;
-       case 'T':
-           break;
-       case 'O':
-           break;
-       case 'r':
-           //fprintf(fp, "SET ROTATE: %s\n", buf + 1);
-           rotate_count = atoi(buf + 1);
-           break;
-       case 'b':
-           //fprintf(fp, "SET BUFFERED: %s\n", buf + 1);
-           do_buffer = (buf[1] == '1');
-           break;
-       case 'F':
-           fflush(fp);
-           break;
-       default:
-           /* Just in case .. */
-           fprintf(fp, "%s", buf);
-           break;
-       }
+        /* First byte indicates what we're logging! */
+        switch (buf[0]) {
+        case 'L':
+            if (buf[1] != '\0') {
+                fprintf(fp, "%s", buf + 1);
+            }
+            if (!do_buffer)
+                fflush(fp);
+            break;
+        case 'R':
+            fclose(fp);
+            rotate(argv[1], rotate_count);
+            fp = fopen(argv[1], "a");
+            if (fp == NULL) {
+                perror("fopen");
+                exit(1);
+            }
+            break;
+        case 'T':
+            break;
+        case 'O':
+            break;
+        case 'r':
+            //fprintf(fp, "SET ROTATE: %s\n", buf + 1);
+            rotate_count = atoi(buf + 1);
+            break;
+        case 'b':
+            //fprintf(fp, "SET BUFFERED: %s\n", buf + 1);
+            do_buffer = (buf[1] == '1');
+            break;
+        case 'F':
+            fflush(fp);
+            break;
+        default:
+            /* Just in case .. */
+            fprintf(fp, "%s", buf);
+            break;
+        }
     }
     fclose(fp);
     fp = NULL;
index 2ca6c9d498030a0b99b83873d49a0a8b21ada79d..c3e56e08b36a8f5472eb138eabc38158037c493b 100644 (file)
@@ -2875,8 +2875,7 @@ parse_IpAddress_list(IpAddress_list ** head)
             s->s = ipa;
 
             *head = s;
-        }
-        else
+        } else
             self_destruct();
     }
 }
index f0266eebbc03bde95d9f3ea7a12149a468ac0cee..c46c91feb823aaf635e20b2375a70526d1522eb0 100644 (file)
@@ -1,7 +1,8 @@
 #ifndef SQUID_SRC_LOG_CONFIG_H
 #define SQUID_SRC_LOG_CONFIG_H
 
-namespace Log {
+namespace Log
+{
 
 class LogConfig
 {
index 9a6ff35e45b52085a789116c6b33e4d4a6125b54..1113dce70bc72103a9ae2cabe9504a61bbe2a593 100644 (file)
@@ -56,30 +56,30 @@ logfileOpen(const char *path, size_t bufsz, int fatal_flag)
     patharg = path;
     /* need to call the per-logfile-type code */
     if (strncmp(path, "stdio:", 6) == 0) {
-       patharg = path + 6;
-       ret = logfile_mod_stdio_open(lf, patharg, bufsz, fatal_flag);
+        patharg = path + 6;
+        ret = logfile_mod_stdio_open(lf, patharg, bufsz, fatal_flag);
     } else if (strncmp(path, "daemon:", 7) == 0) {
-       patharg = path + 7;
-       ret = logfile_mod_daemon_open(lf, patharg, bufsz, fatal_flag);
+        patharg = path + 7;
+        ret = logfile_mod_daemon_open(lf, patharg, bufsz, fatal_flag);
     } else if (strncmp(path, "udp:", 4) == 0) {
-       patharg = path + 4;
-       ret = logfile_mod_udp_open(lf, patharg, bufsz, fatal_flag);
+        patharg = path + 4;
+        ret = logfile_mod_udp_open(lf, patharg, bufsz, fatal_flag);
 #if HAVE_SYSLOG
     } else if (strncmp(path, "syslog:", 7) == 0) {
-       patharg = path + 7;
-       ret = logfile_mod_syslog_open(lf, patharg, bufsz, fatal_flag);
+        patharg = path + 7;
+        ret = logfile_mod_syslog_open(lf, patharg, bufsz, fatal_flag);
 #endif
     } else {
-       ret = logfile_mod_stdio_open(lf, patharg, bufsz, fatal_flag);
+        ret = logfile_mod_stdio_open(lf, patharg, bufsz, fatal_flag);
     }
     if (!ret) {
-       if (fatal_flag)
-           fatalf("logfileOpen: path %s: couldn't open!\n", path);
-       else
-           debugs(50, 1, "logfileOpen: path " << path << ": couldn't open!");
-       lf->f_close(lf);
-       cbdataFree(lf);
-       return NULL;
+        if (fatal_flag)
+            fatalf("logfileOpen: path %s: couldn't open!\n", path);
+        else
+            debugs(50, 1, "logfileOpen: path " << path << ": couldn't open!");
+        lf->f_close(lf);
+        cbdataFree(lf);
+        return NULL;
     }
     assert(lf->data != NULL);
 
index bb6df08344ee7b95e44d976a37120e0d2f25dc33..4d98e2fd782ddd86cb3dc0bbc62e8dd3690afb73 100644 (file)
@@ -4,7 +4,8 @@
 #include "config.h"
 #include "dlink.h"
 
-class logfile_buffer_t {
+class logfile_buffer_t
+{
 public:
     char *buf;
     int size;
@@ -22,7 +23,8 @@ typedef void LOGFLUSH(Logfile *);
 typedef void LOGROTATE(Logfile *);
 typedef void LOGCLOSE(Logfile *);
 
-class Logfile {
+class Logfile
+{
 
 public:
     char path[SQUID_MAXPATHLEN];
index 624804fefea021c4657a941d056a8d36bf203bbc..42c4bd27d405e905e87ecc0116ca5e9228308e00 100644 (file)
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  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.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
@@ -42,7 +42,7 @@
 #define        LOGFILE_MAXBUFS         128
 
 /* Size of the logfile buffer */
-/* 
+/*
  * For optimal performance this should match LOGFILE_BUFSIZ in logfile-daemon.c
  */
 #define        LOGFILE_BUFSZ           32768
@@ -122,38 +122,38 @@ logfileHandleWrite(int fd, void *data)
     ret = FD_WRITE_METHOD(ll->wfd, b->buf + b->written_len, b->len - b->written_len);
     debugs(50, 3, "logfileHandleWrite: " << lf->path << ": write returned " << ret);
     if (ret < 0) {
-       if (ignoreErrno(errno)) {
-           /* something temporary */
-           goto reschedule;
-       }
-       debugs(50, DBG_IMPORTANT,"logfileHandleWrite: " << lf->path << ": error writing (" << xstrerror() << ")");
-       /* XXX should handle this better */
-       fatal("I don't handle this error well!");
+        if (ignoreErrno(errno)) {
+            /* something temporary */
+            goto reschedule;
+        }
+        debugs(50, DBG_IMPORTANT,"logfileHandleWrite: " << lf->path << ": error writing (" << xstrerror() << ")");
+        /* XXX should handle this better */
+        fatal("I don't handle this error well!");
     }
     if (ret == 0) {
-       /* error? */
-       debugs(50, DBG_IMPORTANT, "logfileHandleWrite: " << lf->path << ": wrote 0 bytes?");
-       /* XXX should handle this better */
-       fatal("I don't handle this error well!");
+        /* error? */
+        debugs(50, DBG_IMPORTANT, "logfileHandleWrite: " << lf->path << ": wrote 0 bytes?");
+        /* XXX should handle this better */
+        fatal("I don't handle this error well!");
     }
     /* ret > 0, so something was written */
     b->written_len += ret;
     assert(b->written_len <= b->len);
     if (b->written_len == b->len) {
-       /* written the whole buffer! */
-       logfileFreeBuffer(lf, b);
-       b = NULL;
+        /* written the whole buffer! */
+        logfileFreeBuffer(lf, b);
+        b = NULL;
     }
     /* Is there more to write? */
     if (ll->bufs.head == NULL) {
-       goto finish;
+        goto finish;
     }
     /* there is, so schedule more */
 
-  reschedule:
+reschedule:
     commSetSelect(ll->wfd, COMM_SELECT_WRITE, logfileHandleWrite, lf, 0);
     ll->flush_pending = 1;
-  finish:
+finish:
     return;
 }
 
@@ -162,13 +162,13 @@ logfileQueueWrite(Logfile * lf)
 {
     l_daemon_t *ll = (l_daemon_t *) lf->data;
     if (ll->flush_pending || ll->bufs.head == NULL) {
-       return;
+        return;
     }
     ll->flush_pending = 1;
     if (ll->bufs.head) {
-       logfile_buffer_t *b = static_cast<logfile_buffer_t*>(ll->bufs.head->data);
-       if (b->len + 2 <= b->size)
-           logfile_mod_daemon_append(lf, "F\n", 2);
+        logfile_buffer_t *b = static_cast<logfile_buffer_t*>(ll->bufs.head->data);
+        if (b->len + 2 <= b->size)
+            logfile_mod_daemon_append(lf, "F\n", 2);
     }
     /* Ok, schedule a write-event */
     commSetSelect(ll->wfd, COMM_SELECT_WRITE, logfileHandleWrite, lf, 0);
@@ -183,23 +183,23 @@ logfile_mod_daemon_append(Logfile * lf, const char *buf, int len)
 
     /* Is there a buffer? If not, create one */
     if (ll->bufs.head == NULL) {
-       logfileNewBuffer(lf);
+        logfileNewBuffer(lf);
     }
     debugs(50, 3, "logfile_mod_daemon_append: " << lf->path << ": appending " << len << " bytes");
     /* Copy what can be copied */
     while (len > 0) {
-       b = static_cast<logfile_buffer_t*>(ll->bufs.tail->data);
-       debugs(50, 3, "logfile_mod_daemon_append: current buffer has " << b->len << " of " << b->size << " bytes before append");
-       s = min(len, (b->size - b->len));
-       xmemcpy(b->buf + b->len, buf, s);
-       len = len - s;
-       buf = buf + s;
-       b->len = b->len + s;
-       assert(b->len <= LOGFILE_BUFSZ);
-       assert(len >= 0);
-       if (len > 0) {
-           logfileNewBuffer(lf);
-       }
+        b = static_cast<logfile_buffer_t*>(ll->bufs.tail->data);
+        debugs(50, 3, "logfile_mod_daemon_append: current buffer has " << b->len << " of " << b->size << " bytes before append");
+        s = min(len, (b->size - b->len));
+        xmemcpy(b->buf + b->len, buf, s);
+        len = len - s;
+        buf = buf + s;
+        b->len = b->len + s;
+        assert(b->len <= LOGFILE_BUFSZ);
+        assert(len >= 0);
+        if (len > 0) {
+            logfileNewBuffer(lf);
+        }
     }
 }
 
@@ -243,13 +243,13 @@ logfile_mod_daemon_open(Logfile * lf, const char *path, size_t bufsz, int fatal_
     ll->eol = 1;
     {
         IpAddress localhost;
-       args[0] = "(logfile-daemon)";
-       args[1] = path;
-       args[2] = NULL;
+        args[0] = "(logfile-daemon)";
+        args[1] = path;
+        args[2] = NULL;
         localhost.SetLocalhost();
-       ll->pid = ipcCreate(IPC_STREAM, Log::TheConfig.logfile_daemon, args, "logfile-daemon", localhost, &ll->rfd, &ll->wfd, NULL);
-       if (ll->pid < 0)
-           fatal("Couldn't start logfile helper");
+        ll->pid = ipcCreate(IPC_STREAM, Log::TheConfig.logfile_daemon, args, "logfile-daemon", localhost, &ll->rfd, &ll->wfd, NULL);
+        if (ll->pid < 0)
+            fatal("Couldn't start logfile helper");
     }
     ll->nbufs = 0;
 
@@ -272,7 +272,7 @@ logfile_mod_daemon_close(Logfile * lf)
     debugs(50, 1, "Logfile Daemon: closing log " << lf->path);
     logfileFlush(lf);
     if (ll->rfd == ll->wfd)
-       comm_close(ll->rfd);
+        comm_close(ll->rfd);
     else {
         comm_close(ll->rfd);
         comm_close(ll->wfd);
@@ -307,11 +307,11 @@ logfile_mod_daemon_writeline(Logfile * lf, const char *buf, size_t len)
     l_daemon_t *ll = static_cast<l_daemon_t *>(lf->data);
     /* Make sure the logfile buffer isn't too large */
     if (ll->nbufs > LOGFILE_MAXBUFS) {
-       if (ll->last_warned < squid_curtime - LOGFILE_WARN_TIME) {
-           ll->last_warned = squid_curtime;
-           debugs(50, DBG_IMPORTANT, "Logfile: " << lf->path << ": queue is too large; some log messages have been lost.");
-       }
-       return;
+        if (ll->last_warned < squid_curtime - LOGFILE_WARN_TIME) {
+            ll->last_warned = squid_curtime;
+            debugs(50, DBG_IMPORTANT, "Logfile: " << lf->path << ": queue is too large; some log messages have been lost.");
+        }
+        return;
     }
     /* Append this data to the end buffer; create a new one if needed */
     /* Are we eol? If so, prefix with our logfile command byte */
@@ -339,9 +339,9 @@ logfile_mod_daemon_lineend(Logfile * lf)
     ll->eol = 1;
     /* Kick a write off if the head buffer is -full- */
     if (ll->bufs.head != NULL) {
-       b = static_cast<logfile_buffer_t*>(ll->bufs.head->data);
-       if (b->node.next != NULL || !Config.onoff.buffered_logs)
-           logfileQueueWrite(lf);
+        b = static_cast<logfile_buffer_t*>(ll->bufs.head->data);
+        if (b->node.next != NULL || !Config.onoff.buffered_logs)
+            logfileQueueWrite(lf);
     }
 }
 
@@ -350,14 +350,14 @@ logfile_mod_daemon_flush(Logfile * lf)
 {
     l_daemon_t *ll = static_cast<l_daemon_t *>(lf->data);
     if (commUnsetNonBlocking(ll->wfd)) {
-       debugs(50, DBG_IMPORTANT, "Logfile Daemon: Couldn't set the pipe blocking for flush! You're now missing some log entries.");
-       return;
+        debugs(50, DBG_IMPORTANT, "Logfile Daemon: Couldn't set the pipe blocking for flush! You're now missing some log entries.");
+        return;
     }
     while (ll->bufs.head != NULL) {
-       logfileHandleWrite(ll->wfd, lf);
+        logfileHandleWrite(ll->wfd, lf);
     }
     if (commSetNonBlocking(ll->wfd)) {
-       fatalf("Logfile Daemon: %s: Couldn't set the pipe non-blocking for flush!\n", lf->path);
-       return;
+        fatalf("Logfile Daemon: %s: Couldn't set the pipe non-blocking for flush!\n", lf->path);
+        return;
     }
 }
index 1baed9d538355bf699c2e1be80fd11255c2fac98..583a1c27118ad53bc4eccf220f50e2694284fa1c 100644 (file)
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  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.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
index 9788e6bfef852b9d8e225104f3b8269d6b366091..7a009140c7cf8308dc0b24e30a741b4c7b2f911d 100644 (file)
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  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.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
@@ -55,10 +55,10 @@ logfileWriteWrapper(Logfile * lf, const void *buf, size_t len)
     fd_bytes(ll->fd, s, FD_WRITE);
 
     if (s == len)
-       return;
+        return;
 
     if (!lf->flags.fatal)
-       return;
+        return;
 
     fatalf("logfileWrite (stdio): %s: %s\n", lf->path, xstrerror());
 }
@@ -69,17 +69,17 @@ logfile_mod_stdio_writeline(Logfile * lf, const char *buf, size_t len)
     l_stdio_t *ll = (l_stdio_t *) lf->data;
 
     if (0 == ll->bufsz) {
-       /* buffering disabled */
-       logfileWriteWrapper(lf, buf, len);
-       return;
+        /* buffering disabled */
+        logfileWriteWrapper(lf, buf, len);
+        return;
     }
     if (ll->offset > 0 && (ll->offset + len) > ll->bufsz)
-       logfileFlush(lf);
+        logfileFlush(lf);
 
     if (len > ll->bufsz) {
-       /* too big to fit in buffer */
-       logfileWriteWrapper(lf, buf, len);
-       return;
+        /* too big to fit in buffer */
+        logfileWriteWrapper(lf, buf, len);
+        return;
     }
     /* buffer it */
     xmemcpy(ll->buf + ll->offset, buf, len);
@@ -107,7 +107,7 @@ logfile_mod_stdio_flush(Logfile * lf)
 {
     l_stdio_t *ll = (l_stdio_t *) lf->data;
     if (0 == ll->offset)
-       return;
+        return;
     logfileWriteWrapper(lf, ll->buf, (size_t) ll->offset);
     ll->offset = 0;
 }
@@ -129,8 +129,8 @@ logfile_mod_stdio_rotate(Logfile * lf)
 #ifdef S_ISREG
 
     if (stat(lf->path, &sb) == 0)
-       if (S_ISREG(sb.st_mode) == 0)
-           return;
+        if (S_ISREG(sb.st_mode) == 0)
+            return;
 
 #endif
 
@@ -138,10 +138,10 @@ logfile_mod_stdio_rotate(Logfile * lf)
 
     /* Rotate numbers 0 through N up one */
     for (i = Config.Log.rotateNumber; i > 1;) {
-       i--;
-       snprintf(from, MAXPATHLEN, "%s.%d", lf->path, i - 1);
-       snprintf(to, MAXPATHLEN, "%s.%d", lf->path, i);
-       xrename(from, to);
+        i--;
+        snprintf(from, MAXPATHLEN, "%s.%d", lf->path, i - 1);
+        snprintf(to, MAXPATHLEN, "%s.%d", lf->path, i);
+        xrename(from, to);
     }
 
     /* Rotate the current log to .0 */
@@ -150,15 +150,15 @@ logfile_mod_stdio_rotate(Logfile * lf)
     file_close(ll->fd);                /* always close */
 
     if (Config.Log.rotateNumber > 0) {
-       snprintf(to, MAXPATHLEN, "%s.%d", lf->path, 0);
-       xrename(lf->path, to);
+        snprintf(to, MAXPATHLEN, "%s.%d", lf->path, 0);
+        xrename(lf->path, to);
     }
     /* Reopen the log.  It may have been renamed "manually" */
     ll->fd = file_open(lf->path, O_WRONLY | O_CREAT | O_TEXT);
 
     if (DISK_ERROR == ll->fd && lf->flags.fatal) {
-       debugs(50, DBG_CRITICAL, "logfileRotate (stdio): " << lf->path << ": " << xstrerror());
-       fatalf("Cannot open %s: %s", lf->path, xstrerror());
+        debugs(50, DBG_CRITICAL, "logfileRotate (stdio): " << lf->path << ": " << xstrerror());
+        fatalf("Cannot open %s: %s", lf->path, xstrerror());
     }
 }
 
@@ -169,10 +169,10 @@ logfile_mod_stdio_close(Logfile * lf)
     lf->f_flush(lf);
 
     if (ll->fd >= 0)
-       file_close(ll->fd);
+        file_close(ll->fd);
 
     if (ll->buf)
-       xfree(ll->buf);
+        xfree(ll->buf);
 
     xfree(lf->data);
     lf->data = NULL;
@@ -197,23 +197,23 @@ logfile_mod_stdio_open(Logfile * lf, const char *path, size_t bufsz, int fatal_f
     ll->fd = file_open(path, O_WRONLY | O_CREAT | O_TEXT);
 
     if (DISK_ERROR == ll->fd) {
-       if (ENOENT == errno && fatal_flag) {
-           fatalf("Cannot open '%s' because\n"
-               "\tthe parent directory does not exist.\n"
-               "\tPlease create the directory.\n", path);
-       } else if (EACCES == errno && fatal_flag) {
-           fatalf("Cannot open '%s' for writing.\n"
-               "\tThe parent directory must be writeable by the\n"
-               "\tuser '%s', which is the cache_effective_user\n"
-               "\tset in squid.conf.", path, Config.effectiveUser);
-       } else {
-           debugs(50, DBG_IMPORTANT, "logfileOpen (stdio): " <<  path << ": " << xstrerror());
-           return 0;
-       }
+        if (ENOENT == errno && fatal_flag) {
+            fatalf("Cannot open '%s' because\n"
+                   "\tthe parent directory does not exist.\n"
+                   "\tPlease create the directory.\n", path);
+        } else if (EACCES == errno && fatal_flag) {
+            fatalf("Cannot open '%s' for writing.\n"
+                   "\tThe parent directory must be writeable by the\n"
+                   "\tuser '%s', which is the cache_effective_user\n"
+                   "\tset in squid.conf.", path, Config.effectiveUser);
+        } else {
+            debugs(50, DBG_IMPORTANT, "logfileOpen (stdio): " <<  path << ": " << xstrerror());
+            return 0;
+        }
     }
     if (bufsz > 0) {
-       ll->buf = static_cast<char*>(xmalloc(bufsz));
-       ll->bufsz = bufsz;
+        ll->buf = static_cast<char*>(xmalloc(bufsz));
+        ll->bufsz = bufsz;
     }
     return 1;
 }
index 5e61ef7d61cce668acaceb64b1a17b7455a2b881..ca41dbd13b45bbc45371b8fd9d120d30d6245e80 100644 (file)
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  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.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
index c47126edc562fa65907dbe4c56fa2a2617614afa..c79d9dc7a57b58a59f0fe381e91c4aba42ea5cde 100644 (file)
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  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.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
@@ -51,63 +51,62 @@ static int
 syslog_ntoa(const char *s)
 {
 #define syslog_symbol(a) #a, a
-    static syslog_symbol_t symbols[] =
-    {
+    static syslog_symbol_t symbols[] = {
 #ifdef LOG_AUTHPRIV
-       {syslog_symbol(LOG_AUTHPRIV)},
+        {syslog_symbol(LOG_AUTHPRIV)},
 #endif
 #ifdef LOG_DAEMON
-       {syslog_symbol(LOG_DAEMON)},
+        {syslog_symbol(LOG_DAEMON)},
 #endif
 #ifdef LOG_LOCAL0
-       {syslog_symbol(LOG_LOCAL0)},
+        {syslog_symbol(LOG_LOCAL0)},
 #endif
 #ifdef LOG_LOCAL1
-       {syslog_symbol(LOG_LOCAL1)},
+        {syslog_symbol(LOG_LOCAL1)},
 #endif
 #ifdef LOG_LOCAL2
-       {syslog_symbol(LOG_LOCAL2)},
+        {syslog_symbol(LOG_LOCAL2)},
 #endif
 #ifdef LOG_LOCAL3
-       {syslog_symbol(LOG_LOCAL3)},
+        {syslog_symbol(LOG_LOCAL3)},
 #endif
 #ifdef LOG_LOCAL4
-       {syslog_symbol(LOG_LOCAL4)},
+        {syslog_symbol(LOG_LOCAL4)},
 #endif
 #ifdef LOG_LOCAL5
-       {syslog_symbol(LOG_LOCAL5)},
+        {syslog_symbol(LOG_LOCAL5)},
 #endif
 #ifdef LOG_LOCAL6
-       {syslog_symbol(LOG_LOCAL6)},
+        {syslog_symbol(LOG_LOCAL6)},
 #endif
 #ifdef LOG_LOCAL7
-       {syslog_symbol(LOG_LOCAL7)},
+        {syslog_symbol(LOG_LOCAL7)},
 #endif
 #ifdef LOG_USER
-       {syslog_symbol(LOG_USER)},
+        {syslog_symbol(LOG_USER)},
 #endif
 #ifdef LOG_ERR
-       {syslog_symbol(LOG_ERR)},
+        {syslog_symbol(LOG_ERR)},
 #endif
 #ifdef LOG_WARNING
-       {syslog_symbol(LOG_WARNING)},
+        {syslog_symbol(LOG_WARNING)},
 #endif
 #ifdef LOG_NOTICE
-       {syslog_symbol(LOG_NOTICE)},
+        {syslog_symbol(LOG_NOTICE)},
 #endif
 #ifdef LOG_INFO
-       {syslog_symbol(LOG_INFO)},
+        {syslog_symbol(LOG_INFO)},
 #endif
 #ifdef LOG_DEBUG
-       {syslog_symbol(LOG_DEBUG)},
+        {syslog_symbol(LOG_DEBUG)},
 #endif
-       {NULL, 0}
+        {NULL, 0}
     };
     syslog_symbol_t *p;
 
     for (p = symbols; p->name != NULL; ++p)
-       if (!strcmp(s, p->name) || !strcasecmp(s, p->name + 4))
-           return p->value;
+        if (!strcmp(s, p->name) || !strcasecmp(s, p->name + 4))
+            return p->value;
 
     debugs(1, 1, "Unknown syslog facility/priority '" << s << "'");
     return 0;
@@ -185,7 +184,7 @@ logfile_mod_syslog_open(Logfile * lf, const char *path, size_t bufsz, int fatal_
         ll->syslog_priority |= syslog_ntoa(priority);
         xfree(priority);
         if ((ll->syslog_priority & PRIORITY_MASK) == 0)
-        ll->syslog_priority |= LOG_INFO;
+            ll->syslog_priority |= LOG_INFO;
     }
 
     return 1;
index b5bce2d4966dfd7db5c25db9789eb0e0611bcfff..d31c0a4a8c0c8324218de3e04fe76505e588e22e 100644 (file)
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  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.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
index 343d3b80bd305535edfd6fdbf56b9b36be5afcc5..5ef9ea99e5f92c82d033750b7800ff48c9691bd8 100644 (file)
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  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.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
@@ -60,10 +60,10 @@ logfile_mod_udp_write(Logfile * lf, const char *buf, size_t len)
     fd_bytes(ll->fd, s, FD_WRITE);
 #if 0
     if (s < 0) {
-       debugs(1, 1, "logfile (udp): got errno (" << errno << "):" << xstrerror());
+        debugs(1, 1, "logfile (udp): got errno (" << errno << "):" << xstrerror());
     }
     if (s != len) {
-       debugs(1, 1, "logfile (udp): len=" << len << ", wrote=" << s);
+        debugs(1, 1, "logfile (udp): len=" << len << ", wrote=" << s);
     }
 #endif
 
@@ -75,7 +75,7 @@ logfile_mod_udp_flush(Logfile * lf)
 {
     l_udp_t *ll = (l_udp_t *) lf->data;
     if (0 == ll->offset)
-       return;
+        return;
     logfile_mod_udp_write(lf, ll->buf, (size_t) ll->offset);
     ll->offset = 0;
 }
@@ -86,17 +86,17 @@ logfile_mod_udp_writeline(Logfile * lf, const char *buf, size_t len)
     l_udp_t *ll = (l_udp_t *) lf->data;
 
     if (0 == ll->bufsz) {
-       /* buffering disabled */
-       logfile_mod_udp_write(lf, buf, len);
-       return;
+        /* buffering disabled */
+        logfile_mod_udp_write(lf, buf, len);
+        return;
     }
     if (ll->offset > 0 && (ll->offset + len + 4) > ll->bufsz)
-       logfile_mod_udp_flush(lf);
+        logfile_mod_udp_flush(lf);
 
     if (len > ll->bufsz) {
-       /* too big to fit in buffer */
-       logfile_mod_udp_write(lf, buf, len);
-       return;
+        /* too big to fit in buffer */
+        logfile_mod_udp_write(lf, buf, len);
+        return;
     }
     /* buffer it */
     xmemcpy(ll->buf + ll->offset, buf, len);
@@ -131,10 +131,10 @@ logfile_mod_udp_close(Logfile * lf)
     lf->f_flush(lf);
 
     if (ll->fd >= 0)
-       file_close(ll->fd);
+        file_close(ll->fd);
 
     if (ll->buf)
-       xfree(ll->buf);
+        xfree(ll->buf);
 
     xfree(lf->data);
     lf->data = NULL;
@@ -162,17 +162,17 @@ logfile_mod_udp_open(Logfile * lf, const char *path, size_t bufsz, int fatal_fla
     lf->data = ll;
 
     if (strncmp(path, "//", 2) == 0) {
-       path += 2;
+        path += 2;
     }
     strAddr = xstrdup(path);
     if (!GetHostWithPort(strAddr, &addr)) {
-       if (lf->flags.fatal) {
-           fatalf("Invalid UDP logging address '%s'\n", lf->path);
-       } else {
-           debugs(50, DBG_IMPORTANT, "Invalid UDP logging address '" << lf->path << "'");
-           safe_free(strAddr);
-           return FALSE;
-       }
+        if (lf->flags.fatal) {
+            fatalf("Invalid UDP logging address '%s'\n", lf->path);
+        } else {
+            debugs(50, DBG_IMPORTANT, "Invalid UDP logging address '" << lf->path << "'");
+            safe_free(strAddr);
+            return FALSE;
+        }
     }
     safe_free(strAddr);
 
@@ -187,35 +187,34 @@ logfile_mod_udp_open(Logfile * lf, const char *path, size_t bufsz, int fatal_fla
 
     ll->fd = comm_open(SOCK_DGRAM, IPPROTO_UDP, no_addr, COMM_NONBLOCKING, "UDP log socket");
     if (ll->fd < 0) {
-       if (lf->flags.fatal) {
-           fatalf("Unable to open UDP socket for logging\n");
-       } else {
-           debugs(50, DBG_IMPORTANT, "Unable to open UDP socket for logging");
-           return FALSE;
-       }
-    }
-    else if (comm_connect_addr(ll->fd, &addr)) {
-       if (lf->flags.fatal) {
-           fatalf("Unable to connect to %s for UDP log: %s\n", lf->path, xstrerror());
-       } else {
-           debugs(50, DBG_IMPORTANT, "Unable to connect to " << lf->path << " for UDP log: " << xstrerror());
-           return FALSE;
-       }
+        if (lf->flags.fatal) {
+            fatalf("Unable to open UDP socket for logging\n");
+        } else {
+            debugs(50, DBG_IMPORTANT, "Unable to open UDP socket for logging");
+            return FALSE;
+        }
+    } else if (comm_connect_addr(ll->fd, &addr)) {
+        if (lf->flags.fatal) {
+            fatalf("Unable to connect to %s for UDP log: %s\n", lf->path, xstrerror());
+        } else {
+            debugs(50, DBG_IMPORTANT, "Unable to connect to " << lf->path << " for UDP log: " << xstrerror());
+            return FALSE;
+        }
     }
     if (ll->fd == -1) {
-       if (ENOENT == errno && fatal_flag) {
-           fatalf("Cannot open '%s' because\n"
-               "\tthe parent directory does not exist.\n"
-               "\tPlease create the directory.\n", path);
-       } else if (EACCES == errno && fatal_flag) {
-           fatalf("Cannot open '%s' for writing.\n"
-               "\tThe parent directory must be writeable by the\n"
-               "\tuser '%s', which is the cache_effective_user\n"
-               "\tset in squid.conf.", path, Config.effectiveUser);
-       } else {
-           debugs(50, DBG_IMPORTANT, "logfileOpen (UDP): " << lf->path << ": " << xstrerror());
-           return 0;
-       }
+        if (ENOENT == errno && fatal_flag) {
+            fatalf("Cannot open '%s' because\n"
+                   "\tthe parent directory does not exist.\n"
+                   "\tPlease create the directory.\n", path);
+        } else if (EACCES == errno && fatal_flag) {
+            fatalf("Cannot open '%s' for writing.\n"
+                   "\tThe parent directory must be writeable by the\n"
+                   "\tuser '%s', which is the cache_effective_user\n"
+                   "\tset in squid.conf.", path, Config.effectiveUser);
+        } else {
+            debugs(50, DBG_IMPORTANT, "logfileOpen (UDP): " << lf->path << ": " << xstrerror());
+            return 0;
+        }
     }
     /* Force buffer size to something roughly fitting inside an MTU */
     /*
@@ -225,8 +224,8 @@ logfile_mod_udp_open(Logfile * lf, const char *path, size_t bufsz, int fatal_fla
      */
     bufsz = 1400;
     if (bufsz > 0) {
-       ll->buf = static_cast<char*>(xmalloc(bufsz));
-       ll->bufsz = bufsz;
+        ll->buf = static_cast<char*>(xmalloc(bufsz));
+        ll->bufsz = bufsz;
     }
 
     return 1;
index 1d7ba4a42f43ba34afade203f9887d93a041d86b..3c7418072d2ab9a38bdd659c863d260316e8f5b1 100644 (file)
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  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.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.