1 /*
2  * ----------------------------------------------------------------
3  * ircproxy Connection Configuration Functions Header
4  * ----------------------------------------------------------------
5  * Copyright (C) 1997-2009 Jonas Kvinge
6  *
7  * This file is part of ircproxy.
8  *
9  * ircproxy is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * ircproxy is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with ircproxy.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * Additional permission under GNU GPL version 3 section 7
23  *
24  * If you modify ircproxy, or any covered work, by linking or
25  * combining it with openssl (or a modified version of that library),
26  * containing parts covered by the terms of the OpenSSL License and the
27  * SSLeay License, the licensors of ircproxy grant you additional
28  * permission to convey the resulting work.
29  *
30  * $Id: conn_conf.h 54 2009-03-18 18:23:29Z jonasio $
31  *
32  */
33 
34 #ifdef CONN_CONF_H
35 #warning "conn_conf.h already included."
36 #else
37 #define CONN_CONF_H
38 
39 #define CONN_CONF_NAME_DEFAULT			"Connection001"
40 #define CONN_CONF_NICK_DEFAULT			"ircproxy"
41 #define CONN_CONF_AWAYNICK_DEFAULT		"ircproxyA"
42 #define CONN_CONF_USER_DEFAULT			"ircproxy"
43 #define CONN_CONF_HOST_DEFAULT			"0.0.0.0"
44 #define CONN_CONF_USERMODE_DEFAULT		"+i"
45 #define CONN_CONF_USERINFO_DEFAULT		"ircproxy"
46 #define CONN_CONF_CHANS_DEFAULT			"#eclipsed"
47 #define CONN_CONF_AUTOCONNECT_DEFAULT		1
48 #define CONN_CONF_LOGGING_DEFAULT		1
49 #define CONN_CONF_AUTOAWAY_DEFAULT		1
50 #define CONN_CONF_PUBLICAWAY_DEFAULT		1
51 #define CONN_CONF_REGAINNICK_DEFAULT		1
52 #define CONN_CONF_MAXCLIENTS_DEFAULT		5
53 #define CONN_CONF_SENDMAXLINES_DEFAULT		1024
54 #define CONN_CONF_SENDLINETIME_DEFAULT		10
55 #define CONN_CONF_SENDMAXBUFFER_DEFAULT		1024
56 #define CONN_CONF_SENDBUFFERTIME_DEFAULT	120
57 #define CONN_CONF_AWAYMSG_DEFAULT		"Not here, detached."
58 #define CONN_CONF_PUBLICAWAYMSG_DEFAULT		"is gone."
59 #define CONN_CONF_PUBLICBACKMSG_DEFAULT		"is back."
60 #define CONN_CONF_CHANCYCLE_DEFAULT		TRUE
61 #define CONN_CONF_NICKSERVNUH_DEFAULT		"NickServ!nickserv@nickserv"
62 #define CONN_CONF_NICKSERVPASS_DEFAULT		"blah"
63 #define CONN_CONF_NICKSERVTEXT_DEFAULT		"*nickname is owned by someone else*"
64 
65 #define CONN_CONF_SERVERHOST_DEFAULT		"irc.night-light.net"
66 #define CONN_CONF_SERVERPORT_DEFAULT		"6667"
67 #define CONN_CONF_SERVERPASS_NONE		"0"
68 #define CONN_CONF_SERVERPASS_DEFAULT		"0"
69 
70 /* BIT MASKS - JONAS (24.11.2007) */
71 
72 #define CONN_CONF_BITMASK_IPV6				1
73 #define CONN_CONF_BITMASK_SSL				2
74 #define CONN_CONF_BITMASK_AUTOCONNECT			4
75 #define CONN_CONF_BITMASK_LOGGING			8
76 #define CONN_CONF_BITMASK_AUTOAWAY			16
77 #define CONN_CONF_BITMASK_PUBLICAWAY			32
78 #define CONN_CONF_BITMASK_REGAINNICK			64
79 #define CONN_CONF_BITMASK_CHANCYCLE			128
80 #define CONN_CONF_BITMASK_AUTOATTACH			256
81 #define CONN_CONF_BITMASK_RAWLOG			512
82 
83 /* MACROS - JONAS (24.11.2007) */
84 
85 #define ConnConf_SetIPv6(x)				((x)->ConfFlags |= CONN_CONF_BITMASK_IPV6)
86 #define ConnConf_SetSSL(x)				((x)->ConfFlags |= CONN_CONF_BITMASK_SSL)
87 #define ConnConf_SetAutoConnect(x)			((x)->ConfFlags |= CONN_CONF_BITMASK_AUTOCONNECT)
88 #define ConnConf_SetLogging(x)				((x)->ConfFlags |= CONN_CONF_BITMASK_LOGGING)
89 #define ConnConf_SetAutoAway(x)				((x)->ConfFlags |= CONN_CONF_BITMASK_AUTOAWAY)
90 #define ConnConf_SetPublicAway(x)			((x)->ConfFlags |= CONN_CONF_BITMASK_PUBLICAWAY)
91 #define ConnConf_SetRegainNick(x)			((x)->ConfFlags |= CONN_CONF_BITMASK_REGAINNICK)
92 #define ConnConf_SetChanCycle(x)			((x)->ConfFlags |= CONN_CONF_BITMASK_CHANCYCLE)
93 #define ConnConf_SetAutoAttach(x)			((x)->ConfFlags |= CONN_CONF_BITMASK_AUTOATTACH)
94 #define ConnConf_SetRawLog(x)				((x)->ConfFlags |= CONN_CONF_BITMASK_RAWLOG)
95 
96 #define ConnConf_ClearIPv6(x)				((x)->ConfFlags &= ~CONN_CONF_BITMASK_IPV6)
97 #define ConnConf_ClearSSL(x)				((x)->ConfFlags &= ~CONN_CONF_BITMASK_SSL)
98 #define ConnConf_ClearAutoConnect(x)			((x)->ConfFlags &= ~CONN_CONF_BITMASK_AUTOCONNECT)
99 #define ConnConf_ClearLogging(x)			((x)->ConfFlags &= ~CONN_CONF_BITMASK_LOGGING)
100 #define ConnConf_ClearAutoAway(x)			((x)->ConfFlags &= ~CONN_CONF_BITMASK_AUTOAWAY)
101 #define ConnConf_ClearPublicAway(x)			((x)->ConfFlags &= ~CONN_CONF_BITMASK_PUBLICAWAY)
102 #define ConnConf_ClearRegainNick(x)			((x)->ConfFlags &= ~CONN_CONF_BITMASK_REGAINNICK)
103 #define ConnConf_ClearChanCycle(x)			((x)->ConfFlags &= ~CONN_CONF_BITMASK_CHANCYCLE)
104 #define ConnConf_ClearAutoAttach(x)			((x)->ConfFlags &= ~CONN_CONF_BITMASK_AUTOATTACH)
105 #define ConnConf_ClearRawLog(x)				((x)->ConfFlags &= ~CONN_CONF_BITMASK_RAWLOG)
106 
107 #define ConnConf_IsIPv6(x)				((x)->ConfFlags & CONN_CONF_BITMASK_IPV6)
108 #define ConnConf_IsSSL(x)				((x)->ConfFlags & CONN_CONF_BITMASK_SSL)
109 #define ConnConf_IsAutoConnect(x)			((x)->ConfFlags & CONN_CONF_BITMASK_AUTOCONNECT)
110 #define ConnConf_IsLogging(x)				((x)->ConfFlags & CONN_CONF_BITMASK_LOGGING)
111 #define ConnConf_IsAutoAway(x)				((x)->ConfFlags & CONN_CONF_BITMASK_AUTOAWAY)
112 #define ConnConf_IsPublicAway(x)			((x)->ConfFlags & CONN_CONF_BITMASK_PUBLICAWAY)
113 #define ConnConf_IsRegainNick(x)			((x)->ConfFlags & CONN_CONF_BITMASK_REGAINNICK)
114 #define ConnConf_IsChanCycle(x)				((x)->ConfFlags & CONN_CONF_BITMASK_CHANCYCLE)
115 #define ConnConf_IsAutoAttach(x)			((x)->ConfFlags & CONN_CONF_BITMASK_AUTOATTACH)
116 #define ConnConf_IsRawLog(x)				((x)->ConfFlags & CONN_CONF_BITMASK_RAWLOG)
117 
118 /* STRUCTURES - JONAS (18.07.2001) */
119 
120 struct ConnConf_Struct {
121 
122   char *Name;
123   char *Nick;
124   char *AwayNick;
125   char *User;
126   char *Host;
127   char *Mode;
128   char *Info;
129   char *Chans;
130   char *AwayMsg;
131   char *PublicDetachMsg;
132   char *PublicAttachMsg;
133   char *NickServNUH;
134   char *NickServPass;
135   char *NickServText;
136 
137   unsigned short int MaxClients;
138   unsigned short int SendMaxLines;
139   unsigned short int SendLineTime;
140   unsigned short int SendMaxBuffer;
141   unsigned short int SendBufferTime;
142 
143   unsigned long int ConfFlags;
144   unsigned long int ChanLogFlags;
145 
146   unsigned short int Servers;
147 
148   struct ConnConfServer_Struct *Server_Head;
149   struct ConnConfServer_Struct *Server_Tail;
150 
151   struct ConnConf_Struct *Next;
152   struct ConnConf_Struct *Prev;
153 
154 };
155 
156 struct ConnConfServer_Struct {
157 
158   char *Host;
159   unsigned long int Port;
160   char *Pass;
161 
162   struct ConnConfServer_Struct *Next;
163   struct ConnConfServer_Struct *Prev;
164 
165 };
166 
167 /* FUNCTION PROTOTYPES - JONAS (18.07.2001) */
168 
169 signed long int conn_conf_read(void);
170 struct ConnConf_Struct *conn_conf_add(const char *const NamePT);
171 void conn_conf_rem(struct ConnConf_Struct *ConnConf);
172 struct ConnConf_Struct *conn_conf_get(const char *const NamePT);
173 void conn_conf_destroy(void);
174 struct ConnConfServer_Struct *conn_conf_addserver(struct ConnConf_Struct *ConnConf, const char *const HostPT, const unsigned long int Port, const char *const PassPT);
175 void conn_conf_remserver(struct ConnConf_Struct *ConnConf, struct ConnConfServer_Struct *ConnConfServer);
176 struct ConnConfServer_Struct *conn_conf_getserver(struct ConnConf_Struct *ConnConf, const char *const HostPT);
177 void conn_conf_remservers(struct ConnConf_Struct *ConnConf);
178 
179 #endif
180