1 /* 2 * server.h: header for server.c 3 * 4 * Written By Michael Sandrof 5 * 6 * Copyright (c) 1990 Michael Sandrof. 7 * Copyright (c) 1991, 1992 Troy Rollo. 8 * Copyright (c) 1992-2003 Matthew R. Green. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. The name of the author may not be used to endorse or promote products 20 * derived from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * $Id: server.h,v 1.18 2007-03-30 15:27:36 f Exp $ 35 */ 36 37 #ifndef __server_h_ 38 #define __server_h_ 39 40 /* for ChannelList */ 41 #include "names.h" 42 /**************************** Patched by Flier ******************************/ 43 #if defined(HAVE_SSL) || defined(HAVE_OPENSSL) 44 #include "myssl.h" 45 #endif 46 /****************************************************************************/ 47 48 /* 49 * type definition to distinguish different 50 * server versions 51 */ 52 #define Server2_5 0 53 #define Server2_6 1 54 #define Server2_7 2 55 #define Server2_8 3 56 #define Server2_9 4 57 #define Server2_10 5 58 #define Server2_11 6 59 #define Server2_12 7 60 #define Server2_90 90 61 62 /* Server: a structure for the server_list */ 63 typedef struct 64 { 65 char *name; /* the name of the server */ 66 char *itsname; /* the server's idea of its name */ 67 char *password; /* password for that server */ 68 int port; /* port number on that server */ 69 char *nickname; /* nickname for this server */ 70 char *group; /* what group the server is in */ 71 char *away; /* away message for this server */ 72 int operator; /* true if operator */ 73 int version; /* the version of the server - 74 * defined above */ 75 char *version_string; /* what is says */ 76 int whois; /* true if server sends numeric 318 */ 77 int flags; /* Various flags */ 78 /**************************** PATCHED by Flier ******************************/ 79 int umodeflags; /* holds usermode for lowercase modes */ 80 int umodeflags2; /* holds usermode for uppercase modes */ 81 /****************************************************************************/ 82 int connected; /* true if connection is assured */ 83 int write; /* write descriptor */ 84 int read; /* read descriptior */ 85 pid_t pid; /* process id of server */ 86 int eof; /* eof flag for server */ 87 int motd; /* motd flag (used in notice.c) */ 88 int sent; /* set if something has been sent, 89 * used for redirect */ 90 char *buffer; /* buffer of what dgets() doesn't get */ 91 WhoisQueue *WQ_head; /* WHOIS Queue head */ 92 WhoisQueue *WQ_tail; /* WHOIS Queue tail */ 93 WhoisStuff whois_stuff; /* Whois Queue current collection buffer */ 94 int close_serv; /* Server to close when we're LOGGED_IN */ 95 time_t ctcp_last_reply_time; /* used to limit flooding */ 96 time_t ctcp_flood_time; 97 int ctcp_backlog_size; 98 int *ctcp_send_size; 99 struct in_addr local_addr; /* ip address of this connection */ 100 ChannelList *chan_list; /* list of channels for this server */ 101 void (*parse_server) _((char *)); /* pointer to parser for this server */ 102 /**************************** PATCHED by Flier ******************************/ 103 int SZWI; /* when doing whois */ 104 int SZWho; /* when doing who */ 105 int SZUnban; /* when doing unban */ 106 char *LastMessage; /* last received message */ 107 char *LastNotice; /* last received notice */ 108 char *LastMessageSent; /* last sent message */ 109 char *LastNoticeSent; /* last sent notice */ 110 char *LastJoin; /* last person to join */ 111 time_t ConnectTime; /* when the server was connected */ 112 struct nicks *arlist,*arcur; /* auto-reply list */ 113 struct nicks *nicklist, /* tabkey list */ 114 *nickcur; 115 ChannelList *ChanPendingList; /* list of channels pending for join */ 116 int compl_count; /* how many channels have we traversed */ 117 void *compl_last; /* pointer to last completion string */ 118 void *compl_next; /* where to start next completion */ 119 ChannelList *compl_channel; /* last channel completion */ 120 121 #if defined(HAVE_SSL) || defined(HAVE_OPENSSL) 122 int enable_ssl; 123 #if defined(HAVE_SSL) 124 gnutls_session_t session; 125 gnutls_certificate_credentials_t xcred; 126 #elif defined(HAVE_OPENSSL) 127 SSL *ssl_fd; 128 SSL_CTX *ctx; 129 #endif 130 #endif 131 /****************************************************************************/ 132 } Server; 133 134 typedef struct ser_group_list 135 { 136 struct ser_group_list *next; 137 char *name; 138 int number; 139 } SGroup; 140 141 typedef unsigned short ServerType; 142 143 int find_server_group _((char *, int)); 144 char * find_server_group_name _((int)); 145 void add_to_server_list _((char *, int, char *, char *, char *, int)); 146 void build_server_list _((char *)); 147 int connect_to_server _((char *, int, char *, char *, int)); 148 /**************************** PATCHED by Flier ******************************/ 149 /*void get_connected _((int));*/ 150 void get_connected _((int, int)); 151 /****************************************************************************/ 152 int read_server_file _((void)); 153 void display_server_list _((void)); 154 void do_server _((fd_set *, fd_set *)); 155 #ifdef HAVE_STDARG_H 156 void send_to_server _((char *, ...)); 157 #else 158 void send_to_server _(()); 159 #endif /* HAVE_STDARG_H */ 160 int get_server_whois _((int)); 161 162 WhoisStuff *get_server_whois_stuff _((int)); 163 WhoisQueue *get_server_qhead _((int)); 164 WhoisQueue *get_server_qtail _((int)); 165 166 extern int save_chan_from; /* to keep the channel list if all servers 167 * are lost */ 168 169 extern int attempting_to_connect; 170 extern int number_of_servers; 171 extern int connected_to_server; 172 extern int never_connected; 173 extern int using_server_process; 174 extern int primary_server; 175 extern int from_server; 176 extern char *connect_next_nick; 177 extern char *connect_next_password; 178 extern int parsing_server_index; 179 extern SGroup *server_group_list; 180 181 void servercmd _((char *, char *, char *)); 182 char *get_server_nickname _((int)); 183 char *get_server_name _((int)); 184 char *get_server_itsname _((int)); 185 void set_server_flag _((int, int, int)); 186 int find_in_server_list _((char *, int, char *)); 187 char *create_server_list _((void)); 188 void remove_from_server_list _((int)); 189 void set_server_motd _((int, int)); 190 int get_server_motd _((int)); 191 int get_server_operator _((int)); 192 int get_server_2_6_2 _((int)); 193 int get_server_version _((int)); 194 char *get_server_password _((int)); 195 void close_server _((int, char *)); 196 void MarkAllAway _((char *, char *)); 197 int is_server_connected _((int)); 198 void flush_server _((void)); 199 int get_server_flag _((int, int)); 200 /**************************** PATCHED by Flier ******************************/ 201 int get_server_umode_flag _((int, char)); 202 void set_server_umode_flag _((int, char, int)); 203 /****************************************************************************/ 204 void set_server_operator _((int, int)); 205 void server_is_connected _((int, int)); 206 int parse_server_index _((char *)); 207 void parse_server_info _((char **, char **, char **, char **, char **)); 208 void set_server_bits _((fd_set *, fd_set *)); 209 void set_server_itsname _((int, char *)); 210 void set_server_version _((int, int)); 211 int is_server_open _((int)); 212 /**************************** PATCHED by Flier ******************************/ 213 int is_server_valid _((int)); 214 /****************************************************************************/ 215 int get_server_port _((int)); 216 char *get_server_group _((int)); 217 char *set_server_password _((int, char *)); 218 void set_server_nickname _((int, char *)); 219 void set_server_2_6_2 _((int, int)); 220 void set_server_qhead _((int, WhoisQueue *)); 221 void set_server_qtail _((int, WhoisQueue *)); 222 void set_server_whois _((int, int)); 223 void close_all_server _((void)); 224 void disconnectcmd _((char *, char *, char *)); 225 void ctcp_reply_backlog_change _((int)); 226 227 /* server_list: the list of servers that the user can connect to,etc */ 228 extern Server *server_list; 229 230 #define SERVER_2_6_2 0x0100 231 #define CLOSE_PENDING 0x0200 /* set for servers who are being switched away from, but have not yet connected. */ 232 #define LOGGED_IN 0x0400 233 #define CLEAR_PENDING 0x0800 /* set for servers whose channels are to be removed when a connect has been established. */ 234 /**************************** Patched by Flier ******************************/ 235 #define SSL_CONNECT 0x100000 236 /****************************************************************************/ 237 238 #endif /* __server_h_ */ 239