PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/ccze-0.2.1/src/ccze.h

#
C Header | 185 lines | 142 code | 18 blank | 25 comment | 0 complexity | 51bc6a5f57a447d6a056264e9ede4fe9 MD5 | raw file
Possible License(s): GPL-2.0
  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. #ifndef _CCZE_H
  22. #define _CCZE_H 1
  23. #ifdef HAVE_SYSTEM_H
  24. # include "system.h"
  25. #endif
  26. #include <pcre.h>
  27. #include <ncurses.h>
  28. #include <stddef.h>
  29. /* Compatibility */
  30. void *ccze_malloc (size_t size);
  31. void *ccze_realloc (void *ptr, size_t size);
  32. void *ccze_calloc (size_t nmemb, size_t size);
  33. /* Colors */
  34. typedef enum
  35. {
  36. CCZE_COLOR_DATE = 0,
  37. CCZE_COLOR_HOST,
  38. CCZE_COLOR_PROC,
  39. CCZE_COLOR_PID,
  40. CCZE_COLOR_PIDB,
  41. CCZE_COLOR_DEFAULT,
  42. CCZE_COLOR_EMAIL,
  43. CCZE_COLOR_SUBJECT,
  44. CCZE_COLOR_DIR,
  45. CCZE_COLOR_SIZE,
  46. CCZE_COLOR_USER,
  47. CCZE_COLOR_HTTPCODES,
  48. CCZE_COLOR_GETSIZE,
  49. CCZE_COLOR_HTTP_GET,
  50. CCZE_COLOR_HTTP_POST,
  51. CCZE_COLOR_HTTP_HEAD,
  52. CCZE_COLOR_HTTP_PUT,
  53. CCZE_COLOR_HTTP_CONNECT,
  54. CCZE_COLOR_HTTP_TRACE,
  55. CCZE_COLOR_UNKNOWN,
  56. CCZE_COLOR_GETTIME,
  57. CCZE_COLOR_URI,
  58. CCZE_COLOR_IDENT,
  59. CCZE_COLOR_CTYPE,
  60. CCZE_COLOR_ERROR,
  61. CCZE_COLOR_PROXY_MISS,
  62. CCZE_COLOR_PROXY_HIT,
  63. CCZE_COLOR_PROXY_DENIED,
  64. CCZE_COLOR_PROXY_REFRESH,
  65. CCZE_COLOR_PROXY_SWAPFAIL,
  66. CCZE_COLOR_DEBUG,
  67. CCZE_COLOR_WARNING,
  68. CCZE_COLOR_PROXY_DIRECT,
  69. CCZE_COLOR_PROXY_PARENT,
  70. CCZE_COLOR_SWAPNUM,
  71. CCZE_COLOR_PROXY_CREATE,
  72. CCZE_COLOR_PROXY_SWAPIN,
  73. CCZE_COLOR_PROXY_SWAPOUT,
  74. CCZE_COLOR_PROXY_RELEASE,
  75. CCZE_COLOR_MAC,
  76. CCZE_COLOR_VERSION,
  77. CCZE_COLOR_ADDRESS,
  78. CCZE_COLOR_NUMBERS,
  79. CCZE_COLOR_SIGNAL,
  80. CCZE_COLOR_SERVICE,
  81. CCZE_COLOR_PROT,
  82. CCZE_COLOR_BADWORD,
  83. CCZE_COLOR_GOODWORD,
  84. CCZE_COLOR_SYSTEMWORD,
  85. CCZE_COLOR_INCOMING,
  86. CCZE_COLOR_OUTGOING,
  87. CCZE_COLOR_UNIQN,
  88. CCZE_COLOR_REPEAT,
  89. CCZE_COLOR_FIELD,
  90. CCZE_COLOR_CHAIN,
  91. CCZE_COLOR_PERCENTAGE,
  92. CCZE_COLOR_FTPCODES,
  93. CCZE_COLOR_KEYWORD,
  94. CCZE_COLOR_STATIC_BLACK,
  95. CCZE_COLOR_STATIC_RED,
  96. CCZE_COLOR_STATIC_GREEN,
  97. CCZE_COLOR_STATIC_YELLOW,
  98. CCZE_COLOR_STATIC_BLUE,
  99. CCZE_COLOR_STATIC_CYAN,
  100. CCZE_COLOR_STATIC_MAGENTA,
  101. CCZE_COLOR_STATIC_WHITE,
  102. CCZE_COLOR_STATIC_BOLD_BLACK,
  103. CCZE_COLOR_STATIC_BOLD_RED,
  104. CCZE_COLOR_STATIC_BOLD_GREEN,
  105. CCZE_COLOR_STATIC_BOLD_YELLOW,
  106. CCZE_COLOR_STATIC_BOLD_BLUE,
  107. CCZE_COLOR_STATIC_BOLD_CYAN,
  108. CCZE_COLOR_STATIC_BOLD_MAGENTA,
  109. CCZE_COLOR_STATIC_BOLD_WHITE,
  110. CCZE_COLOR_LAST
  111. } ccze_color_t;
  112. int ccze_color (ccze_color_t idx);
  113. int ccze_color_keyword_lookup (const char *key);
  114. /* Helpers */
  115. ccze_color_t ccze_http_action (const char *method);
  116. void ccze_print_date (const char *date);
  117. char *ccze_strbrk (char *str, char delim);
  118. char *xstrdup (const char *str);
  119. /* Display */
  120. void ccze_addstr (ccze_color_t col, const char *str);
  121. void ccze_newline (void);
  122. void ccze_space (void);
  123. void ccze_wordcolor_process_one (char *word, int slookup);
  124. /* Plugins */
  125. typedef void (*ccze_plugin_startup_t) (void);
  126. typedef void (*ccze_plugin_shutdown_t) (void);
  127. typedef int (*ccze_plugin_handle_t) (const char *str, size_t length,
  128. char **rest);
  129. typedef enum
  130. {
  131. CCZE_PLUGIN_TYPE_FULL,
  132. CCZE_PLUGIN_TYPE_PARTIAL,
  133. CCZE_PLUGIN_TYPE_ANY
  134. } ccze_plugin_type_t;
  135. typedef struct
  136. {
  137. int abi_version;
  138. void *dlhandle;
  139. char *name;
  140. char **argv;
  141. ccze_plugin_startup_t startup;
  142. ccze_plugin_shutdown_t shutdown;
  143. ccze_plugin_handle_t handler;
  144. ccze_plugin_type_t type;
  145. char *desc;
  146. } ccze_plugin_t;
  147. char **ccze_plugin_argv_get (const char *name);
  148. const char *ccze_plugin_name_get (void);
  149. #define CCZE_ABI_VERSION 2
  150. #define CCZE_DEFINE_PLUGINS(plugins...) \
  151. char *ccze_plugin_list[] = { plugins, NULL }
  152. #if !defined(BUILTIN)
  153. #define __default_plugin(name) ; \
  154. char ccze_default_plugin[] = # name
  155. #else
  156. #define __default_plugin(name)
  157. #endif
  158. #define CCZE_DEFINE_PLUGIN(name,type,desc) \
  159. ccze_plugin_t ccze_##name##_info = { CCZE_ABI_VERSION, \
  160. NULL, \
  161. # name, NULL, \
  162. ccze_##name##_setup, \
  163. ccze_##name##_shutdown, \
  164. ccze_##name##_handle, \
  165. CCZE_PLUGIN_TYPE_##type, desc } \
  166. __default_plugin (name)
  167. #endif /* !_CCZE_H */