ekg2
|
00001 /* $Id: stuff.h 4597 2008-09-03 21:10:01Z darkjames $ */ 00002 00003 /* 00004 * (C) Copyright 2001-2003 Wojtek Kaniewski <wojtekka@irc.pl> 00005 * Robert J. Woźny <speedy@ziew.org> 00006 * Paweł Maziarz <drg@go2.pl> 00007 * Dawid Jarosz <dawjar@poczta.onet.pl> 00008 * Piotr Domagalski <szalik@szalik.net> 00009 * Adam Mikuta <adammikuta@poczta.onet.pl> 00010 * 00011 * This program is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License Version 2 as 00013 * published by the Free Software Foundation. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00023 */ 00024 00025 #ifndef __EKG_STUFF_H 00026 #define __EKG_STUFF_H 00027 00028 #include <sys/types.h> 00029 #include <sys/time.h> 00030 #include <time.h> 00031 00032 #include <ctype.h> 00033 #include <stdarg.h> 00034 #include <stdio.h> 00035 00036 #include "plugins.h" 00037 #include "sessions.h" 00038 00039 #define BINDING_FUNCTION(x) void x(const char *arg) 00040 00041 struct binding { 00042 struct binding *next; 00043 00044 char *key; 00045 00046 char *action; /* akcja */ 00047 unsigned int internal : 1; /* czy domyślna kombinacja? */ 00048 void (*function)(const char *arg); /* funkcja obsługująca */ 00049 char *arg; /* argument funkcji */ 00050 00051 char *default_action; /* domyślna akcja */ 00052 void (*default_function)(const char *arg); /* domyślna funkcja */ 00053 char *default_arg; /* domyślny argument */ 00054 }; 00055 00056 typedef struct binding_added { 00057 struct binding_added *next; 00058 00059 char *sequence; 00060 struct binding *binding; 00061 } binding_added_t; 00062 00063 #define TIMER(x) int x(int type, void *data) 00064 00065 struct timer { 00066 struct timer *next; 00067 00068 char *name; /* nazwa timera */ 00069 plugin_t *plugin; /* wtyczka obsługująca deksryptor */ 00070 struct timeval ends; /* kiedy się kończy? */ 00071 unsigned int period; /* ile milisekund ma trwać czekanie */ 00072 int (*function)(int, void *); /* funkcja do wywołania */ 00073 void *data; /* dane dla funkcji */ 00074 00075 unsigned int persist : 1; /* czy ma być na zawsze? */ 00076 unsigned int at : 1; /* /at? trzeba się tego jakoś pozbyć 00077 * i ujednolicić z /timer */ 00078 unsigned int is_session : 1; /* czy sesyjny */ 00079 }; 00080 00081 extern char *config_console_charset; /* */ 00082 extern char *server_console_charset; 00083 extern int config_use_unicode; /* for instance in jabber plugin if this is on, than we don't need to make iconv from / to unicode.. */ 00084 extern int config_use_iso; /* this for ncurses */ 00085 extern struct binding *bindings; 00086 extern struct timer *timers; 00087 extern binding_added_t *bindings_added; 00088 extern int config_debug; 00089 extern int config_display_welcome; 00090 extern int config_query_commands; 00091 extern int config_slash_messages; 00092 extern int config_display_color; 00093 extern int config_display_pl_chars; 00094 extern int config_display_crap; 00095 extern int config_default_status_window; 00096 extern char *config_timestamp; 00097 extern int config_timestamp_show; 00098 extern int config_history_savedups; 00099 extern int config_make_window; 00100 extern int config_sort_windows; 00101 extern int config_send_white_lines; 00102 00103 extern char *config_tab_command; 00104 extern int config_save_quit; 00105 extern int config_lastlog_noitems; 00106 extern int config_lastlog_case; 00107 extern int config_lastlog_display_all; 00108 extern char *config_completion_char; 00109 00110 extern int config_changed; 00111 00112 extern int no_mouse; 00113 00114 extern int old_stderr; 00115 00116 extern int in_autoexec; 00117 00118 void binding_free(); 00119 00120 void changed_theme(const char *var); 00121 00122 const char *compile_time(); 00123 00124 void iso_to_ascii(unsigned char *buf); 00125 00126 #ifdef __GNUC__ 00127 char *saprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); 00128 #else 00129 char *saprintf(const char *format, ...); 00130 #endif 00131 00132 const char *timestamp(const char *format); 00133 const char *timestamp_time(const char *format, time_t t); 00134 00135 int isalpha_pl(unsigned char c); 00136 /* makra, dzięki którym pozbywamy się warning'ów */ 00137 #define xisxdigit(c) isxdigit((int) (unsigned char) c) 00138 #define xisdigit(c) isdigit((int) (unsigned char) c) 00139 #define xisalpha(c) isalpha_pl((int) (unsigned char) c) 00140 #define xisalnum(c) isalnum((int) (unsigned char) c) 00141 #define xisspace(c) isspace((int) (unsigned char) c) 00142 #define xtolower(c) tolower((int) (unsigned char) c) 00143 #define xtoupper(c) toupper((int) (unsigned char) c) 00144 00145 struct timer *timer_add(plugin_t *plugin, const char *name, unsigned int period, int persist, int (*function)(int, void *), void *data); 00146 struct timer *timer_add_ms(plugin_t *plugin, const char *name, unsigned int period, int persist, int (*function)(int, void *), void *data); 00147 int timer_remove(plugin_t *plugin, const char *name); 00148 struct timer *timers_removei(struct timer *t); 00149 void timers_destroy(); 00150 00151 const char *ekg_status_string(const int status, const int cmd); 00152 00153 /* funkcje poza stuff.c */ 00154 void ekg_exit(); 00155 void ekg_debug_handler(int level, const char *format, va_list ap); 00156 00157 int ekg_write(int fd, const char *buf, int len); 00158 int remote_request(char *what, ...); 00159 00160 #endif /* __EKG_STUFF_H */ 00161 00162 /* 00163 * Local Variables: 00164 * mode: c 00165 * c-file-style: "k&r" 00166 * c-basic-offset: 8 00167 * indent-tabs-mode: t 00168 * End: 00169 */