1 /************************************************************************* 2 * gruftistats data structures 3 * Copyright (c) 1998-9 Andy Kempling (aurikan@hotmail.com), 4 * Copyright (c) 1998-2001 Colin Phipps <cphipps@doomworld.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it 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 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public 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., 675 Mass Ave, Cambridge, MA 02139, USA. 19 *************************************************************************/ 20 /* $Id: ircstats.h,v 1.12 2001/07/21 10:18:18 cph Exp $ */ 21 #ifndef __GRUFDATA_H__ 22 #define __GRUFDATA_H__ 23 24 #include "config.h" 25 26 #include <stdio.h> 27 #include <sys/types.h> 28 #include <regex.h> 29 30 #ifdef HAVE_LIBDMALLOC 31 #include <dmalloc.h> 32 #endif 33 34 #define NUM_RANDOM 5 35 #define RECORD_MAX 5 36 #define RECORD_NUM 5 37 38 typedef struct rquote_s { 39 char *quote; 40 int choices; 41 } rquote_t; 42 43 typedef struct user_s { 44 char *name; 45 char *curnick; 46 rquote_t quote; 47 char *lastline; 48 long int lines; 49 long int texts[4]; 50 long int acts[4]; 51 long int letters, questions, loud, punct, statword; 52 long int joins; 53 long int kicked; 54 long int kicks; 55 long int nicks; 56 long int statcalls; 57 long int seens; 58 long int urls; 59 long int topics; 60 long int sought; 61 short int alive, monologues, answered; 62 enum { 63 UF_NONE = 0, 64 UF_ASKING = 1, 65 } flags; 66 } user; 67 68 typedef struct { 69 char name[16]; 70 long int lines[24]; 71 long int tlines; 72 char *curtopic; 73 char date[16]; 74 rquote_t quote; 75 } chan; 76 77 typedef struct { 78 unsigned int num; 79 unsigned int delled; 80 char* random[NUM_RANDOM]; 81 char* bywho[NUM_RANDOM]; 82 } some_random_stuff; 83 84 typedef enum LTypes LT; 85 86 typedef const struct { 87 char tag[20]; 88 char *where; 89 int max; 90 } response_settings; 91 92 typedef struct { 93 int num; 94 char name[16]; 95 char date[16]; 96 } record_t; 97 98 typedef struct { 99 char name[32]; 100 record_t record[RECORD_MAX]; 101 } recordset; 102 103 /* Now for some portability stuff.. 104 * If we are missing certain functions, remap them 105 * or define prototypes and get them from lib.c 106 */ 107 108 #ifndef HAVE_STRICMP 109 #ifdef HAVE_STRCASECMP 110 #define stricmp strcasecmp 111 #else 112 #error No case insensitive string compare? 113 #endif 114 #endif 115 116 #ifndef HAVE_STRLCPY 117 size_t strlcpy(char* dest, const char* source, size_t len); 118 #endif 119 #ifndef HAVE_STRLCAT 120 size_t strlcat(char* dest, const char* source, size_t len); 121 #endif 122 #ifndef HAVE_STRLWR 123 char* strlwr(char* s); 124 #endif 125 126 /* More string utility functions */ 127 char* strcasestr_x(char* haystack, const char* needle); 128 void stripansi(char* str); 129 char* strdup_from_rmatch(const char* str, const regmatch_t* prm); 130 131 /* Regexp log format stuff */ 132 /* The type of line */ 133 enum line_type_e { 134 LT_NULL, 135 LT_TEXT, 136 LT_ACT, 137 LT_JOIN, 138 LT_PART, 139 LT_SIGNOFF, 140 LT_KICK, 141 LT_TOPIC, 142 LT_NICK, 143 LT_MODE, 144 LT_DATE_STAMP, 145 LT_CHANNEL, 146 LT_NUM 147 }; 148 149 /* Code which represents a bit of info tha a line might contain */ 150 enum line_part_e { 151 LP_TIME, 152 LP_NICK, 153 LP_OTHERNICK, /* The target of a kick, or nick change */ 154 LP_STRING, /* This is the mode string, kick/quit reason, or line of text */ 155 LP_DATE, 156 LP_CHANNEL, 157 LP_NUM 158 }; 159 160 struct log_parse_s { 161 regex_t compiled_regex; 162 int returned_bit[LP_NUM]; 163 }; 164 165 struct log_parse_s* ReadLogFormatSpec(FILE* infp, int verbose); 166 void output_content(FILE * output, char * line); 167 168 #endif 169