{
    "mode": "man",
    "parameter": "ccze-plugin",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/ccze-plugin/7/json",
    "generated": "2026-06-15T14:33:44Z",
    "synopsis": "",
    "sections": {
        "NAME": {
            "content": "ccze - A robust log colorizer, plugin infrastructure\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "",
            "subsections": [
                {
                    "name": "#include <ccze.h>",
                    "content": "/* Plugin support */\ntypedef void (*cczepluginstartupt) (void);\ntypedef void (*cczepluginshutdownt) (void);\ntypedef int (*cczepluginhandlet) (const char *str, sizet length, char rest);\n\nCCZEDEFINEPLUGIN (name, type, desc);\nCCZEDEFINEPLUGINS (plugins...);\n\n/* Display */\nvoid cczeaddstr (cczecolort col, const char *str);\nvoid cczenewline (void);\nvoid cczespace (void);\nvoid cczewordcolorprocessone (char *word, int slookup);\n\n/* Helpers */\ncczecolort cczehttpaction (const char *method);\nvoid cczeprintdate (const char *date);\n\n/* Command line */\nchar cczepluginargvget (const char *name);\nconst char *cczepluginnameget (void);\n"
                }
            ]
        },
        "DESCRIPTION": {
            "content": "This  manual page attempts to outline the internals of CCZE plugins:  how they work, how they\nare implemented, and how to add new ones.\n\nThere are four required entry points in a plugin: a startup, a shutdown and a handler routine\n(more on these later), and an informational structure.\n\nThe  startup  function  must be of type cczepluginstartupt. This is called right after the\nmodule is loaded.  Its purpose is to initialise all kinds  of  module-specific  global  vari‐\nables, such as the regular expressions.\n\nThe  shutdown  function is its counterpart: this is used to deallocate any memory reserved by\nthe startup code.\n\nThe core part of a plugin is the handler, of type cczepluginhandlet.  This does the actual\ncoloring.   The  string  to process is passed in the str argument, its length in length.  The\nthird argument, rest is a pointer to a string.  Unlike the first two, this argument  is  used\nonly for output.\n\nWhen  a  handler  processed  a  string, it must return a non-zero value, in case it could not\nprocess it, the handler must return with zero.  If the string could be  processed  only  par‐\ntially,  the  part  which  was  deemed unknown by the handler must be passed back in the rest\nvariable.\n\nThe fourth part, although the smallest part, is the most important. Without this, the  module\nis useless, it cannot be loaded.  This part tells CCZE what the startup, shutdown and handler\nfunctions are called.\n\nTo encourage good style, the little details of this structure will not be disclosed  in  this\nmanual page.  Instead, the helper macro, CCZEDEFINEPLUGIN will be explained.\n\nCCZEDEFINEPLUGIN  is  the  macro to use if one wants to make the plugin loadable. Its first\nargument is an unquoted string: the name of the plugin.  The second part is the type  of  the\nplugin,  it  can  be  FULL,  PARTIAL  or ANY. The last argument is a short description of the\nplugin.\n\nIt is assumed  that  the  three  functions  mentioned  earlier  are  called  cczenamesetup,\ncczenameshutdown and cczenamehandle, respectively.\n\nA  FULL  plugin is one that accepts raw input, untouched by any other plugin before, and pro‐\ncesses it.  On the other hand, a PARTIAL plugin relies on previous ones preprocessing the in‐\nput.   For  example,  syslog  is a full plugin, on which ulogd, a partial plugin relies.  The\nsyslog plugin processes the raw input from the logfile, adds colour to most of it,  save  the\nactual  message  sent  by  a  process, that is left to subsequent plugins, like ulogd. An ANY\nplugin is one can act as both other types.\n\nWith CCZEDEFINEPLUGINS one can place more than one plugin into one shared object.\n\nThere are two other helper functions, cczepluginargvget and cczepluginnameget. One  can\npass  arguments  to  CCZE  plugins,  and  these  is  the  function  to  retrieve  them. While\ncczepluginnameget returns the name of the current plugin, cczepluginargvget  returns  a\nNULL-terminated array, with each entry containing an argument.\n",
            "subsections": []
        },
        "DISPLAY METHODS": {
            "content": "The  so-called display methods are the only supported interface to emit something to the dis‐\nplay. These handle both the normal, ncurses-based, and the HTML output. This is a kind of ab‐\nstraction so plugins will not have to worry about the differences between the output formats.\n\nThe  most  important  one  is cczeaddstr, which takes a color (see ccze.h for a list of sup‐\nported color tags) and a string, and displays it appropriately. The cczespace and  cczenew‐\nline functions emit a space and a newline, respectively.\n\nOur  last function, cczewordcolorprocessone passes word to the word colourising engine. If\nthe second argument, slookup is non-zero, the  engine  will  perform  service  lookups  (like\ngetent and friends).\n",
            "subsections": []
        },
        "HELPER METHODS": {
            "content": "We only have two helper methods: cczeprintdate, which simply prints out the date in the ap‐\npropriate colour, and cczehttpaction, which given a HTTP  method,  returns  the  associated\ncolour, in a format suitable for cczeaddstr.\n",
            "subsections": []
        },
        "EXAMPLE": {
            "content": "#include <ccze.h>\n#include <stddef.h>\n#include <string.h>\n\nstatic char cczefooargv;\n\nstatic int\ncczefoohandle (const char *str, sizet length, char rest)\n{\nint i = 1;\n\nif (strstr (str, \"foo\"))\n{\ncczeaddstr (CCZECOLORGOODWORD, str);\nreturn 1;\n}\n\nwhile (cczefooargv[i])\n{\nif (strstr (str, cczefooargv[i]))\n{\ncczeaddstr (CCZECOLORGOODWORD, str);\nreturn 1;\n}\ni++;\n}\nreturn 0;\n}\n\nstatic void\ncczefoostartup (void)\n{\ncczefooargv = cczepluginargvget (cczepluginnameget ());\n}\n\nstatic void\ncczefooshutdown (void)\n{\n}\n\nCCZEDEFINEPLUGIN (foo, PARTIAL, \"Partial FOO coloriser.\");\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "ccze(1)\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "ccze was written by Gergely Nagy <algernon@bonehunter.rulez.org>, based on colorize by Istvan\nKaraszi <colorize@spam.raszi.hu>.\n\n\n\nCCZE 0.2.1                                   2003-03-29                               CCZE-PLUGIN(7)",
            "subsections": []
        }
    },
    "summary": "ccze - A robust log colorizer, plugin infrastructure",
    "flags": [],
    "examples": [
        "#include <ccze.h>",
        "#include <stddef.h>",
        "#include <string.h>",
        "static char cczefooargv;",
        "static int",
        "cczefoohandle (const char *str, sizet length, char rest)",
        "int i = 1;",
        "if (strstr (str, \"foo\"))",
        "cczeaddstr (CCZECOLORGOODWORD, str);",
        "return 1;",
        "while (cczefooargv[i])",
        "if (strstr (str, cczefooargv[i]))",
        "cczeaddstr (CCZECOLORGOODWORD, str);",
        "return 1;",
        "i++;",
        "return 0;",
        "static void",
        "cczefoostartup (void)",
        "cczefooargv = cczepluginargvget (cczepluginnameget ());",
        "static void",
        "cczefooshutdown (void)",
        "CCZEDEFINEPLUGIN (foo, PARTIAL, \"Partial FOO coloriser.\");"
    ],
    "see_also": [
        {
            "name": "ccze",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/ccze/1/json"
        }
    ]
}