1 /* -*- mode: c; c-file-style: "gnu" -*- 2 * ccze.h -- Public interface to CCZE. 3 * Copyright (C) 2002, 2003 Gergely Nagy <algernon@bonehunter.rulez.org> 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 <pcre.h> 29 #include <ncurses.h> 30 #include <stddef.h> 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