From: Automatic source maintenance Date: Mon, 23 Nov 2009 01:16:57 +0000 (-0700) Subject: SourceFormat Enforcement X-Git-Tag: SQUID_3_2_0_1~537 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d65168e8095a339c6f37503f0fd1b4548cce31a;p=thirdparty%2Fsquid.git SourceFormat Enforcement --- diff --git a/helpers/log_daemon/file/log_file_daemon.cc b/helpers/log_daemon/file/log_file_daemon.cc index aaa4e488a7..9552d82ef5 100644 --- a/helpers/log_daemon/file/log_file_daemon.cc +++ b/helpers/log_daemon/file/log_file_daemon.cc @@ -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 \n", argv[0]); - exit(1); + printf("Error: usage: %s \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; diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 2ca6c9d498..c3e56e08b3 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -2875,8 +2875,7 @@ parse_IpAddress_list(IpAddress_list ** head) s->s = ipa; *head = s; - } - else + } else self_destruct(); } } diff --git a/src/log/Config.h b/src/log/Config.h index f0266eebbc..c46c91feb8 100644 --- a/src/log/Config.h +++ b/src/log/Config.h @@ -1,7 +1,8 @@ #ifndef SQUID_SRC_LOG_CONFIG_H #define SQUID_SRC_LOG_CONFIG_H -namespace Log { +namespace Log +{ class LogConfig { diff --git a/src/log/File.cc b/src/log/File.cc index 9a6ff35e45..1113dce70b 100644 --- a/src/log/File.cc +++ b/src/log/File.cc @@ -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); diff --git a/src/log/File.h b/src/log/File.h index bb6df08344..4d98e2fd78 100644 --- a/src/log/File.h +++ b/src/log/File.h @@ -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]; diff --git a/src/log/ModDaemon.cc b/src/log/ModDaemon.cc index 624804fefe..42c4bd27d4 100644 --- a/src/log/ModDaemon.cc +++ b/src/log/ModDaemon.cc @@ -18,12 +18,12 @@ * 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(ll->bufs.head->data); - if (b->len + 2 <= b->size) - logfile_mod_daemon_append(lf, "F\n", 2); + logfile_buffer_t *b = static_cast(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(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(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(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(ll->bufs.head->data); - if (b->node.next != NULL || !Config.onoff.buffered_logs) - logfileQueueWrite(lf); + b = static_cast(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(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; } } diff --git a/src/log/ModDaemon.h b/src/log/ModDaemon.h index 1baed9d538..583a1c2711 100644 --- a/src/log/ModDaemon.h +++ b/src/log/ModDaemon.h @@ -18,12 +18,12 @@ * 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. diff --git a/src/log/ModStdio.cc b/src/log/ModStdio.cc index 9788e6bfef..7a009140c7 100644 --- a/src/log/ModStdio.cc +++ b/src/log/ModStdio.cc @@ -18,12 +18,12 @@ * 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(xmalloc(bufsz)); - ll->bufsz = bufsz; + ll->buf = static_cast(xmalloc(bufsz)); + ll->bufsz = bufsz; } return 1; } diff --git a/src/log/ModStdio.h b/src/log/ModStdio.h index 5e61ef7d61..ca41dbd13b 100644 --- a/src/log/ModStdio.h +++ b/src/log/ModStdio.h @@ -20,12 +20,12 @@ * 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. diff --git a/src/log/ModSyslog.cc b/src/log/ModSyslog.cc index c47126edc5..c79d9dc7a5 100644 --- a/src/log/ModSyslog.cc +++ b/src/log/ModSyslog.cc @@ -18,12 +18,12 @@ * 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; diff --git a/src/log/ModSyslog.h b/src/log/ModSyslog.h index b5bce2d496..d31c0a4a8c 100644 --- a/src/log/ModSyslog.h +++ b/src/log/ModSyslog.h @@ -20,12 +20,12 @@ * 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. diff --git a/src/log/ModUdp.cc b/src/log/ModUdp.cc index 343d3b80bd..5ef9ea99e5 100644 --- a/src/log/ModUdp.cc +++ b/src/log/ModUdp.cc @@ -18,12 +18,12 @@ * 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(xmalloc(bufsz)); - ll->bufsz = bufsz; + ll->buf = static_cast(xmalloc(bufsz)); + ll->bufsz = bufsz; } return 1; diff --git a/src/log/ModUdp.h b/src/log/ModUdp.h index 1d7ba4a42f..3c7418072d 100644 --- a/src/log/ModUdp.h +++ b/src/log/ModUdp.h @@ -20,12 +20,12 @@ * 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.