├── THANKS ├── AUTHORS ├── testsuite ├── bug-procmailsubj.in ├── bug-wnum.in ├── bug-httpd.in ├── bug-procmailsubj.ok ├── bug-procmailsubj2.in ├── bug-sysrepeat.in ├── bug-httpd.ok ├── bug-wnum.ok ├── bug-httpd.test ├── bug-wnum.test ├── bug-sysrepeat.test ├── bug-procmailsubj2.ok ├── version.test ├── bug-procmailsubj2.test ├── bug-procmailsubj.test ├── defs ├── Makefile.in ├── do-test └── bug-sysrepeat.ok ├── ccze.plugins ├── README.md ├── README.old ├── doc ├── Makefile.in ├── ccze-cssdump.1.in ├── ccze-plugin.7.in └── ccze.1.in ├── FAQ ├── Makefile.in ├── ccze.spec ├── ccze.spec.in ├── Rules.mk.in ├── src ├── mod_php.c ├── mod_ulogd.c ├── mod_distcc.c ├── mod_super.c ├── mod_fetchmail.c ├── ccze-cssdump.c ├── mod_vsftpd.c ├── ccze-compat.h ├── mod_sulog.c ├── mod_postfix.c ├── mod_apm.c ├── ccze-private.h ├── mod_ftpstats.c ├── mod_oops.c ├── mod_procmail.c ├── mod_syslog.c ├── mod_exim.c ├── Makefile.in ├── mod_xferlog.c ├── ccze-keywordlookup.c ├── ccze.h ├── mod_httpd.c ├── mod_icecast.c ├── mod_proftpd.c ├── ccze-dump.c ├── mod_squid.c └── ccze-plugin.c ├── NEWS ├── configure.ac ├── system.h.in ├── ChangeLog ├── install-sh └── INSTALL /THANKS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/software-revive/ccze-rv/HEAD/THANKS -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Vadim Ushakov 2 | Gergely Nagy 3 | -------------------------------------------------------------------------------- /testsuite/bug-procmailsubj.in: -------------------------------------------------------------------------------- 1 | From fetchmail Sun Mar 2 21:24:05 2003 2 | Subject: Request 3 | Folder: pisg-general 31641 4 | -------------------------------------------------------------------------------- /testsuite/bug-wnum.in: -------------------------------------------------------------------------------- 1 | Mar 8 00:11:41 pange squid[4815]: Accepting HTTP connections at 0.0.0.0, port 3128, FD 9. 2 | Mar 8 00:11:41 pange squid[4815]: Accepting ICP messages at 0.0.0.0, port 3130, FD 10. 3 | -------------------------------------------------------------------------------- /ccze.plugins: -------------------------------------------------------------------------------- 1 | apm 2 | distcc 3 | exim 4 | fetchmail 5 | ftpstats 6 | httpd 7 | icecast 8 | oops 9 | php 10 | postfix 11 | procmail 12 | proftpd 13 | squid 14 | sulog 15 | super 16 | syslog 17 | ulogd 18 | vsftpd 19 | xferlog 20 | -------------------------------------------------------------------------------- /testsuite/bug-httpd.in: -------------------------------------------------------------------------------- 1 | 193.110.8.48 - - [29/Mar/2003:10:21:41 +0100] "X=a HTTP/1.0" 400 - "-" "-" 2 | 217.21.114.135 - - [27/Mar/2003:13:27:22 +0100] "\x04\x01" 200 145 "-" "-" 3 | 66.140.25.157 - - [29/Mar/2003:15:40:33 +0100] "POST http://66.140.25.157:802/ HTTP/1.0" 200 144 "-" "-" 4 | -------------------------------------------------------------------------------- /testsuite/bug-procmailsubj.ok: -------------------------------------------------------------------------------- 1 | From fetchmail Sun Mar 2 21:24:05 2003 2 | Subject: Request 3 | Folder: pisg-general 31641 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CCZE is a fast log colorizer written in C. 2 | 3 | See the NEWS file for a description of recent changes. 4 | 5 | See the file INSTALL for instructions on how to build and install the 6 | CCZE data and program files. See the CCZE manual for details about 7 | configuration. Type "man ccze" in the shell prompt. 8 | 9 | The official CCZE web page is https://github.com/software-revive/ccze-rv. 10 | 11 | This is a continuation of the original CCZE, abandoned ages ago. 12 | See README.old for the original program description. -------------------------------------------------------------------------------- /testsuite/bug-procmailsubj2.in: -------------------------------------------------------------------------------- 1 | From algernon@gandalph.mad.hu Sat Apr 26 09:26:11 2003 2 | Subject: Re: ccze and light backgrounds 3 | Folder: Inbox/new/1051363571.11590_0.alan-schm1p 2690 4 | From freeciv-dev-bounce@freeciv.org Sat Apr 26 09:26:12 2003 5 | Subject: [Freeciv-Dev] Re: Speeding Up Games 6 | Folder: freeciv/new/1051363572.11603_0.alan-schm1p 4327 7 | From steck@stecksoft.com Sat Apr 26 09:26:12 2003 8 | Subject: Caml Weekly News 9 | Folder: Inbox/new/1051363572.11612_0.alan-schm1p 2497 10 | -------------------------------------------------------------------------------- /README.old: -------------------------------------------------------------------------------- 1 | This is CCZE, a fast log colorizer written in C, intended to be a 2 | drop-in replacement for colorize (http://colorize.raszi.hu). 3 | 4 | See the NEWS file for a description of recent changes to CCZE. 5 | 6 | See the file INSTALL for instructions on how to build and install the 7 | CCZE data and program files. See the CCZE manual for details about 8 | configuration. Type "man ccze" in the shell prompt. 9 | 10 | Please visit the official CCZE web page for more information. The URL 11 | is http://bonehunter.rulez.org/CCZE.html. 12 | -------------------------------------------------------------------------------- /testsuite/bug-sysrepeat.in: -------------------------------------------------------------------------------- 1 | Sep 14 11:45:00 iluvatar xinetd[2965]: Exiting... 2 | Sep 14 11:45:02 iluvatar xinetd[3111]: xinetd Version 2.3.7 started with libwrap loadavg options compiled in. 3 | Sep 14 11:45:02 iluvatar xinetd[3111]: Started working: 5 available services 4 | Sep 14 11:45:04 iluvatar pppd[2755]: Script /etc/ppp/ip-down finished (pid 3079), status = 0x1 5 | Sep 14 11:45:04 iluvatar pppd[2755]: Exit. 6 | Sep 14 12:20:02 iluvatar /USR/SBIN/CRON[10499]: (algernon) CMD (expect /usr/share/doc/tama/examples/tama-nanny.exp 2>/dev/null >/dev/null) 7 | Sep 14 12:27:46 iluvatar uptimed: moving up to position 50: 0 days, 01:04:13 8 | Oct 12 22:40:12 iluvatar last message repeated 10 times 9 | Oct 12 22:40:12 iluvatar -- MARK -- 10 | Oct 12 22:40:12 iluvatar syslog-ng[2854]: syslog-ng version 1.5.15 going down 11 | -------------------------------------------------------------------------------- /doc/Makefile.in: -------------------------------------------------------------------------------- 1 | ## doc/Makefile.in 2 | 3 | ## -- User-modifiable variables -- ## 4 | srcdir = @srcdir@ 5 | top_srcdir = @top_srcdir@ 6 | subdir = doc 7 | 8 | ## == The code below shouldn't need to be touched at all == ## 9 | 10 | include ../Rules.mk 11 | 12 | ## -- Private variables -- ## 13 | MANS = ccze.1 ccze-plugin.7 ccze-cssdump.1 14 | DISTCLEANFILES = ${MANS} 15 | EXTRA_DIST = ccze.1.in ccze-plugin.7.in ccze-cssdump.1.in 16 | 17 | ## -- Generic rules -- ## 18 | all: ${MANS} 19 | 20 | %: %.in ${top_srcdir}/ChangeLog 21 | sed -e "s,@VERSION\@,${VERSION},g" \ 22 | -e "s,@sysconfdir\@,${sysconfdir},g" \ 23 | -e "s,@pkglibdir\@,${pkglibdir},g" \ 24 | <${srcdir}/$@.in >$@T && mv -f $@T $@ 25 | 26 | install: ${MANS} 27 | ${INSTALL} -d ${DESTDIR}${man1dir} 28 | ${INSTALL_DATA} ccze.1 ccze-cssdump.1 ${DESTDIR}${man1dir}/ 29 | ${INSTALL} -d ${DESTDIR}${man7dir} 30 | ${INSTALL_DATA} ccze-plugin.7 ${DESTDIR}${man7dir}/ 31 | 32 | uninstall: 33 | rm -f ${DESTDIR}${man1dir}/ccze.1 ${DESTDIR}${man7dir}/ccze-plugin.7 \ 34 | ${DESTDIR}${man1dir}/ccze-cssdump.1 35 | -------------------------------------------------------------------------------- /testsuite/bug-httpd.ok: -------------------------------------------------------------------------------- 1 | 193.110.8.48 - - [29/Mar/2003:10:21:41 +0100] "X=a HTTP/1.0" 400 - "-" "-" 2 | 217.21.114.135 - - [27/Mar/2003:13:27:22 +0100] "\x04\x01" 200 145 "-" "-" 3 | 66.140.25.157 - - [29/Mar/2003:15:40:33 +0100] "POST http://66.140.25.157:802/ HTTP/1.0" 200 144 "-" "-" 4 | -------------------------------------------------------------------------------- /testsuite/bug-wnum.ok: -------------------------------------------------------------------------------- 1 | Mar 8 00:11:41 pange squid[4815]: Accepting HTTP connections at 0.0.0.0, port 3128, FD 9. 2 | Mar 8 00:11:41 pange squid[4815]: Accepting ICP messages at 0.0.0.0, port 3130, FD 10. 3 | -------------------------------------------------------------------------------- /testsuite/bug-httpd.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ## bug-httpd.test -- Check if bad http requests are recognised 3 | ## -*- sh -*- 4 | ## Copyright (C) 2003 Gergely Nagy 5 | ## 6 | ## This file is part of CCZE. 7 | ## 8 | ## CCZE is free software; you can redistribute it and/or modify 9 | ## it under the terms of the GNU General Public License as published by 10 | ## the Free Software Foundation; either version 2 of the License, or 11 | ## (at your option) any later version. 12 | ## 13 | ## CCZE is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ## GNU General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU General Public License 19 | ## along with this program; if not, write to the Free Software 20 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | DESCRIPTION="Check if bad http requests are recognised." 23 | PROG_CMDLINE="-F /dev/null -phttpd -o nolookups -d" 24 | 25 | # Common definitions 26 | if test -z "${srcdir}"; then 27 | srcdir=`echo "$0" | sed 's,[^/]*$,,'` 28 | test "${srcdir}" = "$0" && srcdir=. 29 | test -z "${srcdir}" && srcdir=. 30 | test "${VERBOSE+set}" != set && VERBOSE=1 31 | fi 32 | . ${srcdir}/defs 33 | . ${srcdir}/do-test 34 | -------------------------------------------------------------------------------- /testsuite/bug-wnum.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ## bug-wnum.test -- Check if single digits are wordcolored right 3 | ## -*- sh -*- 4 | ## Copyright (C) 2003 Gergely Nagy 5 | ## 6 | ## This file is part of CCZE. 7 | ## 8 | ## CCZE is free software; you can redistribute it and/or modify 9 | ## it under the terms of the GNU General Public License as published by 10 | ## the Free Software Foundation; either version 2 of the License, or 11 | ## (at your option) any later version. 12 | ## 13 | ## CCZE is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ## GNU General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU General Public License 19 | ## along with this program; if not, write to the Free Software 20 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | DESCRIPTION="Check if single digits are wordcolored right" 23 | PROG_CMDLINE="-F /dev/null -psyslog -o nolookups -d" 24 | 25 | # Common definitions 26 | if test -z "${srcdir}"; then 27 | srcdir=`echo "$0" | sed 's,[^/]*$,,'` 28 | test "${srcdir}" = "$0" && srcdir=. 29 | test -z "${srcdir}" && srcdir=. 30 | test "${VERBOSE+set}" != set && VERBOSE=1 31 | fi 32 | . ${srcdir}/defs 33 | . ${srcdir}/do-test 34 | -------------------------------------------------------------------------------- /testsuite/bug-sysrepeat.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ## bug-sysrepeat.test -- Check if syslog-ng "repeated n times" stuff is ok 3 | ## -*- sh -*- 4 | ## Copyright (C) 2003 Gergely Nagy 5 | ## 6 | ## This file is part of CCZE. 7 | ## 8 | ## CCZE is free software; you can redistribute it and/or modify 9 | ## it under the terms of the GNU General Public License as published by 10 | ## the Free Software Foundation; either version 2 of the License, or 11 | ## (at your option) any later version. 12 | ## 13 | ## CCZE is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ## GNU General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU General Public License 19 | ## along with this program; if not, write to the Free Software 20 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | DESCRIPTION="Check if syslog-ngs repeat marker is colorised right" 23 | PROG_CMDLINE="-F /dev/null -psyslog -o nolookups -d" 24 | 25 | # Common definitions 26 | if test -z "${srcdir}"; then 27 | srcdir=`echo "$0" | sed 's,[^/]*$,,'` 28 | test "${srcdir}" = "$0" && srcdir=. 29 | test -z "${srcdir}" && srcdir=. 30 | test "${VERBOSE+set}" != set && VERBOSE=1 31 | fi 32 | . ${srcdir}/defs 33 | . ${srcdir}/do-test 34 | -------------------------------------------------------------------------------- /testsuite/bug-procmailsubj2.ok: -------------------------------------------------------------------------------- 1 | From algernon@gandalph.mad.hu Sat Apr 26 09:26:11 2003 2 | Subject: Re: ccze and light backgrounds 3 | Folder: Inbox/new/1051363571.11590_0.alan-schm1p 2690 4 | From freeciv-dev-bounce@freeciv.org Sat Apr 26 09:26:12 2003 5 | Subject: [Freeciv-Dev] Re: Speeding Up Games 6 | Folder: freeciv/new/1051363572.11603_0.alan-schm1p 4327 7 | From steck@stecksoft.com Sat Apr 26 09:26:12 2003 8 | Subject: Caml Weekly News 9 | Folder: Inbox/new/1051363572.11612_0.alan-schm1p 2497 10 | -------------------------------------------------------------------------------- /testsuite/version.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ## version.test -- Test if CCZE responds to --version -*- sh -*- 3 | ## Copyright (C) 2003 Gergely Nagy 4 | ## 5 | ## This file is part of CCZE. 6 | ## 7 | ## CCZE is free software; you can redistribute it and/or modify 8 | ## it under the terms of the GNU General Public License as published by 9 | ## the Free Software Foundation; either version 2 of the License, or 10 | ## (at your option) any later version. 11 | ## 12 | ## CCZE is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | DESCRIPTION="Test if CCZE responds to -V" 22 | PROG_CMDLINE="-V" 23 | 24 | # Common definitions 25 | if test -z "${srcdir}"; then 26 | srcdir=`echo "$0" | sed 's,[^/]*$,,'` 27 | test "${srcdir}" = "$0" && srcdir=. 28 | test -z "${srcdir}" && srcdir=. 29 | test "${VERBOSE+set}" != set && VERBOSE=1 30 | fi 31 | . ${srcdir}/defs 32 | 33 | TEST_OK_LIST="${testname}.ok" 34 | 35 | cat >${testname}.ok < 5 | ## Sample data from Alan Schmitt. 6 | ## 7 | ## This file is part of CCZE. 8 | ## 9 | ## CCZE is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## CCZE is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | DESCRIPTION="Verify if a multi-word subject is correctly colorised" 24 | PROG_CMDLINE="-F /dev/null -p syslog,procmail -o nolookups -d" 25 | 26 | # Common definitions 27 | if test -z "${srcdir}"; then 28 | srcdir=`echo "$0" | sed 's,[^/]*$,,'` 29 | test "${srcdir}" = "$0" && srcdir=. 30 | test -z "${srcdir}" && srcdir=. 31 | test "${VERBOSE+set}" != set && VERBOSE=1 32 | fi 33 | . ${srcdir}/defs 34 | . ${srcdir}/do-test 35 | -------------------------------------------------------------------------------- /testsuite/bug-procmailsubj.test: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ## bug-procmailsubj.test -- Check if a one-word subject in procmailrc is ok 3 | ## -*- sh -*- 4 | ## Copyright (C) 2003 Gergely Nagy 5 | ## Sample data from Morten Brix Pedersen. 6 | ## 7 | ## This file is part of CCZE. 8 | ## 9 | ## CCZE is free software; you can redistribute it and/or modify 10 | ## it under the terms of the GNU General Public License as published by 11 | ## the Free Software Foundation; either version 2 of the License, or 12 | ## (at your option) any later version. 13 | ## 14 | ## CCZE is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ## GNU General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU General Public License 20 | ## along with this program; if not, write to the Free Software 21 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | DESCRIPTION="Verify if a single-word subject in procmailrc is recognised." 24 | PROG_CMDLINE="-F /dev/null -p syslog,procmail -o nolookups -d" 25 | 26 | # Common definitions 27 | if test -z "${srcdir}"; then 28 | srcdir=`echo "$0" | sed 's,[^/]*$,,'` 29 | test "${srcdir}" = "$0" && srcdir=. 30 | test -z "${srcdir}" && srcdir=. 31 | test "${VERBOSE+set}" != set && VERBOSE=1 32 | fi 33 | . ${srcdir}/defs 34 | . ${srcdir}/do-test 35 | -------------------------------------------------------------------------------- /testsuite/defs: -------------------------------------------------------------------------------- 1 | ## -*- shell-script -*- 2 | ## defs - defines the testsuite enviroment 3 | ## Copyright (C) 2003 Gergely Nagy 4 | ## Based on defs (as found in The Autobook) by Gary V. Vaughan 5 | ## 6 | ## This file is part of CCZE. 7 | ## 8 | ## CCZE is free software; you can redistribute it and/or modify 9 | ## it under the terms of the GNU General Public License as published by 10 | ## the Free Software Foundation; either version 2 of the License, or 11 | ## (at your option) any later version. 12 | ## 13 | ## CCZE is distributed in the hope that it will be useful, 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ## GNU General Public License for more details. 17 | ## 18 | ## You should have received a copy of the GNU General Public License 19 | ## along with this program; if not, write to the Free Software 20 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | PACKAGE=${PACKAGE-ccze} 23 | 24 | srcdir=${srcdir-.} 25 | if test ! -d ${srcdir}; then 26 | echo "defs: installation error" 1>&2 27 | exit 1 28 | fi 29 | 30 | srcdir=`\cd ${srcdir} && pwd` 31 | top_builddir=`\cd ${top_builddir-..} && pwd` 32 | 33 | progname=`echo "$0" | sed 's,^.*/,,'` 34 | testname=`echo "${progname}" | sed 's,\.test$,,'` 35 | testsubdir=${testsubdir-test-tmp} 36 | 37 | # User can set VERBOSE to prevent output redirection 38 | TEST_DESC="" 39 | case x${VERBOSE} in 40 | xNO|xno|x0|x) 41 | exec 2>/dev/null 42 | exec 3>/dev/null 43 | ;; 44 | x1) 45 | exec 2>/dev/null 46 | exec 3>&1 47 | TEST_DESC="${DESCRIPTION}" 48 | ;; 49 | *) 50 | TEST_DESC="${DESCRIPTION}" 51 | exec 3>&1 52 | ;; 53 | esac 54 | 55 | rm -rf ${testsubdir} >/dev/null 2>&1 56 | mkdir ${testsubdir} 57 | cd ${testsubdir} \ 58 | || { echo "Cannot make or change into ${testsubdir}"; exit 1; } 59 | 60 | echo "=== Running test ${testname}" >&3 61 | if ! test -z "${TEST_DESC}"; then 62 | echo "=== ${TEST_DESC}" >&3 63 | fi 64 | 65 | CMP="${CMP-cmp}" 66 | RUNPROG="${top_builddir}/src/${PACKAGE}" 67 | -------------------------------------------------------------------------------- /FAQ: -------------------------------------------------------------------------------- 1 | CCZE Frequently Asked Questions -*- outline -*- 2 | =============================== 3 | 4 | * Compiling 5 | 6 | ** CCZE compiles fine, but dies with a relocation error. 7 | 8 | There is an issue with CCZE on some GNU/Linux platforms, when PCRE 9 | gets statically linked into the plugins (RedHat for example). Why this 10 | is a problem, and how to properly fix it, is beyond me. 11 | 12 | However, there is a workaround: When you configure CCZE, pass the 13 | `--with-builtins=all' option to configure. 14 | 15 | * Usage 16 | 17 | ** I would like to combine two files in one terminal. Can I do that? 18 | 19 | Of course! This is just a little bit of shell trickery. Lets suppose 20 | you want to view your access.log and your xferlog in the same terminal: 21 | 22 | server:/var/log# (tail -f apache/access.log & ; tail -f xferlog) | ccze 23 | 24 | ** I would like to combine two files, but with different options. 25 | 26 | This is possible too, once you have a recent enough CCZE (0.1.230 or 27 | later). Just launch any number of CCZEs in the background, in raw ANSI 28 | mode, like this: 29 | 30 | /var/log# (tail -f apache/access.log | ccze -A -p httpd -o nolookups) & 31 | /var/log# (tail -f syslog | ccze -A -p syslog) & 32 | /var/log# tail -f xferlog | ccze -A -p xferlog 33 | 34 | ** Is there an easy way to follow the html output in a browser? Like tail -f? 35 | 36 | Naturally! Although, it is not that simple as a `tail -f'.. Or maybe 37 | it is. 38 | 39 | Anyway: tail -f /var/log/syslog | ccze -h >~/logfiles/syslog.html 40 | 41 | And point your browser to ~/logfiles/syslog.html. 42 | 43 | A more dynamical approach would be this: 44 | 45 | ,----[ ccze.cgi ] 46 | | #! /bin/sh 47 | | cat <${PACKAGE}-${VERSION}.tar.gz 55 | test -z "${distdir}" || rm -rf "${distdir}" 56 | 57 | distcheck: dist 58 | ${GZIP} -dfc ${PACKAGE}-${VERSION}.tar.gz | tar ${TAR_OPTIONS} -xf - 59 | cd ${PACKAGE}-${VERSION} && ./configure --with-builtins=all 60 | ${MAKE} -C ${PACKAGE}-${VERSION} all install check dist \ 61 | DESTDIR=$(shell pwd)/${PACKAGE}-${VERSION} 62 | rm -rf ${PACKAGE}-${VERSION} 63 | @banner="${PACKAGE}-${VERSION}.tar.gz is ready for distribution." ;\ 64 | dashes=`echo "$$banner" | sed -e s/./=/g`; \ 65 | echo "$$dashes" ;\ 66 | echo "$$banner" ;\ 67 | echo "$$dashes" 68 | 69 | ${top_srcdir}/ccze.spec: ccze.spec.in Rules.mk ${top_srcdir}/ChangeLog 70 | sed -e "s,@VERSION@,${VERSION},g" -e "s,@DIST@,${DIST},g" \ 71 | <$@.in >$@ 72 | 73 | check: all 74 | ${MAKE} -C testsuite check 75 | 76 | .PHONY: all-recursive 77 | -------------------------------------------------------------------------------- /ccze.spec: -------------------------------------------------------------------------------- 1 | %define version 0.3.0 2 | %define dist stable 3 | %define release 1 4 | 5 | Summary: A robust log colorizer 6 | Name: ccze 7 | Version: %{version} 8 | Release: %{release} 9 | Vendor: Generic 10 | Packager: Gergely Nagy 11 | URL: http://bonehunter.rulez.org/CCZE.html 12 | Copyright: GPL 13 | Group: Applications/Text 14 | Source: ftp://bonehunter.rulez.org/pub/ccze/%{dist}/ccze-%{version}.tar.gz 15 | BuildRoot: %{_tmppath}/%{name}-root 16 | BuildPrereq: ncurses-devel >= 5.0, pcre-devel >= 3.1 17 | 18 | %description 19 | CCZE is a roboust and modular log colorizer, with plugins for apm, 20 | exim, fetchmail, httpd, postfix, procmail, squid, syslog, ulogd, 21 | vsftpd, xferlog and more. 22 | 23 | %prep 24 | %setup -q 25 | 26 | %build 27 | %configure --with-builtins=all 28 | make 29 | 30 | %install 31 | %makeinstall 32 | install -d %{buildroot}/%{_sysconfdir} 33 | src/ccze-dump >%{buildroot}/%{_sysconfdir}/cczerc 34 | 35 | %clean 36 | rm -rf %{buildroot} 37 | 38 | %files 39 | %defattr(-,root,root,-) 40 | %doc AUTHORS ChangeLog ChangeLog-0.1 NEWS README THANKS FAQ 41 | %config %{_sysconfdir}/cczerc 42 | %{_bindir}/ccze 43 | %{_bindir}/ccze-cssdump 44 | %{_includedir}/ccze.h 45 | %{_mandir}/man1/ccze.1* 46 | %{_mandir}/man1/ccze-cssdump.1* 47 | %{_mandir}/man7/ccze-plugin.7* 48 | 49 | %changelog 50 | * Sat Mar 29 2003 Gergely Nagy 51 | - Support different distributions than CCZE stable. 52 | * Tue Feb 25 2003 Gergely Nagy 53 | - Include FAQ. 54 | * Thu Feb 20 2003 Gergely Nagy 55 | - Use %{buildroot}, %configure and %makeinstall. 56 | - Improved description. 57 | * Sat Jan 25 2003 Gergely Nagy 58 | - Include %{_includedir}/ccze.h 59 | * Mon Jan 13 2003 Gergely Nagy 60 | - Include ccze-cssdump and its manual page. 61 | - Packager changed to myself. 62 | * Wed Nov 20 2002 Gergely Nagy 63 | - Build all modules statically. 64 | * Tue Nov 19 2002 Gergely Nagy 65 | - Use src/ccze-dump to generate the default configuration file. 66 | * Tue Nov 19 2002 Gergely Nagy 67 | - Simplified and made it version-neultral. 68 | * Sun Nov 17 2002 Andreas Brenk 69 | - Initial creation 70 | -------------------------------------------------------------------------------- /ccze.spec.in: -------------------------------------------------------------------------------- 1 | %define version @VERSION@ 2 | %define dist @DIST@ 3 | %define release 1 4 | 5 | Summary: A robust log colorizer 6 | Name: ccze 7 | Version: %{version} 8 | Release: %{release} 9 | Vendor: Generic 10 | Packager: Gergely Nagy 11 | URL: http://bonehunter.rulez.org/CCZE.html 12 | Copyright: GPL 13 | Group: Applications/Text 14 | Source: ftp://bonehunter.rulez.org/pub/ccze/%{dist}/ccze-%{version}.tar.gz 15 | BuildRoot: %{_tmppath}/%{name}-root 16 | BuildPrereq: ncurses-devel >= 5.0, pcre-devel >= 3.1 17 | 18 | %description 19 | CCZE is a roboust and modular log colorizer, with plugins for apm, 20 | exim, fetchmail, httpd, postfix, procmail, squid, syslog, ulogd, 21 | vsftpd, xferlog and more. 22 | 23 | %prep 24 | %setup -q 25 | 26 | %build 27 | %configure --with-builtins=all 28 | make 29 | 30 | %install 31 | %makeinstall 32 | install -d %{buildroot}/%{_sysconfdir} 33 | src/ccze-dump >%{buildroot}/%{_sysconfdir}/cczerc 34 | 35 | %clean 36 | rm -rf %{buildroot} 37 | 38 | %files 39 | %defattr(-,root,root,-) 40 | %doc AUTHORS ChangeLog ChangeLog-0.1 NEWS README THANKS FAQ 41 | %config %{_sysconfdir}/cczerc 42 | %{_bindir}/ccze 43 | %{_bindir}/ccze-cssdump 44 | %{_includedir}/ccze.h 45 | %{_mandir}/man1/ccze.1* 46 | %{_mandir}/man1/ccze-cssdump.1* 47 | %{_mandir}/man7/ccze-plugin.7* 48 | 49 | %changelog 50 | * Sat Mar 29 2003 Gergely Nagy 51 | - Support different distributions than CCZE stable. 52 | * Tue Feb 25 2003 Gergely Nagy 53 | - Include FAQ. 54 | * Thu Feb 20 2003 Gergely Nagy 55 | - Use %{buildroot}, %configure and %makeinstall. 56 | - Improved description. 57 | * Sat Jan 25 2003 Gergely Nagy 58 | - Include %{_includedir}/ccze.h 59 | * Mon Jan 13 2003 Gergely Nagy 60 | - Include ccze-cssdump and its manual page. 61 | - Packager changed to myself. 62 | * Wed Nov 20 2002 Gergely Nagy 63 | - Build all modules statically. 64 | * Tue Nov 19 2002 Gergely Nagy 65 | - Use src/ccze-dump to generate the default configuration file. 66 | * Tue Nov 19 2002 Gergely Nagy 67 | - Simplified and made it version-neultral. 68 | * Sun Nov 17 2002 Andreas Brenk 69 | - Initial creation 70 | -------------------------------------------------------------------------------- /Rules.mk.in: -------------------------------------------------------------------------------- 1 | ## Rules.mk -- Common variables and rules for all Makefiles -*- Makefile -*- 2 | 3 | SHELL = /bin/sh 4 | 5 | PACKAGE = ccze 6 | PATCHLEVEL = 0 7 | VERSION = 0.3.${PATCHLEVEL} 8 | DIST = stable 9 | 10 | PROGRAM = ${PACKAGE} 11 | VPATH = ${srcdir} 12 | 13 | ## -- User modifiable variables -- ## 14 | prefix = @prefix@ 15 | exec_prefix = @exec_prefix@ 16 | sysconfdir = @sysconfdir@ 17 | bindir = @bindir@ 18 | mandir = @mandir@ 19 | man1dir = ${mandir}/man1 20 | man7dir = ${mandir}/man7 21 | libdir = @libdir@ 22 | includedir = @includedir@ 23 | pkglibdir = ${libdir}/${PACKAGE} 24 | 25 | CC = @CC@ 26 | CFLAGS = @CFLAGS@ 27 | LDFLAGS = @LDFLAGS@ 28 | TAR = tar 29 | GZIP = gzip 30 | TAR_OPTIONS = 31 | GZIP_ENV = --best 32 | 33 | ETAGS = etags 34 | 35 | INSTALL = @INSTALL@ 36 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 37 | INSTALL_DATA = @INSTALL_DATA@ 38 | INSTALL_DIR = @INSTALL@ -d 39 | EXTRAVERSION = 40 | 41 | ## -- Private variables -- ## 42 | ifeq (${subdir},) 43 | top_builddir = . 44 | else 45 | top_builddir = .. 46 | endif 47 | builddir = @builddir@ 48 | 49 | DISTFILES = ${SOURCES} ${HEADERS} Makefile.in ${TESTS} ${EXTRA_DIST} 50 | 51 | ## -- Generic rules -- ## 52 | all: 53 | 54 | TAGS:: ${SOURCES} ${HEADERS} 55 | test -z "${SOURCES}${HEADERS}" || ${ETAGS} ${SOURCES} ${HEADERS} 56 | 57 | mostlyclean clean:: 58 | rm -f *~ *.o *.so *.da ${PROGRAM} TAGS 59 | test -z "${CLEANFILES}" || rm -rf ${CLEANFILES} 60 | distclean:: clean 61 | rm -f Makefile 62 | test -z "${DISTCLEANFILES}" || rm -rf ${DISTCLEANFILES} 63 | maintainer-clean:: distclean 64 | test -z "${MAINTCLEANFILES}" || rm -rf ${MAINTCLEANFILES} 65 | 66 | distdir = ${top_builddir}/${PACKAGE}-${VERSION}/${subdir} 67 | distdir: ${DISTFILES} 68 | ${INSTALL_DIR} ${distdir} 69 | @list='${DISTFILES}'; for f in $$list; do \ 70 | if test -e ${srcdir}/$$f; then \ 71 | fn=${srcdir}/$$f; \ 72 | else \ 73 | fn=$$f; \ 74 | fi ; \ 75 | echo cp -p $$fn ${distdir}/$$f ;\ 76 | cp -p $$fn ${distdir}/$$f ;\ 77 | done 78 | 79 | ${top_builddir}/Rules.mk: ${top_srcdir}/Rules.mk.in ${top_builddir}/config.status 80 | cd ${top_builddir} && ./config.status 81 | ${builddir}/Makefile: ${srcdir}/Makefile.in ${top_builddir}/config.status 82 | cd ${top_builddir} && ./config.status 83 | 84 | ## -- ${MAKE} control -- ## 85 | .PHONY: all install clean distclean mostlyclean uninstall maintainer-clean \ 86 | distdir dist distcheck 87 | .SUFFIXES: 88 | .SUFFIXES: .c .o .so 89 | .DEFAULT: all 90 | -------------------------------------------------------------------------------- /doc/ccze-cssdump.1.in: -------------------------------------------------------------------------------- 1 | .\" Hey Emacs! This is -*- nroff -*-! 2 | .\" Copyright (C) 2003 Gergely Nagy 3 | .\" 4 | .\" Permission is granted to make and distribute verbatim copies of this 5 | .\" manual provided the copyright notice and this permission notice are 6 | .\" preserved on all copies. 7 | .\" 8 | .\" Permission is granted to copy and distribute modified versions of this 9 | .\" manual under the conditions for verbatim copying, provided that the 10 | .\" entire resulting derived work is distributed under the terms of a 11 | .\" permission notice identical to this one. 12 | .\" 13 | .\" Permission is granted to copy and distribute translations of this 14 | .\" manual into another language, under the above conditions for modified 15 | .\" versions, except that this permission notice may be stated in a 16 | .\" translation approved by the Author. 17 | .TH CCZE-CSSDUMP 1 "2003-01-13" "CCZE @VERSION@" CCZE 18 | .SH NAME 19 | ccze\-cssdump \- Dump CCZE color setup into CSS format 20 | .SH SYNOPSIS 21 | .B ccze\-cssdump 22 | .RI [ options ] 23 | .SH DESCRIPTION 24 | This manual page documents briefly the 25 | .B ccze\-cssdump 26 | utility, which is a simple tool to dump the color setup of CCZE into 27 | Cascading Style Sheet format, to be used later by \fBccze \-h \-o 28 | cssfile\fR. 29 | .SH OPTIONS 30 | This program follows the usual GNU command line syntax, with long 31 | options starting with two dashes (`\-'). A summary of options is 32 | included below. 33 | .TP 34 | .B \-F, \-\-rcfile \fIrcfile\fB 35 | Read \fIrcfile\fR as a configuration file upon startup. 36 | .TP 37 | .B \-l, \-\-load 38 | Load the default configuration files upon startup. 39 | .TP 40 | .B \-\-help 41 | Show summary of options and exit. 42 | .TP 43 | .B \-V, \-\-version 44 | Show version of program. 45 | .SH FILES 46 | .TP 47 | .IR @sysconfdir@/colorizerc ", " $HOME/.colorizerc 48 | .RS 49 | These files are the default configuration files for \fBcolorize\fR, 50 | and are parsed by \fBccze\fR for the sake of full compatibility. 51 | .RE 52 | .IR @sysconfdir@/cczerc ", " $HOME/.cczerc 53 | .RS 54 | This two are the main configuration files, in which one can change the 55 | colors used by the program to his liking. See the comments in the 56 | beginning of \fI@sysconfdir@/cczerc\fR for a description on the files' 57 | structure. 58 | .RE 59 | .SH "SEE ALSO" 60 | .BR ccze (1) 61 | .SH AUTHOR 62 | ccze was written by Gergely Nagy , 63 | based on colorize by Istvan Karaszi . 64 | -------------------------------------------------------------------------------- /src/mod_php.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_php.c -- php.log colorizers for CCZE 3 | * Copyright (C) 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "ccze-compat.h" 27 | 28 | static void ccze_php_setup (void); 29 | static void ccze_php_shutdown (void); 30 | static int ccze_php_handle (const char *str, size_t length, char **rest); 31 | 32 | static pcre *reg_php; 33 | static pcre_extra *hints_php; 34 | 35 | static char * 36 | ccze_php_process (const char *str, int *offsets, int match) 37 | { 38 | char *date = NULL, *rest = NULL; 39 | 40 | pcre_get_substring (str, offsets, match, 1, (const char **)&date); 41 | pcre_get_substring (str, offsets, match, 2, (const char **)&rest); 42 | 43 | ccze_addstr (CCZE_COLOR_DATE, date); 44 | ccze_space (); 45 | ccze_addstr (CCZE_COLOR_KEYWORD, "PHP"); 46 | ccze_space (); 47 | 48 | free (date); 49 | 50 | return rest; 51 | } 52 | 53 | static void 54 | ccze_php_setup (void) 55 | { 56 | const char *error; 57 | int errptr; 58 | 59 | reg_php = pcre_compile ("^(\\[\\d+-...-\\d+ \\d+:\\d+:\\d+\\]) PHP (.*)$", 60 | 0, &error, &errptr, NULL); 61 | hints_php = pcre_study (reg_php, 0, &error); 62 | } 63 | 64 | static void 65 | ccze_php_shutdown (void) 66 | { 67 | free (reg_php); 68 | free (hints_php); 69 | } 70 | 71 | static int 72 | ccze_php_handle (const char *str, size_t length, char **rest) 73 | { 74 | int match, offsets[99]; 75 | 76 | if ((match = pcre_exec (reg_php, hints_php, str, length, 77 | 0, 0, offsets, 99)) >= 0) 78 | { 79 | *rest = ccze_php_process (str, offsets, match); 80 | return 1; 81 | } 82 | 83 | return 0; 84 | } 85 | 86 | CCZE_DEFINE_PLUGIN (php, FULL, "Coloriser for PHP logs."); 87 | -------------------------------------------------------------------------------- /testsuite/Makefile.in: -------------------------------------------------------------------------------- 1 | ## src/Makefile 2 | 3 | ## -- User-modifiable variables -- ## 4 | srcdir = @srcdir@ 5 | top_srcdir = @top_srcdir@ 6 | subdir = testsuite 7 | 8 | ## == The code below shouldn't need to be touched at all == ## 9 | 10 | include ../Rules.mk 11 | 12 | TESTS_ENVIRONMENT = top_builddir=$(top_builddir) \ 13 | VERSION=$(VERSION) 14 | TESTS = version.test bug-wnum.test bug-procmailsubj.test \ 15 | bug-procmailsubj2.test bug-sysrepeat.test bug-httpd.test 16 | TEST_IO = $(foreach test,${TESTS},\ 17 | $(addsuffix .ok,$(basename $(test)))) \ 18 | $(foreach test,${TESTS},\ 19 | $(addsuffix .in,$(basename $(test)))) 20 | EXTRA_DIST = defs do-test \ 21 | $(filter-out version.in,$(filter-out version.ok,\ 22 | ${TEST_IO})) 23 | 24 | ## -- Standard targets -- ## 25 | all: ; 26 | 27 | # Taken from autoconf 28 | check: ${TESTS} 29 | @failed=0; all=0; xfail=0; xpass=0; \ 30 | srcdir=$(srcdir); export srcdir; \ 31 | list='$(TESTS)'; \ 32 | if test -n "$$list"; then \ 33 | for tst in $$list; do \ 34 | if test -f ./$$tst; then dir=./; \ 35 | elif test -f $$tst; then dir=; \ 36 | else dir="$(srcdir)/"; fi; \ 37 | if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ 38 | all=`expr $$all + 1`; \ 39 | case " $(XFAIL_TESTS) " in \ 40 | *" $$tst "*) \ 41 | xpass=`expr $$xpass + 1`; \ 42 | failed=`expr $$failed + 1`; \ 43 | echo "XPASS: $$tst"; \ 44 | ;; \ 45 | *) \ 46 | echo "PASS: $$tst"; \ 47 | ;; \ 48 | esac; \ 49 | elif test $$? -ne 77; then \ 50 | all=`expr $$all + 1`; \ 51 | case " $(XFAIL_TESTS) " in \ 52 | *" $$tst "*) \ 53 | xfail=`expr $$xfail + 1`; \ 54 | echo "XFAIL: $$tst"; \ 55 | ;; \ 56 | *) \ 57 | failed=`expr $$failed + 1`; \ 58 | echo "FAIL: $$tst"; \ 59 | ;; \ 60 | esac; \ 61 | fi; \ 62 | done; \ 63 | if test "$$failed" -eq 0; then \ 64 | if test "$$xfail" -eq 0; then \ 65 | banner="All $$all tests passed"; \ 66 | else \ 67 | banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ 68 | fi; \ 69 | else \ 70 | if test "$$xpass" -eq 0; then \ 71 | banner="$$failed of $$all tests failed"; \ 72 | else \ 73 | banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ 74 | fi; \ 75 | fi; \ 76 | dashes=`echo "$$banner" | sed s/./=/g`; \ 77 | echo "$$dashes"; \ 78 | echo "$$banner"; \ 79 | echo "$$dashes"; \ 80 | test "$$failed" -eq 0; \ 81 | fi 82 | @rm -rf test-tmp 83 | -------------------------------------------------------------------------------- /testsuite/do-test: -------------------------------------------------------------------------------- 1 | ## -*- shell-script -*- 2 | ## do-test - run the test script 3 | ## Copyright (C) 2003 Gergely Nagy 4 | ## 5 | ## This file is part of CCZE. 6 | ## 7 | ## CCZE is free software; you can redistribute it and/or modify 8 | ## it under the terms of the GNU General Public License as published by 9 | ## the Free Software Foundation; either version 2 of the License, or 10 | ## (at your option) any later version. 11 | ## 12 | ## CCZE is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | 21 | # Run the test saving stderr to a file, and showing stdout if VERBOSE == 1 22 | if test -f ${srcdir}/${testname}.in; then 23 | ${RUNPROG} ${PROG_CMDLINE} < ${srcdir}/${testname}.in \ 24 | 2>${testname}.err | tee -i ${testname}.out >&2 25 | else 26 | if test -f ${testname}.in; then 27 | ${RUNPROG} ${PROG_CMDLINE} < ${testname}.in \ 28 | 2>${testname}.err | tee -i ${testname}.out >&2 29 | else 30 | ${RUNPROG} ${PROG_CMDLINE} 2>${testname}.err | \ 31 | tee -i ${testname}.out >&2 32 | fi 33 | fi 34 | 35 | if test -f ${srcdir}/${testname}.ok; then 36 | TEST_OK_LIST=${TEST_OK_LIST-${srcdir}/${testname}.ok} 37 | fi 38 | 39 | if test -f ${srcdir}/${testname}.errok; then 40 | TEST_ERROK_LIST=${TEST_ERROK_LIST-${srcdir}/${testname}.errok} 41 | fi 42 | 43 | # Test against expected output 44 | case x${TEST_OK_LIST} in 45 | x) 46 | TEST_OK=yes 47 | ;; 48 | x*) 49 | TEST_OK=no 50 | ;; 51 | esac 52 | 53 | for f in ${TEST_OK_LIST}; do 54 | if test -f $f; then 55 | if ${CMP} -s ${testname}.out $f; then 56 | TEST_OK=yes 57 | fi 58 | fi 59 | done 60 | 61 | if ! test ${TEST_OK} = yes; then 62 | echo "ok:" >&2 63 | cat ${testname}.ok >&2 64 | exit 1 65 | fi 66 | 67 | # Munge error output to remove leading directories, `lt-' or trailing `.exe' 68 | sed -e "s,^[^:]*[lt-]*${PACKAGE}[.ex]*:,${PACKAGE}:," \ 69 | ${testname}.err > sederr && mv sederr ${testname}.err 70 | 71 | # Show stderr if doesn't match expected output if VERBOSE == 1 72 | case x${TEST_ERROK_LIST} in 73 | x) 74 | TEST_ERROK=yes 75 | ;; 76 | x*) 77 | TEST_ERROK=no 78 | ;; 79 | esac 80 | 81 | for f in ${TEST_ERROK_LIST}; do 82 | if test -f $f; then 83 | if ${CMP} -s ${testname}.err $f; then 84 | TEST_ERROK=yes 85 | fi 86 | fi 87 | done 88 | 89 | if ! test ${TEST_ERROK} = yes; then 90 | echo "err:" >&2 91 | cat ${testname}.err >&2 92 | echo "errok:" >&2 93 | cat ${testname}.errok >&2 94 | exit 1 95 | fi 96 | -------------------------------------------------------------------------------- /src/mod_ulogd.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_ulogd.c -- ulogd-related colorizers for CCZE 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "ccze-compat.h" 27 | 28 | static void ccze_ulogd_setup (void); 29 | static void ccze_ulogd_shutdown (void); 30 | static int ccze_ulogd_handle (const char *str, size_t length, char **rest); 31 | 32 | static pcre *reg_ulogd; 33 | 34 | static char * 35 | ccze_ulogd_process (const char *msg) 36 | { 37 | char *word, *tmp, *field, *value; 38 | char *msg2 = xstrdup (msg); 39 | 40 | word = xstrdup (ccze_strbrk (msg2, ' ')); 41 | do 42 | { 43 | if ((tmp = strchr (word, '=')) != NULL) 44 | { 45 | field = strndup (word, tmp - word); 46 | value = strdup (tmp + 1); 47 | ccze_addstr (CCZE_COLOR_FIELD, field); 48 | ccze_addstr (CCZE_COLOR_DEFAULT, "="); 49 | ccze_wordcolor_process_one (value, 1); 50 | free (field); 51 | ccze_space (); 52 | } 53 | else 54 | { 55 | ccze_addstr (CCZE_COLOR_FIELD, word); 56 | ccze_space (); 57 | } 58 | } while ((word = xstrdup (ccze_strbrk (NULL, ' '))) != NULL); 59 | free (msg2); 60 | 61 | return NULL; 62 | } 63 | 64 | static void 65 | ccze_ulogd_setup (void) 66 | { 67 | const char *error; 68 | int errptr; 69 | 70 | reg_ulogd = pcre_compile 71 | ("(IN|OUT|MAC|TTL|SRC|TOS|PREC|SPT)=", 0, &error, 72 | &errptr, NULL); 73 | } 74 | 75 | static void 76 | ccze_ulogd_shutdown (void) 77 | { 78 | free (reg_ulogd); 79 | } 80 | 81 | static int 82 | ccze_ulogd_handle (const char *str, size_t length, char **rest) 83 | { 84 | int offsets[10]; 85 | 86 | if (pcre_exec (reg_ulogd, NULL, str, length, 0, 0, offsets, 2) >= 0) 87 | { 88 | if (rest) 89 | *rest = ccze_ulogd_process (str); 90 | else 91 | ccze_ulogd_process (str); 92 | 93 | return 1; 94 | } 95 | 96 | return 0; 97 | } 98 | 99 | CCZE_DEFINE_PLUGIN (ulogd, PARTIAL, "Coloriser for ulogd sub-logs."); 100 | -------------------------------------------------------------------------------- /src/mod_distcc.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_distcc.c -- distcc.log colorizers for CCZE 3 | * Copyright (C) 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "ccze-compat.h" 27 | 28 | static void ccze_distcc_setup (void); 29 | static void ccze_distcc_shutdown (void); 30 | static int ccze_distcc_handle (const char *str, size_t length, char **rest); 31 | 32 | static pcre *reg_distcc; 33 | static pcre_extra *hints_distcc; 34 | 35 | static char * 36 | ccze_distcc_process (const char *str, int *offsets, int match) 37 | { 38 | char *pid, *func, *rest; 39 | 40 | pcre_get_substring (str, offsets, match, 1, (const char **)&pid); 41 | pcre_get_substring (str, offsets, match, 2, (const char **)&func); 42 | pcre_get_substring (str, offsets, match, 3, (const char **)&rest); 43 | 44 | ccze_addstr (CCZE_COLOR_PROC, "distccd"); 45 | ccze_addstr (CCZE_COLOR_PIDB, "["); 46 | ccze_addstr (CCZE_COLOR_PID, pid); 47 | ccze_addstr (CCZE_COLOR_PIDB, "]"); 48 | ccze_space (); 49 | 50 | if (func && func[0] != '\0') 51 | { 52 | ccze_addstr (CCZE_COLOR_KEYWORD, func); 53 | ccze_space (); 54 | } 55 | 56 | free (pid); 57 | free (func); 58 | 59 | return rest; 60 | } 61 | 62 | static void 63 | ccze_distcc_setup (void) 64 | { 65 | const char *error; 66 | int errptr; 67 | 68 | reg_distcc = pcre_compile ("^distccd\\[(\\d+)\\] (\\([^\\)]+\\))? ?(.*)", 69 | 0, &error, &errptr, NULL); 70 | hints_distcc = pcre_study (reg_distcc, 0, &error); 71 | } 72 | 73 | static void 74 | ccze_distcc_shutdown (void) 75 | { 76 | free (reg_distcc); 77 | free (hints_distcc); 78 | } 79 | 80 | static int 81 | ccze_distcc_handle (const char *str, size_t length, char **rest) 82 | { 83 | int match, offsets[99]; 84 | 85 | if ((match = pcre_exec (reg_distcc, hints_distcc, str, length, 86 | 0, 0, offsets, 99)) >= 0) 87 | { 88 | *rest = ccze_distcc_process (str, offsets, match); 89 | return 1; 90 | } 91 | 92 | return 0; 93 | } 94 | 95 | CCZE_DEFINE_PLUGIN (distcc, FULL, "Coloriser for distcc(1) logs."); 96 | -------------------------------------------------------------------------------- /src/mod_super.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_super.c -- super-related colorizers for CCZE 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | static void ccze_super_setup (void); 26 | static void ccze_super_shutdown (void); 27 | static int ccze_super_handle (const char *str, size_t length, char **rest); 28 | 29 | static pcre *reg_super; 30 | static pcre_extra *hints_super; 31 | 32 | static char * 33 | ccze_super_process (const char *str, int *offsets, int match) 34 | { 35 | char *email, *date, *space, *suptag, *other; 36 | 37 | pcre_get_substring (str, offsets, match, 1, (const char **)&email); 38 | pcre_get_substring (str, offsets, match, 2, (const char **)&date); 39 | pcre_get_substring (str, offsets, match, 3, (const char **)&space); 40 | pcre_get_substring (str, offsets, match, 4, (const char **)&suptag); 41 | pcre_get_substring (str, offsets, match, 5, (const char **)&other); 42 | 43 | ccze_addstr (CCZE_COLOR_EMAIL, email); 44 | ccze_space (); 45 | ccze_addstr (CCZE_COLOR_DATE, date); 46 | ccze_addstr (CCZE_COLOR_DEFAULT, space); 47 | ccze_addstr (CCZE_COLOR_PROC, suptag); 48 | ccze_space (); 49 | ccze_addstr (CCZE_COLOR_PIDB, "("); 50 | ccze_addstr (CCZE_COLOR_DEFAULT, other); 51 | ccze_addstr (CCZE_COLOR_PIDB, ")"); 52 | 53 | ccze_newline (); 54 | 55 | return NULL; 56 | } 57 | 58 | static void 59 | ccze_super_setup (void) 60 | { 61 | const char *error; 62 | int errptr; 63 | 64 | reg_super = pcre_compile 65 | ("^(\\S+)\\s(\\w+\\s+\\w+\\s+\\d+\\s+\\d+:\\d+:\\d+\\s+\\d+)" 66 | "(\\s+)(\\S+)\\s\\(([^\\)]+)\\)", 0, &error, &errptr, NULL); 67 | hints_super = pcre_study (reg_super, 0, &error); 68 | } 69 | 70 | static void 71 | ccze_super_shutdown (void) 72 | { 73 | free (reg_super); 74 | free (hints_super); 75 | } 76 | 77 | static int 78 | ccze_super_handle (const char *str, size_t length, char **rest) 79 | { 80 | int match, offsets[99]; 81 | 82 | if ((match = pcre_exec (reg_super, hints_super, str, length, 83 | 0, 0, offsets, 99)) >= 0) 84 | { 85 | *rest = ccze_super_process (str, offsets, match); 86 | return 1; 87 | } 88 | 89 | return 0; 90 | } 91 | 92 | CCZE_DEFINE_PLUGIN (super, FULL, "Coloriser for super(1) logs."); 93 | -------------------------------------------------------------------------------- /src/mod_fetchmail.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_fetchmail.c -- fetchmail-related colorizers for CCZE 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | static void ccze_fetchmail_setup (void); 27 | static void ccze_fetchmail_shutdown (void); 28 | static int ccze_fetchmail_handle (const char *str, size_t length, char **rest); 29 | 30 | static pcre *reg_fetchmail; 31 | 32 | static char * 33 | ccze_fetchmail_process (const char *str, int *offsets, int match) 34 | { 35 | char *start, *addy, *current, *full, *rest; 36 | 37 | pcre_get_substring (str, offsets, match, 1, (const char **)&start); 38 | pcre_get_substring (str, offsets, match, 2, (const char **)&addy); 39 | pcre_get_substring (str, offsets, match, 3, (const char **)¤t); 40 | pcre_get_substring (str, offsets, match, 4, (const char **)&full); 41 | pcre_get_substring (str, offsets, match, 5, (const char **)&rest); 42 | 43 | ccze_addstr (CCZE_COLOR_DEFAULT, start); 44 | ccze_space (); 45 | ccze_addstr (CCZE_COLOR_EMAIL, addy); 46 | ccze_addstr (CCZE_COLOR_DEFAULT, ":"); 47 | ccze_addstr (CCZE_COLOR_NUMBERS, current); 48 | ccze_space (); 49 | ccze_addstr (CCZE_COLOR_DEFAULT, "of"); 50 | ccze_space (); 51 | ccze_addstr (CCZE_COLOR_NUMBERS, full); 52 | ccze_space (); 53 | 54 | free (start); 55 | free (addy); 56 | free (current); 57 | free (full); 58 | 59 | return rest; 60 | } 61 | 62 | static void 63 | ccze_fetchmail_setup (void) 64 | { 65 | const char *error; 66 | int errptr; 67 | 68 | reg_fetchmail = pcre_compile 69 | ("(reading message) ([^@]*@[^:]*):([0-9]*) of ([0-9]*) (.*)", 0, 70 | &error, &errptr, NULL); 71 | } 72 | 73 | static void 74 | ccze_fetchmail_shutdown (void) 75 | { 76 | free (reg_fetchmail); 77 | } 78 | 79 | static int 80 | ccze_fetchmail_handle (const char *str, size_t length, char **rest) 81 | { 82 | int offsets[99], match; 83 | 84 | if ((match = pcre_exec (reg_fetchmail, NULL, str, length, 0, 0, offsets, 99)) >= 0) 85 | { 86 | if (rest) 87 | *rest = ccze_fetchmail_process (str, offsets, match); 88 | else 89 | ccze_fetchmail_process (str, offsets, match); 90 | 91 | return 1; 92 | } 93 | 94 | return 0; 95 | } 96 | 97 | CCZE_DEFINE_PLUGIN (fetchmail, PARTIAL, 98 | "Coloriser for fetchmail(1) sub-logs."); 99 | -------------------------------------------------------------------------------- /src/ccze-cssdump.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * ccze-cssdump.c -- Dump internal color table into css format 3 | * Copyright (C) 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #ifdef HAVE_ARGP_H 24 | # include 25 | #endif 26 | 27 | #include "ccze-compat.h" 28 | #include "ccze-private.h" 29 | #include "ccze-color.c" 30 | 31 | const char *argp_program_name = "ccze-cssdump"; 32 | const char *argp_program_version = "ccze-cssdump (ccze 0.1." PATCHLEVEL ")"; 33 | const char *argp_program_bug_address = ""; 34 | static struct argp_option options[] = { 35 | {NULL, 0, NULL, 0, "", 1}, 36 | {"rcfile", 'F', "FILE", 0, "Read configuration from FILE", 1}, 37 | {"load", 'l', NULL, 0, "Load default configuration files", 1}, 38 | {NULL, 0, NULL, 0, NULL, 0} 39 | }; 40 | 41 | ccze_config_t ccze_config = { 42 | .scroll = 1, 43 | .convdate = 0, 44 | .remfac = 0, 45 | .wcol = 1, 46 | .slookup = 1, 47 | .rcfile = NULL, 48 | .cssfile = NULL, 49 | .transparent = 1, 50 | .pluginlist_len = 0, 51 | .pluginlist_alloc = 10, 52 | .color_argv_len = 0, 53 | .color_argv_alloc = 10, 54 | .mode = CCZE_MODE_HTML 55 | }; 56 | 57 | static error_t parse_opt (int key, char *arg, struct argp_state *state); 58 | static struct argp argp = 59 | {options, parse_opt, 0, "ccze -- cheer up 'yer logs.", NULL, NULL, NULL}; 60 | 61 | static int ccze_loaddefs = 0; 62 | 63 | static error_t 64 | parse_opt (int key, char *arg, struct argp_state *state) 65 | { 66 | switch (key) 67 | { 68 | case 'F': 69 | ccze_config.rcfile = arg; 70 | break; 71 | case 'l': 72 | ccze_loaddefs = 1; 73 | break; 74 | default: 75 | return ARGP_ERR_UNKNOWN; 76 | } 77 | return 0; 78 | } 79 | 80 | int 81 | main (int argc, char *argv[]) 82 | { 83 | argp_parse (&argp, argc, argv, 0, 0, NULL); 84 | 85 | ccze_color_init (); 86 | 87 | if (ccze_config.rcfile) 88 | ccze_color_load (ccze_config.rcfile); 89 | else if (ccze_loaddefs) 90 | { 91 | char *home, *homerc; 92 | 93 | ccze_color_load (SYSCONFDIR "/colorizerc"); 94 | ccze_color_load (SYSCONFDIR "/cczerc"); 95 | home = getenv ("HOME"); 96 | if (home) 97 | { 98 | asprintf (&homerc, "%s/.colorizerc", home); 99 | ccze_color_load (homerc); 100 | free (homerc); 101 | asprintf (&homerc, "%s/.cczerc", home); 102 | ccze_color_load (homerc); 103 | free (homerc); 104 | } 105 | } 106 | 107 | ccze_colors_to_css (); 108 | return 0; 109 | } 110 | -------------------------------------------------------------------------------- /src/mod_vsftpd.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_vstpd.c -- VSFTPd-related colorizers for CCZE 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | static void ccze_vsftpd_setup (void); 26 | static void ccze_vsftpd_shutdown (void); 27 | static int ccze_vsftpd_handle (const char *str, size_t length, char **rest); 28 | 29 | static pcre *reg_vsftpd; 30 | static pcre_extra *hints_vsftpd; 31 | 32 | static char * 33 | ccze_vsftpd_log_process (const char *str, int *offsets, int match) 34 | { 35 | char *date, *sspace, *pid, *user, *other; 36 | 37 | pcre_get_substring (str, offsets, match, 1, (const char **)&date); 38 | pcre_get_substring (str, offsets, match, 2, (const char **)&sspace); 39 | pcre_get_substring (str, offsets, match, 3, (const char **)&pid); 40 | pcre_get_substring (str, offsets, match, 5, (const char **)&user); 41 | pcre_get_substring (str, offsets, match, 6, (const char **)&other); 42 | 43 | ccze_addstr (CCZE_COLOR_DATE, date); 44 | ccze_addstr (CCZE_COLOR_DEFAULT, sspace); 45 | 46 | ccze_addstr (CCZE_COLOR_PIDB, "["); 47 | ccze_addstr (CCZE_COLOR_DEFAULT, "pid "); 48 | ccze_addstr (CCZE_COLOR_PID, pid); 49 | ccze_addstr (CCZE_COLOR_PIDB, "]"); 50 | ccze_space(); 51 | 52 | if (*user) 53 | { 54 | ccze_addstr (CCZE_COLOR_PIDB, "["); 55 | ccze_addstr (CCZE_COLOR_USER, user); 56 | ccze_addstr (CCZE_COLOR_PIDB, "]"); 57 | ccze_space (); 58 | } 59 | 60 | free (date); 61 | free (sspace); 62 | free (pid); 63 | free (user); 64 | 65 | return other; 66 | } 67 | 68 | static void 69 | ccze_vsftpd_setup (void) 70 | { 71 | const char *error; 72 | int errptr; 73 | 74 | reg_vsftpd = pcre_compile 75 | ("^(\\S+\\s+\\S+\\s+\\d{1,2}\\s+\\d{1,2}:\\d{1,2}:\\d{1,2}\\s+\\d+)" 76 | "(\\s+)\\[pid (\\d+)\\]\\s+(\\[(\\S+)\\])?\\s*(.*)$", 0, &error, 77 | &errptr, NULL); 78 | hints_vsftpd = pcre_study (reg_vsftpd, 0, &error); 79 | } 80 | 81 | static void 82 | ccze_vsftpd_shutdown (void) 83 | { 84 | free (reg_vsftpd); 85 | free (hints_vsftpd); 86 | } 87 | 88 | static int 89 | ccze_vsftpd_handle (const char *str, size_t length, char **rest) 90 | { 91 | int match, offsets[99]; 92 | 93 | if ((match = pcre_exec (reg_vsftpd, hints_vsftpd, str, length, 94 | 0, 0, offsets, 99)) >= 0) 95 | { 96 | *rest = ccze_vsftpd_log_process (str, offsets, match); 97 | return 1; 98 | } 99 | 100 | return 0; 101 | } 102 | 103 | CCZE_DEFINE_PLUGIN (vsftpd, FULL, "Coloriser for vsftpd(8) logs."); 104 | -------------------------------------------------------------------------------- /src/ccze-compat.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * ccze-compat.h -- OS compatibility stuff for CCZE, prototypes 3 | * Copyright (C) 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef _CCZE_COMPAT_H 23 | #define _CCZE_COMPAT_H 1 24 | 25 | #include "system.h" 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #ifndef HAVE_STRNDUP 33 | char *strndup (const char *s, size_t size); 34 | #endif 35 | int ccze_getsubopt (char **optionp, char *const *tokens, 36 | char **valuep); 37 | 38 | #ifndef HAVE_SCANDIR 39 | int scandir (const char *dir, struct dirent ***namelist, 40 | int (*select)(const struct dirent *), 41 | int (*compar)(const struct dirent **, const struct dirent **)); 42 | #endif 43 | #ifndef HAVE_ALPHASORT 44 | int alphasort (const struct dirent **a, const struct dirent **b) 45 | #endif 46 | 47 | #ifndef HAVE_ASPRINTF 48 | int 49 | asprintf(char **ptr, const char *fmt, ...); 50 | #endif 51 | 52 | #ifndef HAVE_ARGP_PARSE 53 | struct argp_option 54 | { 55 | char *name; 56 | int key; 57 | const char *arg; 58 | int flags; 59 | char *doc; 60 | int group; 61 | }; 62 | struct argp; 63 | struct argp_state; 64 | typedef error_t (*argp_parser_t) (int key, char *arg, 65 | struct argp_state *state); 66 | #define ARGP_ERR_UNKNOWN E2BIG 67 | #define OPTION_HIDDEN 0x2 68 | struct argp 69 | { 70 | const struct argp_option *options; 71 | argp_parser_t parser; 72 | const char *args_doc; 73 | const char *doc; 74 | /* The rest is ignored */ 75 | const void *children; 76 | char *(*help_filter) (int key, const char *text, void *input); 77 | const char *domain; 78 | }; 79 | 80 | struct argp_state 81 | { 82 | /* This is deliberately not compatible with glibc's one. We only use 83 | ->input anyway */ 84 | void *input; 85 | }; 86 | 87 | extern const char *argp_program_version; 88 | extern const char *argp_program_bug_address; 89 | extern const char *argp_program_name; 90 | 91 | error_t argp_parse (const struct argp *argps, int argc, char **argv, 92 | unsigned flags, int arg_index, void *input); 93 | error_t argp_error (const struct argp_state *state, char *fmt, ...) 94 | __attribute__ ((noreturn)); 95 | #endif 96 | 97 | #ifndef HAVE_GETLINE 98 | ssize_t getline(char **lineptr, size_t *n, FILE *stream); 99 | #endif 100 | #ifndef HAVE_GETDELIM 101 | ssize_t 102 | getdelim (char **lineptr, size_t *n, int delim, FILE *stream); 103 | #endif 104 | 105 | #ifdef _AIX 106 | char *strndup (const char *s, size_t size); 107 | #endif 108 | 109 | #endif /* !_CCZE_COMPAT_H */ 110 | -------------------------------------------------------------------------------- /src/mod_sulog.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_sulog.c -- su-related colorizers for CCZE 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | static void ccze_sulog_setup (void); 26 | static void ccze_sulog_shutdown (void); 27 | static int ccze_sulog_handle (const char *str, size_t length, char **rest); 28 | 29 | static pcre *reg_sulog; 30 | static pcre_extra *hints_sulog; 31 | 32 | static char * 33 | ccze_sulog_process (const char *str, int *offsets, int match) 34 | { 35 | char *date, *islogin, *tty, *fromuser, *touser; 36 | 37 | pcre_get_substring (str, offsets, match, 1, (const char **)&date); 38 | pcre_get_substring (str, offsets, match, 2, (const char **)&islogin); 39 | pcre_get_substring (str, offsets, match, 3, (const char **)&tty); 40 | pcre_get_substring (str, offsets, match, 4, (const char **)&fromuser); 41 | pcre_get_substring (str, offsets, match, 5, (const char **)&touser); 42 | 43 | ccze_addstr (CCZE_COLOR_DEFAULT, "SU "); 44 | ccze_addstr (CCZE_COLOR_DATE, date); 45 | ccze_space (); 46 | ccze_addstr (CCZE_COLOR_DEFAULT, islogin); 47 | ccze_space (); 48 | switch (tty[0]) 49 | { 50 | case '?': 51 | ccze_addstr (CCZE_COLOR_UNKNOWN, tty); 52 | break; 53 | default: 54 | ccze_addstr (CCZE_COLOR_DIR, tty); 55 | break; 56 | } 57 | ccze_space (); 58 | ccze_addstr (CCZE_COLOR_USER, fromuser); 59 | ccze_addstr (CCZE_COLOR_DEFAULT, "-"); 60 | ccze_addstr (CCZE_COLOR_USER, touser); 61 | 62 | ccze_newline (); 63 | 64 | free (date); 65 | free (islogin); 66 | free (tty); 67 | free (fromuser); 68 | free (touser); 69 | 70 | return NULL; 71 | } 72 | 73 | static void 74 | ccze_sulog_setup (void) 75 | { 76 | const char *error; 77 | int errptr; 78 | 79 | reg_sulog = pcre_compile ("^SU (\\d{2}\\/\\d{2} \\d{2}:\\d{2}) ([\\+\\-]) " 80 | "(\\S+) ([^\\-]+)-(.*)$", 0, &error, &errptr, 81 | NULL); 82 | hints_sulog = pcre_study (reg_sulog, 0, &error); 83 | } 84 | 85 | static void 86 | ccze_sulog_shutdown (void) 87 | { 88 | free (reg_sulog); 89 | free (hints_sulog); 90 | } 91 | 92 | static int 93 | ccze_sulog_handle (const char *str, size_t length, char **rest) 94 | { 95 | int match, offsets[99]; 96 | 97 | if ((match = pcre_exec (reg_sulog, hints_sulog, str, length, 98 | 0, 0, offsets, 99)) >= 0) 99 | { 100 | *rest = ccze_sulog_process (str, offsets, match); 101 | return 1; 102 | } 103 | 104 | return 0; 105 | } 106 | 107 | CCZE_DEFINE_PLUGIN (sulog, FULL, "Coloriser for su(1) logs."); 108 | -------------------------------------------------------------------------------- /src/mod_postfix.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_postfix.c -- Postfix colorizer for CCZE 3 | * Copyright (C) 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "ccze-compat.h" 27 | 28 | static void ccze_postfix_setup (void); 29 | static void ccze_postfix_shutdown (void); 30 | static int ccze_postfix_handle (const char *str, size_t length, char **rest); 31 | 32 | static pcre *reg_postfix; 33 | 34 | static int 35 | _ccze_postfix_process_one (const char *s, char **rest) 36 | { 37 | char *field, *value; 38 | size_t i; 39 | 40 | if (!strchr (s, '=')) 41 | return 1; 42 | 43 | field = strndup (s, strchr (s, '=') - s); 44 | i = strlen (s); 45 | i -= strlen (field) + 1; 46 | value = strndup (&s[strlen (field) + 1], i); 47 | 48 | ccze_addstr (CCZE_COLOR_FIELD, field); 49 | ccze_addstr (CCZE_COLOR_DEFAULT, "="); 50 | ccze_wordcolor_process_one (value, 1); 51 | 52 | return 0; 53 | } 54 | 55 | static char * 56 | ccze_postfix_process (const char *str, int *offsets, int match) 57 | { 58 | char *spoolid, *s, *rest, *tmp; 59 | int r; 60 | 61 | pcre_get_substring (str, offsets, match, 1, (const char **)&spoolid); 62 | pcre_get_substring (str, offsets, match, 2, (const char **)&s); 63 | pcre_get_substring (str, offsets, match, 4, (const char **)&rest); 64 | 65 | ccze_addstr (CCZE_COLOR_UNIQN, spoolid); 66 | ccze_addstr (CCZE_COLOR_DEFAULT, ": "); 67 | 68 | tmp = ccze_strbrk (s, ','); 69 | 70 | do 71 | { 72 | r = _ccze_postfix_process_one (tmp, &rest); 73 | if (r) 74 | ccze_addstr (CCZE_COLOR_DEFAULT, tmp); 75 | else 76 | tmp = ccze_strbrk (NULL, ','); 77 | if (tmp) 78 | ccze_addstr (CCZE_COLOR_DEFAULT, ","); 79 | } while (!r && (tmp != NULL)); 80 | 81 | return NULL; 82 | } 83 | 84 | static void 85 | ccze_postfix_setup (void) 86 | { 87 | const char *error; 88 | int errptr; 89 | 90 | reg_postfix = pcre_compile 91 | ("^([\\dA-F]+): ((client|to|message-id|uid|resent-message-id|from)(=.*))", 92 | 0, &error, &errptr, NULL); 93 | } 94 | 95 | static void 96 | ccze_postfix_shutdown (void) 97 | { 98 | free (reg_postfix); 99 | } 100 | 101 | static int 102 | ccze_postfix_handle (const char *str, size_t length, char **rest) 103 | { 104 | int match, offsets[99]; 105 | 106 | if ((match = pcre_exec (reg_postfix, NULL, str, length, 107 | 0, 0, offsets, 99)) >= 0) 108 | { 109 | if (rest) 110 | *rest = ccze_postfix_process (str, offsets, match); 111 | else 112 | ccze_postfix_process (str, offsets, match); 113 | 114 | return 1; 115 | } 116 | 117 | return 0; 118 | } 119 | 120 | CCZE_DEFINE_PLUGIN (postfix, PARTIAL, "Coloriser for postfix(1) sub-logs."); 121 | -------------------------------------------------------------------------------- /src/mod_apm.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_apm.c -- apm colorizers for CCZE 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | static void ccze_apm_setup (void); 27 | static void ccze_apm_shutdown (void); 28 | static int ccze_apm_handle (const char *str, size_t length, char **rest); 29 | 30 | static pcre *reg_apm; 31 | 32 | static char * 33 | ccze_apm_process (const char *str, int *offsets, int match) 34 | { 35 | char *battery, *charge, *rate, *stuff1, *elapsed, *remain; 36 | char *stuff2; 37 | 38 | pcre_get_substring (str, offsets, match, 1, (const char **)&battery); 39 | pcre_get_substring (str, offsets, match, 2, (const char **)&charge); 40 | pcre_get_substring (str, offsets, match, 4, (const char **)&rate); 41 | pcre_get_substring (str, offsets, match, 5, (const char **)&stuff1); 42 | pcre_get_substring (str, offsets, match, 6, (const char **)&elapsed); 43 | pcre_get_substring (str, offsets, match, 7, (const char **)&remain); 44 | pcre_get_substring (str, offsets, match, 8, (const char **)&stuff2); 45 | 46 | ccze_addstr (CCZE_COLOR_DEFAULT, "Battery:"); 47 | ccze_space (); 48 | ccze_addstr (CCZE_COLOR_PERCENTAGE, battery); 49 | ccze_addstr (CCZE_COLOR_DEFAULT, "%,"); 50 | ccze_space (); 51 | ccze_addstr (CCZE_COLOR_SYSTEMWORD, charge); 52 | ccze_space (); 53 | ccze_addstr (CCZE_COLOR_DEFAULT, "("); 54 | ccze_addstr (CCZE_COLOR_PERCENTAGE, rate); 55 | ccze_addstr (CCZE_COLOR_DEFAULT, "%"); 56 | ccze_space (); 57 | ccze_addstr (CCZE_COLOR_DEFAULT, stuff1); 58 | ccze_space (); 59 | ccze_addstr (CCZE_COLOR_DATE, elapsed); 60 | ccze_addstr (CCZE_COLOR_DEFAULT, "),"); 61 | ccze_space (); 62 | ccze_addstr (CCZE_COLOR_DATE, remain); 63 | ccze_space (); 64 | 65 | free (battery); 66 | free (charge); 67 | free (rate); 68 | free (stuff1); 69 | free (elapsed); 70 | free (remain); 71 | 72 | return stuff2; 73 | } 74 | 75 | static void 76 | ccze_apm_setup (void) 77 | { 78 | const char *error; 79 | int errptr; 80 | 81 | reg_apm = pcre_compile 82 | ("Battery: (-?\\d*)%, ((.*)charging) \\((-?\\d*)% ([^ ]*) " 83 | "(\\d*:\\d*:\\d*)\\), (\\d*:\\d*:\\d*) (.*)", 0, &error, &errptr, NULL); 84 | } 85 | 86 | static void 87 | ccze_apm_shutdown (void) 88 | { 89 | free (reg_apm); 90 | } 91 | 92 | static int 93 | ccze_apm_handle (const char *str, size_t length, char **rest) 94 | { 95 | int match, offsets[99]; 96 | 97 | if ((match = pcre_exec (reg_apm, NULL, str, length, 98 | 0, 0, offsets, 99)) >= 0) 99 | { 100 | if (rest) 101 | *rest = ccze_apm_process (str, offsets, match); 102 | else 103 | ccze_apm_process (str, offsets, match); 104 | 105 | return 1; 106 | } 107 | 108 | return 0; 109 | } 110 | 111 | CCZE_DEFINE_PLUGIN (apm, PARTIAL, "Coloriser for APM sub-logs."); 112 | -------------------------------------------------------------------------------- /src/ccze-private.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * ccze-private.h -- Internal CCZE function prototypes 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef _CCZE_PRIVATE_H 23 | #define _CCZE_PRIVATE_H 1 24 | 25 | #include 26 | 27 | /* ccze-keywordlookup.c */ 28 | 29 | typedef struct _keyword_t keyword_t; 30 | typedef struct { 31 | keyword_t * keywords[256]; 32 | size_t keywords_nr[256]; 33 | int keywords_sorted; 34 | } keywords_t; 35 | 36 | void ccze_keyword_clean(keywords_t * K); 37 | void ccze_keyword_add(keywords_t * K, const char ** words, size_t words_nr, ccze_color_t color); 38 | void ccze_keyword_add1(keywords_t * K, const char * word, ccze_color_t color); 39 | int ccze_keyword_match_prefix(keywords_t * K, const char * word, size_t word_len, ccze_color_t * color); 40 | int ccze_keyword_match(keywords_t * K, const char * word, size_t word_len, ccze_color_t * color); 41 | 42 | /* ccze-color.c */ 43 | void ccze_color_init (void); 44 | void ccze_color_parse (char *line); 45 | void ccze_color_load (const char *fn); 46 | 47 | int ccze_color_strip_attrib (int color); 48 | char *ccze_color_to_name_simple (int color); 49 | char *ccze_color_lookup_name (ccze_color_t color); 50 | char *ccze_color_to_css (ccze_color_t cidx); 51 | void ccze_colors_to_css (void); 52 | char *ccze_cssbody_color (void); 53 | 54 | /* ccze-plugin.c */ 55 | void ccze_plugin_init (void); 56 | void ccze_plugin_argv_init (void); 57 | int ccze_plugin_argv_set (const char *name, const char *args); 58 | void ccze_plugin_argv_finalise (void); 59 | ccze_plugin_t **ccze_plugins (void); 60 | void ccze_plugin_load_all (void); 61 | void ccze_plugin_load (const char *name); 62 | void ccze_plugin_add (ccze_plugin_t *plugin); 63 | void ccze_plugin_setup (void); 64 | void ccze_plugin_shutdown (void); 65 | void ccze_plugin_finalise (void); 66 | void ccze_plugin_run (ccze_plugin_t **pluginset, char *subject, 67 | size_t subjlen, char **rest, 68 | ccze_plugin_type_t type, int *handled, 69 | int *status); 70 | void ccze_plugin_load_all_builtins (void); 71 | int ccze_plugin_list_fancy (void); 72 | 73 | /* ccze-wordcolor.c */ 74 | void ccze_wordcolor_process (const char *msg, int wcol, int slookup); 75 | void ccze_wordcolor_setup (void); 76 | void ccze_wordcolor_shutdown (void); 77 | 78 | /* ccze.c */ 79 | typedef enum 80 | { 81 | CCZE_MODE_CURSES, 82 | CCZE_MODE_RAW_ANSI, 83 | CCZE_MODE_HTML, 84 | CCZE_MODE_DEBUG, 85 | CCZE_MODE_PLUGIN_LIST 86 | } ccze_mode_t; 87 | 88 | typedef struct 89 | { 90 | int scroll; 91 | int convdate; 92 | int wcol; 93 | int slookup; 94 | int remfac; 95 | int transparent; 96 | char *rcfile; 97 | char *cssfile; 98 | char **pluginlist; 99 | int pluginlist_alloc, pluginlist_len; 100 | char **color_argv; 101 | int color_argv_alloc, color_argv_len; 102 | 103 | ccze_mode_t mode; 104 | } ccze_config_t; 105 | 106 | extern ccze_config_t ccze_config; 107 | 108 | #endif /* !_CCZE_PRIVATE_H */ 109 | -------------------------------------------------------------------------------- /src/mod_ftpstats.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_ftpstats.c -- Stats coloriser for CCZE. 3 | * Copyright (C) 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "ccze-compat.h" 27 | 28 | static void ccze_ftpstats_setup (void); 29 | static void ccze_ftpstats_shutdown (void); 30 | static int ccze_ftpstats_handle (const char *str, size_t length, char **rest); 31 | 32 | static pcre *reg_ftpstats; 33 | static pcre_extra *hints_ftpstats; 34 | 35 | static char * 36 | ccze_ftpstats_process (const char *str, int *offsets, int match) 37 | { 38 | char *date, *sessionid, *user, *host, *type, *size, *duration, *file; 39 | 40 | pcre_get_substring (str, offsets, match, 1, (const char **)&date); 41 | pcre_get_substring (str, offsets, match, 2, (const char **)&sessionid); 42 | pcre_get_substring (str, offsets, match, 3, (const char **)&user); 43 | pcre_get_substring (str, offsets, match, 4, (const char **)&host); 44 | pcre_get_substring (str, offsets, match, 5, (const char **)&type); 45 | pcre_get_substring (str, offsets, match, 6, (const char **)&size); 46 | pcre_get_substring (str, offsets, match, 7, (const char **)&duration); 47 | pcre_get_substring (str, offsets, match, 8, (const char **)&file); 48 | 49 | ccze_print_date (date); 50 | ccze_space (); 51 | ccze_addstr (CCZE_COLOR_UNIQN, sessionid); 52 | ccze_space (); 53 | ccze_addstr (CCZE_COLOR_USER, user); 54 | ccze_space (); 55 | ccze_addstr (CCZE_COLOR_HOST, host); 56 | ccze_space (); 57 | ccze_addstr (CCZE_COLOR_FTPCODES, type); 58 | ccze_space (); 59 | ccze_addstr (CCZE_COLOR_GETSIZE, size); 60 | ccze_space (); 61 | ccze_addstr (CCZE_COLOR_DATE, duration); 62 | ccze_space (); 63 | ccze_addstr (CCZE_COLOR_DIR, file); 64 | ccze_newline (); 65 | 66 | free (file); 67 | free (duration); 68 | free (size); 69 | free (type); 70 | free (host); 71 | free (user); 72 | free (sessionid); 73 | free (date); 74 | 75 | return NULL; 76 | } 77 | 78 | static void 79 | ccze_ftpstats_setup (void) 80 | { 81 | const char *error; 82 | int errptr; 83 | 84 | reg_ftpstats = pcre_compile 85 | ("^(\\d{9,10})\\s([\\da-f]+\\.[\\da-f]+)\\s([^\\s]+)\\s([^\\s]+)" 86 | "\\s(U|D)\\s(\\d+)\\s(\\d+)\\s(.*)$", 87 | 0, &error, &errptr, NULL); 88 | hints_ftpstats = pcre_study (reg_ftpstats, 0, &error); 89 | } 90 | 91 | static void 92 | ccze_ftpstats_shutdown (void) 93 | { 94 | free (reg_ftpstats); 95 | free (hints_ftpstats); 96 | } 97 | 98 | static int 99 | ccze_ftpstats_handle (const char *str, size_t length, char **rest) 100 | { 101 | int match, offsets[99]; 102 | 103 | if ((match = pcre_exec (reg_ftpstats, hints_ftpstats, str, length, 104 | 0, 0, offsets, 99)) >= 0) 105 | { 106 | *rest = ccze_ftpstats_process (str, offsets, match); 107 | return 1; 108 | } 109 | 110 | return 0; 111 | } 112 | 113 | CCZE_DEFINE_PLUGIN (ftpstats, FULL, "Coloriser for ftpstats (pure-ftpd) logs."); 114 | -------------------------------------------------------------------------------- /src/mod_oops.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_oops.c -- oops/oops.log colorizers for CCZE 3 | * Copyright (C) 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "ccze-compat.h" 27 | 28 | static void ccze_oops_setup (void); 29 | static void ccze_oops_shutdown (void); 30 | static int ccze_oops_handle (const char *str, size_t length, char **rest); 31 | 32 | static pcre *reg_oops; 33 | static pcre_extra *hints_oops; 34 | 35 | static char * 36 | ccze_oops_process (const char *str, int *offsets, int match) 37 | { 38 | char *date, *sp1, *id, *field, *sp2, *value, *etc; 39 | 40 | pcre_get_substring (str, offsets, match, 1, (const char **)&date); 41 | pcre_get_substring (str, offsets, match, 4, (const char **)&sp1); 42 | pcre_get_substring (str, offsets, match, 5, (const char **)&id); 43 | pcre_get_substring (str, offsets, match, 6, (const char **)&field); 44 | pcre_get_substring (str, offsets, match, 7, (const char **)&sp2); 45 | pcre_get_substring (str, offsets, match, 8, (const char **)&value); 46 | pcre_get_substring (str, offsets, match, 9, (const char **)&etc); 47 | 48 | ccze_addstr (CCZE_COLOR_DATE, date); 49 | ccze_addstr (CCZE_COLOR_DEFAULT, sp1); 50 | 51 | ccze_addstr (CCZE_COLOR_PIDB, "["); 52 | ccze_addstr (CCZE_COLOR_PROC, id); 53 | ccze_addstr (CCZE_COLOR_PIDB, "]"); 54 | 55 | ccze_addstr (CCZE_COLOR_KEYWORD, "statistics()"); 56 | ccze_addstr (CCZE_COLOR_DEFAULT, ":"); 57 | ccze_space (); 58 | 59 | ccze_addstr (CCZE_COLOR_FIELD, field); 60 | ccze_addstr (CCZE_COLOR_DEFAULT, sp2); 61 | ccze_addstr (CCZE_COLOR_DEFAULT, ":"); 62 | ccze_space (); 63 | ccze_addstr (CCZE_COLOR_NUMBERS, value); 64 | ccze_addstr (CCZE_COLOR_DEFAULT, etc); 65 | 66 | ccze_newline (); 67 | 68 | free (date); 69 | free (sp1); 70 | free (id); 71 | free (field); 72 | free (sp2); 73 | free (value); 74 | free (etc); 75 | 76 | return NULL; 77 | } 78 | 79 | static void 80 | ccze_oops_setup (void) 81 | { 82 | const char *error; 83 | int errptr; 84 | 85 | reg_oops = pcre_compile 86 | ("^((Mon|Tue|Wed|Thu|Fri|Sat|Sun) " 87 | "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) " 88 | "\\d+ \\d+:\\d+:\\d+ \\d+)(\\s+)\\[([\\dxa-fA-F]+)\\]" 89 | "statistics\\(\\): ([\\S]+)(\\s*): (\\d+)(.*)", 90 | 0, &error, &errptr, NULL); 91 | hints_oops = pcre_study (reg_oops, 0, &error); 92 | } 93 | 94 | static void 95 | ccze_oops_shutdown (void) 96 | { 97 | free (reg_oops); 98 | free (hints_oops); 99 | } 100 | 101 | static int 102 | ccze_oops_handle (const char *str, size_t length, char **rest) 103 | { 104 | int match, offsets[99]; 105 | 106 | if ((match = pcre_exec (reg_oops, hints_oops, str, length, 107 | 0, 0, offsets, 99)) >= 0) 108 | { 109 | *rest = ccze_oops_process (str, offsets, match); 110 | return 1; 111 | } 112 | 113 | return 0; 114 | } 115 | 116 | CCZE_DEFINE_PLUGIN (oops, FULL, "Coloriser for oops proxy logs."); 117 | -------------------------------------------------------------------------------- /testsuite/bug-sysrepeat.ok: -------------------------------------------------------------------------------- 1 | Sep 14 11:45:00 iluvatar xinetd[2965]: Exiting... 2 | Sep 14 11:45:02 iluvatar xinetd[3111]: xinetd Version 2.3.7 started with libwrap loadavg options compiled in. 3 | Sep 14 11:45:02 iluvatar xinetd[3111]: Started working: 5 available services 4 | Sep 14 11:45:04 iluvatar pppd[2755]: Script /etc/ppp/ip-down finished (pid 3079), status =
0x1
5 | Sep 14 11:45:04 iluvatar pppd[2755]: Exit. 6 | Sep 14 12:20:02 iluvatar /USR/SBIN/CRON[10499]: (algernon) CMD (expect /usr/share/doc/tama/examples/tama-nanny.exp 2>/dev/null >/dev/null) 7 | Sep 14 12:27:46 iluvatar uptimed: moving up to position 50: 0 days, 01:04:13 8 | Oct 12 22:40:12 iluvatar last message repeated 10 times 9 | Oct 12 22:40:12 iluvatar -- MARK -- 10 | Oct 12 22:40:12 iluvatar syslog-ng[2854]: syslog-ng version 1.5.15 going down 11 | -------------------------------------------------------------------------------- /src/mod_procmail.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_procmail.c -- procmail-related colorizers for CCZE 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | static void ccze_procmail_setup (void); 27 | static void ccze_procmail_shutdown (void); 28 | static int ccze_procmail_handle (const char *str, size_t length, char **rest); 29 | 30 | static pcre *reg_procmail; 31 | static pcre_extra *hints_procmail; 32 | 33 | static char * 34 | ccze_procmail_process (const char *str, int *offsets, int match) 35 | { 36 | char *header = NULL, *value = NULL, *space1 = NULL; 37 | char *space2 = NULL, *extra = NULL; 38 | int handled = 0; 39 | ccze_color_t col = CCZE_COLOR_UNKNOWN; 40 | 41 | pcre_get_substring (str, offsets, match, 1, (const char **)&space1); 42 | pcre_get_substring (str, offsets, match, 2, (const char **)&header); 43 | pcre_get_substring (str, offsets, match, 3, (const char **)&value); 44 | pcre_get_substring (str, offsets, match, 4, (const char **)&space2); 45 | pcre_get_substring (str, offsets, match, 5, (const char **)&extra); 46 | 47 | if (!strcasecmp ("from", header) || !strcasecmp (">from", header)) 48 | { 49 | col = CCZE_COLOR_EMAIL; 50 | handled = 1; 51 | } 52 | if (!strcasecmp ("subject:", header)) 53 | { 54 | col = CCZE_COLOR_SUBJECT; 55 | handled = 1; 56 | } 57 | if (!strcasecmp ("folder:", header)) 58 | { 59 | col = CCZE_COLOR_DIR; 60 | handled = 1; 61 | } 62 | 63 | if (!handled) 64 | { 65 | free (header); 66 | free (value); 67 | free (extra); 68 | return strdup (str); 69 | } 70 | 71 | ccze_addstr (CCZE_COLOR_DEFAULT, space1); 72 | ccze_addstr (CCZE_COLOR_DEFAULT, header); 73 | ccze_space (); 74 | 75 | ccze_addstr (col, value); 76 | if (col == CCZE_COLOR_EMAIL) 77 | col = CCZE_COLOR_DEFAULT; 78 | ccze_addstr (col, space2); 79 | 80 | if (!strcasecmp ("folder:", header)) 81 | col = CCZE_COLOR_SIZE; 82 | else if (!strcasecmp ("from", header)) 83 | col = CCZE_COLOR_DATE; 84 | 85 | ccze_addstr (col, extra); 86 | ccze_newline(); 87 | 88 | free (extra); 89 | free (header); 90 | free (value); 91 | 92 | return NULL; 93 | } 94 | 95 | static void 96 | ccze_procmail_setup (void) 97 | { 98 | const char *error; 99 | int errptr; 100 | 101 | reg_procmail = pcre_compile 102 | ("^(\\s*)(>?From|Subject:|Folder:)?\\s(\\S+)(\\s+)?(.*)", 0, 103 | &error, &errptr, NULL); 104 | hints_procmail = pcre_study (reg_procmail, 0, &error); 105 | } 106 | 107 | static void 108 | ccze_procmail_shutdown (void) 109 | { 110 | free (reg_procmail); 111 | free (hints_procmail); 112 | } 113 | 114 | static int 115 | ccze_procmail_handle (const char *str, size_t length, char **rest) 116 | { 117 | int match, offsets[99]; 118 | 119 | if ((match = pcre_exec (reg_procmail, hints_procmail, str, length, 120 | 0, 0, offsets, 99)) >= 0) 121 | { 122 | *rest = ccze_procmail_process (str, offsets, match); 123 | return 1; 124 | } 125 | 126 | return 0; 127 | } 128 | 129 | CCZE_DEFINE_PLUGIN (procmail, FULL, "Coloriser for procmail(1) logs."); 130 | -------------------------------------------------------------------------------- /src/mod_syslog.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_syslog.c -- Syslog-related colorizers for CCZE 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "ccze-compat.h" 27 | 28 | static void ccze_syslog_setup (void); 29 | static void ccze_syslog_shutdown (void); 30 | static int ccze_syslog_handle (const char *str, size_t length, char **rest); 31 | 32 | static pcre *reg_syslog; 33 | static pcre_extra *hints_syslog; 34 | 35 | static char * 36 | ccze_syslog_process (const char *str, int *offsets, int match) 37 | { 38 | char *date = NULL, *host = NULL, *send = NULL, *process = NULL; 39 | char *msg = NULL, *pid = NULL, *tmp = NULL, *toret; 40 | 41 | pcre_get_substring (str, offsets, match, 1, (const char **)&date); 42 | pcre_get_substring (str, offsets, match, 2, (const char **)&host); 43 | pcre_get_substring (str, offsets, match, 3, (const char **)&send); 44 | 45 | if ((strstr (send, "last message repeated") && strstr (send, "times")) || 46 | (strstr (send, "-- MARK --"))) 47 | msg = strdup (send); 48 | else 49 | { 50 | pcre_get_substring (str, offsets, match, 4, (const char **)&process); 51 | pcre_get_substring (str, offsets, match, 5, (const char **)&msg); 52 | } 53 | 54 | if (process) 55 | { 56 | char *t; 57 | if ((t = strchr (process, '['))) 58 | { 59 | char *t2 = strchr (t, ']'); 60 | 61 | pid = strndup (&t[1], (size_t)(t2 - t - 1)); 62 | tmp = strndup (process, (size_t)(t - process)); 63 | free (process); 64 | process = tmp; 65 | } 66 | } 67 | 68 | ccze_addstr (CCZE_COLOR_DATE, date); 69 | ccze_space (); 70 | 71 | ccze_addstr (CCZE_COLOR_HOST, host); 72 | ccze_space (); 73 | 74 | if (process) 75 | { 76 | ccze_addstr (CCZE_COLOR_PROC, process); 77 | if (pid) 78 | { 79 | ccze_addstr (CCZE_COLOR_PIDB, "["); 80 | ccze_addstr (CCZE_COLOR_PID, pid); 81 | ccze_addstr (CCZE_COLOR_PIDB, "]"); 82 | ccze_addstr (CCZE_COLOR_PROC, ":"); 83 | } 84 | ccze_space (); 85 | toret = strdup (msg); 86 | } 87 | else 88 | toret = strdup (send); 89 | 90 | free (date); 91 | free (host); 92 | free (send); 93 | free (process); 94 | free (msg); 95 | free (pid); 96 | 97 | return toret; 98 | } 99 | 100 | static void 101 | ccze_syslog_setup (void) 102 | { 103 | const char *error; 104 | int errptr; 105 | 106 | reg_syslog = pcre_compile ("^(\\S*\\s{1,2}\\d{1,2}\\s\\d\\d:\\d\\d:\\d\\d)" 107 | "\\s(\\S+)\\s((\\S+:?)\\s(.*))$", 0, &error, 108 | &errptr, NULL); 109 | hints_syslog = pcre_study (reg_syslog, 0, &error); 110 | } 111 | 112 | static void 113 | ccze_syslog_shutdown (void) 114 | { 115 | free (reg_syslog); 116 | free (hints_syslog); 117 | } 118 | 119 | static int 120 | ccze_syslog_handle (const char *str, size_t length, char **rest) 121 | { 122 | int match, offsets[99]; 123 | 124 | if ((match = pcre_exec (reg_syslog, hints_syslog, str, length, 125 | 0, 0, offsets, 99)) >= 0) 126 | { 127 | *rest = ccze_syslog_process (str, offsets, match); 128 | return 1; 129 | } 130 | 131 | return 0; 132 | } 133 | 134 | CCZE_DEFINE_PLUGIN (syslog, FULL, "Generic syslog(8) log coloriser."); 135 | -------------------------------------------------------------------------------- /src/mod_exim.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_exim.c -- Exim log-coloriser module for CCZE 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | static void ccze_exim_setup (void); 27 | static void ccze_exim_shutdown (void); 28 | static int ccze_exim_handle (const char *str, size_t length, char **rest); 29 | 30 | static pcre *reg_exim, *reg_exim_actiontype, *reg_exim_uniqn; 31 | static pcre_extra *hints_exim; 32 | 33 | static char * 34 | ccze_exim_process (const char *str, int *offsets, int match) 35 | { 36 | char *date, *msg=NULL, *action=NULL, *uniqn=NULL, *msgfull; 37 | int match2, offsets2[99]; 38 | ccze_color_t color = CCZE_COLOR_UNKNOWN; 39 | 40 | pcre_get_substring (str, offsets, match, 1, (const char **)&date); 41 | pcre_get_substring (str, offsets, match, 2, (const char **)&msgfull); 42 | 43 | if ((match2 = pcre_exec (reg_exim_actiontype, NULL, msgfull, 44 | strlen (msgfull), 0, 0, offsets2, 99)) >= 0) 45 | { 46 | pcre_get_substring (msgfull, offsets2, match2, 1, 47 | (const char **)&uniqn); 48 | pcre_get_substring (msgfull, offsets2, match2, 2, 49 | (const char **)&action); 50 | pcre_get_substring (msgfull, offsets2, match2, 3, 51 | (const char **)&msg); 52 | if (action[0] == '<') 53 | color = CCZE_COLOR_INCOMING; 54 | else if (action[1] == '>') 55 | color = CCZE_COLOR_OUTGOING; 56 | else if (action[0] == '=' || action[0] == '*') 57 | color = CCZE_COLOR_ERROR; 58 | } 59 | else if ((match2 = pcre_exec (reg_exim_uniqn, NULL, msgfull, 60 | strlen (msgfull), 0, 0, offsets2, 99)) >= 0) 61 | { 62 | pcre_get_substring (msgfull, offsets2, match2, 1, 63 | (const char **)&uniqn); 64 | pcre_get_substring (msgfull, offsets2, match2, 2, 65 | (const char **)&msg); 66 | } 67 | else 68 | msg = strdup (msgfull); 69 | 70 | ccze_print_date (date); 71 | ccze_space (); 72 | 73 | if (uniqn && uniqn[0]) 74 | { 75 | ccze_addstr (CCZE_COLOR_UNIQN, uniqn); 76 | ccze_space(); 77 | } 78 | 79 | if (action && action[0]) 80 | { 81 | ccze_addstr (color, action); 82 | ccze_space(); 83 | } 84 | 85 | return msg; 86 | } 87 | 88 | static void 89 | ccze_exim_setup (void) 90 | { 91 | const char *error; 92 | int errptr; 93 | 94 | reg_exim = pcre_compile 95 | ("^(\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2})\\s(.*)$", 0, 96 | &error, &errptr, NULL); 97 | hints_exim = pcre_study (reg_exim, 0, &error); 98 | 99 | reg_exim_actiontype = pcre_compile 100 | ("^(\\S{16})\\s([<=\\*][=>\\*])\\s(\\S+.*)$", 0, &error, 101 | &errptr, NULL); 102 | reg_exim_uniqn = pcre_compile ("^(\\S{16})\\s(.*)$", 0, &error, 103 | &errptr, NULL); 104 | } 105 | 106 | static void 107 | ccze_exim_shutdown (void) 108 | { 109 | free (reg_exim); 110 | free (hints_exim); 111 | free (reg_exim_actiontype); 112 | free (reg_exim_uniqn); 113 | } 114 | 115 | static int 116 | ccze_exim_handle (const char *str, size_t length, char **rest) 117 | { 118 | int match, offsets[99]; 119 | 120 | if ((match = pcre_exec (reg_exim, hints_exim, str, length, 121 | 0, 0, offsets, 99)) >= 0) 122 | { 123 | *rest = ccze_exim_process (str, offsets, match); 124 | return 1; 125 | } 126 | 127 | return 0; 128 | } 129 | 130 | CCZE_DEFINE_PLUGIN (exim, FULL, "Coloriser for exim logs."); 131 | -------------------------------------------------------------------------------- /src/Makefile.in: -------------------------------------------------------------------------------- 1 | ## src/Makefile 2 | 3 | ## -- User-modifiable variables -- ## 4 | srcdir = @srcdir@ 5 | top_srcdir = @top_srcdir@ 6 | subdir = src 7 | 8 | ## == The code below shouldn't need to be touched at all == ## 9 | 10 | include ../Rules.mk 11 | 12 | ## -- Private variables -- ## 13 | ALL_LDFLAGS = ${LDFLAGS} ${LIBS} 14 | 15 | INCLUDES = -I. -I${srcdir} -I${top_builddir} 16 | DEFINES = -DPATCHLEVEL=\"${PATCHLEVEL}\" -DSYSCONFDIR=\"${sysconfdir}\" \ 17 | -D_GNU_SOURCE=1 -DPKGLIBDIR=\"${pkglibdir}\" -DHAVE_SYSTEM_H=1 \ 18 | -DBUILTIN=1 19 | WFLAGS = @WFLAGS@ 20 | WFLAGS_GCC = -Wshadow -Wpointer-arith -Waggregate-return \ 21 | -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual \ 22 | -Wbad-function-cast -Wsign-compare -Wchar-subscripts \ 23 | -Wcomment -Wformat -Wformat-nonliteral -Wformat-security \ 24 | -Wimplicit -Wmain -Wmissing-braces -Wparentheses \ 25 | -Wreturn-type -Wswitch \ 26 | -Wmissing-noreturn -Wmissing-declarations @WFLAGS_3X@ 27 | WFLAGS_ICC = -Wall -wd193,279,810,869,1418,1419 28 | WFLAGS_3X = -Wsequence-point -Wdiv-by-zero -W -Wunused \ 29 | -Wno-unused-parameter -Wno-unused-function 30 | ALL_CFLAGS = ${INCLUDES} ${DEFINES} ${WFLAGS} ${CFLAGS} @PCRE_CFLAGS@ 31 | 32 | LIBS = @PCRE_LIBS@ @LIBS@ 33 | 34 | SOURCES = ccze.c ccze-color.c ccze-plugin.c ccze-wordcolor.c \ 35 | $(addprefix mod_,$(addsuffix .c, ${ALL_PLUGINS})) \ 36 | ccze-keywordlookup.c ccze-dump.c ccze-cssdump.c ccze-compat.c 37 | HEADERS = ccze.h ccze-compat.h ccze-private.h 38 | ALL_PLUGINS = @ALL_PLUGINS@ 39 | S_PLUGINS = @S_PLUGINS@ 40 | SH_PLUGINS = $(filter-out ${S_PLUGINS},${ALL_PLUGINS}) 41 | PLUGIN_SHOBJS = $(addsuffix .so,${SH_PLUGINS}) 42 | PLUGIN_SOBJS = $(addsuffix .o,$(addprefix mod_,${S_PLUGINS})) 43 | PLUGIN_OBJS = ${PLUGIN_SHOBJS} ${PLUGIN_SOBJS} 44 | CLEANFILES = ccze-dump ccze-cssdump 45 | DISTCLEANFILES = ccze-builtins.c 46 | OBJECTS = ccze.o ccze-color.o ccze-plugin.o ccze-wordcolor.o \ 47 | ccze-keywordlookup.o ccze-builtins.o ccze-compat.o 48 | 49 | ## -- Standard targets -- ## 50 | all: ${PROGRAM} ${PLUGIN_SHOBJS} ccze-dump ccze-cssdump 51 | 52 | install: all 53 | ${INSTALL} -d ${DESTDIR}${bindir} 54 | ${INSTALL_PROGRAM} ${PROGRAM} ccze-cssdump ${DESTDIR}${bindir}/ 55 | ${INSTALL} -d ${DESTDIR}${includedir} 56 | ${INSTALL_DATA} ${srcdir}/ccze.h ${DESTDIR}${includedir} 57 | ifneq (${SH_PLUGINS},) 58 | ${INSTALL} -d ${DESTDIR}${pkglibdir} 59 | ${INSTALL_DATA} ${PLUGIN_SHOBJS} ${DESTDIR}${pkglibdir}/ 60 | endif 61 | 62 | install-strip: 63 | ${MAKE} INSTALL_PROGRAM='${INSTALL_PROGRAM} -s' \ 64 | INSTALL_DATA='${INSTALL_DATA} -s' install 65 | 66 | uninstall: 67 | rm -f ${DESTDIR}${bindir}/${PROGRAM} \ 68 | ${DESTDIR}${bindir}/ccze-cssdump \ 69 | ${DESTDIR}${includedir}/ccze.h 70 | ifneq (${SH_PLUGINS},) 71 | rm -f $(addprefix ${DESTDIR}${pkglibdir}/,${PLUGIN_SHOBJS}) 72 | endif 73 | 74 | ## -- Specific targets -- ## 75 | ${PROGRAM}: ${OBJECTS} ${PLUGIN_SOBJS} 76 | ${CC} -rdynamic ${ALL_CFLAGS} -o $@ $^ ${ALL_LDFLAGS} 77 | ccze-dump ccze-cssdump: %: %.o ccze-compat.o ccze-color.c 78 | ${CC} ${ALL_CFLAGS} -o $@ $@.o ccze-compat.o 79 | ccze-builtins.c: Makefile 80 | echo '#include ' >$@ 81 | echo '#include "ccze-private.h"' >>$@ 82 | echo >>$@ 83 | ifneq (${S_PLUGINS},) 84 | for p in ${S_PLUGINS}; do \ 85 | echo "extern ccze_plugin_t ccze_$${p}_info;" >>$@; \ 86 | done 87 | endif 88 | echo "void" >>$@ 89 | echo "ccze_plugin_load_all_builtins (void)" >>$@ 90 | echo "{" >>$@ 91 | ifneq (${S_PLUGINS},) 92 | for p in ${S_PLUGINS}; do \ 93 | echo " ccze_plugin_add (&ccze_$${p}_info);" >>$@; \ 94 | done 95 | endif 96 | echo "}" >>$@ 97 | %.o: %.c ccze.h 98 | ${CC} -c ${CPPFLAGS} ${ALL_CFLAGS} $< 99 | %.so: mod_%.c ccze.h 100 | ${CC} -fPIC -DPIC ${ALL_CFLAGS} ${ALL_LDFLAGS} -o $@ $< -shared 101 | 102 | ## -- Dependencies -- ## 103 | ccze.o: ccze.c ${top_builddir}/system.h ccze.h ccze-private.h \ 104 | ${top_srcdir}/ChangeLog 105 | ccze-color.o: ccze-color.c ${top_builddir}/system.h ccze.h ccze-private.h 106 | ccze-plugin.o: ccze-plugin.c ${top_builddir}/system.h ccze.h ccze-private.h 107 | ccze-wordcolor.o: ccze-wordcolor.c ${top_builddir}/system.h ccze.h \ 108 | ccze-private.h 109 | ccze-keywordlookup.o: ccze-keywordlookup.c ${top_builddir}/system.h ccze.h \ 110 | ccze-private.h 111 | ccze-compat.o: ccze-compat.c ${top_builddir}/system.h ccze-compat.h \ 112 | ccze.h 113 | ${top_builddir}/system.h: ${top_builddir}/config.status 114 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | NEWS -- list of user-visible changes -*- outline -*- 2 | 3 | * CCZE 0.3.0 [Phoenix] -- 2020-09-02 4 | 5 | Phoenix rises from the ashes 17 years after the last release. 6 | The upstream is dead, but long live CCZE! Most of the work was done 7 7 | years ago, but I was too lazy to make the release. Sorry. 8 | 9 | The new maintainer is Vadim Ushakov, and the new site URL is 10 | https://github.com/software-revive/ccze-rv. 11 | 12 | No new features introduced in this release, but we've achieved SIGNIFICANT 13 | performance improvements. And also fixed an old segfault. 14 | 15 | * CCZE 0.2.1 [Fireflower] -- 2003-05-13 16 | 17 | The Fireflower release brings transparency and background colour 18 | support for the raw ANSI output mode, documentation updates and minor 19 | bugfixes all over the place. 20 | 21 | * CCZE 0.2.0 [Mephisto] -- 2003-03-29 22 | 23 | Mephisto features raw ANSI output support, without the use of 24 | nCurses. This adds support for scrollback, both on console and in 25 | xterms. Also, it allows one to send CCZE to the background, and mix 26 | various logs and options on one terminal. 27 | 28 | A new coloriser for Pure-FTPD's Stats log format was added, and the 29 | httpd module was modified to handle Pure-FTPD's CLF format, and bad 30 | HTTP requests. 31 | 32 | * CCZE 0.1.228 [Largo] -- 2003-03-20 33 | 34 | This release features many many internal enhancements, mostly for the 35 | plug-in system, a coloriser for proftpd logs, and various fixes all 36 | over the place. 37 | 38 | * CCZE 0.1.212 [Avatar] -- 2003-03-04 39 | 40 | Implemented support for passing arguments to plugins. None of the 41 | plugins shipped with CCZE support this, however, external plugins 42 | might (and do, for that matter, see the homepage). 43 | 44 | Also, some minor bugs (misformatting on the manual page, garbled 45 | output, and not properly recognised procmail logs) were also squashed. 46 | 47 | * CCZE 0.1.200 [Enigma of the Absolute] -- 2003-02-21 48 | 49 | During the past few weeks, CCZE was ported to Cygwin and Tru64 (many 50 | thanks to Jon Ewing and Erik Braun for their help). 51 | 52 | Also, a coloriser for distccd.log files was added too. 53 | 54 | * CCZE 0.1.171 [Mesmerism] -- 2003-02-09. 55 | 56 | This release brings colorisers for php.log, oops/oops.log, 57 | icecast/icecast.log and icecast/usage.log. Also, it is now possible to 58 | disable any of the built-in plugins, that is, they behave as loadable 59 | modules when --plugin is specified. 60 | 61 | For the benefit of transparent xterm users, CCZE defaults to not alter 62 | the background colour by default. 63 | 64 | * CCZE 0.1.150 [The Cardinal Sin] -- 2003-02-04. 65 | 66 | Since the last release, a great deal of code cleanup took place, 67 | resulting in most of the modules' sources getting renamed. As usual, 68 | bugs were fixed during this process, so certain characters will get 69 | escaped in the HTML output. 70 | 71 | Also, a full-blown coloriser module was added for xferlog files, and a 72 | syslog-subcoloriser for postfix logs. 73 | 74 | CCZE also handles SIGHUP nicely, by effectively restarting itself. 75 | 76 | * CCZE 0.1.134 [Song of the Dispossessed] -- 2003-01-19. 77 | 78 | Colours (even the background of the outputted HTML) can now be changed 79 | on the command-line too. During this process, CCZE was ported to 80 | FreeBSD. 81 | 82 | * CCZE 0.1.122 [Wild in The Woods] -- 2003-01-13. 83 | 84 | HTML output was cleaned up and made customisable. From now on, CCZE 85 | uses Cascading Style Sheets. 86 | 87 | * CCZE 0.1.108 [Devorzhum] -- 2003-01-10. 88 | 89 | In this release experimental HTML output was added. It is not really 90 | customisable yet, but produces usable output (better than that of 91 | colorize! :). 92 | 93 | * CCZE 0.1.103 [For My Fallen Angel] -- 2002.12.02. 94 | 95 | Many internal cleanups and documentation updates, support for built-in 96 | and partial plugins, and more. 97 | 98 | * CCZE 0.1.91 [Like Gods of the Sun] -- 2002.11.19. 99 | 100 | Major restructuring in the plugin code: cleaner, better, lighter. The 101 | new design allows sub-colorisers, to colorise syslog messages (with 102 | the date, host and that kind of stuff handled by the syslog module) 103 | for example. Two such plugins are included: one for ulogd, another for 104 | apmd. 105 | 106 | * CCZE 0.1.80 [The Stance of Evander Sinque] -- 2002.10.12. 107 | 108 | This is mainly a minor convenience-enhanced release. The major change 109 | is that CCZE will now exit if it could not load any plugins. 110 | 111 | * CCZE 0.1.72 [Base Level Erotica] -- 2002.10.04. 112 | 113 | Brown paper-bag release, as I broke all the modules in 0.1.64. Apart 114 | from this fix, this release is the same as 0.1.70 yesterday. 115 | 116 | * CCZE 0.1.70 [Edenbeast] -- 2002.10.03. 117 | 118 | Initial public release. 119 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl configure.ac for ccze 2 | dnl Copyright (C) 2002, 2003 Gergely Nagy 3 | dnl 4 | dnl Process this file with autoconf to produce a configure script. 5 | dnl 6 | dnl This file is part of ccze. 7 | dnl 8 | dnl ccze is free software; you can redistribute it and/or modify 9 | dnl it under the terms of the GNU General Public License as published by 10 | dnl the Free Software Foundation; either version 2 of the License, or 11 | dnl (at your option) any later version. 12 | dnl 13 | dnl ccze is distributed in the hope that it will be useful, 14 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | dnl GNU General Public License for more details. 17 | dnl 18 | dnl You should have received a copy of the GNU General Public License 19 | dnl along with this program; if not, write to the Free Software 20 | dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | dnl ********************** 23 | dnl * Boilerplate 24 | dnl ********************** 25 | AC_PREREQ(2.54) 26 | AC_INIT([ccze], [0.3.0], [https://github.com/software-revive/ccze-rv]) 27 | AC_CONFIG_SRCDIR(src/ccze.c) 28 | 29 | AC_CONFIG_HEADERS(system.h) 30 | 31 | AC_CANONICAL_HOST 32 | AC_SUBST(host_os) 33 | 34 | VERSION="$PACKAGE_VERSION" 35 | 36 | dnl ********************** 37 | dnl * Programs 38 | dnl ********************** 39 | AC_CHECK_TOOL(CC, cc) 40 | AC_PROG_CC 41 | 42 | WFLAGS="" 43 | WFLAGS_3X="" 44 | if test "x$ac_compiler_gnu" = "xyes"; then 45 | WFLAGS='${WFLAGS_GCC}' 46 | AC_MSG_CHECKING(whether we are using GCC 3) 47 | GCCVER=$(${CC} -dumpversion 2>/dev/null) 48 | case ${GCCVER} in 49 | 3.*) 50 | WFLAGS_3X='${WFLAGS_3X}' 51 | AC_MSG_RESULT(yes) 52 | ;; 53 | *) 54 | AC_MSG_RESULT(no) 55 | ;; 56 | esac 57 | else 58 | AC_MSG_CHECKING(whether we are using the Intel C compiler) 59 | if ${CC} -V 2>&1 | head -n 1 | grep -q "Intel(R)"; then 60 | AC_MSG_RESULT(yes) 61 | WFLAGS='${WFLAGS_ICC}' 62 | else 63 | AC_MSG_RESULT(no) 64 | fi 65 | fi 66 | AC_SUBST(WFLAGS) 67 | AC_SUBST(WFLAGS_3X) 68 | 69 | AC_PROG_CPP 70 | AC_PROG_INSTALL 71 | 72 | dnl ********************** 73 | dnl * Headers 74 | dnl ********************** 75 | AC_HEADER_STDC 76 | AC_HEADER_DIRENT 77 | AC_CHECK_HEADERS([argp.h getopt.h netdb.h fcntl.h stddef.h]) 78 | 79 | dnl ********************** 80 | dnl * Typedefs & co 81 | dnl ********************** 82 | AC_C_CONST 83 | AC_C_VOLATILE 84 | AC_TYPE_SIZE_T 85 | AC_TYPE_SIGNAL 86 | 87 | AC_CHECK_TYPE(error_t, int) 88 | 89 | dnl ********************** 90 | dnl * Library functions 91 | dnl ********************** 92 | AC_FUNC_MALLOC 93 | AC_FUNC_REALLOC 94 | AC_FUNC_STRFTIME 95 | AC_FUNC_STAT 96 | AC_FUNC_MEMCMP 97 | AC_FUNC_VPRINTF 98 | AC_FUNC_CLOSEDIR_VOID 99 | AC_CHECK_FUNCS([alphasort argp_parse asprintf getdelim getline getopt_long \ 100 | getsubopt memchr memset scandir strcasecmp strchr strdup \ 101 | strndup strstr]) 102 | 103 | AC_CHECK_LIB(ncurses, initscr, [], [AC_ERROR(NCurses library not found)]) 104 | AC_CHECK_FUNC(dlopen, [], [AC_CHECK_LIB(dl, dlopen)]) 105 | AC_CHECK_FUNC(getopt_long, [], [AC_CHECK_LIB(gnugetopt, getopt_long)]) 106 | 107 | if test -z "${PCRE_CONFIG}"; then 108 | AC_PATH_PROG(PCRE_CONFIG, pcre-config, no) 109 | fi 110 | AC_MSG_CHECKING(for PCRE) 111 | if test "${PCRE_CONFIG}" = "no"; then 112 | AC_ERROR(PCRE not found) 113 | fi 114 | PCRE_CFLAGS=$($PCRE_CONFIG --cflags) 115 | PCRE_LIBS=$($PCRE_CONFIG --libs) 116 | AC_SUBST(PCRE_CFLAGS) 117 | AC_SUBST(PCRE_LIBS) 118 | AC_MSG_RESULT(found) 119 | 120 | AC_MSG_CHECKING(for suboptarg) 121 | AC_RUN_IFELSE(AC_LANG_PROGRAM( 122 | [[#include 123 | #include 124 | #include 125 | 126 | static char **empty_subopts[[]] = { NULL }; 127 | extern char *suboptarg; 128 | ]], 129 | [[ char *subopts = "something"; 130 | char *value; 131 | 132 | getsubopt (&subopts, empty_subopts, &value); 133 | exit (!suboptarg);]]), [have_suboptarg="yes"], 134 | [have_suboptarg="no"], [have_suboptarg="no"]) 135 | AC_MSG_RESULT(${have_suboptarg}) 136 | case ${have_suboptarg} in 137 | yes) 138 | AC_DEFINE_UNQUOTED(HAVE_SUBOPTARG, 1, 139 | Define this if you have the suboptarg variable) 140 | ;; 141 | esac 142 | 143 | dnl ********************** 144 | dnl * Plugins 145 | dnl ********************** 146 | ALL_PLUGINS=$(tr '\n' ' ' < ${srcdir}/ccze.plugins) 147 | AC_SUBST(ALL_PLUGINS) 148 | AC_ARG_WITH(builtins, 149 | [ --with-builtins=LIST Build the listed plugins into the binary], 150 | [case $withval in 151 | all) 152 | S_PLUGINS=$ALL_PLUGINS;; 153 | *) 154 | S_PLUGINS="$(echo $withval | sed 's/,/ /g')";; 155 | esac], [S_PLUGINS=""]) 156 | AC_SUBST(S_PLUGINS) 157 | 158 | dnl ********************** 159 | dnl * Output 160 | dnl ********************** 161 | AC_CONFIG_FILES([ 162 | Rules.mk 163 | Makefile 164 | doc/Makefile 165 | src/Makefile 166 | testsuite/Makefile 167 | ]) 168 | 169 | AC_OUTPUT 170 | -------------------------------------------------------------------------------- /src/mod_xferlog.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_xferlog -- Xferlog colorizer for CCZE. 3 | * Copyright (C) 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | static void ccze_xferlog_setup (void); 26 | static void ccze_xferlog_shutdown (void); 27 | static int ccze_xferlog_handle (const char *str, size_t length, char **rest); 28 | 29 | static pcre *reg_xferlog; 30 | static pcre_extra *hints_xferlog; 31 | 32 | static char * 33 | ccze_xferlog_log_process (const char *str, int *offsets, int match) 34 | { 35 | char *curtime, *transtime, *host, *fsize, *fname, *transtype; 36 | char *actionflag, *direction, *amode, *user, *service, *amethod; 37 | char *auid, *status; 38 | 39 | pcre_get_substring (str, offsets, match, 1, (const char **)&curtime); 40 | pcre_get_substring (str, offsets, match, 2, (const char **)&transtime); 41 | pcre_get_substring (str, offsets, match, 3, (const char **)&host); 42 | pcre_get_substring (str, offsets, match, 4, (const char **)&fsize); 43 | pcre_get_substring (str, offsets, match, 5, (const char **)&fname); 44 | pcre_get_substring (str, offsets, match, 6, (const char **)&transtype); 45 | pcre_get_substring (str, offsets, match, 7, (const char **)&actionflag); 46 | pcre_get_substring (str, offsets, match, 8, (const char **)&direction); 47 | pcre_get_substring (str, offsets, match, 9, (const char **)&amode); 48 | pcre_get_substring (str, offsets, match, 10, (const char **)&user); 49 | pcre_get_substring (str, offsets, match, 11, (const char **)&service); 50 | pcre_get_substring (str, offsets, match, 12, (const char **)&amethod); 51 | pcre_get_substring (str, offsets, match, 13, (const char **)&auid); 52 | pcre_get_substring (str, offsets, match, 14, (const char **)&status); 53 | 54 | ccze_addstr (CCZE_COLOR_DATE, curtime); 55 | ccze_space (); 56 | ccze_addstr (CCZE_COLOR_GETTIME, transtime); 57 | ccze_space (); 58 | ccze_addstr (CCZE_COLOR_HOST, host); 59 | ccze_space (); 60 | ccze_addstr (CCZE_COLOR_GETSIZE, fsize); 61 | ccze_space (); 62 | ccze_addstr (CCZE_COLOR_DIR, fname); 63 | ccze_space (); 64 | ccze_addstr (CCZE_COLOR_PIDB, transtype); 65 | ccze_space (); 66 | ccze_addstr (CCZE_COLOR_FTPCODES, actionflag); 67 | ccze_space (); 68 | ccze_addstr (CCZE_COLOR_FTPCODES, direction); 69 | ccze_space (); 70 | ccze_addstr (CCZE_COLOR_FTPCODES, amode); 71 | ccze_space (); 72 | ccze_addstr (CCZE_COLOR_USER, user); 73 | ccze_space (); 74 | ccze_addstr (CCZE_COLOR_SERVICE, service); 75 | ccze_space (); 76 | ccze_addstr (CCZE_COLOR_FTPCODES, amethod); 77 | ccze_space (); 78 | ccze_addstr (CCZE_COLOR_USER, auid); 79 | ccze_space (); 80 | ccze_addstr (CCZE_COLOR_FTPCODES, status); 81 | 82 | ccze_newline (); 83 | 84 | free (curtime); 85 | free (transtime); 86 | free (host); 87 | free (fsize); 88 | free (fname); 89 | free (transtype); 90 | free (actionflag); 91 | free (direction); 92 | free (amode); 93 | free (user); 94 | free (service); 95 | free (amethod); 96 | free (auid); 97 | free (status); 98 | 99 | return NULL; 100 | } 101 | 102 | static void 103 | ccze_xferlog_setup (void) 104 | { 105 | const char *error; 106 | int errptr; 107 | 108 | /* FIXME: Does not handle spaces in filenames! */ 109 | reg_xferlog = pcre_compile 110 | ("^(... ... +\\d{1,2} +\\d{1,2}:\\d{1,2}:\\d{1,2} \\d+) (\\d+) ([^ ]+) " 111 | "(\\d+) (\\S+) (a|b) (C|U|T|_) (o|i) (a|g|r) ([^ ]+) ([^ ]+) " 112 | "(0|1) ([^ ]+) (c|i)", 0, &error, 113 | &errptr, NULL); 114 | hints_xferlog = pcre_study (reg_xferlog, 0, &error); 115 | } 116 | 117 | static void 118 | ccze_xferlog_shutdown (void) 119 | { 120 | free (reg_xferlog); 121 | free (hints_xferlog); 122 | } 123 | 124 | static int 125 | ccze_xferlog_handle (const char *str, size_t length, char **rest) 126 | { 127 | int match, offsets[99]; 128 | 129 | if ((match = pcre_exec (reg_xferlog, hints_xferlog, str, length, 130 | 0, 0, offsets, 99)) >= 0) 131 | { 132 | *rest = ccze_xferlog_log_process (str, offsets, match); 133 | return 1; 134 | } 135 | 136 | return 0; 137 | } 138 | 139 | CCZE_DEFINE_PLUGIN (xferlog, FULL, "Generic xferlog coloriser."); 140 | -------------------------------------------------------------------------------- /src/ccze-keywordlookup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Vadim Ushakov 3 | * 4 | * This file is part of ccze. 5 | * 6 | * ccze is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ccze is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 14 | * License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "ccze-private.h" 27 | #include "ccze-compat.h" 28 | 29 | struct _keyword_t { 30 | char * word; 31 | size_t word_len; 32 | ccze_color_t color; 33 | }; 34 | 35 | static unsigned PAGE(const char * word, size_t word_len) 36 | { 37 | unsigned p = (unsigned) word[0]; 38 | if (word_len > 0) 39 | p ^= (unsigned) word[1] * 2; 40 | return 0xFF & p; 41 | } 42 | 43 | static int keyword_compar(const keyword_t * a, const keyword_t * b) 44 | { 45 | return b->word_len - a->word_len; 46 | } 47 | 48 | static void sort_keywords(keywords_t * K) 49 | { 50 | size_t i; 51 | if (K->keywords_sorted) 52 | return; 53 | for (i = 0; i < 255; i++) 54 | qsort(K->keywords[i], K->keywords_nr[i], sizeof(keyword_t), (__compar_fn_t)keyword_compar); 55 | K->keywords_sorted = 1; 56 | } 57 | 58 | int ccze_keyword_match_prefix(keywords_t * K, const char * word, size_t word_len, ccze_color_t * color) 59 | { 60 | sort_keywords(K); 61 | 62 | size_t i; 63 | unsigned p = PAGE(word, word_len); 64 | 65 | keyword_t * page = K->keywords[p]; 66 | 67 | for (i = 0; i < K->keywords_nr[p]; i++) 68 | { 69 | //printf("\n----- '%s'\n", page[i].word); 70 | if (word_len >= page[i].word_len && memcmp(word, page[i].word, page[i].word_len) == 0) 71 | { 72 | *color = page[i].color; 73 | return 1; 74 | } 75 | } 76 | return 0; 77 | } 78 | 79 | static keyword_t * keyword_match(keywords_t * K, const char * word, size_t word_len) 80 | { 81 | size_t i; 82 | unsigned p = PAGE(word, word_len); 83 | 84 | keyword_t * page = K->keywords[p]; 85 | 86 | for (i = 0; i < K->keywords_nr[p]; i++) 87 | { 88 | //printf("\n+++++ '%s'\n", page[i].word); 89 | if (word_len == page[i].word_len && memcmp(word, page[i].word, page[i].word_len) == 0) 90 | { 91 | return &page[i]; 92 | } 93 | } 94 | return NULL; 95 | } 96 | 97 | int ccze_keyword_match(keywords_t * K, const char * word, size_t word_len, ccze_color_t * color) 98 | { 99 | keyword_t * k = keyword_match(K, word, word_len); 100 | if (k) 101 | { 102 | *color = k->color; 103 | return 1; 104 | } 105 | return 0; 106 | } 107 | 108 | void ccze_keyword_add(keywords_t * K, const char ** words, size_t words_nr, ccze_color_t color) 109 | { 110 | size_t i; 111 | 112 | if (words_nr == 1) 113 | { 114 | size_t word_len = strlen(words[0]); 115 | unsigned p = PAGE(words[0], word_len); 116 | K->keywords[p] = realloc(K->keywords[p], (K->keywords_nr[p] + 1) * sizeof(keyword_t)); 117 | } 118 | else 119 | { 120 | for (i = 0; i < 255; i++) 121 | { 122 | K->keywords[i] = realloc(K->keywords[i], (K->keywords_nr[i] + words_nr) * sizeof(keyword_t)); 123 | } 124 | } 125 | 126 | for (i = 0; i < words_nr; i++) 127 | { 128 | size_t word_len = strlen(words[i]); 129 | 130 | keyword_t * k1 = keyword_match(K, words[i], word_len); 131 | if (k1) 132 | { 133 | k1->color = color; 134 | } 135 | else 136 | { 137 | unsigned p = PAGE(words[i], word_len); 138 | keyword_t * k2 = K->keywords[p] + K->keywords_nr[p]; 139 | K->keywords_nr[p]++; 140 | k2->word = strdup(words[i]); 141 | k2->word_len = word_len; 142 | k2->color = color; 143 | } 144 | } 145 | 146 | K->keywords_sorted = 0; 147 | } 148 | 149 | void ccze_keyword_add1(keywords_t * K, const char * word, ccze_color_t color) 150 | { 151 | ccze_keyword_add(K, &word, 1, color); 152 | } 153 | 154 | void ccze_keyword_clean(keywords_t * K) 155 | { 156 | size_t i; 157 | for (i = 0; i < 255; i++) 158 | { 159 | size_t j; 160 | if (K->keywords[i]) 161 | { 162 | for (j = 0; j < K->keywords_nr[i]; j++) 163 | { 164 | if (K->keywords[i][j].word); 165 | free(K->keywords[i][j].word); 166 | } 167 | free(K->keywords[i]); 168 | } 169 | K->keywords[i] = NULL; 170 | K->keywords_nr[i] = 0; 171 | } 172 | } 173 | 174 | -------------------------------------------------------------------------------- /src/ccze.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * ccze.h -- Public interface to CCZE. 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef _CCZE_H 23 | #define _CCZE_H 1 24 | 25 | #ifdef HAVE_SYSTEM_H 26 | # include "system.h" 27 | #endif 28 | #include 29 | #include 30 | #include 31 | 32 | /* Compatibility */ 33 | void *ccze_malloc (size_t size); 34 | void *ccze_realloc (void *ptr, size_t size); 35 | void *ccze_calloc (size_t nmemb, size_t size); 36 | 37 | /* Colors */ 38 | typedef enum 39 | { 40 | CCZE_COLOR_DATE = 0, 41 | CCZE_COLOR_HOST, 42 | CCZE_COLOR_PROC, 43 | CCZE_COLOR_PID, 44 | CCZE_COLOR_PIDB, 45 | CCZE_COLOR_DEFAULT, 46 | CCZE_COLOR_EMAIL, 47 | CCZE_COLOR_SUBJECT, 48 | CCZE_COLOR_DIR, 49 | CCZE_COLOR_SIZE, 50 | CCZE_COLOR_USER, 51 | CCZE_COLOR_HTTPCODES, 52 | CCZE_COLOR_GETSIZE, 53 | CCZE_COLOR_HTTP_GET, 54 | CCZE_COLOR_HTTP_POST, 55 | CCZE_COLOR_HTTP_HEAD, 56 | CCZE_COLOR_HTTP_PUT, 57 | CCZE_COLOR_HTTP_CONNECT, 58 | CCZE_COLOR_HTTP_TRACE, 59 | CCZE_COLOR_UNKNOWN, 60 | CCZE_COLOR_GETTIME, 61 | CCZE_COLOR_URI, 62 | CCZE_COLOR_IDENT, 63 | CCZE_COLOR_CTYPE, 64 | CCZE_COLOR_ERROR, 65 | CCZE_COLOR_PROXY_MISS, 66 | CCZE_COLOR_PROXY_HIT, 67 | CCZE_COLOR_PROXY_DENIED, 68 | CCZE_COLOR_PROXY_REFRESH, 69 | CCZE_COLOR_PROXY_SWAPFAIL, 70 | CCZE_COLOR_DEBUG, 71 | CCZE_COLOR_WARNING, 72 | CCZE_COLOR_PROXY_DIRECT, 73 | CCZE_COLOR_PROXY_PARENT, 74 | CCZE_COLOR_SWAPNUM, 75 | CCZE_COLOR_PROXY_CREATE, 76 | CCZE_COLOR_PROXY_SWAPIN, 77 | CCZE_COLOR_PROXY_SWAPOUT, 78 | CCZE_COLOR_PROXY_RELEASE, 79 | CCZE_COLOR_MAC, 80 | CCZE_COLOR_VERSION, 81 | CCZE_COLOR_ADDRESS, 82 | CCZE_COLOR_NUMBERS, 83 | CCZE_COLOR_SIGNAL, 84 | CCZE_COLOR_SERVICE, 85 | CCZE_COLOR_PROT, 86 | CCZE_COLOR_BADWORD, 87 | CCZE_COLOR_GOODWORD, 88 | CCZE_COLOR_SYSTEMWORD, 89 | CCZE_COLOR_INCOMING, 90 | CCZE_COLOR_OUTGOING, 91 | CCZE_COLOR_UNIQN, 92 | CCZE_COLOR_REPEAT, 93 | CCZE_COLOR_FIELD, 94 | CCZE_COLOR_CHAIN, 95 | CCZE_COLOR_PERCENTAGE, 96 | CCZE_COLOR_FTPCODES, 97 | CCZE_COLOR_KEYWORD, 98 | 99 | CCZE_COLOR_STATIC_BLACK, 100 | CCZE_COLOR_STATIC_RED, 101 | CCZE_COLOR_STATIC_GREEN, 102 | CCZE_COLOR_STATIC_YELLOW, 103 | CCZE_COLOR_STATIC_BLUE, 104 | CCZE_COLOR_STATIC_CYAN, 105 | CCZE_COLOR_STATIC_MAGENTA, 106 | CCZE_COLOR_STATIC_WHITE, 107 | CCZE_COLOR_STATIC_BOLD_BLACK, 108 | CCZE_COLOR_STATIC_BOLD_RED, 109 | CCZE_COLOR_STATIC_BOLD_GREEN, 110 | CCZE_COLOR_STATIC_BOLD_YELLOW, 111 | CCZE_COLOR_STATIC_BOLD_BLUE, 112 | CCZE_COLOR_STATIC_BOLD_CYAN, 113 | CCZE_COLOR_STATIC_BOLD_MAGENTA, 114 | CCZE_COLOR_STATIC_BOLD_WHITE, 115 | 116 | CCZE_COLOR_LAST 117 | } ccze_color_t; 118 | 119 | int ccze_color (ccze_color_t idx); 120 | int ccze_color_keyword_lookup (const char *key); 121 | 122 | /* Helpers */ 123 | ccze_color_t ccze_http_action (const char *method); 124 | void ccze_print_date (const char *date); 125 | char *ccze_strbrk (char *str, char delim); 126 | char *xstrdup (const char *str); 127 | 128 | /* Display */ 129 | void ccze_addstr (ccze_color_t col, const char *str); 130 | void ccze_newline (void); 131 | void ccze_space (void); 132 | void ccze_wordcolor_process_one (char *word, int slookup); 133 | 134 | /* Plugins */ 135 | typedef void (*ccze_plugin_startup_t) (void); 136 | typedef void (*ccze_plugin_shutdown_t) (void); 137 | typedef int (*ccze_plugin_handle_t) (const char *str, size_t length, 138 | char **rest); 139 | 140 | typedef enum 141 | { 142 | CCZE_PLUGIN_TYPE_FULL, 143 | CCZE_PLUGIN_TYPE_PARTIAL, 144 | CCZE_PLUGIN_TYPE_ANY 145 | } ccze_plugin_type_t; 146 | 147 | typedef struct 148 | { 149 | int abi_version; 150 | void *dlhandle; 151 | char *name; 152 | char **argv; 153 | ccze_plugin_startup_t startup; 154 | ccze_plugin_shutdown_t shutdown; 155 | ccze_plugin_handle_t handler; 156 | ccze_plugin_type_t type; 157 | char *desc; 158 | } ccze_plugin_t; 159 | 160 | char **ccze_plugin_argv_get (const char *name); 161 | const char *ccze_plugin_name_get (void); 162 | 163 | #define CCZE_ABI_VERSION 2 164 | 165 | #define CCZE_DEFINE_PLUGINS(plugins...) \ 166 | char *ccze_plugin_list[] = { plugins, NULL } 167 | 168 | #if !defined(BUILTIN) 169 | #define __default_plugin(name) ; \ 170 | char ccze_default_plugin[] = # name 171 | #else 172 | #define __default_plugin(name) 173 | #endif 174 | 175 | #define CCZE_DEFINE_PLUGIN(name,type,desc) \ 176 | ccze_plugin_t ccze_##name##_info = { CCZE_ABI_VERSION, \ 177 | NULL, \ 178 | # name, NULL, \ 179 | ccze_##name##_setup, \ 180 | ccze_##name##_shutdown, \ 181 | ccze_##name##_handle, \ 182 | CCZE_PLUGIN_TYPE_##type, desc } \ 183 | __default_plugin (name) 184 | 185 | #endif /* !_CCZE_H */ 186 | -------------------------------------------------------------------------------- /system.h.in: -------------------------------------------------------------------------------- 1 | /* system.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if the `closedir' function returns void instead of `int'. */ 4 | #undef CLOSEDIR_VOID 5 | 6 | /* Define to 1 if you have the `alphasort' function. */ 7 | #undef HAVE_ALPHASORT 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_ARGP_H 11 | 12 | /* Define to 1 if you have the `argp_parse' function. */ 13 | #undef HAVE_ARGP_PARSE 14 | 15 | /* Define to 1 if you have the `asprintf' function. */ 16 | #undef HAVE_ASPRINTF 17 | 18 | /* Define to 1 if you have the header file, and it defines `DIR'. 19 | */ 20 | #undef HAVE_DIRENT_H 21 | 22 | /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ 23 | #undef HAVE_DOPRNT 24 | 25 | /* Define to 1 if you have the header file. */ 26 | #undef HAVE_FCNTL_H 27 | 28 | /* Define to 1 if you have the `getdelim' function. */ 29 | #undef HAVE_GETDELIM 30 | 31 | /* Define to 1 if you have the `getline' function. */ 32 | #undef HAVE_GETLINE 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #undef HAVE_GETOPT_H 36 | 37 | /* Define to 1 if you have the `getopt_long' function. */ 38 | #undef HAVE_GETOPT_LONG 39 | 40 | /* Define to 1 if you have the `getsubopt' function. */ 41 | #undef HAVE_GETSUBOPT 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #undef HAVE_INTTYPES_H 45 | 46 | /* Define to 1 if you have the `dl' library (-ldl). */ 47 | #undef HAVE_LIBDL 48 | 49 | /* Define to 1 if you have the `gnugetopt' library (-lgnugetopt). */ 50 | #undef HAVE_LIBGNUGETOPT 51 | 52 | /* Define to 1 if you have the `ncurses' library (-lncurses). */ 53 | #undef HAVE_LIBNCURSES 54 | 55 | /* Define to 1 if your system has a GNU libc compatible `malloc' function, and 56 | to 0 otherwise. */ 57 | #undef HAVE_MALLOC 58 | 59 | /* Define to 1 if you have the `memchr' function. */ 60 | #undef HAVE_MEMCHR 61 | 62 | /* Define to 1 if you have the header file. */ 63 | #undef HAVE_MEMORY_H 64 | 65 | /* Define to 1 if you have the `memset' function. */ 66 | #undef HAVE_MEMSET 67 | 68 | /* Define to 1 if you have the header file, and it defines `DIR'. */ 69 | #undef HAVE_NDIR_H 70 | 71 | /* Define to 1 if you have the header file. */ 72 | #undef HAVE_NETDB_H 73 | 74 | /* Define to 1 if your system has a GNU libc compatible `realloc' function, 75 | and to 0 otherwise. */ 76 | #undef HAVE_REALLOC 77 | 78 | /* Define to 1 if you have the `scandir' function. */ 79 | #undef HAVE_SCANDIR 80 | 81 | /* Define to 1 if `stat' has the bug that it succeeds when given the 82 | zero-length file name argument. */ 83 | #undef HAVE_STAT_EMPTY_STRING_BUG 84 | 85 | /* Define to 1 if you have the header file. */ 86 | #undef HAVE_STDDEF_H 87 | 88 | /* Define to 1 if you have the header file. */ 89 | #undef HAVE_STDINT_H 90 | 91 | /* Define to 1 if you have the header file. */ 92 | #undef HAVE_STDLIB_H 93 | 94 | /* Define to 1 if you have the `strcasecmp' function. */ 95 | #undef HAVE_STRCASECMP 96 | 97 | /* Define to 1 if you have the `strchr' function. */ 98 | #undef HAVE_STRCHR 99 | 100 | /* Define to 1 if you have the `strdup' function. */ 101 | #undef HAVE_STRDUP 102 | 103 | /* Define to 1 if you have the `strftime' function. */ 104 | #undef HAVE_STRFTIME 105 | 106 | /* Define to 1 if you have the header file. */ 107 | #undef HAVE_STRINGS_H 108 | 109 | /* Define to 1 if you have the header file. */ 110 | #undef HAVE_STRING_H 111 | 112 | /* Define to 1 if you have the `strndup' function. */ 113 | #undef HAVE_STRNDUP 114 | 115 | /* Define to 1 if you have the `strstr' function. */ 116 | #undef HAVE_STRSTR 117 | 118 | /* Define this if you have the suboptarg variable */ 119 | #undef HAVE_SUBOPTARG 120 | 121 | /* Define to 1 if you have the header file, and it defines `DIR'. 122 | */ 123 | #undef HAVE_SYS_DIR_H 124 | 125 | /* Define to 1 if you have the header file, and it defines `DIR'. 126 | */ 127 | #undef HAVE_SYS_NDIR_H 128 | 129 | /* Define to 1 if you have the header file. */ 130 | #undef HAVE_SYS_STAT_H 131 | 132 | /* Define to 1 if you have the header file. */ 133 | #undef HAVE_SYS_TYPES_H 134 | 135 | /* Define to 1 if you have the header file. */ 136 | #undef HAVE_UNISTD_H 137 | 138 | /* Define to 1 if you have the `vprintf' function. */ 139 | #undef HAVE_VPRINTF 140 | 141 | /* Define to 1 if `lstat' dereferences a symlink specified with a trailing 142 | slash. */ 143 | #undef LSTAT_FOLLOWS_SLASHED_SYMLINK 144 | 145 | /* Define to the address where bug reports for this package should be sent. */ 146 | #undef PACKAGE_BUGREPORT 147 | 148 | /* Define to the full name of this package. */ 149 | #undef PACKAGE_NAME 150 | 151 | /* Define to the full name and version of this package. */ 152 | #undef PACKAGE_STRING 153 | 154 | /* Define to the one symbol short name of this package. */ 155 | #undef PACKAGE_TARNAME 156 | 157 | /* Define to the version of this package. */ 158 | #undef PACKAGE_VERSION 159 | 160 | /* Define as the return type of signal handlers (`int' or `void'). */ 161 | #undef RETSIGTYPE 162 | 163 | /* Define to 1 if you have the ANSI C header files. */ 164 | #undef STDC_HEADERS 165 | 166 | /* Define to empty if `const' does not conform to ANSI C. */ 167 | #undef const 168 | 169 | /* Define to rpl_malloc if the replacement function should be used. */ 170 | #undef malloc 171 | 172 | /* Define to rpl_realloc if the replacement function should be used. */ 173 | #undef realloc 174 | 175 | /* Define to `unsigned' if does not define. */ 176 | #undef size_t 177 | 178 | /* Define to empty if the keyword `volatile' does not work. Warning: valid 179 | code using `volatile' can become incorrect without. Disable with care. */ 180 | #undef volatile 181 | -------------------------------------------------------------------------------- /src/mod_httpd.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_httpd.c -- httpd-related colorizers for CCZE 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | static void ccze_httpd_setup (void); 27 | static void ccze_httpd_shutdown (void); 28 | static int ccze_httpd_handle (const char *str, size_t length, char **rest); 29 | 30 | static pcre *reg_httpd_access, *reg_httpd_error; 31 | static pcre_extra *hints_httpd_access, *hints_httpd_error; 32 | 33 | static ccze_color_t 34 | _ccze_httpd_error (const char *level) 35 | { 36 | if (strstr (level, "debug") || strstr (level, "info") || 37 | strstr (level, "notice")) 38 | return CCZE_COLOR_DEBUG; 39 | if (strstr (level, "warn")) 40 | return CCZE_COLOR_WARNING; 41 | if (strstr (level, "error") || strstr (level, "crit") || 42 | strstr (level, "alert") || strstr (level, "emerg")) 43 | return CCZE_COLOR_ERROR; 44 | return CCZE_COLOR_UNKNOWN; 45 | } 46 | 47 | static char * 48 | ccze_httpd_access_log_process (const char *str, int *offsets, int match) 49 | { 50 | char *host, *vhost, *user, *date, *full_action, *method, *http_code; 51 | char *gsize, *other; 52 | 53 | pcre_get_substring (str, offsets, match, 1, (const char **)&vhost); 54 | pcre_get_substring (str, offsets, match, 2, (const char **)&host); 55 | pcre_get_substring (str, offsets, match, 3, (const char **)&user); 56 | pcre_get_substring (str, offsets, match, 4, (const char **)&date); 57 | pcre_get_substring (str, offsets, match, 5, (const char **)&full_action); 58 | pcre_get_substring (str, offsets, match, 6, (const char **)&method); 59 | pcre_get_substring (str, offsets, match, 7, (const char **)&http_code); 60 | pcre_get_substring (str, offsets, match, 8, (const char **)&gsize); 61 | pcre_get_substring (str, offsets, match, 9, (const char **)&other); 62 | 63 | ccze_addstr (CCZE_COLOR_HOST, vhost); 64 | ccze_space(); 65 | ccze_addstr (CCZE_COLOR_HOST, host); 66 | if (host[0]) 67 | ccze_space (); 68 | ccze_addstr (CCZE_COLOR_DEFAULT, "-"); 69 | ccze_space (); 70 | 71 | ccze_addstr (CCZE_COLOR_USER, user); 72 | ccze_space (); 73 | 74 | ccze_addstr (CCZE_COLOR_DATE, date); 75 | ccze_space (); 76 | 77 | ccze_addstr (ccze_http_action (method), full_action); 78 | ccze_space (); 79 | 80 | ccze_addstr (CCZE_COLOR_HTTPCODES, http_code); 81 | ccze_space (); 82 | 83 | ccze_addstr (CCZE_COLOR_GETSIZE, gsize); 84 | ccze_space (); 85 | 86 | ccze_addstr (CCZE_COLOR_DEFAULT, other); 87 | ccze_newline (); 88 | 89 | free (host); 90 | free (user); 91 | free (date); 92 | free (method); 93 | free (full_action); 94 | free (http_code); 95 | free (gsize); 96 | 97 | return NULL; 98 | } 99 | 100 | static char * 101 | ccze_httpd_error_log_process (const char *str, int *offsets, int match) 102 | { 103 | char *date, *level, *msg; 104 | ccze_color_t lcol; 105 | 106 | pcre_get_substring (str, offsets, match, 1, (const char **)&date); 107 | pcre_get_substring (str, offsets, match, 2, (const char **)&level); 108 | pcre_get_substring (str, offsets, match, 3, (const char **)&msg); 109 | 110 | ccze_addstr (CCZE_COLOR_DATE, date); 111 | ccze_space (); 112 | 113 | lcol = _ccze_httpd_error (level); 114 | ccze_addstr (lcol, level); 115 | ccze_space (); 116 | 117 | ccze_addstr (lcol, msg); 118 | 119 | ccze_newline (); 120 | 121 | free (date); 122 | free (level); 123 | free (msg); 124 | 125 | return NULL; 126 | } 127 | 128 | static void 129 | ccze_httpd_setup (void) 130 | { 131 | const char *error; 132 | int errptr; 133 | 134 | reg_httpd_access = pcre_compile 135 | ("^(\\S*)\\s(\\S*)?\\s?-\\s(\\S+)\\s(\\[\\d{1,2}\\/\\S*" 136 | "\\/\\d{4}:\\d{2}:\\d{2}:\\d{2}.{0,6}[^\\]]*\\])\\s" 137 | "(\"([^ \"]+)\\s*[^\"]*\")\\s(\\d{3})\\s(\\d+|-)\\s*(.*)$", 138 | 0, &error, &errptr, NULL); 139 | hints_httpd_access = pcre_study (reg_httpd_access, 0, &error); 140 | 141 | reg_httpd_error = pcre_compile 142 | ("^(\\[\\w{3}\\s\\w{3}\\s{1,2}\\d{1,2}\\s\\d{2}:\\d{2}:\\d{2}\\s" 143 | "\\d{4}\\])\\s(\\[\\w*\\])\\s(.*)$", 0, &error, &errptr, NULL); 144 | hints_httpd_error = pcre_study (reg_httpd_error, 0, &error); 145 | } 146 | 147 | static void 148 | ccze_httpd_shutdown (void) 149 | { 150 | free (reg_httpd_access); 151 | free (hints_httpd_access); 152 | free (reg_httpd_error); 153 | free (hints_httpd_error); 154 | } 155 | 156 | static int 157 | ccze_httpd_handle (const char *str, size_t length, char **rest) 158 | { 159 | int match, offsets[99]; 160 | 161 | if ((match = pcre_exec (reg_httpd_access, hints_httpd_access, 162 | str, length, 0, 0, offsets, 99)) >= 0) 163 | { 164 | *rest = ccze_httpd_access_log_process (str, offsets, match); 165 | return 1; 166 | } 167 | if ((match = pcre_exec (reg_httpd_error, hints_httpd_error, 168 | str, length, 0, 0, offsets, 99)) >= 0) 169 | { 170 | *rest = ccze_httpd_error_log_process (str, offsets, match); 171 | return 1; 172 | } 173 | 174 | return 0; 175 | } 176 | 177 | CCZE_DEFINE_PLUGIN (httpd, FULL, 178 | "Coloriser for generic HTTPD access and error logs."); 179 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | # do not edit -- automatically generated by arch changelog 2 | # tag: automatic-ChangeLog--algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.2 3 | # 4 | 5 | 2003-05-13 17:51:30 GMT Gergely Nagy patch-1 6 | 7 | Summary: 8 | The `Fireflower' release 9 | Revision: 10 | ccze--0.2--patch-1 11 | 12 | Always cold outside 13 | And it's freezing inside 14 | Into the fire we ride 15 | 16 | * NEWS: Updated. 17 | * debian/changelog: Likewise. 18 | 19 | Patches applied: 20 | 21 | * algernon@bonehunter-rulez.org--iluvatar-archive/ccze--0.3--patch-12 22 | Run `make check' during distcheck 23 | 24 | * algernon@bonehunter-rulez.org--iluvatar-archive/ccze--0.3--patch-11 25 | Fixed procmail subject coloring 26 | 27 | * algernon@bonehunter-rulez.org--iluvatar-archive/ccze--0.3--patch-10 28 | Fixed the testsuite 29 | 30 | * algernon@bonehunter-rulez.org--iluvatar-archive/ccze--0.3--patch-9 31 | Support transparency in the ANSI output too 32 | 33 | * algernon@bonehunter-rulez.org--iluvatar-archive/ccze--0.3--patch-8 34 | Raw ANSI supports background colors 35 | 36 | * algernon@bonehunter-rulez.org--iluvatar-archive/ccze--0.3--patch-7 37 | Documented ccze-dump 38 | 39 | * algernon@bonehunter-rulez.org--iluvatar-archive/ccze--0.3--patch-6 40 | ChangeLog id update 41 | 42 | * algernon@bonehunter-rulez.org--iluvatar-archive/ccze--0.3--patch-5 43 | TODO removed 44 | 45 | * algernon@bonehunter-rulez.org--iluvatar-archive/ccze--0.3--patch-4 46 | Fixed double module loading 47 | 48 | * algernon@bonehunter-rulez.org--iluvatar-archive/ccze--0.3--patch-3 49 | Added --mode 50 | 51 | * algernon@bonehunter-rulez.org--iluvatar-archive/ccze--0.3--patch-2 52 | Documented --list-plugins 53 | 54 | * algernon@bonehunter-rulez.org--iluvatar-archive/ccze--0.3--patch-1 55 | Fixed a compile-time warning 56 | 57 | new files: 58 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log/base-0 59 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log/patch-1 60 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log/patch-10 61 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log/patch-11 62 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log/patch-12 63 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log/patch-2 64 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log/patch-3 65 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log/patch-4 66 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log/patch-5 67 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log/patch-6 68 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log/patch-7 69 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log/patch-8 70 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log/patch-9 71 | testsuite/.arch-ids/bug-procmailsubj2.in.id 72 | testsuite/.arch-ids/bug-procmailsubj2.ok.id 73 | testsuite/.arch-ids/bug-procmailsubj2.test.id 74 | testsuite/bug-procmailsubj2.in testsuite/bug-procmailsubj2.ok 75 | testsuite/bug-procmailsubj2.test 76 | 77 | modified files: 78 | Makefile.in NEWS ccze.spec.in debian/changelog debian/rules 79 | doc/ccze.1.in src/ccze-color.c src/ccze-plugin.c src/ccze.c 80 | src/mod_procmail.c testsuite/Makefile.in 81 | testsuite/bug-httpd.ok testsuite/bug-procmailsubj.ok 82 | testsuite/bug-procmailsubj.test testsuite/do-test 83 | 84 | new directories: 85 | {arch}/ccze/ccze/ccze--0.3 86 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive 87 | {arch}/ccze/ccze/ccze--0.3/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log 88 | 89 | new patches: 90 | algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.3--base-0 91 | algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.3--patch-1 92 | algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.3--patch-2 93 | algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.3--patch-3 94 | algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.3--patch-4 95 | algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.3--patch-5 96 | algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.3--patch-6 97 | algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.3--patch-7 98 | algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.3--patch-8 99 | algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.3--patch-9 100 | algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.3--patch-10 101 | algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.3--patch-11 102 | algernon@bonehunter.rulez.org--iluvatar-archive/ccze--0.3--patch-12 103 | 104 | 105 | 2003-03-29 19:04:20 GMT Gergely Nagy base-0 106 | 107 | Summary: 108 | The `Mephisto' release. 109 | Revision: 110 | ccze--0.2--base-0 111 | 112 | (Instrumental) 113 | 114 | * NEWS: Updated. 115 | * debian/changelog: Likewise. 116 | * configure.ac: Likewise. 117 | * Rules.mk.in: Likewise. 118 | * src/ccze.c: Likewise. 119 | * ChangeLog-0.1: ChangeLog of the old 0.1 branch. 120 | * Makefile.in (EXTRA_DIST): Added ChangeLog-0.1. 121 | * ccze.spec.in (%doc): Likewise. 122 | 123 | new files: 124 | .arch-ids/ChangeLog.id ChangeLog 125 | 126 | modified files: 127 | Makefile.in NEWS Rules.mk.in ccze.spec.in configure.ac 128 | debian/changelog src/ccze.c 129 | 130 | renamed files: 131 | .arch-ids/ChangeLog.id 132 | ==> .arch-ids/ChangeLog-0.1.id 133 | ChangeLog 134 | ==> ChangeLog-0.1 135 | 136 | 137 | new directories: 138 | {arch}/ccze/ccze/ccze--0.2 139 | {arch}/ccze/ccze/ccze--0.2/algernon@bonehunter.rulez.org--iluvatar-archive 140 | {arch}/ccze/ccze/ccze--0.2/algernon@bonehunter.rulez.org--iluvatar-archive/patch-log 141 | 142 | 143 | -------------------------------------------------------------------------------- /src/mod_icecast.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_icecast.c -- icecast/{usage,icecast}.log colorizers for CCZE 3 | * Copyright (C) 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "ccze-compat.h" 27 | 28 | static void ccze_icecast_setup (void); 29 | static void ccze_icecast_shutdown (void); 30 | static int ccze_icecast_handle (const char *str, size_t length, char **rest); 31 | 32 | static pcre *reg_icecast, *reg_icecast_usage; 33 | static pcre_extra *hints_icecast, *hints_icecast_usage; 34 | 35 | static char * 36 | ccze_icecast_process (const char *str, int *offsets, int match) 37 | { 38 | char *date = NULL, *admin = NULL, *threadno = NULL, *thread = NULL; 39 | char *rest = NULL; 40 | 41 | pcre_get_substring (str, offsets, match, 1, (const char **)&date); 42 | pcre_get_substring (str, offsets, match, 2, (const char **)&admin); 43 | pcre_get_substring (str, offsets, match, 4, (const char **)&threadno); 44 | pcre_get_substring (str, offsets, match, 5, (const char **)&thread); 45 | pcre_get_substring (str, offsets, match, 6, (const char **)&rest); 46 | 47 | ccze_addstr (CCZE_COLOR_DATE, date); 48 | ccze_space (); 49 | 50 | if (admin && admin[0] != '\0') 51 | { 52 | ccze_addstr (CCZE_COLOR_KEYWORD, admin); 53 | ccze_space (); 54 | ccze_addstr (CCZE_COLOR_PIDB, "["); 55 | ccze_addstr (CCZE_COLOR_HOST, thread); 56 | ccze_addstr (CCZE_COLOR_PIDB, "]"); 57 | } 58 | else 59 | { 60 | ccze_addstr (CCZE_COLOR_PIDB, "["); 61 | ccze_addstr (CCZE_COLOR_NUMBERS, threadno); 62 | ccze_addstr (CCZE_COLOR_DEFAULT, ":"); 63 | ccze_addstr (CCZE_COLOR_KEYWORD, thread); 64 | ccze_addstr (CCZE_COLOR_PIDB, "]"); 65 | } 66 | ccze_space (); 67 | 68 | free (date); 69 | free (admin); 70 | free (threadno); 71 | free (thread); 72 | 73 | return rest; 74 | } 75 | 76 | static char * 77 | ccze_icecast_usage_process (const char *str, int *offsets, int match) 78 | { 79 | char *date, *threadno, *thread, *date2, *bw, *src; 80 | char *unit, *clients, *admins; 81 | 82 | pcre_get_substring (str, offsets, match, 1, (const char **)&date); 83 | pcre_get_substring (str, offsets, match, 3, (const char **)&threadno); 84 | pcre_get_substring (str, offsets, match, 4, (const char **)&thread); 85 | pcre_get_substring (str, offsets, match, 5, (const char **)&date2); 86 | pcre_get_substring (str, offsets, match, 6, (const char **)&bw); 87 | pcre_get_substring (str, offsets, match, 7, (const char **)&unit); 88 | pcre_get_substring (str, offsets, match, 8, (const char **)&src); 89 | pcre_get_substring (str, offsets, match, 9, (const char **)&clients); 90 | pcre_get_substring (str, offsets, match, 10, (const char **)&admins); 91 | 92 | 93 | ccze_addstr (CCZE_COLOR_DATE, date); 94 | ccze_space (); 95 | 96 | ccze_addstr (CCZE_COLOR_PIDB, "["); 97 | ccze_addstr (CCZE_COLOR_NUMBERS, threadno); 98 | ccze_addstr (CCZE_COLOR_DEFAULT, ":"); 99 | ccze_addstr (CCZE_COLOR_KEYWORD, thread); 100 | ccze_addstr (CCZE_COLOR_PIDB, "]"); 101 | ccze_space (); 102 | 103 | ccze_addstr (CCZE_COLOR_DATE, date2); 104 | ccze_space (); 105 | 106 | ccze_addstr (CCZE_COLOR_KEYWORD, "Bandwidth:"); 107 | ccze_addstr (CCZE_COLOR_NUMBERS, bw); 108 | ccze_addstr (CCZE_COLOR_DEFAULT, unit); 109 | ccze_space (); 110 | 111 | ccze_addstr (CCZE_COLOR_KEYWORD, "Sources:"); 112 | ccze_addstr (CCZE_COLOR_NUMBERS, src); 113 | ccze_space (); 114 | 115 | ccze_addstr (CCZE_COLOR_KEYWORD, "Clients:"); 116 | ccze_addstr (CCZE_COLOR_NUMBERS, clients); 117 | ccze_space (); 118 | 119 | ccze_addstr (CCZE_COLOR_KEYWORD, "Admins:"); 120 | ccze_addstr (CCZE_COLOR_NUMBERS, admins); 121 | 122 | ccze_newline (); 123 | 124 | free (date); 125 | free (threadno); 126 | free (thread); 127 | free (date2); 128 | free (bw); 129 | free (unit); 130 | free (src); 131 | free (clients); 132 | free (admins); 133 | 134 | return NULL; 135 | } 136 | 137 | static void 138 | ccze_icecast_setup (void) 139 | { 140 | const char *error; 141 | int errptr; 142 | 143 | reg_icecast = pcre_compile ("^(\\[\\d+/.../\\d+:\\d+:\\d+:\\d+\\]) " 144 | "(Admin)? *(\\[(\\d+)?:?([^\\]]*)\\]) (.*)$", 145 | 0, &error, &errptr, NULL); 146 | hints_icecast = pcre_study (reg_icecast, 0, &error); 147 | 148 | reg_icecast_usage = pcre_compile ("^(\\[\\d+/.../\\d+:\\d+:\\d+:\\d+\\]) " 149 | "(\\[(\\d+):([^\\]]*)\\]) " 150 | "(\\[\\d+/.../\\d+:\\d+:\\d+:\\d+\\]) " 151 | "Bandwidth:([\\d\\.]+)([^ ]*) " 152 | "Sources:(\\d+) " 153 | "Clients:(\\d+) Admins:(\\d+)", 154 | 0, &error, &errptr, NULL); 155 | hints_icecast_usage = pcre_study (reg_icecast_usage, 0, &error); 156 | } 157 | 158 | static void 159 | ccze_icecast_shutdown (void) 160 | { 161 | free (reg_icecast); 162 | free (hints_icecast); 163 | free (reg_icecast_usage); 164 | free (hints_icecast_usage); 165 | } 166 | 167 | static int 168 | ccze_icecast_handle (const char *str, size_t length, char **rest) 169 | { 170 | int match, offsets[99]; 171 | 172 | if ((match = pcre_exec (reg_icecast_usage, hints_icecast_usage, 173 | str, length, 0, 0, offsets, 99)) >= 0) 174 | { 175 | *rest = ccze_icecast_usage_process (str, offsets, match); 176 | return 1; 177 | } 178 | 179 | if ((match = pcre_exec (reg_icecast, hints_icecast, str, length, 180 | 0, 0, offsets, 99)) >= 0) 181 | { 182 | *rest = ccze_icecast_process (str, offsets, match); 183 | return 1; 184 | } 185 | 186 | return 0; 187 | } 188 | 189 | CCZE_DEFINE_PLUGIN (icecast, FULL, "Coloriser for Icecast(8) logs."); 190 | -------------------------------------------------------------------------------- /src/mod_proftpd.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_proftpd.c -- proftpd-related colorizers for CCZE 3 | * Copyright (C) 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | static void ccze_proftpd_setup (void); 27 | static void ccze_proftpd_shutdown (void); 28 | static int ccze_proftpd_handle (const char *str, size_t length, char **rest); 29 | 30 | static pcre *reg_proftpd_access, *reg_proftpd_auth; 31 | static pcre_extra *hints_proftpd_access, *hints_proftpd_auth; 32 | 33 | static char * 34 | ccze_proftpd_access_log_process (const char *str, int *offsets, int match) 35 | { 36 | char *host, *user, *auser, *date, *command, *file, *ftpcode, *size; 37 | 38 | pcre_get_substring (str, offsets, match, 1, (const char **)&host); 39 | pcre_get_substring (str, offsets, match, 2, (const char **)&user); 40 | pcre_get_substring (str, offsets, match, 3, (const char **)&auser); 41 | pcre_get_substring (str, offsets, match, 4, (const char **)&date); 42 | pcre_get_substring (str, offsets, match, 5, (const char **)&command); 43 | pcre_get_substring (str, offsets, match, 6, (const char **)&file); 44 | pcre_get_substring (str, offsets, match, 7, (const char **)&ftpcode); 45 | pcre_get_substring (str, offsets, match, 8, (const char **)&size); 46 | 47 | ccze_addstr (CCZE_COLOR_HOST, host); 48 | ccze_space (); 49 | ccze_addstr (CCZE_COLOR_USER, user); 50 | ccze_space (); 51 | ccze_addstr (CCZE_COLOR_USER, auser); 52 | ccze_space (); 53 | 54 | ccze_addstr (CCZE_COLOR_DEFAULT, "["); 55 | ccze_print_date (date); 56 | ccze_addstr (CCZE_COLOR_DEFAULT, "]"); 57 | ccze_space (); 58 | 59 | ccze_addstr (CCZE_COLOR_DEFAULT, "\""); 60 | ccze_addstr (CCZE_COLOR_KEYWORD, command); 61 | ccze_space (); 62 | ccze_addstr (CCZE_COLOR_URI, file); 63 | ccze_addstr (CCZE_COLOR_DEFAULT, "\""); 64 | ccze_space (); 65 | 66 | ccze_addstr (CCZE_COLOR_FTPCODES, ftpcode); 67 | ccze_space (); 68 | ccze_addstr (CCZE_COLOR_GETSIZE, size); 69 | 70 | ccze_newline (); 71 | 72 | free (size); 73 | free (ftpcode); 74 | free (file); 75 | free (command); 76 | free (date); 77 | free (auser); 78 | free (user); 79 | free (host); 80 | 81 | return NULL; 82 | } 83 | 84 | static char * 85 | ccze_proftpd_auth_log_process (const char *str, int *offsets, int match) 86 | { 87 | char *servhost, *pid, *remhost, *date, *cmd, *value, *ftpcode; 88 | 89 | pcre_get_substring (str, offsets, match, 1, (const char **)&servhost); 90 | pcre_get_substring (str, offsets, match, 2, (const char **)&pid); 91 | pcre_get_substring (str, offsets, match, 3, (const char **)&remhost); 92 | pcre_get_substring (str, offsets, match, 4, (const char **)&date); 93 | pcre_get_substring (str, offsets, match, 5, (const char **)&cmd); 94 | pcre_get_substring (str, offsets, match, 6, (const char **)&value); 95 | pcre_get_substring (str, offsets, match, 7, (const char **)&ftpcode); 96 | 97 | ccze_addstr (CCZE_COLOR_HOST, servhost); 98 | ccze_space (); 99 | ccze_addstr (CCZE_COLOR_DEFAULT, "ftp server"); 100 | ccze_space (); 101 | ccze_addstr (CCZE_COLOR_PIDB, "["); 102 | ccze_addstr (CCZE_COLOR_PID, pid); 103 | ccze_addstr (CCZE_COLOR_PIDB, "]"); 104 | ccze_space (); 105 | ccze_addstr (CCZE_COLOR_HOST, remhost); 106 | ccze_space (); 107 | ccze_addstr (CCZE_COLOR_DEFAULT, "["); 108 | ccze_print_date (date); 109 | ccze_addstr (CCZE_COLOR_DEFAULT, "]"); 110 | ccze_space (); 111 | ccze_addstr (CCZE_COLOR_DEFAULT, "\""); 112 | ccze_addstr (CCZE_COLOR_KEYWORD, cmd); 113 | ccze_space (); 114 | ccze_addstr (CCZE_COLOR_DEFAULT, value); 115 | ccze_addstr (CCZE_COLOR_DEFAULT, "\""); 116 | ccze_space (); 117 | ccze_addstr (CCZE_COLOR_FTPCODES, ftpcode); 118 | 119 | ccze_newline (); 120 | 121 | free (ftpcode); 122 | free (value); 123 | free (cmd); 124 | free (date); 125 | free (remhost); 126 | free (pid); 127 | free (servhost); 128 | 129 | return NULL; 130 | } 131 | 132 | static void 133 | ccze_proftpd_setup (void) 134 | { 135 | const char *error; 136 | int errptr; 137 | 138 | reg_proftpd_access = pcre_compile 139 | ("^(\\d+\\.\\d+\\.\\d+\\.\\d+) (\\S+) (\\S+) " 140 | "\\[(\\d{2}/.{3}/\\d{4}:\\d{2}:\\d{2}:\\d{2} [\\-\\+]\\d{4})\\] " 141 | "\"([A-Z]+) ([^\"]+)\" (\\d{3}) (-|\\d+)", 0, &error, &errptr, NULL); 142 | hints_proftpd_access = pcre_study (reg_proftpd_access, 0, &error); 143 | 144 | reg_proftpd_auth = pcre_compile 145 | ("^(\\S+) ftp server \\[(\\d+)\\] (\\d+\\.\\d+\\.\\d+\\.\\d+) " 146 | "\\[(\\d{2}/.{3}/\\d{4}:\\d{2}:\\d{2}:\\d{2} [\\-\\+]\\d{4})\\] " 147 | "\"([A-Z]+) ([^\"]+)\" (\\d{3})", 0, &error, &errptr, NULL); 148 | hints_proftpd_auth = pcre_study (reg_proftpd_auth, 0, &error); 149 | } 150 | 151 | static void 152 | ccze_proftpd_shutdown (void) 153 | { 154 | free (reg_proftpd_auth); 155 | free (hints_proftpd_auth); 156 | free (reg_proftpd_access); 157 | free (hints_proftpd_access); 158 | } 159 | 160 | static int 161 | ccze_proftpd_handle (const char *str, size_t length, char **rest) 162 | { 163 | int match, offsets[99]; 164 | 165 | if ((match = pcre_exec (reg_proftpd_access, hints_proftpd_access, 166 | str, length, 0, 0, offsets, 99)) >= 0) 167 | { 168 | *rest = ccze_proftpd_access_log_process (str, offsets, match); 169 | return 1; 170 | } 171 | if ((match = pcre_exec (reg_proftpd_auth, hints_proftpd_auth, 172 | str, length, 0, 0, offsets, 99)) >= 0) 173 | { 174 | *rest = ccze_proftpd_auth_log_process (str, offsets, match); 175 | return 1; 176 | } 177 | 178 | return 0; 179 | } 180 | 181 | CCZE_DEFINE_PLUGIN (proftpd, FULL, 182 | "Coloriser for proftpd access and auth logs."); 183 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # install - install a program, script, or datafile 4 | # This comes from X11R5 (mit/util/scripts/install.sh). 5 | # 6 | # Copyright 1991 by the Massachusetts Institute of Technology 7 | # 8 | # Permission to use, copy, modify, distribute, and sell this software and its 9 | # documentation for any purpose is hereby granted without fee, provided that 10 | # the above copyright notice appear in all copies and that both that 11 | # copyright notice and this permission notice appear in supporting 12 | # documentation, and that the name of M.I.T. not be used in advertising or 13 | # publicity pertaining to distribution of the software without specific, 14 | # written prior permission. M.I.T. makes no representations about the 15 | # suitability of this software for any purpose. It is provided "as is" 16 | # without express or implied warranty. 17 | # 18 | # Calling this script install-sh is preferred over install.sh, to prevent 19 | # `make' implicit rules from creating a file called install from it 20 | # when there is no Makefile. 21 | # 22 | # This script is compatible with the BSD install script, but was written 23 | # from scratch. It can only install one file at a time, a restriction 24 | # shared with many OS's install programs. 25 | 26 | 27 | # set DOITPROG to echo to test this script 28 | 29 | # Don't use :- since 4.3BSD and earlier shells don't like it. 30 | doit="${DOITPROG-}" 31 | 32 | 33 | # put in absolute paths if you don't have them in your path; or use env. vars. 34 | 35 | mvprog="${MVPROG-mv}" 36 | cpprog="${CPPROG-cp}" 37 | chmodprog="${CHMODPROG-chmod}" 38 | chownprog="${CHOWNPROG-chown}" 39 | chgrpprog="${CHGRPPROG-chgrp}" 40 | stripprog="${STRIPPROG-strip}" 41 | rmprog="${RMPROG-rm}" 42 | mkdirprog="${MKDIRPROG-mkdir}" 43 | 44 | transformbasename="" 45 | transform_arg="" 46 | instcmd="$mvprog" 47 | chmodcmd="$chmodprog 0755" 48 | chowncmd="" 49 | chgrpcmd="" 50 | stripcmd="" 51 | rmcmd="$rmprog -f" 52 | mvcmd="$mvprog" 53 | src="" 54 | dst="" 55 | dir_arg="" 56 | 57 | while [ x"$1" != x ]; do 58 | case $1 in 59 | -c) instcmd="$cpprog" 60 | shift 61 | continue;; 62 | 63 | -d) dir_arg=true 64 | shift 65 | continue;; 66 | 67 | -m) chmodcmd="$chmodprog $2" 68 | shift 69 | shift 70 | continue;; 71 | 72 | -o) chowncmd="$chownprog $2" 73 | shift 74 | shift 75 | continue;; 76 | 77 | -g) chgrpcmd="$chgrpprog $2" 78 | shift 79 | shift 80 | continue;; 81 | 82 | -s) stripcmd="$stripprog" 83 | shift 84 | continue;; 85 | 86 | -t=*) transformarg=`echo $1 | sed 's/-t=//'` 87 | shift 88 | continue;; 89 | 90 | -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 91 | shift 92 | continue;; 93 | 94 | *) if [ x"$src" = x ] 95 | then 96 | src=$1 97 | else 98 | # this colon is to work around a 386BSD /bin/sh bug 99 | : 100 | dst=$1 101 | fi 102 | shift 103 | continue;; 104 | esac 105 | done 106 | 107 | if [ x"$src" = x ] 108 | then 109 | echo "install: no input file specified" 110 | exit 1 111 | else 112 | true 113 | fi 114 | 115 | if [ x"$dir_arg" != x ]; then 116 | dst=$src 117 | src="" 118 | 119 | if [ -d $dst ]; then 120 | instcmd=: 121 | chmodcmd="" 122 | else 123 | instcmd=mkdir 124 | fi 125 | else 126 | 127 | # Waiting for this to be detected by the "$instcmd $src $dsttmp" command 128 | # might cause directories to be created, which would be especially bad 129 | # if $src (and thus $dsttmp) contains '*'. 130 | 131 | if [ -f $src -o -d $src ] 132 | then 133 | true 134 | else 135 | echo "install: $src does not exist" 136 | exit 1 137 | fi 138 | 139 | if [ x"$dst" = x ] 140 | then 141 | echo "install: no destination specified" 142 | exit 1 143 | else 144 | true 145 | fi 146 | 147 | # If destination is a directory, append the input filename; if your system 148 | # does not like double slashes in filenames, you may need to add some logic 149 | 150 | if [ -d $dst ] 151 | then 152 | dst="$dst"/`basename $src` 153 | else 154 | true 155 | fi 156 | fi 157 | 158 | ## this sed command emulates the dirname command 159 | dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 160 | 161 | # Make sure that the destination directory exists. 162 | # this part is taken from Noah Friedman's mkinstalldirs script 163 | 164 | # Skip lots of stat calls in the usual case. 165 | if [ ! -d "$dstdir" ]; then 166 | defaultIFS=' 167 | ' 168 | IFS="${IFS-${defaultIFS}}" 169 | 170 | oIFS="${IFS}" 171 | # Some sh's can't handle IFS=/ for some reason. 172 | IFS='%' 173 | set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` 174 | IFS="${oIFS}" 175 | 176 | pathcomp='' 177 | 178 | while [ $# -ne 0 ] ; do 179 | pathcomp="${pathcomp}${1}" 180 | shift 181 | 182 | if [ ! -d "${pathcomp}" ] ; 183 | then 184 | $mkdirprog "${pathcomp}" 185 | else 186 | true 187 | fi 188 | 189 | pathcomp="${pathcomp}/" 190 | done 191 | fi 192 | 193 | if [ x"$dir_arg" != x ] 194 | then 195 | $doit $instcmd $dst && 196 | 197 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && 198 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && 199 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && 200 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi 201 | else 202 | 203 | # If we're going to rename the final executable, determine the name now. 204 | 205 | if [ x"$transformarg" = x ] 206 | then 207 | dstfile=`basename $dst` 208 | else 209 | dstfile=`basename $dst $transformbasename | 210 | sed $transformarg`$transformbasename 211 | fi 212 | 213 | # don't allow the sed command to completely eliminate the filename 214 | 215 | if [ x"$dstfile" = x ] 216 | then 217 | dstfile=`basename $dst` 218 | else 219 | true 220 | fi 221 | 222 | # Make a temp file name in the proper directory. 223 | 224 | dsttmp=$dstdir/#inst.$$# 225 | 226 | # Move or copy the file name to the temp name 227 | 228 | $doit $instcmd $src $dsttmp && 229 | 230 | trap "rm -f ${dsttmp}" 0 && 231 | 232 | # and set any options; do chmod last to preserve setuid bits 233 | 234 | # If any of these fail, we abort the whole thing. If we want to 235 | # ignore errors from any of these, just make sure not to ignore 236 | # errors from the above "$doit $instcmd $src $dsttmp" command. 237 | 238 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && 239 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && 240 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && 241 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && 242 | 243 | # Now rename the file to the real destination. 244 | 245 | $doit $rmcmd -f $dstdir/$dstfile && 246 | $doit $mvcmd $dsttmp $dstdir/$dstfile 247 | 248 | fi && 249 | 250 | 251 | exit 0 252 | -------------------------------------------------------------------------------- /src/ccze-dump.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * ccze-dump.c -- Dump internal color table 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #define CCZE_DUMP 1 23 | 24 | #include 25 | #ifdef HAVE_ARGP_H 26 | # include 27 | #endif 28 | 29 | #include "ccze-color.c" 30 | #include "ccze-compat.h" 31 | 32 | ccze_config_t ccze_config = { 33 | .scroll = 1, 34 | .convdate = 0, 35 | .remfac = 0, 36 | .wcol = 1, 37 | .slookup = 1, 38 | .rcfile = NULL, 39 | .cssfile = NULL, 40 | .transparent = 1, 41 | .pluginlist_len = 0, 42 | .pluginlist_alloc = 10, 43 | .color_argv_len = 0, 44 | .color_argv_alloc = 10, 45 | .mode = CCZE_MODE_CURSES 46 | }; 47 | 48 | const char *argp_program_name = "ccze-dump"; 49 | const char *argp_program_version = "ccze-dump (ccze 0.1." PATCHLEVEL ")"; 50 | const char *argp_program_bug_address = ""; 51 | static struct argp_option options[] = { 52 | {NULL, 0, NULL, 0, "", 1}, 53 | {"rcfile", 'F', "FILE", 0, "Read configuration from FILE", 1}, 54 | {"load", 'l', NULL, 0, "Load default configuration files", 1}, 55 | {NULL, 0, NULL, 0, NULL, 0} 56 | }; 57 | 58 | static error_t parse_opt (int key, char *arg, struct argp_state *state); 59 | static struct argp argp = 60 | {options, parse_opt, 0, "ccze -- cheer up 'yer logs.", NULL, NULL, NULL}; 61 | 62 | static int ccze_loaddefs = 0; 63 | 64 | static error_t 65 | parse_opt (int key, char *arg, struct argp_state *state) 66 | { 67 | switch (key) 68 | { 69 | case 'F': 70 | ccze_config.rcfile = arg; 71 | break; 72 | case 'l': 73 | ccze_loaddefs = 1; 74 | break; 75 | default: 76 | return ARGP_ERR_UNKNOWN; 77 | } 78 | return 0; 79 | } 80 | 81 | static char * 82 | ccze_dump_color_get_attrib (int color) 83 | { 84 | char *str = (char *)ccze_calloc (100, sizeof (char)); 85 | 86 | if (color & A_BOLD) 87 | strcat (str, "bold "); 88 | if (color & A_UNDERLINE) 89 | strcat (str, "underline "); 90 | if (color & A_REVERSE) 91 | strcat (str, "reverse "); 92 | if (color & A_BLINK) 93 | strcat (str, "blink "); 94 | 95 | return str; 96 | } 97 | 98 | static char * 99 | ccze_dump_color_to_name (int color) 100 | { 101 | int my_color = ccze_color_strip_attrib (color); 102 | 103 | if (my_color < COLOR_PAIR (8)) 104 | return ccze_color_to_name_simple (my_color); 105 | else 106 | { 107 | int i,j; 108 | char *str, *cj, *ci; 109 | 110 | j = (my_color >> 8) % 8; 111 | i = (my_color >> 8) / 8; 112 | cj = ccze_color_to_name_simple (COLOR_PAIR (j)); 113 | ci = ccze_color_to_name_simple (COLOR_PAIR (i)); 114 | asprintf (&str, "%s on_%s", cj, ci); 115 | return str; 116 | } 117 | } 118 | 119 | static char * 120 | ccze_dump_color_comment (int cidx) 121 | { 122 | return ccze_color_keyword_map[cidx].comment; 123 | } 124 | 125 | static int 126 | ccze_dump_color_hidden (int cidx) 127 | { 128 | return !ccze_color_keyword_map[cidx].settable; 129 | } 130 | 131 | static int 132 | ccze_dump_color_to_idx (ccze_color_t color) 133 | { 134 | size_t cidx; 135 | 136 | for (cidx = 0; cidx < sizeof (ccze_color_keyword_map); cidx++) 137 | if (ccze_color_keyword_map[cidx].idx == color) 138 | return cidx; 139 | return 0; 140 | } 141 | 142 | int 143 | main (int argc, char *argv[]) 144 | { 145 | ccze_color_t cidx; 146 | char line[256]; 147 | int color; 148 | size_t llen; 149 | 150 | argp_parse (&argp, argc, argv, 0, 0, NULL); 151 | 152 | ccze_color_init (); 153 | 154 | if (ccze_config.rcfile) 155 | ccze_color_load (ccze_config.rcfile); 156 | else if (ccze_loaddefs) 157 | { 158 | char *home, *homerc; 159 | 160 | ccze_color_load (SYSCONFDIR "/colorizerc"); 161 | ccze_color_load (SYSCONFDIR "/cczerc"); 162 | home = getenv ("HOME"); 163 | if (home) 164 | { 165 | asprintf (&homerc, "%s/.colorizerc", home); 166 | ccze_color_load (homerc); 167 | free (homerc); 168 | asprintf (&homerc, "%s/.cczerc", home); 169 | ccze_color_load (homerc); 170 | free (homerc); 171 | } 172 | } 173 | 174 | printf ("# Configuration file for ccze\n#\n"); 175 | printf ("# Available 'pre' attributes: bold, underline, underscore, " 176 | "blink, reverse\n"); 177 | printf ("# Available colors: black, red, green, yellow, blue, magenta, " 178 | "cyan, white\n"); 179 | printf ("# Available bgcolors: on_black, on_red, on_green, on_yellow, " 180 | "on_blue, on_magenta, on_cyan, on_white\n#\n"); 181 | printf ("# You can also use item names in color definition, like:\n#\n"); 182 | printf ("# default blue\n# date 'default'\n#\n"); 183 | printf ("# Here you defined default color to blue, and date color to " 184 | "default value's color, so\n"); 185 | printf ("# your date color is blue. (You can only use predefined item " 186 | "names!)\n\n"); 187 | printf ("# item color # comment (what is " 188 | "color, or why it's that ;)\n\n"); 189 | 190 | /* Dump colors */ 191 | for (cidx = CCZE_COLOR_DATE; cidx < CCZE_COLOR_LAST; cidx++) 192 | { 193 | if (ccze_dump_color_hidden (cidx)) 194 | continue; 195 | 196 | color = ccze_color (cidx); 197 | 198 | strcpy (line, ccze_color_lookup_name (cidx)); 199 | llen = strlen (line); 200 | memset (&line[llen], ' ', 16 - llen); 201 | line[16]='\0'; 202 | strcat (line, ccze_dump_color_get_attrib (color)); 203 | strcat (line, ccze_dump_color_to_name (color)); 204 | llen = strlen (line); 205 | memset (&line[llen], ' ', 42 - llen); 206 | line[40]='#'; 207 | line[42]='\0'; 208 | strcat (line, ccze_dump_color_comment (ccze_dump_color_to_idx (cidx))); 209 | 210 | printf ("%s\n", line); 211 | } 212 | 213 | /* CSS codes */ 214 | printf ("\n# CSS codes for the HTML output\n"); 215 | for (color = 0; color < 8; color++) 216 | { 217 | strcpy (line, "css"); 218 | strcat (line, ccze_colorname_map[color].name); 219 | llen = strlen (line); 220 | memset (&line[llen], ' ', 16 - llen); 221 | line[16]='\0'; 222 | strcat (line, ccze_csscolor_normal_map[color]); 223 | printf ("%s\n", line); 224 | 225 | strcpy (line, "cssbold"); 226 | strcat (line, ccze_colorname_map[color].name); 227 | llen = strlen (line); 228 | memset (&line[llen], ' ', 16 - llen); 229 | line[16]='\0'; 230 | strcat (line, ccze_csscolor_bold_map[color]); 231 | printf ("%s\n", line); 232 | } 233 | 234 | strcpy (line, "cssbody"); 235 | llen = strlen (line); 236 | memset (&line[llen], ' ', 16 - llen); 237 | line[16]='\0'; 238 | strcat (line, ccze_cssbody_color ()); 239 | printf ("%s\n", line); 240 | 241 | return 0; 242 | } 243 | -------------------------------------------------------------------------------- /doc/ccze-plugin.7.in: -------------------------------------------------------------------------------- 1 | .\" Hey Emacs! This is -*- mode: nroff; fill-column: 76 -*-! 2 | .\" Copyright (C) 2002, 2003 Gergely Nagy 3 | .\" 4 | .\" Permission is granted to make and distribute verbatim copies of this 5 | .\" manual provided the copyright notice and this permission notice are 6 | .\" preserved on all copies. 7 | .\" 8 | .\" Permission is granted to copy and distribute modified versions of this 9 | .\" manual under the conditions for verbatim copying, provided that the 10 | .\" entire resulting derived work is distributed under the terms of a 11 | .\" permission notice identical to this one. 12 | .\" 13 | .\" Permission is granted to copy and distribute translations of this 14 | .\" manual into another language, under the above conditions for modified 15 | .\" versions, except that this permission notice may be stated in a 16 | .\" translation approved by the Author. 17 | .TH CCZE-PLUGIN 7 "2003-03-29" "CCZE @VERSION@" CCZE 18 | .SH NAME 19 | ccze \- A robust log colorizer, plugin infrastructure 20 | .SH SYNOPSIS 21 | .B #include 22 | 23 | .B /* Plugin support */ 24 | .br 25 | .BI "typedef void (*" ccze_plugin_startup_t ") (void);" 26 | .br 27 | .BI "typedef void (*" ccze_plugin_shutdown_t ") (void);" 28 | .br 29 | .BI "typedef int (*" ccze_plugin_handle_t ") (const char *" str , 30 | .BI "size_t " length ", char **" rest ); 31 | 32 | .BI "CCZE_DEFINE_PLUGIN (" name ", " type ", " desc ); 33 | .br 34 | .BI "CCZE_DEFINE_PLUGINS (" plugins "...);" 35 | .br 36 | 37 | .B /* Display */ 38 | .br 39 | .BI "void ccze_addstr (ccze_color_t " col ", const char *" str ");" 40 | .br 41 | .B void ccze_newline (void); 42 | .br 43 | .B void ccze_space (void); 44 | .br 45 | .BI "void ccze_wordcolor_process_one (char *" word ", int " slookup ");" 46 | .br 47 | 48 | .B /* Helpers */ 49 | .br 50 | .BI "ccze_color_t ccze_http_action (const char *" method ");" 51 | .br 52 | .BI "void ccze_print_date (const char *" date ");" 53 | 54 | .B /* Command line */ 55 | .br 56 | .BI "char **ccze_plugin_argv_get (const char *" name ");" 57 | .br 58 | .BI "const char *ccze_plugin_name_get (void);" 59 | .SH DESCRIPTION 60 | This manual page attempts to outline the internals of CCZE plugins: how 61 | they work, how they are implemented, and how to add new ones. 62 | 63 | There are four required entry points in a plugin: a \fIstartup\fR, a 64 | \fIshutdown\fR and a \fIhandler\fR routine (more on these later), and an 65 | informational structure. 66 | 67 | The \fIstartup\fR function must be of type \fBccze_plugin_startup_t\fR. This 68 | is called right after the module is loaded. Its purpose is to initialise 69 | all kinds of module\-specific global variables, such as the regular 70 | expressions. 71 | 72 | The \fIshutdown\fR function is its counterpart: this is used to deallocate 73 | any memory reserved by the \fIstartup\fR code. 74 | 75 | The core part of a plugin is the \fIhandler\fR, of type 76 | \fBccze_plugin_handle_t\fR. This does the actual coloring. The string to 77 | process is passed in the \fIstr\fR argument, its length in \fIlength\fR. 78 | The third argument, \fIrest\fR is a pointer to a string. Unlike the first 79 | two, this argument is used only for output. 80 | 81 | When a handler processed a string, it must return a non\-zero value, in case 82 | it could not process it, the handler must return with zero. If the string 83 | could be processed only partially, the part which was deemed unknown by the 84 | handler must be passed back in the \fIrest\fR variable. 85 | 86 | The fourth part, although the smallest part, is the most important. Without 87 | this, the module is useless, it cannot be loaded. This part tells CCZE what 88 | the \fIstartup\fR, \fIshutdown\fR and \fIhandler\fR functions are called. 89 | 90 | To encourage good style, the little details of this structure will not be 91 | disclosed in this manual page. Instead, the helper macro, 92 | \fICCZE_DEFINE_PLUGIN\fR will be explained. 93 | 94 | \fICCZE_DEFINE_PLUGIN\fR is the macro to use if one wants to make the plugin 95 | loadable. Its first argument is an unquoted string: the name of the plugin. 96 | The second part is the type of the plugin, it can be \fIFULL\fR, 97 | \fIPARTIAL\fR or \fIANY\fR. The last argument is a short description of the 98 | plugin. 99 | 100 | It is assumed that the three functions mentioned earlier are called 101 | \fIccze_\fBname\fI_setup\fR, \fIccze_\fBname\fI_shutdown\fR and 102 | \fIccze_\fBname\fI_handle\fR, respectively. 103 | 104 | A \fIFULL\fR plugin is one that accepts raw input, untouched by any other 105 | plugin before, and processes it. On the other hand, a \fIPARTIAL\fR plugin 106 | relies on previous ones preprocessing the input. For example, \fIsyslog\fR 107 | is a full plugin, on which \fIulogd\fR, a partial plugin relies. The 108 | \fIsyslog\fR plugin processes the raw input from the logfile, adds colour to 109 | most of it, save the actual message sent by a process, that is left to 110 | subsequent plugins, like \fIulogd\fR. An \fIANY\fR plugin is one can act as 111 | both other types. 112 | 113 | With \fICCZE_DEFINE_PLUGINS\fR one can place more than one plugin into one 114 | shared object. 115 | 116 | There are two other helper functions, \fIccze_plugin_argv_get\fR and 117 | \fIccze_plugin_name_get\fR. One can pass arguments to CCZE plugins, and 118 | these is the function to retrieve them. While \fIccze_plugin_name_get\fR 119 | returns the name of the current plugin, \fIccze_plugin_argv_get\fR returns a 120 | NULL\-terminated array, with each entry containing an argument. 121 | .SH "DISPLAY METHODS" 122 | The so\-called \fIdisplay methods\fR are the \fBonly\fR supported interface 123 | to emit something to the display. These handle both the normal, 124 | ncurses\-based, and the HTML output. This is a kind of abstraction so 125 | plugins will not have to worry about the differences between the output 126 | formats. 127 | 128 | The most important one is \fIccze_addstr\fR, which takes a color (see 129 | \fIccze.h\fR for a list of supported color tags) and a string, and displays 130 | it appropriately. The \fIccze_space\fR and \fIccze_newline\fR functions emit 131 | a space and a newline, respectively. 132 | 133 | Our last function, \fIccze_wordcolor_process_one\fR passes \fBword\fR to the 134 | word colourising engine. If the second argument, \fBslookup\fR is non\-zero, 135 | the engine will perform service lookups (like \fIgetent\fR and friends). 136 | .SH "HELPER METHODS" 137 | We only have two helper methods: \fIccze_print_date\fR, which simply prints 138 | out the date in the appropriate colour, and \fIccze_http_action\fR, which 139 | given a HTTP \fBmethod\fR, returns the associated colour, in a format 140 | suitable for \fIccze_addstr\fR. 141 | .SH EXAMPLE 142 | .nf 143 | #include 144 | #include 145 | #include 146 | 147 | static char **ccze_foo_argv; 148 | 149 | static int 150 | ccze_foo_handle (const char *str, size_t length, char **rest) 151 | { 152 | int i = 1; 153 | 154 | if (strstr (str, "foo")) 155 | { 156 | ccze_addstr (CCZE_COLOR_GOODWORD, str); 157 | return 1; 158 | } 159 | 160 | while (ccze_foo_argv[i]) 161 | { 162 | if (strstr (str, ccze_foo_argv[i])) 163 | { 164 | ccze_addstr (CCZE_COLOR_GOODWORD, str); 165 | return 1; 166 | } 167 | i++; 168 | } 169 | return 0; 170 | } 171 | 172 | static void 173 | ccze_foo_startup (void) 174 | { 175 | ccze_foo_argv = ccze_plugin_argv_get (ccze_plugin_name_get ()); 176 | } 177 | 178 | static void 179 | ccze_foo_shutdown (void) 180 | { 181 | } 182 | 183 | CCZE_DEFINE_PLUGIN (foo, PARTIAL, "Partial FOO coloriser."); 184 | .fi 185 | .SH "SEE ALSO" 186 | .BR ccze (1) 187 | .SH AUTHOR 188 | ccze was written by Gergely Nagy , based on 189 | colorize by Istvan Karaszi . 190 | -------------------------------------------------------------------------------- /doc/ccze.1.in: -------------------------------------------------------------------------------- 1 | .\" Hey Emacs! This is -*- nroff -*-! 2 | .\" Copyright (C) 2002, 2003 Gergely Nagy 3 | .\" 4 | .\" Permission is granted to make and distribute verbatim copies of this 5 | .\" manual provided the copyright notice and this permission notice are 6 | .\" preserved on all copies. 7 | .\" 8 | .\" Permission is granted to copy and distribute modified versions of this 9 | .\" manual under the conditions for verbatim copying, provided that the 10 | .\" entire resulting derived work is distributed under the terms of a 11 | .\" permission notice identical to this one. 12 | .\" 13 | .\" Permission is granted to copy and distribute translations of this 14 | .\" manual into another language, under the above conditions for modified 15 | .\" versions, except that this permission notice may be stated in a 16 | .\" translation approved by the Author. 17 | .TH CCZE 1 "2003-04-24" "CCZE @VERSION@" CCZE 18 | .SH NAME 19 | ccze \- A robust log colorizer 20 | .SH SYNOPSIS 21 | .B ccze 22 | .RI [ options "] <" logfile 23 | .SH DESCRIPTION 24 | This manual page documents briefly the 25 | .B ccze 26 | utility, which is a drop\-in replacement for 27 | .BR colorize , 28 | but written in C, to be faster and less resource\-hungry. The goal was 29 | to be fully backwards compatible, yet superior with respect to speed 30 | and features. 31 | .SH OPTIONS 32 | These programs follow the usual GNU command line syntax, with long 33 | options starting with two dashes (`\-'). A summary of options is 34 | included below. 35 | .TP 36 | .B \-a, \-\-argument \fIPLUGIN=ARGUMENTS\fB 37 | Use this option to pass \fIARGUMENTS\fR to the specified 38 | \fIPLUGIN\fR. The argument list is whitespace separated. 39 | .TP 40 | .B \-A, \-\-raw\-ansi 41 | If one wants to enable raw ANSI color sequences instead of using 42 | curses, this option does just that. 43 | .TP 44 | .B \-c, \-\-color \fIKEY=COLOR\fB 45 | Set the color of the keyword \fIKEY\fR to \fICOLOR\fR, like one would 46 | do in one of the configuration files. 47 | .TP 48 | .B \-C, \-\-convert\-date 49 | Convert unix timestamp to readable date format (in 50 | oops and squid logs, for example). 51 | .TP 52 | .B \-F, \-\-rcfile \fIrcfile\fB 53 | Read \fIrcfile\fR as a configuration file upon startup, instead of the 54 | default ones. 55 | .TP 56 | .B \-h, \-\-html 57 | Instead of colorising the input onto the console, output it in HTML 58 | format instead. 59 | .TP 60 | .B \-l, \-\-list\-plugins 61 | List all available (loaded) plugins, along with their type and a short 62 | description. 63 | .TP 64 | .B \-m, \-\-mode \fImode\fB 65 | Change the output mode. Available modes are \fIcurses\fR, \fIansi\fR 66 | and \fIhtml\fR. 67 | .TP 68 | .B \-o, \-\-options \fIOPTIONS...\fB 69 | \fBCCZE\fR is able to toggle some of its features with this 70 | option. You can toggle the \fIscroll\fR, \fIwordcolor\fR, 71 | \fIlookups\fR, and \fItransparent\fR features, or you can fiddle with 72 | \fIcssfile\fR. All of these are enabled by default, except 73 | \fIcssfile\fR. One can turn them off by prefixing the option with a 74 | "no". 75 | 76 | With \fIscroll\fR, one can enable or disable scrolling. If the output 77 | is not redirected, it is wise to leave it enabled. 78 | 79 | The \fIwordcolor\fR option makes \fBccze\fR search for different 80 | keywords in unparsed input, and color those too. Since it is quite 81 | fast, and makes the output look better, it is recommended to leave 82 | this enabled. 83 | 84 | However, \fIlookups\fR is an option that might be better to 85 | disable. When on, \fBccze\fR will try to look up usernames, service 86 | names, and lots of other stuff, which will slow down coloring a great 87 | deal. If one is piping a long log through \fBccze\fR, this option 88 | might be turned off to speed up the process. 89 | 90 | With the \fItransparent\fR option, one can make CCZE treat black 91 | background colors as transparent \- that means, a black background 92 | will appear transparent in a similar X terminal. If turned off, it 93 | will appear as black. 94 | 95 | If \fIcssfile\fR is set, then CCZE will not inline the Cascading Style 96 | Sheet information into the outputted HTML, but include a link to the 97 | external stylesheet given in this paramater. 98 | .TP 99 | .B \-p, \-\-plugin \fIPLUGIN\fR 100 | While the default action is to load all plugins (see the \fBPlugins\fR 101 | section below), when this option is present, only the specified 102 | plugins will be loaded. If one knows what kind of log will be piped 103 | through \fBccze\fR, using this option may result in a slight speedup. 104 | .TP 105 | .B \-r, \-\-remove\-facilty 106 | Syslog\-ng puts the facility level before log messages. With this 107 | switch, these can be cut off. 108 | .TP 109 | .B \-\-help 110 | Show summary of options and exit. 111 | .TP 112 | .B \-V, \-\-version 113 | Show version of program. 114 | .SH PLUGINS 115 | Different programs have different kind of logs, and every kind of log 116 | \fBccze\fR supports is implemented via a plug\-in. They are by default 117 | located under \fI@pkglibdir@\fR and \fI$HOME/.ccze\fR (so they can 118 | be overridden by the user easily). 119 | 120 | At the moment, the following modules are bundled with the official 121 | release: 122 | .TP 123 | .IR apm 124 | For coloring apmd's logs. 125 | .TP 126 | .IR distcc 127 | For coloring distccd's logs. (See \fIdistccd\fR(1)) 128 | .TP 129 | .IR exim 130 | For coloring exim's \fImain.log\fR. (See \fIexim\fR(8)) 131 | .TP 132 | .IR fetchmail 133 | For coloring fetchmail's log files. (See \fIfetchmail\fR(1)) 134 | .TP 135 | .IR ftpstats 136 | For coloring ftpStats compatible log files, such as Pure\-FTPD's 137 | \fIStats\fR log format. 138 | .TP 139 | .IR httpd 140 | For coloring apache\-style \fIaccess.log\fR and \fIerror.log\fR 141 | files. (See \fIapache\fR(8)) 142 | 143 | As a side\-effect, all compatible formats, like \fIpure\-ftpd\fR(8)'s 144 | common\-log format is also supported by this plugin. 145 | .TP 146 | .IR icecast 147 | For coloring \fIicecast/icecast.log\fR and \fIicecast/usage.log\fR 148 | files. (See \fIicecast\fR(8)) 149 | .TP 150 | .IR oops 151 | For coloring \fIoops/oops.log\fR files. 152 | .TP 153 | .IR php 154 | For coloring \fIphp.log\fR files. 155 | .TP 156 | .IR postfix 157 | For coloring postfix logs. (See \fIpostfix\fR(1)) 158 | .TP 159 | .IR procmail 160 | For coloring procmail's log file. (See \fIprocmail\fR(1)) 161 | .TP 162 | .IR proftpd 163 | For coloring proftpd's \fIaccess.log\fR and \fIauth.log\fR files. (See 164 | \fIproftpd\fR(8)) 165 | .TP 166 | .IR squid 167 | For coloring squid's \fIaccess.log\fR, \fIstore.log\fR and 168 | \fIcache.log\fR files. (See \fIsquid\fR(8)) 169 | .TP 170 | .IR sulog 171 | For coloring \fIsulog\fR files. (See \fIsu\fR(1)) 172 | .TP 173 | .IR super 174 | For coloring \fIsuper.log\fR files. (See \fIsuper\fR(1)) 175 | .TP 176 | .IR syslog 177 | For coloring generic syslog messages. (See \fIsyslogd\fR(8)) 178 | .TP 179 | .IR ulogd 180 | For coloring ulogd logs. 181 | .TP 182 | .IR vsftpd 183 | For coloring \fIvsftpd.log\fR files. (See \fIvsftpd\fR(8)) 184 | .TP 185 | .IR xferlog 186 | For coloring \fIxferlog\fR files. (See \fIxferlog\fR(5)) 187 | .SH FILES 188 | .TP 189 | .IR @sysconfdir@/colorizerc ", " $HOME/.colorizerc 190 | .RS 191 | These files are the default configuration files for \fBcolorize\fR, 192 | and are parsed by \fBccze\fR for the sake of full compatibility. 193 | .RE 194 | .IR @sysconfdir@/cczerc ", " $HOME/.cczerc 195 | .RS 196 | This two are the main configuration files, in which one can change the 197 | colors used by the program to his liking. See the comments in the 198 | beginning of \fI@sysconfdir@/cczerc\fR for a description on the files' 199 | structure. 200 | 201 | If neither of these files exist on your system, consider using the 202 | \fBccze\-dump\fR utility in the source tree, which dumps the default 203 | color set to standard output. 204 | .RE 205 | .SH "SEE ALSO" 206 | .BR colorize (1) 207 | .SH AUTHOR 208 | ccze was written by Gergely Nagy , 209 | based on colorize by Istvan Karaszi . 210 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Basic Installation 2 | ================== 3 | 4 | These are generic installation instructions. 5 | 6 | The `configure' shell script attempts to guess correct values for 7 | various system-dependent variables used during compilation. It uses 8 | those values to create a `Makefile' in each directory of the package. 9 | It may also create one or more `.h' files containing system-dependent 10 | definitions. Finally, it creates a shell script `config.status' that 11 | you can run in the future to recreate the current configuration, a file 12 | `config.cache' that saves the results of its tests to speed up 13 | reconfiguring, and a file `config.log' containing compiler output 14 | (useful mainly for debugging `configure'). 15 | 16 | If you need to do unusual things to compile the package, please try 17 | to figure out how `configure' could check whether to do them, and mail 18 | diffs or instructions to the address given in the `README' so they can 19 | be considered for the next release. If at some point `config.cache' 20 | contains results you don't want to keep, you may remove or edit it. 21 | 22 | The file `configure.in' is used to create `configure' by a program 23 | called `autoconf'. You only need `configure.in' if you want to change 24 | it or regenerate `configure' using a newer version of `autoconf'. 25 | 26 | The simplest way to compile this package is: 27 | 28 | 1. `cd' to the directory containing the package's source code and type 29 | `./configure' to configure the package for your system. If you're 30 | using `csh' on an old version of System V, you might need to type 31 | `sh ./configure' instead to prevent `csh' from trying to execute 32 | `configure' itself. 33 | 34 | Running `configure' takes awhile. While running, it prints some 35 | messages telling which features it is checking for. 36 | 37 | 2. Type `make' to compile the package. 38 | 39 | 3. Optionally, type `make check' to run any self-tests that come with 40 | the package. 41 | 42 | 4. Type `make install' to install the programs and any data files and 43 | documentation. 44 | 45 | 5. You can remove the program binaries and object files from the 46 | source code directory by typing `make clean'. To also remove the 47 | files that `configure' created (so you can compile the package for 48 | a different kind of computer), type `make distclean'. There is 49 | also a `make maintainer-clean' target, but that is intended mainly 50 | for the package's developers. If you use it, you may have to get 51 | all sorts of other programs in order to regenerate files that came 52 | with the distribution. 53 | 54 | Compilers and Options 55 | ===================== 56 | 57 | Some systems require unusual options for compilation or linking that 58 | the `configure' script does not know about. You can give `configure' 59 | initial values for variables by setting them in the environment. Using 60 | a Bourne-compatible shell, you can do that on the command line like 61 | this: 62 | CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure 63 | 64 | Or on systems that have the `env' program, you can do it like this: 65 | env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure 66 | 67 | Compiling For Multiple Architectures 68 | ==================================== 69 | 70 | You can compile the package for more than one kind of computer at the 71 | same time, by placing the object files for each architecture in their 72 | own directory. To do this, you must use a version of `make' that 73 | supports the `VPATH' variable, such as GNU `make'. `cd' to the 74 | directory where you want the object files and executables to go and run 75 | the `configure' script. `configure' automatically checks for the 76 | source code in the directory that `configure' is in and in `..'. 77 | 78 | If you have to use a `make' that does not supports the `VPATH' 79 | variable, you have to compile the package for one architecture at a time 80 | in the source code directory. After you have installed the package for 81 | one architecture, use `make distclean' before reconfiguring for another 82 | architecture. 83 | 84 | Installation Names 85 | ================== 86 | 87 | By default, `make install' will install the package's files in 88 | `/usr/local/bin', `/usr/local/man', etc. You can specify an 89 | installation prefix other than `/usr/local' by giving `configure' the 90 | option `--prefix=PATH'. 91 | 92 | You can specify separate installation prefixes for 93 | architecture-specific files and architecture-independent files. If you 94 | give `configure' the option `--exec-prefix=PATH', the package will use 95 | PATH as the prefix for installing programs and libraries. 96 | Documentation and other data files will still use the regular prefix. 97 | 98 | In addition, if you use an unusual directory layout you can give 99 | options like `--bindir=PATH' to specify different values for particular 100 | kinds of files. Run `configure --help' for a list of the directories 101 | you can set and what kinds of files go in them. 102 | 103 | If the package supports it, you can cause programs to be installed 104 | with an extra prefix or suffix on their names by giving `configure' the 105 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 106 | 107 | Optional Features 108 | ================= 109 | 110 | Some packages pay attention to `--enable-FEATURE' options to 111 | `configure', where FEATURE indicates an optional part of the package. 112 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE 113 | is something like `gnu-as' or `x' (for the X Window System). The 114 | `README' should mention any `--enable-' and `--with-' options that the 115 | package recognizes. 116 | 117 | For packages that use the X Window System, `configure' can usually 118 | find the X include and library files automatically, but if it doesn't, 119 | you can use the `configure' options `--x-includes=DIR' and 120 | `--x-libraries=DIR' to specify their locations. 121 | 122 | Specifying the System Type 123 | ========================== 124 | 125 | There may be some features `configure' can not figure out 126 | automatically, but needs to determine by the type of host the package 127 | will run on. Usually `configure' can figure that out, but if it prints 128 | a message saying it can not guess the host type, give it the 129 | `--host=TYPE' option. TYPE can either be a short name for the system 130 | type, such as `sun4', or a canonical name with three fields: 131 | CPU-COMPANY-SYSTEM 132 | 133 | See the file `config.sub' for the possible values of each field. If 134 | `config.sub' isn't included in this package, then this package doesn't 135 | need to know the host type. 136 | 137 | If you are building compiler tools for cross-compiling, you can also 138 | use the `--target=TYPE' option to select the type of system they will 139 | produce code for and the `--build=TYPE' option to select the type of 140 | system on which you are compiling the package. 141 | 142 | Sharing Defaults 143 | ================ 144 | 145 | If you want to set default values for `configure' scripts to share, 146 | you can create a site shell script called `config.site' that gives 147 | default values for variables like `CC', `cache_file', and `prefix'. 148 | `configure' looks for `PREFIX/share/config.site' if it exists, then 149 | `PREFIX/etc/config.site' if it exists. Or, you can set the 150 | `CONFIG_SITE' environment variable to the location of the site script. 151 | A warning: not all `configure' scripts look for a site script. 152 | 153 | Operation Controls 154 | ================== 155 | 156 | `configure' recognizes the following options to control how it 157 | operates. 158 | 159 | `--cache-file=FILE' 160 | Use and save the results of the tests in FILE instead of 161 | `./config.cache'. Set FILE to `/dev/null' to disable caching, for 162 | debugging `configure'. 163 | 164 | `--help' 165 | Print a summary of the options to `configure', and exit. 166 | 167 | `--quiet' 168 | `--silent' 169 | `-q' 170 | Do not print messages saying which checks are being made. To 171 | suppress all normal output, redirect it to `/dev/null' (any error 172 | messages will still be shown). 173 | 174 | `--srcdir=DIR' 175 | Look for the package's source code in directory DIR. Usually 176 | `configure' can determine that directory automatically. 177 | 178 | `--version' 179 | Print the version of Autoconf used to generate the `configure' 180 | script, and exit. 181 | 182 | `configure' also accepts some other, not widely useful, options. 183 | -------------------------------------------------------------------------------- /src/mod_squid.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * mod_squid.c -- Squid-related colorizers for CCZE 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | static void ccze_squid_setup (void); 27 | static void ccze_squid_shutdown (void); 28 | static int ccze_squid_handle (const char *str, size_t length, char **rest); 29 | 30 | static pcre *reg_squid_access, *reg_squid_store, *reg_squid_cache; 31 | static pcre_extra *hints_squid_access, *hints_squid_store, *hints_squid_cache; 32 | 33 | static ccze_color_t 34 | _ccze_proxy_action (const char *action) 35 | { 36 | if (strstr (action, "ERR") == action) 37 | return CCZE_COLOR_ERROR; 38 | if (strstr (action, "MISS")) 39 | return CCZE_COLOR_PROXY_MISS; 40 | if (strstr (action, "HIT")) 41 | return CCZE_COLOR_PROXY_HIT; 42 | if (strstr (action, "DENIED")) 43 | return CCZE_COLOR_PROXY_DENIED; 44 | if (strstr (action, "REFRESH")) 45 | return CCZE_COLOR_PROXY_REFRESH; 46 | if (strstr (action, "SWAPFAIL")) 47 | return CCZE_COLOR_PROXY_SWAPFAIL; 48 | if (strstr (action, "NONE")) 49 | return CCZE_COLOR_DEBUG; 50 | 51 | return CCZE_COLOR_UNKNOWN; 52 | } 53 | 54 | static ccze_color_t 55 | _ccze_proxy_hierarch (const char *hierar) 56 | { 57 | if (strstr (hierar, "NO") == hierar) 58 | return CCZE_COLOR_WARNING; 59 | if (strstr (hierar, "DIRECT")) 60 | return CCZE_COLOR_PROXY_DIRECT; 61 | if (strstr (hierar, "PARENT")) 62 | return CCZE_COLOR_PROXY_PARENT; 63 | if (strstr (hierar, "MISS")) 64 | return CCZE_COLOR_PROXY_MISS; 65 | 66 | return CCZE_COLOR_UNKNOWN; 67 | } 68 | 69 | static ccze_color_t 70 | _ccze_proxy_tag (const char *tag) 71 | { 72 | if (strstr (tag, "CREATE")) 73 | return CCZE_COLOR_PROXY_CREATE; 74 | if (strstr (tag, "SWAPIN")) 75 | return CCZE_COLOR_PROXY_SWAPIN; 76 | if (strstr (tag, "SWAPOUT")) 77 | return CCZE_COLOR_PROXY_SWAPOUT; 78 | if (strstr (tag, "RELEASE")) 79 | return CCZE_COLOR_PROXY_RELEASE; 80 | 81 | return CCZE_COLOR_UNKNOWN; 82 | } 83 | 84 | static char * 85 | ccze_squid_access_log_process (const char *str, int *offsets, int match) 86 | { 87 | char *date, *espace, *elaps, *host, *action, *httpc, *gsize; 88 | char *method, *uri, *ident, *hierar, *fhost, *ctype; 89 | 90 | pcre_get_substring (str, offsets, match, 1, (const char **)&date); 91 | pcre_get_substring (str, offsets, match, 2, (const char **)&espace); 92 | pcre_get_substring (str, offsets, match, 3, (const char **)&elaps); 93 | pcre_get_substring (str, offsets, match, 4, (const char **)&host); 94 | pcre_get_substring (str, offsets, match, 5, (const char **)&action); 95 | pcre_get_substring (str, offsets, match, 6, (const char **)&httpc); 96 | pcre_get_substring (str, offsets, match, 7, (const char **)&gsize); 97 | pcre_get_substring (str, offsets, match, 8, (const char **)&method); 98 | pcre_get_substring (str, offsets, match, 9, (const char **)&uri); 99 | pcre_get_substring (str, offsets, match, 10, (const char **)&ident); 100 | pcre_get_substring (str, offsets, match, 11, (const char **)&hierar); 101 | pcre_get_substring (str, offsets, match, 12, (const char **)&fhost); 102 | pcre_get_substring (str, offsets, match, 13, (const char **)&ctype); 103 | 104 | ccze_print_date (date); 105 | ccze_addstr (CCZE_COLOR_DEFAULT, espace); 106 | ccze_addstr (CCZE_COLOR_GETTIME, elaps); 107 | ccze_space (); 108 | 109 | ccze_addstr (CCZE_COLOR_HOST, host); 110 | ccze_space (); 111 | 112 | ccze_addstr (_ccze_proxy_action (action), action); 113 | ccze_addstr (CCZE_COLOR_DEFAULT, "/"); 114 | ccze_addstr (CCZE_COLOR_HTTPCODES, httpc); 115 | ccze_space (); 116 | 117 | ccze_addstr (CCZE_COLOR_GETSIZE, gsize); 118 | ccze_space (); 119 | 120 | ccze_addstr (ccze_http_action (method), method); 121 | ccze_space (); 122 | 123 | ccze_addstr (CCZE_COLOR_URI, uri); 124 | ccze_space (); 125 | 126 | ccze_addstr (CCZE_COLOR_IDENT, ident); 127 | ccze_space (); 128 | 129 | ccze_addstr (_ccze_proxy_hierarch (hierar), hierar); 130 | ccze_addstr (CCZE_COLOR_DEFAULT, "/"); 131 | ccze_addstr (CCZE_COLOR_HOST, fhost); 132 | ccze_space (); 133 | 134 | ccze_addstr (CCZE_COLOR_CTYPE, ctype); 135 | 136 | ccze_newline (); 137 | 138 | free (date); 139 | free (espace); 140 | free (elaps); 141 | free (host); 142 | free (action); 143 | free (httpc); 144 | free (gsize); 145 | free (method); 146 | free (uri); 147 | free (ident); 148 | free (hierar); 149 | free (fhost); 150 | free (ctype); 151 | 152 | return NULL; 153 | } 154 | 155 | static char * 156 | ccze_squid_cache_log_process (const char *str, int *offsets, int match) 157 | { 158 | char *date, *other; 159 | 160 | pcre_get_substring (str, offsets, match, 1, (const char **)&date); 161 | pcre_get_substring (str, offsets, match, 3, (const char **)&other); 162 | 163 | ccze_addstr (CCZE_COLOR_DATE, date); 164 | ccze_space(); 165 | 166 | free (date); 167 | return other; 168 | } 169 | 170 | static char * 171 | ccze_squid_store_log_process (const char *str, int *offsets, int match) 172 | { 173 | char *date, *tag, *swapnum, *swapname, *swapsum, *space1, *hcode; 174 | char *hdate, *lmdate, *expire, *ctype, *size, *read, *method; 175 | char *uri, *space2, *space3, *space4; 176 | 177 | pcre_get_substring (str, offsets, match, 1, (const char **)&date); 178 | pcre_get_substring (str, offsets, match, 2, (const char **)&tag); 179 | pcre_get_substring (str, offsets, match, 3, (const char **)&swapnum); 180 | pcre_get_substring (str, offsets, match, 4, (const char **)&swapname); 181 | pcre_get_substring (str, offsets, match, 5, (const char **)&swapsum); 182 | pcre_get_substring (str, offsets, match, 6, (const char **)&space1); 183 | pcre_get_substring (str, offsets, match, 7, (const char **)&hcode); 184 | pcre_get_substring (str, offsets, match, 8, (const char **)&space2); 185 | pcre_get_substring (str, offsets, match, 9, (const char **)&hdate); 186 | pcre_get_substring (str, offsets, match, 10, (const char **)&space3); 187 | pcre_get_substring (str, offsets, match, 11, (const char **)&lmdate); 188 | pcre_get_substring (str, offsets, match, 12, (const char **)&space4); 189 | pcre_get_substring (str, offsets, match, 13, (const char **)&expire); 190 | pcre_get_substring (str, offsets, match, 14, (const char **)&ctype); 191 | pcre_get_substring (str, offsets, match, 15, (const char **)&size); 192 | pcre_get_substring (str, offsets, match, 16, (const char **)&read); 193 | pcre_get_substring (str, offsets, match, 17, (const char **)&method); 194 | pcre_get_substring (str, offsets, match, 18, (const char **)&uri); 195 | 196 | ccze_print_date (date); 197 | ccze_space(); 198 | ccze_addstr (_ccze_proxy_tag (tag), tag); 199 | ccze_space(); 200 | ccze_addstr (CCZE_COLOR_SWAPNUM, swapnum); 201 | ccze_space(); 202 | ccze_addstr (CCZE_COLOR_SWAPNUM, swapname); 203 | ccze_space(); 204 | ccze_addstr (CCZE_COLOR_SWAPNUM, swapsum); 205 | ccze_addstr (CCZE_COLOR_DEFAULT, space1); 206 | ccze_addstr (CCZE_COLOR_HTTPCODES, hcode); 207 | ccze_addstr (CCZE_COLOR_DEFAULT, space2); 208 | ccze_print_date (hdate); 209 | ccze_addstr (CCZE_COLOR_DEFAULT, space3); 210 | ccze_print_date (lmdate); 211 | ccze_addstr (CCZE_COLOR_DEFAULT, space4); 212 | ccze_print_date (expire); 213 | ccze_space(); 214 | ccze_addstr (CCZE_COLOR_CTYPE, ctype); 215 | ccze_space(); 216 | ccze_addstr (CCZE_COLOR_GETSIZE, size); 217 | ccze_addstr (CCZE_COLOR_DEFAULT, "/"); 218 | ccze_addstr (CCZE_COLOR_GETSIZE, read); 219 | ccze_space(); 220 | ccze_addstr (ccze_http_action (method), method); 221 | ccze_space(); 222 | ccze_addstr (CCZE_COLOR_URI, uri); 223 | 224 | ccze_newline (); 225 | 226 | free (date); 227 | free (tag); 228 | free (swapnum); 229 | free (swapname); 230 | free (swapsum); 231 | free (space1); 232 | free (hcode); 233 | free (hdate); 234 | free (lmdate); 235 | free (expire); 236 | free (ctype); 237 | free (size); 238 | free (read); 239 | free (method); 240 | free (uri); 241 | free (space2); 242 | free (space3); 243 | free (space4); 244 | 245 | return NULL; 246 | } 247 | 248 | static void 249 | ccze_squid_setup (void) 250 | { 251 | const char *error; 252 | int errptr; 253 | 254 | reg_squid_access = pcre_compile 255 | ("^(\\d{9,10}\\.\\d{3})(\\s+)(\\d+)\\s(\\S+)\\s(\\w+)\\/(\\d{3})" 256 | "\\s(\\d+)\\s(\\w+)\\s(\\S+)\\s(\\S+)\\s(\\w+)\\/([\\d\\.]+|-)\\s(.*)", 257 | 0, &error, &errptr, NULL); 258 | hints_squid_access = pcre_study (reg_squid_access, 0, &error); 259 | 260 | reg_squid_cache = pcre_compile 261 | ("^(\\d{4}\\/\\d{2}\\/\\d{2}\\s(\\d{2}:){2}\\d{2}\\|)\\s(.*)$", 0, 262 | &error, &errptr, NULL); 263 | hints_squid_cache = pcre_study (reg_squid_cache, 0, &error); 264 | 265 | reg_squid_store = pcre_compile 266 | ("^([\\d\\.]+)\\s(\\w+)\\s(\\-?[\\dA-F]+)\\s+(\\S+)\\s([\\dA-F]+)" 267 | "(\\s+)(\\d{3}|\\?)(\\s+)(\\-?[\\d\\?]+)(\\s+)(\\-?[\\d\\?]+)(\\s+)" 268 | "(\\-?[\\d\\?]+)\\s(\\S+)\\s(\\-?[\\d|\\?]+)\\/(\\-?[\\d|\\?]+)\\s" 269 | "(\\S+)\\s(.*)", 0, &error, &errptr, NULL); 270 | hints_squid_store = pcre_study (reg_squid_store, 0, &error); 271 | } 272 | 273 | static void 274 | ccze_squid_shutdown (void) 275 | { 276 | free (reg_squid_access); 277 | free (hints_squid_access); 278 | free (reg_squid_cache); 279 | free (hints_squid_cache); 280 | free (reg_squid_store); 281 | free (hints_squid_store); 282 | } 283 | 284 | static int 285 | ccze_squid_handle (const char *str, size_t length, char **rest) 286 | { 287 | int match, offsets[99]; 288 | 289 | if ((match = pcre_exec (reg_squid_access, hints_squid_access, str, 290 | length, 0, 0, offsets, 99)) >= 0) 291 | { 292 | *rest = ccze_squid_access_log_process (str, offsets, match); 293 | return 1; 294 | } 295 | 296 | if ((match = pcre_exec (reg_squid_store, hints_squid_store, str, 297 | length, 0, 0, offsets, 99)) >= 0) 298 | { 299 | *rest = ccze_squid_store_log_process (str, offsets, match); 300 | return 1; 301 | } 302 | 303 | if ((match = pcre_exec (reg_squid_cache, hints_squid_cache, str, 304 | length, 0, 0, offsets, 99)) >= 0) 305 | { 306 | *rest = ccze_squid_cache_log_process (str, offsets, match); 307 | return 1; 308 | } 309 | 310 | return 0; 311 | } 312 | 313 | CCZE_DEFINE_PLUGIN (squid, FULL, 314 | "Coloriser for squid access, store and cache logs."); 315 | -------------------------------------------------------------------------------- /src/ccze-plugin.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: c; c-file-style: "gnu" -*- 2 | * ccze-plugin.c -- Plugin interface for CCZE. 3 | * Copyright (C) 2002, 2003 Gergely Nagy 4 | * 5 | * This file is part of ccze. 6 | * 7 | * ccze is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * ccze is distributed in the hope that it will be useful, but WITHOUT 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 | * License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "ccze-private.h" 32 | 33 | static ccze_plugin_t **plugins; 34 | static size_t plugins_alloc, plugins_len; 35 | static ccze_plugin_t **plugin_args; 36 | static size_t plugin_args_alloc, plugin_args_len; 37 | static char *plugin_running = NULL; 38 | 39 | static ccze_plugin_t * 40 | _ccze_plugin_find (const char *name) 41 | { 42 | size_t i; 43 | 44 | for (i = 0; i < plugins_len; i++) 45 | { 46 | if (!strcmp (plugins[i]->name, name)) 47 | return plugins[i]; 48 | } 49 | return NULL; 50 | } 51 | 52 | static int 53 | _ccze_plugin_loaded (const char *name) 54 | { 55 | if (_ccze_plugin_find (name)) 56 | return 1; 57 | 58 | return 0; 59 | } 60 | 61 | static int 62 | _ccze_plugin_allow (const char *name) 63 | { 64 | int i = 0; 65 | int rval = 0; 66 | 67 | if (_ccze_plugin_loaded (name)) 68 | return 0; 69 | if (ccze_config.pluginlist_len == 0) 70 | return 1; 71 | 72 | while (i < ccze_config.pluginlist_len) 73 | { 74 | if (!strcmp (ccze_config.pluginlist[i], name)) 75 | { 76 | rval = 1; 77 | break; 78 | } 79 | i++; 80 | } 81 | 82 | return rval; 83 | } 84 | 85 | void 86 | ccze_plugin_add (ccze_plugin_t *plugin) 87 | { 88 | if (!_ccze_plugin_allow (plugin->name)) 89 | return; 90 | 91 | plugins[plugins_len] = plugin; 92 | plugins_len++; 93 | if (plugins_len >= plugins_alloc) 94 | { 95 | plugins_alloc *= 2; 96 | plugins = (ccze_plugin_t **)ccze_realloc 97 | (plugins, plugins_alloc * sizeof (ccze_plugin_t *)); 98 | } 99 | } 100 | 101 | void 102 | ccze_plugin_init (void) 103 | { 104 | plugins_alloc = 10; 105 | plugins_len = 0; 106 | plugins = (ccze_plugin_t **)ccze_calloc (plugins_alloc, 107 | sizeof (ccze_plugin_t *)); 108 | } 109 | 110 | void 111 | ccze_plugin_argv_init (void) 112 | { 113 | plugin_args_alloc = 10; 114 | plugin_args_len = 0; 115 | plugin_args = (ccze_plugin_t **)ccze_calloc (plugin_args_alloc, 116 | sizeof (ccze_plugin_t *)); 117 | } 118 | 119 | static void 120 | _ccze_plugin_load (const char *name, const char *path, int recurse) 121 | { 122 | ccze_plugin_t *plugin; 123 | char *tmp, *n; 124 | void *dlhandle; 125 | char **pluginlist = NULL; 126 | int bailout = 0; 127 | 128 | if (_ccze_plugin_loaded (name)) 129 | return; 130 | 131 | dlhandle = dlopen (path, RTLD_LAZY); 132 | if (dlerror () || !dlhandle) 133 | return; 134 | 135 | asprintf (&tmp, "ccze_%s_info", name); 136 | plugin = (ccze_plugin_t *)dlsym (dlhandle, tmp); 137 | free (tmp); 138 | if (dlerror () || !plugin) 139 | { 140 | if (!plugin) 141 | { 142 | n = (char *)dlsym (dlhandle, "ccze_default_plugin"); 143 | asprintf (&tmp, "ccze_%s_info", n); 144 | plugin = (ccze_plugin_t *)dlsym (dlhandle, tmp); 145 | free (tmp); 146 | if (!plugin) 147 | bailout = 1; 148 | else 149 | plugin->name = strdup (name); 150 | } 151 | else 152 | { 153 | dlclose (dlhandle); 154 | return; 155 | } 156 | } 157 | if (!bailout) 158 | { 159 | if (plugin->abi_version != CCZE_ABI_VERSION) 160 | { 161 | dlclose (dlhandle); 162 | return; 163 | } 164 | 165 | plugin->dlhandle = dlhandle; 166 | 167 | ccze_plugin_add (plugin); 168 | } 169 | 170 | /* If there are more plugins defined in the file, load them all! */ 171 | if (recurse) 172 | { 173 | pluginlist = (char **)dlsym (dlhandle, "ccze_plugin_list"); 174 | if (pluginlist) 175 | { 176 | int i = 0; 177 | 178 | while (pluginlist[i]) 179 | { 180 | if (!_ccze_plugin_loaded (pluginlist[i])) 181 | _ccze_plugin_load (pluginlist[i], path, 0); 182 | i++; 183 | } 184 | } 185 | } 186 | } 187 | 188 | void 189 | ccze_plugin_load (const char *name) 190 | { 191 | char *home; 192 | char *path; 193 | 194 | if ((home = getenv ("HOME")) != NULL) 195 | { 196 | asprintf (&path, "%s/.ccze/%s.so", home, name); 197 | if (access (path, F_OK)) 198 | { 199 | free (path); 200 | asprintf (&path, PKGLIBDIR "/%s.so", name); 201 | } 202 | } 203 | else 204 | asprintf (&path, PKGLIBDIR "/%s.so", name); 205 | 206 | _ccze_plugin_load (name, path, 1); 207 | free (path); 208 | } 209 | 210 | static int 211 | _ccze_plugin_select (const struct dirent *de) 212 | { 213 | if (strstr (de->d_name, ".so")) 214 | return 1; 215 | return 0; 216 | } 217 | 218 | static void 219 | _ccze_plugin_load_set (struct dirent ***namelist, int nn, const char *base) 220 | { 221 | int m, n = nn; 222 | 223 | m = 0; 224 | while (m < n) 225 | { 226 | char *tmp = strdup ((*namelist)[m]->d_name); 227 | char *tmp2 = strstr (tmp, ".so"); 228 | char *path; 229 | tmp2[0] = '\0'; 230 | 231 | if (!_ccze_plugin_loaded (tmp)) 232 | { 233 | asprintf (&path, "%s/%s.so", base, tmp); 234 | _ccze_plugin_load (tmp, path, 1); 235 | free (path); 236 | } 237 | free (tmp); 238 | free ((*namelist)[m]); 239 | m++; 240 | } 241 | free (*namelist); 242 | } 243 | 244 | void 245 | ccze_plugin_load_all (void) 246 | { 247 | struct dirent **namelist; 248 | int n; 249 | char *homeplugs, *home; 250 | 251 | if ((home = getenv ("HOME")) != NULL) 252 | { 253 | asprintf (&homeplugs, "%s/.ccze", home); 254 | n = scandir (homeplugs, &namelist, _ccze_plugin_select, alphasort); 255 | if (n != -1) 256 | _ccze_plugin_load_set (&namelist, n, homeplugs); 257 | free (homeplugs); 258 | } 259 | 260 | n = scandir (PKGLIBDIR, &namelist, _ccze_plugin_select, alphasort); 261 | if (n != -1) 262 | _ccze_plugin_load_set (&namelist, n, PKGLIBDIR); 263 | } 264 | 265 | void 266 | ccze_plugin_finalise (void) 267 | { 268 | plugins[plugins_len] = NULL; 269 | } 270 | 271 | ccze_plugin_t ** 272 | ccze_plugins (void) 273 | { 274 | return plugins; 275 | } 276 | 277 | void 278 | ccze_plugin_setup (void) 279 | { 280 | size_t i; 281 | 282 | for (i = 0; i < plugins_len; i++) 283 | { 284 | if (plugins[i]) 285 | { 286 | plugin_running = plugins[i]->name; 287 | (*(plugins[i]->startup))(); 288 | } 289 | } 290 | plugin_running = NULL; 291 | } 292 | 293 | void 294 | ccze_plugin_shutdown (void) 295 | { 296 | size_t i; 297 | 298 | for (i = 0; i < plugins_len; i++) 299 | { 300 | if (plugins[i]) 301 | { 302 | plugin_running = plugins[i]->name; 303 | (*(plugins[i]->shutdown)) (); 304 | free (plugins[i]->argv); 305 | if (plugins[i]->dlhandle) 306 | dlclose (plugins[i]->dlhandle); 307 | } 308 | } 309 | 310 | plugin_running = NULL; 311 | free (plugins); 312 | } 313 | 314 | void 315 | ccze_plugin_run (ccze_plugin_t **pluginset, char *subject, size_t subjlen, 316 | char **rest, ccze_plugin_type_t type, int *handled, 317 | int *status) 318 | { 319 | int i = 0; 320 | 321 | while (pluginset[i]) 322 | { 323 | if (pluginset[i]->type == type || 324 | pluginset[i]->type == CCZE_PLUGIN_TYPE_ANY) 325 | { 326 | plugin_running = pluginset[i]->name; 327 | if ((*handled = (*(pluginset[i]->handler)) 328 | (subject, subjlen, rest)) != 0) 329 | { 330 | *status = *handled; 331 | break; 332 | } 333 | } 334 | i++; 335 | } 336 | plugin_running = NULL; 337 | } 338 | 339 | char ** 340 | ccze_plugin_argv_get (const char *name) 341 | { 342 | ccze_plugin_t *p = _ccze_plugin_find (name); 343 | 344 | if (!p) 345 | return NULL; 346 | return p->argv; 347 | } 348 | 349 | int 350 | ccze_plugin_argv_set (const char *name, const char *args) 351 | { 352 | ccze_plugin_t *p = NULL; 353 | size_t i, j = 1; 354 | char *args_copy, *arg; 355 | 356 | if (!args || !name) 357 | return -1; 358 | 359 | for (i = 0; i < plugin_args_len; i++) 360 | { 361 | if (!strcmp (plugin_args[i]->name, name)) 362 | p = plugin_args[i]; 363 | } 364 | 365 | if (p) 366 | { 367 | free (p->argv); 368 | p->argv = NULL; 369 | } 370 | else 371 | { 372 | p = (ccze_plugin_t *)ccze_malloc (sizeof (ccze_plugin_t)); 373 | p->name = strdup (name); 374 | p->argv = NULL; 375 | i = plugin_args_len++; 376 | if (plugin_args_len >= plugin_args_alloc) 377 | { 378 | plugin_args_alloc *= 2; 379 | plugin_args = (ccze_plugin_t **)ccze_realloc 380 | (plugin_args, plugin_args_alloc * sizeof (ccze_plugin_t *)); 381 | } 382 | } 383 | 384 | args_copy = strdup (args); 385 | arg = strtok (args_copy, " \t\n"); 386 | do 387 | { 388 | p->argv = (char **)ccze_realloc (p->argv, (j + 1) * sizeof (char *)); 389 | p->argv[j++] = strdup (arg); 390 | } while ((arg = strtok (NULL, " \t\n")) != NULL); 391 | p->argv = (char **)ccze_realloc (p->argv, (j + 1) * sizeof (char *)); 392 | p->argv[j] = NULL; 393 | p->argv[0] = strdup (name); 394 | plugin_args[i] = p; 395 | free (args_copy); 396 | 397 | return 1; 398 | } 399 | 400 | void 401 | ccze_plugin_argv_finalise (void) 402 | { 403 | ccze_plugin_t *p; 404 | size_t i; 405 | 406 | for (i = 0; i < plugin_args_len; i++) 407 | { 408 | p = _ccze_plugin_find (plugin_args[i]->name); 409 | if (p) 410 | p->argv = plugin_args[i]->argv; 411 | free (plugin_args[i]); 412 | } 413 | free (plugin_args); 414 | } 415 | 416 | const char * 417 | ccze_plugin_name_get (void) 418 | { 419 | return plugin_running; 420 | } 421 | 422 | int 423 | ccze_plugin_list_fancy (void) 424 | { 425 | size_t i; 426 | 427 | printf ("Available plugins:\n\n"); 428 | printf ("%-10s| %-8s| %s\n", "Name", "Type", "Description"); 429 | printf ("------------------------------------------------------------\n"); 430 | 431 | for (i = 0; i < plugins_len; i++) 432 | { 433 | if (plugins[i]) 434 | { 435 | char *type = "Unknown"; 436 | 437 | switch (plugins[i]->type) 438 | { 439 | case CCZE_PLUGIN_TYPE_FULL: 440 | type = "Full"; 441 | break; 442 | case CCZE_PLUGIN_TYPE_PARTIAL: 443 | type = "Partial"; 444 | break; 445 | case CCZE_PLUGIN_TYPE_ANY: 446 | type = "Any"; 447 | break; 448 | } 449 | printf ("%-10s| %-8s| %s\n", plugins[i]->name, type, 450 | (plugins[i]->desc) ? plugins[i]->desc : "Undocumented."); 451 | } 452 | } 453 | plugin_running = NULL; 454 | 455 | return 0; 456 | } 457 | --------------------------------------------------------------------------------