1 /* echat.h 2 * 3 * copyright (c) 2000-2003 SeaD 4 * see GPL for copying info 5 * 6 */ 7 8 #ifndef _ECHAT_H 9 #define _ECHAT_H 1 10 11 #include <stdlib.h> 12 #include <stdio.h> 13 14 #define NAME "eChat" 15 #define VERSION "0.04 beta1" 16 #define AUTHOR "SeaD" 17 #define MAIL "sead@mail.ru" 18 19 #ifdef RU 20 # include "mesg_ru.h" 21 #endif /* RU */ 22 #ifdef TU 23 # include "mesg_tu.h" 24 #endif /* TU */ 25 #ifndef LANG 26 # include "mesg_en.h" 27 #endif /* EN */ 28 29 #ifdef FREEBSD 30 # define SYSTEM "FreeBSD" 31 #endif /* FREEBSD */ 32 #ifdef LINUX 33 # define SYSTEM "Linux" 34 #endif /* LINUX */ 35 #ifdef WIN32 36 # define SYSTEM "CygWin32" 37 #endif /* WIN32 */ 38 #ifndef SYSTEM 39 # define SYSTEM "Unknown" 40 #endif /* SYSTEM */ 41 42 #define CNF_ECHATRC "echatrc" 43 44 #define BUF_SIZE 1024 45 #define MSG_SIZE 1000 /* udp broadcast limit */ 46 #define STR_SIZE 800 /* STR_SIZE <= MSG_SIZE */ 47 48 #define PATH_SIZE 256 /* must be enough */ 49 #define HIST_SIZE 50 50 #define SCRN_SIZE 500 51 #define LINE_SIZE 80 /* LINE_SIZE >= COLS - users_width */ 52 #define PBUF_SIZE 20 53 #define ADDR_SIZE 16 /* strlen("255.255.255.255") == 15 */ 54 #define TIME_SIZE 10 /* strlen("23:59:59") == 8 */ 55 56 #define USERS_MAX 32 /* may be increased */ 57 #define CHANNELS_MAX 8 58 #define ADDRS_MAX 8 59 #define NICK_MAXLEN 20 /* recomended NICK_MAXLEN <= 20 */ 60 #define CHANNEL_MAXLEN NICK_MAXLEN 61 62 #define LOCALHOST "127.0.0.1" /* loopback interface address */ 63 #define BROADCAST "255.255.255.255" /* broadcast address */ 64 #define ALLHOSTS "224.0.0.1" /* igmp all hosts address */ 65 #define VMCAST "227.0.0.2" /* vypress multicast address */ 66 #define VPORT (unsigned short) 8167 /* Vypress Chat, quickChat */ 67 #define PPORT (unsigned short) 8169 /* ProChat */ 68 #ifdef TCP 69 # define CLIENTS_MAX 8 /* tcp connections */ 70 #endif /* TCP */ 71 #define PACKET_ECHAT 'Z' /* eChat packets */ 72 #define PACKET_ECVER '1' /* eChat proto version */ 73 #define PACKET_VYPRESS 'X' /* Vypress Chat packets */ 74 #define PACKET_VYPRESSXOR 'Y' /* Vypress XOR packets */ 75 #define CHR_XOR (unsigned char) 0 /* XOR-byte */ 76 #define HEADER_LEN 10 /* packet header length */ 77 #define MSG_SPLIT '\0' /* strings splitter */ 78 79 #define CHR_CHNL '#' /* channel first letter */ 80 #define CHR_NICK ':' /* nick last letter */ 81 82 #define MOD_NORMAL 0 83 #define MOD_DND 1 84 #define MOD_AWAY 2 85 #define MOD_OFF 3 86 87 #define COL_SYSTEM 10 /* system text */ 88 #define COL_ERROR 11 /* error text */ 89 #define COL_MESG 12 /* message text */ 90 #define COL_MY 13 /* my text */ 91 #define COL_CHAT 14 /* others text */ 92 93 struct config_t { 94 char file[PATH_SIZE+2]; 95 char nick[NICK_MAXLEN+2]; 96 int gender; 97 char channel[STR_SIZE+2]; 98 int mode; 99 char active; 100 char answer_dnd[STR_SIZE+2]; 101 char answer_away[STR_SIZE+2]; 102 char answer_off[STR_SIZE+2]; 103 char me_action[STR_SIZE+2]; 104 char favorite[STR_SIZE+2]; 105 char ignore[STR_SIZE+2]; 106 char ban[STR_SIZE+2]; 107 char address[STR_SIZE+2]; 108 unsigned short port; 109 char packet_mcast; 110 char packet_bcast; 111 char packet_route; 112 char packet_vchat; 113 char packet_qchat; 114 char packet_pchat; 115 unsigned char packet_xor; 116 char head_nick[STR_SIZE+2]; 117 char head_top[STR_SIZE+2]; 118 char head_users[STR_SIZE+2]; 119 char ps[STR_SIZE+2]; 120 char style; 121 char ascii; 122 char percent; 123 char status_str; 124 char seconds; 125 int users_width; 126 int users_refresh; 127 int scroll_step; 128 #ifdef CHARSET 129 char charset; 130 #endif /* CHARSET */ 131 char beep_system; 132 char beep_chat; 133 char beep_join; 134 char beep_mesg; 135 char beep_beep; 136 char my_only; 137 char verbose; 138 char server; 139 #ifdef SHELL 140 char shell[STR_SIZE+2]; 141 #endif /* SHELL */ 142 char log_main[PATH_SIZE+2]; 143 char log_mesg[PATH_SIZE+2]; 144 char log_priv[PATH_SIZE+2]; 145 int color_bkgr; 146 int color_border; 147 int color_head; 148 int color_status; 149 int color_system; 150 int color_error; 151 int color_mesg; 152 int color_my; 153 int color_chat; 154 }; 155 156 struct addr_t { 157 char addr[ADDR_SIZE+1]; 158 char net[ADDR_SIZE+1]; 159 unsigned short port; 160 char proto; 161 char ubm_cast; 162 }; 163 164 struct user_t { 165 char nick[NICK_MAXLEN+2]; 166 char gender; 167 int mode; 168 char active; 169 char favorite; 170 char ignore; 171 char addr[ADDR_SIZE+1]; 172 }; 173 174 struct chnl_t { 175 char name[CHANNEL_MAXLEN+2]; 176 char topic[STR_SIZE+2]; 177 int scrn; 178 int scrn_top; 179 char screen[SCRN_SIZE][LINE_SIZE+2]; 180 int scrn_color[SCRN_SIZE]; 181 char addr[ADDR_SIZE+1]; 182 }; 183 184 struct info_t { 185 char nick[NICK_MAXLEN+2]; 186 char host[STR_SIZE]; 187 char addr[ADDR_SIZE+1]; 188 char chnlslist[STR_SIZE+2]; 189 char uptime[TIME_SIZE+1]; 190 }; 191 192 struct status_t { 193 char nick[NICK_MAXLEN+2]; 194 char gender; 195 char channel[CHANNEL_MAXLEN+2]; 196 int mode; 197 char active; 198 int addrs; 199 char addr[ADDRS_MAX][ADDR_SIZE+1]; 200 char address[ADDR_SIZE+1]; 201 char favorite[USERS_MAX][NICK_MAXLEN+2]; 202 char ignore[USERS_MAX][NICK_MAXLEN+2]; 203 char ban[USERS_MAX][ADDR_SIZE+1]; 204 int users_refresh; 205 char ps[STR_SIZE+2]; 206 char percent; 207 unsigned int start; 208 struct info_t info; 209 int user_sort; 210 int users; 211 struct user_t *talk; 212 struct user_t user[USERS_MAX]; 213 int strn; 214 int strn_end; 215 int strn_cur; 216 int strn_width; 217 int scrn_width; 218 int channels; 219 char *topic; 220 struct chnl_t *room; 221 struct chnl_t *room_str; 222 struct chnl_t chnl[CHANNELS_MAX+1]; 223 int hist; 224 char history[HIST_SIZE][STR_SIZE+2]; 225 char packet_buf[PBUF_SIZE][MSG_SIZE+2]; 226 int packet_len; 227 #ifdef TCP 228 int clients; 229 #endif /* TCP */ 230 }; 231 232 /* echat.c 233 */ 234 extern char *buf; 235 extern char *packet; 236 extern char *message; 237 extern struct config_t *config; 238 extern struct status_t *status; 239 240 #ifdef DEBUG 241 extern FILE *debug_file; 242 #endif /* DEBUG */ 243 244 /* chat_chnl.c 245 */ 246 void chnl_parse(void); 247 int chnl_getnum(void); 248 void chnl_refresh(void); 249 void chnl_next(void); 250 void chnl_join(void); 251 void chnl_leave(void); 252 void chnl_init(void); 253 void chnl_kill(void); 254 void chat_join(void); 255 void chat_rejoin(void); 256 void chat_leave(void); 257 void chat_nick(void); 258 259 /* chat_cmnd.c 260 */ 261 void cmnd_clear(void); 262 void cmnd_load(void); 263 void cmnd_active(void); 264 void cmnd_parse(void); 265 266 /* chat_conf.c 267 */ 268 void conf_init(int argc, char *argv[]); 269 int conf_read(void); 270 int conf_write(void); 271 272 #ifdef CHARSET 273 /* chat_cset.c 274 */ 275 void cset_inout(void); 276 void cset_outin(void); 277 void cset_string(void); 278 #endif /* CHARSET */ 279 280 /* chat_parm.c 281 */ 282 void parm_getopt(int argc, char *argv[]); 283 284 /* chat_syst.c 285 */ 286 void write_log(char *logfile); 287 void chat_exit(int reason); 288 void sig_init(void); 289 void sig_func(int signal); 290 void sig_process(void); 291 char *time_get(void); 292 void time_up(void); 293 void time_users(void); 294 295 /* chat_user.c 296 */ 297 void user_parse(void); 298 void user_refresh(void); 299 int user_getnum(void); 300 void user_delfavorite(void); 301 void user_addfavorite(void); 302 void user_parsfavorite(void); 303 void user_delignore(void); 304 void user_addignore(void); 305 void user_parsignore(void); 306 void user_delban(void); 307 void user_addban(void); 308 void user_parsban(void); 309 int user_setfavorite(void); 310 int user_favorite(void); 311 int user_setignore(void); 312 int user_ignore(void); 313 void user_add(void); 314 void user_del(void); 315 void user_rescan(void); 316 void user_nick(void); 317 void user_mode(void); 318 void user_active(void); 319 320 /* curs_strn.c 321 */ 322 void string_show(void); 323 void screen_show(void); 324 void read_str(void); 325 void write_str(char *name, int color); 326 void write_tcp(char *name); 327 328 /* curs_term.c 329 */ 330 void term_init(void); 331 void term_kill(void); 332 void window_init(void); 333 void refresh_users(void); 334 void refresh_room(void); 335 void refresh_text(void); 336 void refresh_input(void); 337 void refresh_read(void); 338 void window_refresh(void); 339 void status_ok(char *status); 340 void status_error(char *status); 341 void beep_system(void); 342 void beep_chat(void); 343 void beep_join(void); 344 void beep_mesg(void); 345 void beep_beep(void); 346 347 /* pckt_actn.c 348 */ 349 void recv_welcome(void); 350 void recv_bye(void); 351 void recv_join(void); 352 void recv_leave(void); 353 void recv_here(void); 354 void recv_herewe(void); 355 void recv_herewho(void); 356 void recv_hereim(void); 357 void recv_chat(void); 358 void recv_me(void); 359 void recv_mesg(void); 360 void recv_mass(void); 361 void recv_mesgack(void); 362 void recv_topic(void); 363 void recv_topicreq(void); 364 void recv_topicnew(void); 365 void recv_nick(void); 366 void recv_mode(void); 367 void recv_active(void); 368 void recv_privjoin(void); 369 void recv_privjoinack(void); 370 void recv_privleave(void); 371 void recv_privchat(void); 372 void recv_privme(void); 373 void recv_beep(void); 374 void recv_beepack(void); 375 void recv_info(void); 376 void recv_inform(void); 377 void recv_exec(void); 378 void recv_execack(void); 379 void recv_chnls(void); 380 void recv_chnlslist(void); 381 382 /* pckt_addr.c 383 */ 384 void addr_del(void); 385 void addr_parse(void); 386 int addr_netcmp(char *addr1, char *addr2); 387 void addr_init(void); 388 389 /* pckt_comm.c 390 */ 391 392 int pars_number(void); 393 char *pars_word(void); 394 void recv_message(void); 395 void send_welcome(void); 396 void send_bye(void); 397 void send_join(void); 398 void send_leave(void); 399 void send_here(void); 400 void send_herewe(void); 401 void send_herewho(void); 402 void send_hereim(void); 403 void send_chat(void); 404 void send_me(void); 405 void send_mesg(void); 406 void send_mass(void); 407 void send_mesgack(void); 408 void send_topic(void); 409 void send_topicreq(void); 410 void send_topicnew(void); 411 void send_nick(void); 412 void send_mode(void); 413 void send_active(void); 414 void send_privjoin(void); 415 void send_privjoinack(void); 416 void send_privleave(void); 417 void send_privchat(void); 418 void send_privme(void); 419 void send_beep(void); 420 void send_beepack(void); 421 void send_info(void); 422 void send_inform(void); 423 void send_exec(void); 424 void send_execack(void); 425 void send_userchnls(void); 426 void send_userchnlslist(void); 427 428 /* sock_tcp.c 429 */ 430 #ifdef TCP 431 void sock_tcpinit(void); 432 void sock_tcpkill(void); 433 void sock_tcprecv(void); 434 void sock_tcpsend(void); 435 #endif /* TCP */ 436 437 /* sock_udp.c 438 */ 439 void sock_init(void); 440 void sock_kill(void); 441 void sock_recv(void); 442 void sock_bsend(void); 443 void sock_usend(void); 444 445 #endif /* _ECHAT_H */ 446