1 /*
2  * proto.h
3  *   prototypes for every function used outside its own module
4  *
5  * (i guess i'm not very modular, cuz there are a LOT of these.)
6  * with full prototyping, some have been moved to other .h files
7  * because they use structures in those
8  * (saves including those .h files EVERY time) - Beldin
9  */
10 /*
11  * Copyright (C) 1997 Robey Pointer
12  * Copyright (C) 1999 - 2021 Eggheads Development Team
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
27  */
28 
29 #ifndef _EGG_PROTO_H
30 #define _EGG_PROTO_H
31 
32 #include "lush.h"
33 #include "misc_file.h"
34 
35 #define dprintf dprintf_eggdrop
36 
37 struct chanset_t;               /* keeps the compiler warnings down :) */
38 struct userrec;
39 struct maskrec;
40 struct igrec;
41 struct flag_record;
42 struct list_type;
43 struct tand_t_struct;
44 
45 #ifndef MAKING_MODS
46 extern void (*encrypt_pass) (char *, char *);
47 extern char *(*encrypt_pass2) (char *);
48 extern char *(*verify_pass2) (char *, char *);
49 extern char *(*encrypt_string) (char *, char *);
50 extern char *(*decrypt_string) (char *, char *);
51 extern int (*rfc_casecmp) (const char *, const char *);
52 extern int (*rfc_ncasecmp) (const char *, const char *, int);
53 extern int (*rfc_toupper) (int);
54 extern int (*rfc_tolower) (int);
55 extern int (*match_noterej) (struct userrec *, char *);
56 #endif
57 
58 /* botcmd.c */
59 void bot_share(int, char *);
60 int base64_to_int(char *);
61 
62 /* botnet.c */
63 void set_botnetnick(const char *);
64 void answer_local_whom(int, int);
65 char *lastbot(char *);
66 int nextbot(char *);
67 int in_chain(char *);
68 void tell_bots(int);
69 void tell_bottree(int, int);
70 int botlink(char *, int, char *);
71 int botunlink(int, char *, char *, char *);
72 void dump_links(int);
73 void addbot(char *, char *, char *, char, int);
74 void updatebot(int, char *, char, int);
75 void rembot(char *);
76 struct tand_t_struct *findbot(char *);
77 void unvia(int, struct tand_t_struct *);
78 void check_botnet_pings();
79 int partysock(char *, char *);
80 int addparty(char *, char *, int, char, int, char *, int *);
81 void remparty(char *, int);
82 void partystat(char *, int, int, int);
83 int partynick(char *, int, char *);
84 int partyidle(char *, char *);
85 void partysetidle(char *, int, int);
86 void partyaway(char *, int, char *);
87 void zapfbot(int);
88 void tandem_relay(int, char *, int);
89 int getparty(char *, int);
90 
91 /* botmsg.c */
92 int add_note(char *, char *, char *, int, int);
93 int simple_sprintf EGG_VARARGS(char *, arg1);
94 void tandout_but EGG_VARARGS(int, arg1);
95 char *int_to_base10(int);
96 char *unsigned_int_to_base10(unsigned int);
97 char *int_to_base64(unsigned int);
98 
99 /* chanprog.c */
100 void tell_verbose_uptime(int);
101 void tell_verbose_status(int);
102 void tell_settings(int);
103 int logmodes(char *);
104 int isowner(char *);
105 char *masktype(int);
106 char *maskname(int);
107 void reaffirm_owners();
108 void add_hq_user();
109 void rehash();
110 void reload();
111 void chanprog();
112 void check_timers();
113 void check_utimers();
114 void rmspace(char *s);
115 void check_timers();
116 void set_chanlist(const char *host, struct userrec *rec);
117 void clear_chanlist(void);
118 void clear_chanlist_member(const char *nick);
119 float getcputime();
120 
121 /* cmds.c */
122 int check_dcc_attrs(struct userrec *, int);
123 int check_dcc_chanattrs(struct userrec *, char *, int, int);
124 int check_int_range(char *value, int min, int max);
125 int stripmodes(char *);
126 char *stripmasktype(int);
127 char *check_validpass(struct userrec *, char *);
128 
129 /* dcc.c */
130 void failed_link(int);
131 void strip_mirc_codes(int, char *);
132 int check_ansi(char *);
133 void dupwait_notify(char *);
134 #ifdef TLS
135 int dcc_fingerprint(int);
136 #endif
137 
138 /* dccutil.c */
139 int increase_socks_max();
140 int findidx(int);
141 int findanyidx(int);
142 char *add_cr(char *);
143 void dprint(int, char *, int);
144 void dprintf EGG_VARARGS(int, arg1);
145 void chatout EGG_VARARGS(char *, arg1);
146 extern void (*shareout) ();
147 extern void (*sharein) (int, char *);
148 void chanout_but EGG_VARARGS(int, arg1);
149 void dcc_chatter(int);
150 void lostdcc(int);
151 void killtransfer(int);
152 void removedcc(int);
153 void makepass(char *);
154 void tell_dcc(int);
155 void not_away(int);
156 void set_away(int, char *);
157 void *_get_data_ptr(int, char *, int);
158 void dcc_remove_lost(void);
159 void do_boot(int, char *, char *);
160 int detect_dcc_flood(time_t *, struct chat_info *, int);
161 
162 #define get_data_ptr(x) _get_data_ptr(x,__FILE__,__LINE__)
163 void flush_lines(int, struct chat_info *);
164 struct dcc_t *find_idx(int);
165 int new_dcc(struct dcc_table *, int);
166 void del_dcc(int);
167 void changeover_dcc(int, struct dcc_table *, int);
168 
169 /* dns.c */
170 extern void (*dns_hostbyip) (sockname_t *);
171 void core_dns_hostbyip(sockname_t *);
172 void call_hostbyip(sockname_t *, char *, int);
173 void call_ipbyhost(char *, sockname_t *, int);
174 void dcc_dnshostbyip(sockname_t *);
175 extern void (*dns_ipbyhost) (char *);
176 void core_dns_ipbyhost(char *);
177 void dcc_dnsipbyhost(char *);
178 
179 /* language.c */
180 char *get_language(int);
181 int cmd_loadlanguage(struct userrec *, int, char *);
182 void add_lang_section(char *);
183 int del_lang_section(char *);
184 int exist_lang_section(char *);
185 
186 /* main.c */
187 void fatal(const char *, int);
188 int expected_memory(void);
189 void eggContext(const char *, int, const char *);
190 void eggContextNote(const char *, int, const char *, const char *);
191 void eggAssert(const char *, int, const char *);
192 void backup_userfile(void);
193 int mainloop(int);
194 
195 /* match.c */
196 int casecharcmp(unsigned char, unsigned char);
197 int charcmp(unsigned char, unsigned char);
198 int _wild_match(unsigned char *, unsigned char *);
199 int _wild_match_per(unsigned char *, unsigned char *,
200                     int (*)(unsigned char, unsigned char),
201                     int (*)(unsigned char, unsigned char),
202                     unsigned char *);
203 int addr_match(char *, char *, int, int);
204 int mask_match(char *, char *);
205 int cidr_match(char *, char *, int);
206 int cron_match(const char *, const char *);
207 
208 #define wild_match(a,b) _wild_match((unsigned char *)(a),(unsigned char *)(b))
209 #define wild_match_per(a,b) _wild_match_per((unsigned char *)(a),              \
210                             (unsigned char *)(b),casecharcmp,NULL,NULL)
211 #define wild_match_partial_case(a,b) _wild_match_per((unsigned char *)(a),     \
212                             (unsigned char *)(b),casecharcmp,charcmp,          \
213                             (unsigned char *)strchr((b),' '))
214 #define match_addr(a,b) addr_match((char *)(a),(char *)(b),0,0)
215 #define match_useraddr(a,b) addr_match((char *)(a),(char *)(b),1,0)
216 #define cmp_masks(a,b) addr_match((char *)(a),(char *)(b),0,1)
217 #define cmp_usermasks(a,b) addr_match((char *)(a),(char *)(b),1,1)
218 
219 /* mem.c */
220 void *n_malloc(int, const char *, int);
221 void *n_realloc(void *, int, const char *, int);
222 void n_free(void *, const char *, int);
223 void tell_mem_status(char *);
224 void tell_mem_status_dcc(int);
225 void debug_mem_to_dcc(int);
226 
227 /* misc.c */
228 int egg_strcatn(char *, const char *, size_t);
229 int my_strcpy(char *, char *);
230 void putlog EGG_VARARGS(int, arg1);
231 void flushlogs();
232 void check_logsize();
233 void splitc(char *, char *, char);
234 void splitcn(char *, char *, char, size_t);
235 void remove_crlf(char **);
236 char *newsplit(char **);
237 char *splitnick(char **);
238 void stridx(char *, char *, int);
239 void dumplots(int, const char *, const char *);
240 void daysago(time_t, time_t, char *);
241 void days(time_t, time_t, char *);
242 void daysdur(time_t, time_t, char *);
243 char *egg_uname();
244 void help_subst(char *, char *, struct flag_record *, int, char *);
245 void sub_lang(int, char *);
246 void show_motd(int);
247 void tellhelp(int, char *, struct flag_record *, int);
248 void tellwildhelp(int, char *, struct flag_record *);
249 void tellallhelp(int, char *, struct flag_record *);
250 void showhelp(char *, char *, struct flag_record *, int);
251 void rem_help_reference(char *);
252 void add_help_reference(char *);
253 void debug_help(int);
254 void reload_help_data(void);
255 char *extracthostname(char *);
256 void show_banner(int i);
257 void make_rand_str_from_chars(char *, int, char *);
258 void make_rand_str(char *, int);
259 int oatoi(const char *);
260 int is_file(const char *);
261 void logsuffix_change(char *);
262 char *str_escape(const char *, const char, const char);
263 char *strchr_unescape(char *, const char, const char);
264 void str_unescape(char *, const char);
265 int str_isdigit(const char *);
266 void kill_bot(char *, char *);
267 void maskaddr(const char *, char *, int);
268 #define maskhost(a,b) maskaddr((a),(b),3)
269 #define maskban(a,b)  maskaddr((a),(b),3)
270 int crypto_verify(const char *, const char *);
271 
272 /* net.c */
273 IP my_atoul(char *);
274 unsigned long iptolong(IP);
275 void setsock(int, int);
276 int allocsock(int, int);
277 int alloctclsock(int, int, Tcl_FileProc *, ClientData);
278 int getsock(int, int);
279 void killsock(int);
280 void killtclsock(int);
281 int open_listen(int *);
282 void getvhost(sockname_t *, int);
283 int setsockname(sockname_t *, char *, int, int);
284 int open_address_listen(sockname_t *);
285 int open_telnet_raw(int, sockname_t *);
286 int open_telnet(int, char *, int);
287 int answer(int, sockname_t *, uint16_t *, int);
288 int getdccaddr(sockname_t *, char *, size_t);
289 int getdccfamilyaddr(sockname_t *, char *, size_t, int);
290 void tputs(int, char *, unsigned int);
291 void dequeue_sockets();
292 int sockread(char *, int *, sock_list *, int, int);
293 int sockgets(char *, int *);
294 void tell_netdebug(int);
295 int sanitycheck_dcc(char *, char *, char *, char *);
296 int hostsanitycheck_dcc(char *, char *, sockname_t *, char *, char *);
297 char *iptostr(struct sockaddr *);
298 int sock_has_data(int, int);
299 int sockoptions(int sock, int operation, int sock_options);
300 int flush_inbuf(int idx);
301 int findsock(int sock);
302 void safe_write(int, const void *, size_t);
303 
304 /* tcl.c */
305 struct threaddata *threaddata();
306 int init_threaddata(int);
307 void protect_tcl();
308 void unprotect_tcl();
309 void do_tcl(char *, char *);
310 int readtclprog(char *fname);
311 
312 /* tls.c */
313 #ifdef TLS
314 int ssl_handshake(int, int, int, int, char *, IntFunc);
315 char *ssl_fpconv(char *in, char *out);
316 const char *ssl_getuid(int sock);
317 char *ssl_getfp(int sock);
318 #endif
319 
320 /* userent.c */
321 void list_type_kill(struct list_type *);
322 int list_type_expmem(struct list_type *);
323 int xtra_set();
324 
325 /* userrec.c */
326 struct userrec *adduser(struct userrec *, char *, char *, char *, int);
327 void addhost_by_handle(char *, char *);
328 void clear_masks(struct maskrec *);
329 void clear_userlist(struct userrec *);
330 int u_pass_match(struct userrec *, char *);
331 int delhost_by_handle(char *, char *);
332 int ishost_for_handle(char *, char *);
333 int count_users(struct userrec *);
334 int deluser(char *);
335 void freeuser(struct userrec *);
336 int change_handle(struct userrec *, char *);
337 void correct_handle(char *);
338 int write_user(struct userrec *, FILE *, int);
339 int write_ignores(FILE *f, int);
340 void write_userfile(int);
341 struct userrec *check_dcclist_hand(char *);
342 void touch_laston(struct userrec *, char *, time_t);
343 void user_del_chan(char *);
344 int check_conflags(struct flag_record *fr, int md);
345 
346 /* users.c */
347 void addignore(char *, char *, char *, time_t);
348 int delignore(char *);
349 void tell_ignores(int, char *);
350 int match_ignore(char *);
351 void check_expired_ignores();
352 void autolink_cycle(char *);
353 void tell_file_stats(int, char *);
354 void tell_user_ident(int, char *);
355 void tell_users_match(int, char *, int, int, char *);
356 int readuserfile(char *, struct userrec **);
357 
358 /* rfc1459.c */
359 int _rfc_casecmp(const char *, const char *);
360 int _rfc_ncasecmp(const char *, const char *, int);
361 int _rfc_toupper(int);
362 int _rfc_tolower(int);
363 
364 #endif /* _EGG_PROTO_H */
365