From 8b557db230fabc460e55fa0186e05179825b5704 Mon Sep 17 00:00:00 2001 From: Matthew Mondor Date: Sat, 27 Aug 2016 14:36:00 +0000 Subject: [PATCH] ANSI and 64-bit related cleanup - prototypes Compiled with -Werror=missing-prototypes and -Werror=implicit-function-declaration. Fixed all cases so it builds again. Hopefully fixes cases of implicit pointers cased to int where on x86_64 this results in half-pointers, a common cause of segmentation faults. This involved writing prototypes and making static many functions which weren't, moving to header files external function prototypes, including the proper header files in the code, etc. --- TODO | 8 +++++ include/blalloc.h | 1 + include/common.h | 7 +--- include/confparse.h | 27 ++++++++-------- include/dh.h | 16 +++------- include/fds.h | 2 +- include/find.h | 9 ++---- include/h.h | 79 +++++++++++++++++++++++++++++----------------- include/hash.h | 24 ++++++++++++++ include/hooks.h | 8 ++++- include/ircsprintf.h | 11 +++++++ include/list.h | 20 ++++++++++++ include/msg.h | 3 +- include/rc4.h | 13 ++++++++ include/sbuf.h | 8 ++++- include/send.h | 8 +++-- include/socketengine.h | 11 +++++++ include/struct.h | 2 +- include/structfunc.h | 6 ++-- include/sys.h | 2 +- include/throttle.h | 32 +++++++++---------- include/userban.h | 58 ++++++++++++++++++---------------- include/whowas.h | 4 +-- include/zlink.h | 4 +-- src/blalloc.c | 4 +-- src/bsd.c | 8 ++--- src/channel.c | 7 ++-- src/clientlist.c | 2 ++ src/confparse.c | 1 - src/fds.c | 1 + src/hash.c | 11 +++++++ src/hide.c | 8 +++++ src/ircd.c | 25 ++++++--------- src/ircsprintf.c | 4 +++ src/list.c | 5 ++- src/m_nick.c | 5 --- src/m_rwho.c | 4 +-- src/m_server.c | 8 ++--- src/m_services.c | 2 ++ src/m_stats.c | 1 + src/m_who.c | 6 ++-- src/match.c | 1 + src/modules.c | 28 +++++++++++++--- src/packet.c | 1 + src/parse.c | 1 + src/rc4.c | 5 +++ src/res.c | 2 ++ src/s_bsd.c | 5 +-- src/s_conf.c | 36 +++++++++++---------- src/s_misc.c | 8 +++++ src/s_serv.c | 22 +------------ src/s_user.c | 28 +++++++--------- src/sbuf.c | 15 +++++++-- src/send.c | 15 ++++++++- src/socketengine_devpoll.c | 3 +- src/socketengine_epoll.c | 1 + src/socketengine_kqueue.c | 1 + src/socketengine_poll.c | 7 ++-- src/socketengine_select.c | 1 + src/support.c | 2 +- src/throttle.c | 12 +++++-- src/userban.c | 26 ++++++++------- src/whowas.c | 2 ++ src/zlink.c | 1 + tools/Makefile.in | 20 +++++++----- tools/convert_conf.c | 39 +++++++++++++++++++++-- 66 files changed, 484 insertions(+), 263 deletions(-) create mode 100644 include/list.h create mode 100644 include/rc4.h create mode 100644 include/socketengine.h diff --git a/TODO b/TODO index 0924fd6..5ffbfcb 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,11 @@ +ANSI fixes +---------- + +- Compile with -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast +- Fix any function arg mismatch (use -Werror=) (too many arg) +- Fix format argument related warnings +- Recheck warnings with -Wall + Future TODO List ---------------- diff --git a/include/blalloc.h b/include/blalloc.h index b4e7003..6b8f88b 100644 --- a/include/blalloc.h +++ b/include/blalloc.h @@ -43,6 +43,7 @@ typedef struct BlockHeap BlockHeap *BlockHeapCreate(size_t elemsize, int elemsperblock); int BlockHeapDestroy(BlockHeap *bh); void *BlockHeapAlloc(BlockHeap *bh); +int BlockHeapGarbageCollect(BlockHeap *bh); int BlockHeapFree(BlockHeap *bh, void *ptr); #endif diff --git a/include/common.h b/include/common.h index 876ee0b..b27f7ec 100644 --- a/include/common.h +++ b/include/common.h @@ -52,11 +52,6 @@ #endif #define FOREVER for(;;) /* -Dianora */ -#if !defined(STDC_HEADERS) -char *malloc(), *calloc(); -void free(); -#endif -extern void flush_fdlist_connections(); extern int match(char *, char *); extern int mycmp(char *, char *); extern int mycmp_diff(char *, char *); @@ -114,5 +109,5 @@ extern unsigned char char_atribs[]; #define IsAscii(c) ((u_char)(c) >= 0 && (u_char)(c) <= 0x7f) #define IsGraph(c) ((char_atribs[(u_char)(c)]&PRINT) && ((u_char)(c) != 0x32)) #define IsPunct(c) (!(char_atribs[(u_char)(c)]&(CNTRL|ALPHA|DIGIT))) -extern struct SLink *find_user_link(); +extern struct SLink *find_user_link(void); #endif /* common_include */ diff --git a/include/confparse.h b/include/confparse.h index 64728e9..3d8d129 100644 --- a/include/confparse.h +++ b/include/confparse.h @@ -176,6 +176,20 @@ struct ConfVar #define VARTYPE_NONE 0x0008 /* doesnt take any var */ /* functions for parsing variables into appropriate variables */ +extern int confadd_global(cVar **, int); +extern int confadd_options(cVar **, int); +extern int confadd_class(cVar **, int); +extern int confadd_allow(cVar **, int); +extern int confadd_oper(cVar **, int); +extern int confadd_connect(cVar **, int); +extern int confadd_restrict(cVar **, int); +extern int confadd_super(cVar **, int); +extern int confadd_kill(cVar **, int); +extern int confadd_admin(cVar **, int); +extern int confadd_port(cVar **, int); +extern int confadd_modules(cVar **, int); +extern void confparse_error(char *, int); + #ifdef CONF_TABS @@ -301,19 +315,6 @@ sConf confopentab[] = {(char *) 0, 0, 0} }; -extern int confadd_global(cVar **, int); -extern int confadd_options(cVar **, int); -extern int confadd_class(cVar **, int); -extern int confadd_allow(cVar **, int); -extern int confadd_oper(cVar **, int); -extern int confadd_connect(cVar **, int); -extern int confadd_restrict(cVar **, int); -extern int confadd_super(cVar **, int); -extern int confadd_kill(cVar **, int); -extern int confadd_admin(cVar **, int); -extern int confadd_port(cVar **, int); -extern int confadd_modules(cVar **, int); - struct TopConf tconftab[] = { {CONFT_GLOBAL, CONFF_GLOBAL, CONFF_ADMIN, confglobtab, confadd_global}, diff --git a/include/dh.h b/include/dh.h index cacc26c..e9f64b9 100644 --- a/include/dh.h +++ b/include/dh.h @@ -1,21 +1,15 @@ -#ifndef DH_HEADER -extern int dh_init(); +#ifndef _DH_H_ +#define _DH_H_ + +extern int dh_init(void); extern void dh_end_session(void *); -extern void *dh_start_session(); +extern void *dh_start_session(void); extern char *dh_get_s_public(char *, int, void *); extern int dh_get_s_shared(char *, int *, void *); extern int dh_generate_shared(void *, char *); extern int dh_hexstr_to_raw(char *string, unsigned char *hexout, int *hexlen); -extern void rc4_process_stream_to_buf(void *rc4_context, const unsigned char *istring, - unsigned char *ostring, unsigned int stringlen); -extern void rc4_process_stream(void *rc4_context, unsigned char *istring, unsigned int stringlen); -extern void *rc4_initstate(unsigned char *key, int keylen); -extern void rc4_destroystate(void *a); - -#else - /* this stuff is only included for dh.c .. this is a kludge, * but our header files are fucking disgusting anyway. */ diff --git a/include/fds.h b/include/fds.h index 7c84d08..ad38197 100644 --- a/include/fds.h +++ b/include/fds.h @@ -27,7 +27,7 @@ struct fd_callbackp { #define FDF_WANTREAD 0x01 #define FDF_WANTWRITE 0x02 -void init_fds(); +void init_fds(void); void add_fd(int fd, int type, void *value); void del_fd(int fd); diff --git a/include/find.h b/include/find.h index 60d7fbe..08575c3 100644 --- a/include/find.h +++ b/include/find.h @@ -22,16 +22,11 @@ #ifndef __find_include__ #define __find_include__ +#include "hash.h" + #define find_nickserver(a, b) hash_find_nickserver(a, b) #define find_server(a, b) hash_find_server(a, b) #define find_name(a, b) hash_find_server(a, b) #define find_client(a, b) hash_find_client(a, b) -static inline aClient *find_person(char *name, aClient *cptr) -{ - aClient *acptr = find_client(name, cptr); - - return acptr ? (IsClient(acptr) ? acptr : cptr) : cptr; -} - #endif /* __find_include__ */ diff --git a/include/h.h b/include/h.h index 2f54788..92dfc08 100644 --- a/include/h.h +++ b/include/h.h @@ -95,7 +95,7 @@ extern struct stats *ircstp; extern int bootopt; extern char *canonize(char *); -extern void check_fdlists(); +extern void check_fdlists(void); extern aChannel *find_channel(char *, aChannel *); extern aBan *nick_is_banned(aChannel *, char *, aClient *); extern void remove_matching_bans(aChannel *, aClient *, aClient *); @@ -121,8 +121,8 @@ extern int find_restrict(aClient *); extern int rehash(aClient *, aClient *, int); extern int initconf(char *); extern inline char *finishconf(void); -extern void merge_confs(); -extern int lock_kline_file(); +extern void merge_confs(void); +extern int lock_kline_file(void); extern void clear_scache_hash_table(void); extern char *find_or_add(char *); @@ -157,13 +157,13 @@ extern void add_local_domain(char *, int); extern int check_client(aClient *); extern int check_server_init(aClient *); extern void close_connection(aClient *); -extern void close_listeners(); -extern void open_listeners(); +extern void close_listeners(void); +extern void open_listeners(void); extern int connect_server(aConnect *, aClient *, struct hostent *); extern void get_my_name(aClient *, char *, int); extern int get_sockerr(aClient *); extern int inetport(aClient *, char *, int, u_long); -extern void init_sys(); +extern void init_sys(void); extern int read_message(time_t, fdlist *); extern void report_error(char *, aClient *); extern void set_non_blocking(int, aClient *); @@ -197,10 +197,8 @@ extern void send_authports(aClient *); extern void restart(char *); extern void send_channel_modes(aClient *, aChannel *); -extern void server_reboot(void); extern void terminate(void), write_pidfile(void); -extern int match(char *, char *); extern char *collapse(char *); extern int writecalls, writeb[]; @@ -215,7 +213,7 @@ extern inline int check_registered_user(aClient *); extern char *get_client_name(aClient *, int); extern char *get_client_host(aClient *); extern char *my_name_for_link(char *, aConnect *); -extern char *myctime(time_t), *date(time_t); +extern char *myctime(time_t), *date(time_t), *smalldate(time_t); extern int exit_client(aClient *, aClient *, aClient *, char *); extern void initstats(void); extern char *make_parv_copy(char *, int, char **); @@ -241,7 +239,7 @@ extern void free_chanmember(chanMember *); extern void free_class(aClass *); extern void free_user(anUser *, aClient *); extern void free_channel(aChannel *); -extern aChannel *make_channel(); +extern aChannel *make_channel(void); extern Link *make_link(void); extern DLink *make_dlink(void); extern chanMember *make_chanmember(void); @@ -259,7 +257,7 @@ extern void block_garbage_collect(void); /* list.c */ extern void block_destroy(void); /* list.c */ extern void set_effective_class(aClient *); -extern void initclass(); +extern void initclass(void); extern struct hostent *get_res(char *); extern struct hostent *gethost_byaddr(char *, Link *); @@ -270,17 +268,6 @@ extern time_t timeout_query_list(time_t); extern time_t expire_cache(time_t); extern void del_queries(char *); -extern void clear_channel_hash_table(void); -extern void clear_client_hash_table(void); -extern int add_to_client_hash_table(char *, aClient *); -extern int del_from_client_hash_table(char *, aClient *); -extern int add_to_channel_hash_table(char *, aChannel *); -extern int del_from_channel_hash_table(char *, aChannel *); -extern aChannel *hash_find_channel(char *, aChannel *); -extern aClient *hash_find_client(char *, aClient *); -extern aClient *hash_find_nickserver(char *, aClient *); -extern aClient *hash_find_server(char *, aClient *); - extern void add_history(aClient *, int); extern aClient *get_history(char *, time_t); extern void initwhowas(void); @@ -302,16 +289,15 @@ extern void send_listinfo(aClient *, char *); #endif extern void send_list(aClient *, int); -extern aChannel *hash_get_chan_bucket(int); #ifdef DUMP_DEBUG extern FILE *dumpfp; #endif #ifdef FLUD -int check_for_flood(); -void free_fluders(); -void free_fludees(); +extern int check_for_flood(void); +extern void free_fluders(aClient *, aChannel *); +extern void free_fludees(aClient *); #define MyFludConnect(x) (((x)->fd >= 0) || ((x)->fd == -2)) #endif /* FLUD */ @@ -331,9 +317,44 @@ extern int hash_del_watch_list(aClient *); extern aWatch *hash_get_watch(char *); #define MAXWATCH 128 -DLink *add_to_list(DLink **, void *); -void remove_from_list(DLink **, void *, DLink *); -void print_list_memory(aClient *); +extern DLink *add_to_list(DLink **, void *); +extern void remove_from_list(DLink **, void *, DLink *); +extern void print_list_memory(aClient *); + +extern void init_fdlist(fdlist *); /* defined in fdlist.c */ +extern void read_motd(char *); /* defined in s_serv.c */ +extern void read_shortmotd(char *); /* defined in s_serv.c */ +extern void read_help(char *); /* defined in s_serv.c */ +extern void init_globals(void); +extern void do_pending_klines(void); + +extern int send_motd(aClient *, aClient *, int, char **); +extern void send_topic_burst(aClient *); +#ifdef MAXBUFFERS +extern void reset_sock_opts(int, int); +extern int send_lusers(aClient *,aClient *,int, char **); +#endif +extern int server_was_split; + +extern int do_user(char *, aClient *, aClient *, char *, char *, char *, + unsigned long, unsigned int, char *); +extern int register_user(aClient *, aClient *, char *, char *); + +extern void free_port(aPort *ptr); +extern char *set_classes(void); + +/* ircd.c */ +extern void s_die(void); + +/* hide.c */ +extern void fakeserver_list(aClient *sptr); +extern int is_luserslocked(void) ; +extern void send_fake_users(aClient *sptr); +extern void send_fake_lusers(aClient *sptr) ; +extern void fakelusers_sendlock(aClient *sptr); +extern void fakelinkserver_update(char *name, char *desc); +extern void fakeserver_sendserver(aClient *sptr); + #include "find.h" diff --git a/include/hash.h b/include/hash.h index 6af59e4..63d0281 100644 --- a/include/hash.h +++ b/include/hash.h @@ -22,9 +22,12 @@ /* $Id: hash.h,v 1.1 2005/01/12 07:44:58 mmondor Exp $ */ + #ifndef __hash_include__ #define __hash_include__ +#include "struct.h" + typedef struct hashentry { int hits; @@ -32,6 +35,27 @@ typedef struct hashentry void *list; } aHashEntry; +extern aChannel *hash_get_chan_bucket(int hashv); +extern void clear_client_hash_table(void); +extern void clear_channel_hash_table(void); +extern int add_to_client_hash_table(char *name, aClient *cptr); +extern int add_to_channel_hash_table(char *name, aChannel *chptr); +extern int del_from_client_hash_table(char *name, aClient *cptr); +extern int del_from_channel_hash_table(char *name, aChannel *chptr); +extern aClient *hash_find_client(char *name, aClient *cptr); +extern aClient *hash_find_nickserver(char *name, aClient *cptr); +extern aClient *hash_find_server(char *server, aClient *cptr); +extern aChannel *hash_find_channel(char *name, aChannel *chptr); +extern void count_watch_memory(int *count, u_long *memory); +extern void clear_watch_hash_table(void); +extern int add_to_watch_hash_table(char *nick, aClient *cptr); +extern int hash_check_watch(aClient *cptr, int reply); +extern aWatch *hash_get_watch(char *name); +extern int del_from_watch_hash_table(char *nick, aClient *cptr); +extern int hash_del_watch_list(aClient *cptr); +extern unsigned int hash_whowas_name(char *name); +extern inline aClient *find_person(char *name, aClient *cptr); + /* Taner had BITS_PER_COL 4 BITS_PER_COL_MASK 0xF - Dianora */ #define BITS_PER_COL 3 diff --git a/include/hooks.h b/include/hooks.h index a22a6cd..dc74bdc 100644 --- a/include/hooks.h +++ b/include/hooks.h @@ -4,6 +4,9 @@ * */ +#ifndef _hooks_h_ +#define _hooks_h_ + enum c_hooktype { CHOOK_10SEC, /* Called every 10 seconds or so -- * not guaranteed to be 10 seconds * @@ -63,8 +66,9 @@ enum c_hooktype { MHOOK_UNLOAD /* Params: 2: (char *modulename, void *moduleopaque) */ }; +extern int m_module(aClient *cptr, aClient *sptr, int parc, char *parv[]); extern int call_hooks(enum c_hooktype hooktype, ...); -extern int init_modules(); +extern int init_modules(void); #define MODULE_INTERFACE_VERSION 1006 /* the interface version (hooks, modules.c commands, etc) */ @@ -74,3 +78,5 @@ extern void bircmodule_del_hook(); extern int bircmodule_malloc(int); extern int bircmodule_free(void *); #endif + +#endif diff --git a/include/ircsprintf.h b/include/ircsprintf.h index cd92002..a7bc069 100644 --- a/include/ircsprintf.h +++ b/include/ircsprintf.h @@ -4,6 +4,15 @@ #include #include "setup.h" +#ifndef TOO_OLD + +#define ircsprintf sprintf +#define ircsnprintf snprintf +#define ircvsprintf vsprintf +#define ircvsnprintf vsnprintf + +#else /* TOO_OLD */ + /* define this if you intend to use ircsnprintf or ircvsnprintf */ /* It's not used, and sNprintf functions are not in all libraries */ #define WANT_SNPRINTF @@ -33,6 +42,8 @@ int ircsnprintf(char *str, size_t size, const char *format, ...); # define VA_COPY(x, y) x = y #endif +#endif /* TOO_OLD */ + #endif diff --git a/include/list.h b/include/list.h new file mode 100644 index 0000000..f36c569 --- /dev/null +++ b/include/list.h @@ -0,0 +1,20 @@ +#ifndef _LIST_H_ +#define _LIST_H_ + +extern aClient *make_client(aClient *from, aClient *uplink); +extern aChannel *make_channel(void); +extern anUser *make_user(aClient *cptr); +extern aServer *make_server(aClient *cptr); +extern Link *make_link(void); +extern DLink *make_dlink(void); +extern chanMember *make_chanmember(void); +extern aClass *make_class(void); +extern aOper *make_oper(void); +extern aConnect *make_connect(void); +extern aAllow *make_allow(void); +extern aPort *make_port(void); +extern Conf_Me *make_me(void); +extern void outofmemory(void); +extern Link *find_channel_link(Link *lp, aChannel *chptr); + +#endif diff --git a/include/msg.h b/include/msg.h index 77b3297..40f1639 100644 --- a/include/msg.h +++ b/include/msg.h @@ -24,6 +24,8 @@ #ifndef __msg_include__ #define __msg_include__ +#include "hooks.h" + #define MSG_PRIVATE "PRIVMSG" /* PRIV */ #define MSG_WHO "WHO" /* WHO -> WHOC */ #define MSG_WHOIS "WHOIS" /* WHOI */ @@ -222,7 +224,6 @@ extern int m_dkey(aClient *, aClient *, int, char **); extern int m_resynch(aClient *, aClient *, int, char **); extern int m_luserslock(aClient *, aClient *, int, char **); extern int m_linkscontrol(aClient *, aClient *, int, char **); -extern int m_module(aClient *, aClient *, int, char **); extern int m_rwho(aClient *, aClient *, int, char **); extern int m_svsclone(aClient *, aClient *, int, char **); diff --git a/include/rc4.h b/include/rc4.h new file mode 100644 index 0000000..ccf9388 --- /dev/null +++ b/include/rc4.h @@ -0,0 +1,13 @@ +#ifndef _RC4_H_ +#define _RC4_H_ + +extern void *rc4_initstate(unsigned char *key, int keylen); +extern void rc4_process_stream(void *rc4_context, unsigned char *istring, + unsigned int stringlen); +extern void rc4_process_stream_to_buf(void *rc4_context, + const unsigned char *istring, + unsigned char *ostring, + unsigned int stringlen); +extern void rc4_destroystate(void *a); + +#endif diff --git a/include/sbuf.h b/include/sbuf.h index 34914ef..279ec61 100644 --- a/include/sbuf.h +++ b/include/sbuf.h @@ -21,6 +21,12 @@ #ifndef SBUF_H #define SBUF_H +#include +#ifdef WRITEV_IOV +#include +#include +#endif + /* Definitions */ #define SBUF_LARGE_BUFFER 512 #define SBUF_SMALL_BUFFER 256 @@ -43,7 +49,7 @@ typedef struct _SBuf /* function protoypes */ -extern int sbuf_init(); +extern int sbuf_init(void); extern int sbuf_begin_share(const char* theData, int theLength, void** thePtr); extern int sbuf_end_share(void** thePtr, int theNum); extern int sbuf_put_share(SBuf* theBuf, void *theSBuffer); diff --git a/include/send.h b/include/send.h index c089fd3..44d5517 100644 --- a/include/send.h +++ b/include/send.h @@ -33,7 +33,7 @@ extern int send_queued(aClient *); #include #include "fdlist.h" -extern void init_send(); +extern void init_send(void); extern void send_chatops(char *pattern, ...); extern void send_globops(char *pattern, ...); @@ -86,6 +86,8 @@ extern void vsendto_prefix_one(aClient *to, aClient *from, char *pattern, va_list vl); extern void vsendto_realops(char *pattern, va_list vl); -extern void flush_connections(); -extern void dump_connections(); +extern void flush_connections(int); +extern void dump_connections(int); +extern void flush_fdlist_connections(fdlist *); + #endif diff --git a/include/socketengine.h b/include/socketengine.h new file mode 100644 index 0000000..c8c37a6 --- /dev/null +++ b/include/socketengine.h @@ -0,0 +1,11 @@ +#ifndef _SOCKETENGINE_H_ +#define _SOCKETENGINE_H_ + +extern void engine_init(void); +extern void engine_add_fd(int fd); +extern void engine_del_fd(int fd); +extern void engine_change_fd_state(int fd, unsigned int stateplus); +extern void engine_get_fdsets(fd_set *r, fd_set *w); +extern int engine_read_message(time_t delay); + +#endif diff --git a/include/struct.h b/include/struct.h index c52dd3b..3ec9b65 100644 --- a/include/struct.h +++ b/include/struct.h @@ -74,7 +74,7 @@ extern char REPORT_DO_DNS[256], REPORT_FIN_DNS[256], REPORT_FIN_DNSC[256], REPORT_FAIL_DNS[256], REPORT_DO_ID[256], REPORT_FIN_ID[256], REPORT_FAIL_ID[256]; -#include "hash.h" +/*#include "hash.h"*/ #include "sbuf.h" diff --git a/include/structfunc.h b/include/structfunc.h index 2fb5912..a78af04 100644 --- a/include/structfunc.h +++ b/include/structfunc.h @@ -66,10 +66,10 @@ extern SBuf *ac_sendQ(aClient *); extern SBuf *ac_recvQ(aClient *); extern long ac_sendM(aClient *); extern long ac_sendK(aClient *); -extern long ac_recieveM(aClient *); -extern long ac_recieveK(aClient *); +extern long ac_receiveM(aClient *); +extern long ac_receiveK(aClient *); extern u_short ac_sendB(aClient *); -extern u_short ac_recieveB(aClient *); +extern u_short ac_receiveB(aClient *); extern long ac_lastrecvM(aClient *); extern int ac_priority(aClient *); extern aListener *ac_lstn(aClient *); diff --git a/include/sys.h b/include/sys.h index b3471bb..ea99826 100644 --- a/include/sys.h +++ b/include/sys.h @@ -77,7 +77,7 @@ #define MyFree(x) do { if (x) free(x); (x) = NULL; } while(0) -extern void dummy(); +extern void dummy(int); #ifdef NO_U_TYPES diff --git a/include/throttle.h b/include/throttle.h index 36cf633..0b85ab2 100644 --- a/include/throttle.h +++ b/include/throttle.h @@ -54,18 +54,18 @@ /* setting bits */ extern int throttle_enable, throttle_tcount, throttle_ttime, throttle_rtime; -void throttle_force(char *host); +extern void throttle_force(char *host); #ifdef THROTTLE_ENABLE -int throttle_check(char *ip, int fd, time_t sotime); -void throttle_remove(char *host); -void throttle_timer(time_t now); +extern int throttle_check(char *ip, int fd, time_t sotime); +extern void throttle_remove(char *host); +extern void throttle_timer(time_t now); -void throttle_init(void); -void throttle_rehash(void); -void throttle_resize(int size); -void throttle_stats(aClient *cptr, char *name); +extern void throttle_init(void); +extern void throttle_rehash(void); +extern void throttle_resize(int size); +extern void throttle_stats(aClient *cptr, char *name); #else @@ -117,22 +117,22 @@ typedef struct hash_table_t * function). len is the length of the key, and flags are any flags for the * table (see above). cmpfunc is the function which should be used for * comparison when calling 'hash_find' */ -hash_table *create_hash_table(int elems, size_t offset, size_t len, int flags, - int (*cmpfunc)(void *, void *)); +extern hash_table *create_hash_table(int elems, size_t offset, size_t len, + int flags, int (*cmpfunc)(void *, void *)); /* this function destroys a previously created hashtable */ -void destroy_hash_table(hash_table *table); +extern void destroy_hash_table(hash_table *table); /* this function resizes a hash-table to the new size given with 'elems'. * this is not in any way inexpensive, and should really not be done very * often. */ -void resize_hash_table(hash_table *table, int elems); +extern void resize_hash_table(hash_table *table, int elems); /* this function gets the hash value of a given key, relative to the size of * the hashtable */ -unsigned int hash_get_key_hash(hash_table *table, void *key, size_t offset); +extern unsigned int hash_get_key_hash(hash_table *table, void *key, size_t offset); /* these functions do what you would expect, adding/deleting/finding items * in a hash table */ -int hash_insert(hash_table *table, void *ent); -int hash_delete(hash_table *table, void *ent); -void *hash_find(hash_table *table, void *key); +extern int hash_insert(hash_table *table, void *ent); +extern int hash_delete(hash_table *table, void *ent); +extern void *hash_find(hash_table *table, void *key); #endif /* THROTTLE_H */ /* vi:set ts=8 sts=4 sw=4 tw=79: */ diff --git a/include/userban.h b/include/userban.h index f1a7ea7..99cb7d9 100644 --- a/include/userban.h +++ b/include/userban.h @@ -74,40 +74,42 @@ struct simBan { }; -void init_userban(); +extern void init_userban(void); -struct userBan *make_hostbased_ban(char *, char *); +extern unsigned int cidr_to_netmask(unsigned int cidr); -void add_hostbased_userban(struct userBan *); -void remove_userban(struct userBan *); -void userban_free(struct userBan *); +extern struct userBan *make_hostbased_ban(char *, char *); -struct userBan *check_userbanned(aClient *, unsigned int, unsigned int); -struct userBan *find_userban_exact(struct userBan *, unsigned int); +extern void add_hostbased_userban(struct userBan *); +extern void remove_userban(struct userBan *); +extern void userban_free(struct userBan *); -void expire_userbans(); -void remove_userbans_match_flags(unsigned int, unsigned int); -void report_userbans_match_flags(aClient *cptr, unsigned int, unsigned int); +extern struct userBan *check_userbanned(aClient *, unsigned int, unsigned int); +extern struct userBan *find_userban_exact(struct userBan *, unsigned int); -int user_match_ban(aClient *, struct userBan *); -char *get_userban_host(struct userBan *, char *, int); +extern void expire_userbans(void); +extern void remove_userbans_match_flags(unsigned int, unsigned int); +extern void report_userbans_match_flags(aClient *cptr, unsigned int, unsigned int); -int count_userbans(aClient *cptr); +extern int user_match_ban(aClient *, struct userBan *); +extern char *get_userban_host(struct userBan *, char *, int); + +extern int count_userbans(aClient *cptr); /* Simban Calls */ -struct simBan *make_simpleban(unsigned int, char *); -void add_simban(struct simBan *); -void remove_simban(struct simBan *); -struct simBan *find_simban_exact(struct simBan *); -int user_match_simban(aClient *, struct simBan *); -struct simBan *check_mask_simbanned(char *, unsigned int); -void simban_free(struct simBan *); -void remove_simban(struct simBan *); -void remove_simbans_match_flags(unsigned int, unsigned int); -void remove_simbans_match_mask(unsigned int, char *, int); -void report_simbans_match_flags(aClient *, unsigned int, unsigned int); -void expire_simbans(); -void send_simbans(aClient *, unsigned int); -int count_simbans(aClient *); -void remove_simban(struct simBan *); +extern struct simBan *make_simpleban(unsigned int, char *); +extern void add_simban(struct simBan *); +extern void remove_simban(struct simBan *); +extern struct simBan *find_simban_exact(struct simBan *); +extern int user_match_simban(aClient *, struct simBan *); +extern struct simBan *check_mask_simbanned(char *, unsigned int); +extern void simban_free(struct simBan *); +extern void remove_simban(struct simBan *); +extern void remove_simbans_match_flags(unsigned int, unsigned int); +extern void remove_simbans_match_mask(unsigned int, char *, int); +extern void report_simbans_match_flags(aClient *, unsigned int, unsigned int); +extern void expire_simbans(void); +extern void send_simbans(aClient *, unsigned int); +extern int count_simbans(aClient *); +extern void remove_simban(struct simBan *); diff --git a/include/whowas.h b/include/whowas.h index ab1c9b7..46713df 100644 --- a/include/whowas.h +++ b/include/whowas.h @@ -57,8 +57,6 @@ void off_history(aClient *); * nickname within the timelimit. Returns NULL, if no * one found... */ -aClient *get_history(char *, time_t); - -int m_whowas(aClient *, aClient *, int, char *[]); +extern aClient *get_history(char *, time_t); #endif /* __whowas_include__ */ diff --git a/include/zlink.h b/include/zlink.h index 8e0ef38..d201382 100644 --- a/include/zlink.h +++ b/include/zlink.h @@ -1,5 +1,5 @@ -extern void *zip_create_input_session(); -extern void *zip_create_output_session(); +extern void *zip_create_input_session(void); +extern void *zip_create_output_session(void); extern char *zip_input(void *session, char *buffer, int *len, int *err, char **nbuf, int *nlen); /* largedata is err return */ diff --git a/src/blalloc.c b/src/blalloc.c index f69c940..6944984 100644 --- a/src/blalloc.c +++ b/src/blalloc.c @@ -14,13 +14,11 @@ #include "h.h" #include "numeric.h" #include "blalloc.h" +#include "list.h" /* FUNCTION PROTOTYPES (LOCAL FUNCTIONS ONLY) */ static int newblock(BlockHeap *bh); -/* FUNCTION PROTOTYPES (EXTERN FUNCTIONS ONLY) */ -extern void outofmemory(); /* defined in list.c */ - /* FUNCTION DOCUMENTATION: * * newblock diff --git a/src/bsd.c b/src/bsd.c index dc4ba5c..e34ef14 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -25,20 +25,20 @@ #include "sys.h" #include "h.h" #include "fds.h" +#include "sys.h" #include #include #include extern int errno; /* ...seems that errno.h doesn't define this everywhere */ -#ifndef SYS_ERRLIST_DECLARED -extern char *sys_errlist[]; -#endif #if defined(DEBUGMODE) || defined (DNS_DEBUG) int writecalls = 0, writeb[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int readcalls = 0; #endif -void dummy() +/* XXX Very strange code... */ +/* ARGSUSED */ +void dummy(int sig) { struct sigaction act; diff --git a/src/channel.c b/src/channel.c index df750b0..f577cc1 100644 --- a/src/channel.c +++ b/src/channel.c @@ -26,7 +26,9 @@ #include "numeric.h" #include "channel.h" #include "h.h" +#include "hash.h" #include "userban.h" +#include "list.h" int server_was_split = YES; @@ -53,6 +55,9 @@ static int is_banned(aClient *, aChannel *, chanMember *); static int set_mode(aClient *, aClient *, aChannel *, int, int, char **, char *, char *); static void sub1_from_channel(aChannel *); +static int check_joinrate(aChannel *, time_t, int, aClient *); +static int is_deopped(aClient *, aChannel *); +static void kill_ban_list(aClient *, aChannel *); int check_channelname(aClient *, unsigned char *); void clean_channelname(unsigned char *); @@ -80,8 +85,6 @@ static char *CliSJOINFmt = ":%s SJOIN %ld %s"; static char nickbuf[BUFSIZE], buf[BUFSIZE]; static char modebuf[REALMODEBUFLEN], parabuf[REALMODEBUFLEN]; -/* externally defined function */ -extern Link *find_channel_link(Link *, aChannel *); /* defined in list.c */ #ifdef ANTI_SPAMBOT extern int spam_num; /* defined in s_serv.c */ extern int spam_time; /* defined in s_serv.c */ diff --git a/src/clientlist.c b/src/clientlist.c index 3368775..6f711ba 100644 --- a/src/clientlist.c +++ b/src/clientlist.c @@ -19,6 +19,8 @@ DLink *oper_list = NULL; DLink *listing_clients = NULL; DLink *recvq_clients = NULL; +static int get_list_memory(DLink *); + int get_list_memory(DLink *list) { DLink *lp; diff --git a/src/confparse.c b/src/confparse.c index 7705832..9edbb88 100644 --- a/src/confparse.c +++ b/src/confparse.c @@ -71,7 +71,6 @@ */ extern int forked; -extern char *set_classes(void); extern aPort *new_ports; extern Conf_Me *new_MeLine; diff --git a/src/fds.c b/src/fds.c index 9f7b6d2..cdd418f 100644 --- a/src/fds.c +++ b/src/fds.c @@ -18,6 +18,7 @@ void engine_add_fd(int); void engine_del_fd(int); void engine_change_fd_state(int, unsigned int); +unsigned int get_fd_flags(int fd); struct afd_entry { int type; diff --git a/src/hash.c b/src/hash.c index 1dae1d1..2775638 100644 --- a/src/hash.c +++ b/src/hash.c @@ -24,10 +24,14 @@ #include "sys.h" #include "hash.h" #include "h.h" +#include "msg.h" static aHashEntry clientTable[U_MAX]; static aHashEntry channelTable[CH_MAX]; +static unsigned hash_nick_name(char *nname); +static int hash_channel_name(char *name); + /* * look in whowas.c for the missing ...[WW_MAX]; entry - Dianora * @@ -656,3 +660,10 @@ aChannel *hash_get_chan_bucket(int hashv) return NULL; return (aChannel *)channelTable[hashv].list; } + +inline aClient *find_person(char *name, aClient *cptr) +{ + aClient *acptr = hash_find_client(name, cptr); + + return acptr ? (IsClient(acptr) ? acptr : cptr) : cptr; +} diff --git a/src/hide.c b/src/hide.c index 5c4aab1..8a53a9c 100644 --- a/src/hide.c +++ b/src/hide.c @@ -14,6 +14,7 @@ #include "h.h" #include "fds.h" #include "numeric.h" +#include "msg.h" /* This is how we maintain a 'fake' list of servers */ @@ -22,6 +23,13 @@ struct fakelinkserver { char *description; }; +static struct fakelinkserver *fakelinkserver_find(char *name); +static void fakelinkserver_delete(char *name); +static void fakelinkserver_add(char *name, char *desc); +static void dolocklusers(void); +static void fakelinkserver_reset(void); + + /* lserver_list is a linked list of Link structures, each with the 'cp' member pointing to a struct fakelinkserver */ diff --git a/src/ircd.c b/src/ircd.c index cbd3194..10502b0 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -48,6 +48,7 @@ #include "clones.h" #include "hooks.h" #include "fds.h" +#include "socketengine.h" aMotd *motd; aMotd *helpfile; /* misnomer, aMotd could be generalized */ @@ -99,22 +100,16 @@ float curSendK = 0, curRecvK = 0; #ifdef LOCKFILE extern time_t pending_kline_time; extern struct pkl *pending_klines; -extern void do_pending_klines(void); -#endif -extern void engine_read_message(int); - -void server_reboot(); -void restart(char *); -static void open_debugfile(), setup_signals(); -static void io_loop(); -/* externally needed functions */ - -extern void init_fdlist(fdlist *); /* defined in fdlist.c */ -extern void read_motd(char *); /* defined in s_serv.c */ -extern void read_shortmotd(char *); /* defined in s_serv.c */ -extern void read_help(char *); /* defined in s_serv.c */ -extern void init_globals(); +#endif +/* XXX */ +static void server_reboot(void); +static void open_debugfile(void), setup_signals(void); +static void io_loop(void); +static void get_paths(char *argv); +static void do_recvqs(void); +static void send_safelists(void); +static void s_restart(void); char **myargv; char configfile[PATH_MAX] = {0}; /* Server configuration file */ diff --git a/src/ircsprintf.c b/src/ircsprintf.c index 49fae17..12fa611 100644 --- a/src/ircsprintf.c +++ b/src/ircsprintf.c @@ -1,3 +1,5 @@ +#ifdef TOO_OLD + #include "ircsprintf.h" char num[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -263,3 +265,5 @@ int ircvsnprintf(char *str, size_t size, const char *format, va_list ap) return ret; } #endif + +#endif /* TOO_OLD */ diff --git a/src/list.c b/src/list.c index 9ad1f17..c1479ac 100644 --- a/src/list.c +++ b/src/list.c @@ -28,8 +28,9 @@ #include "blalloc.h" #include "dh.h" #include "zlink.h" +#include "list.h" +#include "rc4.h" -extern int BlockHeapGarbageCollect(BlockHeap *); /* locally defined functions */ @@ -63,8 +64,6 @@ extern int BlockHeapGarbageCollect(BlockHeap *); #define CHANNELS_PREALLOCATE 1024 -void outofmemory(); - int numclients = 0; /* for jolo's block allocator */ diff --git a/src/m_nick.c b/src/m_nick.c index 88753c4..1e55c53 100644 --- a/src/m_nick.c +++ b/src/m_nick.c @@ -34,11 +34,6 @@ #include "h.h" #include "userban.h" -extern int do_user(char *, aClient *, aClient *, char *, char *, char *, - unsigned long, unsigned int, char *); - -extern int register_user(aClient *, aClient *, char *, char *); - extern int user_modes[]; diff --git a/src/m_rwho.c b/src/m_rwho.c index d272237..594a3a8 100644 --- a/src/m_rwho.c +++ b/src/m_rwho.c @@ -31,12 +31,12 @@ #include "channel.h" #include "inet.h" #include "clones.h" +#include "list.h" +#include "userban.h" #include "pcre.h" extern int user_modes[]; -extern unsigned int cidr_to_netmask(unsigned int); -extern Link *find_channel_link(Link *, aChannel *); /* max capturing submatches to allow in all fields combined */ #define MAX_SUBMATCHES 9 diff --git a/src/m_server.c b/src/m_server.c index 30e3330..0b8adf8 100644 --- a/src/m_server.c +++ b/src/m_server.c @@ -24,17 +24,13 @@ #include "numeric.h" #include "h.h" #include "dh.h" +#include "rc4.h" #include "userban.h" #include "zlink.h" #include "throttle.h" #include "clones.h" +#include "msg.h" -/* externally defined functions */ - -extern void fakelinkserver_update(char *, char *); -extern void fakeserver_sendserver(aClient *); -extern void fakelusers_sendlock(aClient *); -extern void reset_sock_opts(int, int); /* internal functions */ diff --git a/src/m_services.c b/src/m_services.c index 67b6515..cd9aa8a 100644 --- a/src/m_services.c +++ b/src/m_services.c @@ -38,6 +38,8 @@ /* Externally defined stuffs */ extern int user_modes[]; +static int channel_svsmode(aClient *cptr, aClient *sptr, int parc, char *parv[]); + /* * the services aliases. * * diff --git a/src/m_stats.c b/src/m_stats.c index 86da888..b31030b 100644 --- a/src/m_stats.c +++ b/src/m_stats.c @@ -39,6 +39,7 @@ #include "res.h" #include "sbuf.h" #include "clones.h" +#include "hash.h" #if defined(DEBUGMODE) && defined(HAVE_GETRUSAGE) #include diff --git a/src/m_who.c b/src/m_who.c index 7d54061..2f827b8 100644 --- a/src/m_who.c +++ b/src/m_who.c @@ -33,18 +33,18 @@ #include #include #include "h.h" +#include "list.h" +#include "userban.h" /* Internally defined stuffs */ SOpts wsopts; int build_searchopts(aClient *, int, char **); int chk_who(aClient *, int); +inline char *first_visible_channel(aClient *cptr, aClient *sptr); /* Externally defined stuffs */ extern int user_modes[]; -extern Link *find_channel_link(Link *, aChannel *); -extern unsigned int cidr_to_netmask(unsigned int); - int build_searchopts(aClient *sptr, int parc, char *parv[]) { static char *who_oper_help[] = diff --git a/src/match.c b/src/match.c index c64db76..9f13017 100644 --- a/src/match.c +++ b/src/match.c @@ -23,6 +23,7 @@ #include "struct.h" #include "common.h" #include "sys.h" +#include "h.h" #if 0 /* this code is depricated, however it may still prove useful in the long run to 'show' it here */ diff --git a/src/modules.c b/src/modules.c index 7c9106f..54dbbdd 100644 --- a/src/modules.c +++ b/src/modules.c @@ -98,11 +98,29 @@ typedef struct loaded_module } aModule; /* Forward decls */ -char *bircmodule_strdup(char *); -void *bircmodule_malloc(int); -void bircmodule_free(void *); -void drop_all_hooks(aModule *owner); -void list_hooks(aClient *sptr); +static char *bircmodule_strdup(char *); +static void *bircmodule_malloc(int); +static void bircmodule_free(void *); +static void drop_all_hooks(aModule *owner); +static void list_hooks(aClient *sptr); +static aModule *find_module(char *name); +static aModule *find_module_opaque(void *opaque); +static int modsym_load(aClient *sptr, char *modname, char *symbol, void + *modulehandle, void **retfunc); +static void list_modules(aClient *sptr); +static void destroy_module(aModule *themod); +static int load_module(aClient *sptr, char *modname); +static int unload_module(aClient *sptr, char *modname); +static char * bircmodule_strdup(char *string); +static void * bircmodule_malloc(int size); +static void bircmodule_free(void *p); +static char * get_texthooktype(enum c_hooktype hooktype); +static DLink ** get_hooklist(enum c_hooktype hooktype); +static void drop_all_hooks(aModule *owner); +static void * bircmodule_add_hook(enum c_hooktype hooktype, void *opaque, void + *funcptr); +static void bircmodule_del_hook(void *opaque); +static void list_hooks(aClient *sptr); aModule * find_module(char *name) diff --git a/src/packet.c b/src/packet.c index 6128089..a463e07 100644 --- a/src/packet.c +++ b/src/packet.c @@ -25,6 +25,7 @@ #include "sys.h" #include "msg.h" #include "h.h" +#include "rc4.h" #include "dh.h" #include "zlink.h" diff --git a/src/parse.c b/src/parse.c index 225ab44..de18444 100644 --- a/src/parse.c +++ b/src/parse.c @@ -28,6 +28,7 @@ #include "sys.h" #include "numeric.h" #include "h.h" +#include "hooks.h" #if defined( HAVE_STRING_H ) #include diff --git a/src/rc4.c b/src/rc4.c index 09d8096..22bbebf 100644 --- a/src/rc4.c +++ b/src/rc4.c @@ -22,6 +22,7 @@ #include #include #include +#include "rc4.h" /* * Transparent rc4 implementation @@ -43,6 +44,10 @@ struct rc4_state RC4BYTE y; }; +/* + * XXX Should consume enough pseudorandom bytes to be less insecure, + * but would be incompatible unless all network updated * to the same code. + */ void *rc4_initstate(unsigned char *key, int keylen) { RC4DWORD i; diff --git a/src/res.c b/src/res.c index 716dfc1..bd53a8c 100644 --- a/src/res.c +++ b/src/res.c @@ -14,6 +14,7 @@ #include "numeric.h" #include "h.h" #include "fds.h" +#include "msg.h" #include #include @@ -93,6 +94,7 @@ static void update_list(ResRQ *, aCache *); static int hash_name(char *); #endif static struct hostent *getres_err(ResRQ *, char *); +static int arpa_to_ip(char *arpastring, unsigned int *saddr); static struct cacheinfo { diff --git a/src/s_bsd.c b/src/s_bsd.c index db70a02..db816b6 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -45,6 +45,7 @@ #include #include #include "hooks.h" +#include "socketengine.h" #ifdef AIX #include @@ -63,10 +64,8 @@ -extern void engine_init(); extern fdlist default_fdlist; extern int forked; -extern void free_port(aPort *); #ifndef IN_LOOPBACKNET #define IN_LOOPBACKNET 0x7f @@ -95,6 +94,8 @@ static struct sockaddr_in mysk; static struct sockaddr *connect_inet(aConnect *, aClient *, int *); static int check_init(aClient *, char *); static void set_sock_opts(int, aClient *); +static void report_listener_error(char *text, aListener *lptr); +static void close_listener(aListener *lptr); #if defined(MAXBUFFERS) static char *readbuf; diff --git a/src/s_conf.c b/src/s_conf.c index 156ba57..c8d950d 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -29,6 +29,7 @@ #include "h.h" #include "userban.h" #include "confparse.h" +#include "list.h" /* This entire file has basically been rewritten from scratch with the * exception of lookup_confhost and attach_Iline/attach_iline fucntions @@ -42,18 +43,26 @@ extern sConf sconftab[]; /* internally defined functions */ -static int lookup_confhost(aConnect *); -static int attach_iline(aClient *, aAllow *, char *, int); +static int lookup_confhost(aConnect *); +static int attach_iline(aClient *, aAllow *, char *, int); +static void free_connect(aConnect *ptr); +static void free_allow(aAllow *ptr); +static void free_oper(aOper *ptr); +static void expire_class(aClass *cl); +static inline aPort *find_port(int port, char *bind); +static inline aOper *find_oper_byname(char *name); +static inline aClass *find_class(char *name); +static inline aClass *find_new_class(char *name); +static void merge_me(void); +static void merge_connects(void); +static void merge_allows(void); +static void merge_opers(void); +static void merge_ports(void); +static void merge_classes(void); +static void merge_options(void); +static void clear_newconfs(void); +static int lookup_confhost(aConnect *aconn); -/* externally defined functions */ - -extern aClass *make_class(); -extern aOper *make_oper(); -extern aConnect *make_connect(); -extern aAllow *make_allow(); -extern struct Conf_Me *make_me(); -extern aPort *make_port(); -extern void read_shortmotd(char *); /* these are our global lists of ACTIVE conf entries */ @@ -79,11 +88,6 @@ aClass *new_classes = NULL; char *new_uservers[MAXUSERVS+1]; /* null terminated array */ Conf_Modules *new_modules = NULL; -#ifdef LOCKFILE -extern void do_pending_klines(void); -#endif -extern void confparse_error(char *, int); - /* initclass() * initialize the default class */ diff --git a/src/s_misc.c b/src/s_misc.c index 7afb240..3bc6cff 100644 --- a/src/s_misc.c +++ b/src/s_misc.c @@ -53,6 +53,14 @@ int currently_processing_netsplit = NO; #endif static void exit_one_client(aClient *, aClient *, aClient *, char *); +#ifdef DCCALLOW +static int remove_dcc_references(aClient *sptr); +#endif +static void exit_one_client_in_split(aClient *cptr, aClient *dead, char *reason); +static void exit_one_server(aClient *cptr, aClient *dead, aClient *from, + aClient *lcptr, char *spinfo, char *comment); +static void exit_server(aClient *lcptr, aClient *cptr, aClient *from, + char *comment); static char *months[] = { diff --git a/src/s_serv.c b/src/s_serv.c index f045e12..9f13f84 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -53,6 +53,7 @@ #include "fdlist.h" #include "throttle.h" #include "clones.h" +#include "list.h" static char buf[BUFSIZE]; extern int rehashed; @@ -60,37 +61,16 @@ extern int forked; /* external variables */ -/* external functions */ - -extern char *smalldate(time_t); /* defined in s_misc.c */ -extern void outofmemory(void); /* defined in list.c */ -extern void s_die(void); -extern int match(char *, char *); /* defined in match.c */ - /* Local function prototypes */ static int isnumber(char *); /* return 0 if not, else return number */ static char *cluster(char *); -int send_motd(aClient *, aClient *, int, char **); -void read_motd(char *); -void read_shortmotd(char *); char motd_last_changed_date[MAX_DATE_STRING]; /* enough room for date */ -void fakeserver_list(aClient *); -int fakelinkscontrol(int, char **); -void fakelinkserver_update(char *, char *); -void fakeserver_sendserver(aClient *); - -int is_luserslocked(); -void send_fake_users(aClient *); -void send_fake_lusers(aClient *); -void fakelusers_sendlock(aClient *); - #ifdef LOCKFILE /* Shadowfax's lockfile code */ -void do_pending_klines(void); struct pkl { diff --git a/src/s_user.c b/src/s_user.c index eb3fca8..2c65b2b 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -40,6 +40,7 @@ #endif /* FLUD */ #include "userban.h" #include "hooks.h" +#include "list.h" #if defined( HAVE_STRING_H) #include @@ -49,15 +50,8 @@ int do_user(char *, aClient *, aClient *, char *, char *, char *, unsigned long, unsigned int, char *); + extern char motd_last_changed_date[]; -extern int send_motd(aClient *, aClient *, int, char **); -extern void send_topic_burst(aClient *); -extern void outofmemory(void); /* defined in list.c */ -#ifdef MAXBUFFERS -extern void reset_sock_opts(); -extern int send_lusers(aClient *,aClient *,int, char **); -#endif -extern int server_was_split; static char buf[BUFSIZE], buf2[BUFSIZE]; int user_modes[] = @@ -98,8 +92,6 @@ int user_modes[] = 0, 0 }; -/* externally defined functions */ -extern Link *find_channel_link(Link *, aChannel *); /* defined in list.c */ #ifdef FLUD int flud_num = FLUD_NUM; int flud_time = FLUD_TIME; @@ -107,13 +99,15 @@ int flud_block = FLUD_BLOCK; extern BlockHeap *free_fludbots; extern BlockHeap *free_Links; -void announce_fluder(aClient *, aClient *, aChannel *, int); -struct fludbot *remove_fluder_reference(struct fludbot **, aClient *); -Link *remove_fludee_reference(Link **, void *); -int check_for_fludblock(aClient *, aClient *, aChannel *, int); -int check_for_flud(aClient *, aClient *, aChannel *, int); -void free_fluders(aClient *, aChannel *); -void free_fludees(aClient *); +static void announce_fluder(aClient *, aClient *, aChannel *, int); +static struct fludbot *remove_fluder_reference(struct fludbot **, aClient *); +static Link *remove_fludee_reference(Link **, void *); +static int check_for_fludblock(aClient *, aClient *, aChannel *, int); +static int check_for_flud(aClient *, aClient *, aChannel *, int); +#endif + +#ifdef MSG_TARGET_LIMIT +static int check_target_limit(aClient *sptr, aClient *acptr); #endif #ifdef ANTI_SPAMBOT diff --git a/src/sbuf.c b/src/sbuf.c index ec64efe..74e6ff4 100644 --- a/src/sbuf.c +++ b/src/sbuf.c @@ -24,12 +24,12 @@ #include "common.h" #include "sys.h" #include "h.h" +#include "sbuf.h" +#include "list.h" #include #include -extern void outofmemory(void); - typedef struct _SBuffer { struct _SBuffer *next; @@ -69,6 +69,17 @@ int sbufsmall_total = 0, sbufsmall_used = 0; int sbuflarge_total = 0, sbuflarge_used = 0; int sbufblock_used = 0, sbufuserblock_used = 0; +static int sbuf_allocblock_general(int theMemorySize, int num, + SBuffer** thePool); +static int sbuf_allocblock_small(int theMemorySize); +static int sbuf_allocblock_large(int theMemorySize); +static int sbuf_allocblock_users(int theCount); +static int sbuf_free(SBuffer* buf); +static int sbuf_user_free(SBufUser* user); +static SBuffer* sbuf_alloc(int theSize); +static SBufUser* sbuf_user_alloc(void); +static int sbuf_alloc_error(void); + #define SBUF_BASE sizeof(SBuffer) #define SBUF_LARGE_TOTAL (SBUF_BASE + SBUF_LARGE_BUFFER) #define SBUF_SMALL_TOTAL (SBUF_BASE + SBUF_SMALL_BUFFER) diff --git a/src/send.c b/src/send.c index ef37f93..852e547 100644 --- a/src/send.c +++ b/src/send.c @@ -27,8 +27,11 @@ #include #include "numeric.h" #include "dh.h" +#include "rc4.h" #include "zlink.h" #include "fds.h" +#include "sbuf.h" +#include "send.h" /* * STOP_SENDING_ON_SHORT_SEND: @@ -45,7 +48,17 @@ extern int currently_processing_netsplit; static char sendbuf[2048]; static char remotebuf[2048]; static char selfbuf[256]; -static int send_message(aClient *, char *, int, void*); + +static int dead_link(aClient *to, char *notice, int sockerr); +static int send_message(aClient *, char *, int, void*); +static inline int prefix_buffer(int remote, aClient *from, char *prefix, + char *buffer, char *pattern, va_list vl); +static inline int check_fake_direction(aClient *from, aClient *to); +#ifdef FLUD +static void sendto_channel_butlocal(aClient *one, aClient *from, + aChannel *chptr, char *pattern, ...); +#endif +static int match_it(aClient *one, char *mask, int what); #ifdef HAVE_ENCRYPTION_ON /* diff --git a/src/socketengine_devpoll.c b/src/socketengine_devpoll.c index 4565e42..deb5819 100644 --- a/src/socketengine_devpoll.c +++ b/src/socketengine_devpoll.c @@ -14,6 +14,7 @@ #include "sys.h" #include "h.h" #include "fds.h" +#include "socketengine.h" #include #include @@ -165,4 +166,4 @@ int engine_read_message(time_t delay) } while (eventsfull && numloops < ENGINE_MAX_LOOPS); return 0; -} \ No newline at end of file +} diff --git a/src/socketengine_epoll.c b/src/socketengine_epoll.c index 5b3d5bc..20033dd 100644 --- a/src/socketengine_epoll.c +++ b/src/socketengine_epoll.c @@ -14,6 +14,7 @@ #include "sys.h" #include "h.h" #include "fds.h" +#include "socketengine.h" #include #include diff --git a/src/socketengine_kqueue.c b/src/socketengine_kqueue.c index 4eca172..5019e98 100644 --- a/src/socketengine_kqueue.c +++ b/src/socketengine_kqueue.c @@ -13,6 +13,7 @@ #include "sys.h" #include "h.h" #include "fds.h" +#include "socketengine.h" #include #include diff --git a/src/socketengine_poll.c b/src/socketengine_poll.c index 4dff01d..25106ca 100644 --- a/src/socketengine_poll.c +++ b/src/socketengine_poll.c @@ -13,13 +13,16 @@ #include "sys.h" #include "h.h" #include "fds.h" +#include "socketengine.h" #include +static void engine_get_pollfds(struct pollfd **pfds, int *numpfds); + struct pollfd poll_fds[MAXCONNECTIONS]; int last_pfd = -1; -void engine_init() +void engine_init(void) { } @@ -70,7 +73,7 @@ void engine_change_fd_state(int fd, unsigned int stateplus) pfd->events |= POLLOUT; } -void engine_get_pollfds(struct pollfd **pfds, int *numpfds) +static void engine_get_pollfds(struct pollfd **pfds, int *numpfds) { *pfds = poll_fds; *numpfds = (last_pfd + 1); diff --git a/src/socketengine_select.c b/src/socketengine_select.c index 1d63c6e..608ef67 100644 --- a/src/socketengine_select.c +++ b/src/socketengine_select.c @@ -13,6 +13,7 @@ #include "sys.h" #include "h.h" #include "fds.h" +#include "socketengine.h" static fd_set g_read_set, g_write_set; diff --git a/src/support.c b/src/support.c index 5800c11..b87d515 100644 --- a/src/support.c +++ b/src/support.c @@ -24,6 +24,7 @@ #include "common.h" #include "sys.h" #include "h.h" +#include "list.h" #define FOREVER for(;;) @@ -31,7 +32,6 @@ extern int errno; /* * ...seems that errno.h doesn't define this * * everywhere */ -extern void outofmemory(); #if !defined( HAVE_STRTOKEN ) /* diff --git a/src/throttle.c b/src/throttle.c index c9d42d6..cc5f52e 100644 --- a/src/throttle.c +++ b/src/throttle.c @@ -45,8 +45,13 @@ #include "queue.h" #include "throttle.h" -BlockHeap *hashent_freelist; -BlockHeap *throttle_freelist; +static BlockHeap *hashent_freelist; +static BlockHeap *throttle_freelist; + +static hashent *hashent_alloc(void); +static void hashent_free(hashent *hp); + + /******************************************************************************* * hash code here. why isn't it in hash.c? see the license. :) @@ -238,6 +243,9 @@ typedef struct throttle_t LIST_ENTRY(throttle_t) lp; } throttle; +static throttle *throttle_alloc(void); +static void throttle_free(throttle *tp); + /* variables for the throttler */ hash_table *throttle_hash; int throttle_tcount = THROTTLE_TRIGCOUNT; diff --git a/src/userban.c b/src/userban.c index c5ebc8f..461f976 100644 --- a/src/userban.c +++ b/src/userban.c @@ -58,14 +58,16 @@ aBanList gcos_bans; aBanList nick_bans; aBanList chan_bans; -struct userBan *userban_alloc(); -struct simBan *simban_alloc(); -uBanEnt *ubanent_alloc(); -void ubanent_free(uBanEnt *); -void userban_free(struct userBan *); -void simban_free(struct simBan *); -unsigned int host_hash(char *n); -unsigned int ip_hash(char *n); +static struct userBan *userban_alloc(void); +static struct simBan *simban_alloc(void); +static uBanEnt *ubanent_alloc(void); +static void ubanent_free(uBanEnt *); +static unsigned int host_hash(char *n); +static unsigned int ip_hash(char *n); +static unsigned int netmask_to_cidr(unsigned int mask); +static void init_banlist(aBanList *a, int numbuckets); +static int count_simlist(uBanEnt *bl, int *mem); +static int count_list(uBanEnt *bl, int *mem); unsigned int cidr_to_netmask(unsigned int cidr) { @@ -75,7 +77,7 @@ unsigned int cidr_to_netmask(unsigned int cidr) return (0xFFFFFFFF - (1 << (32 - cidr)) + 1); } -unsigned int netmask_to_cidr(unsigned int mask) +static unsigned int netmask_to_cidr(unsigned int mask) { int tmp = 0; @@ -1467,7 +1469,7 @@ unsigned int host_hash(char *n) return hv; } -void init_banlist(aBanList *a, int numbuckets) +static void init_banlist(aBanList *a, int numbuckets) { memset(a, 0, sizeof(aBanList)); a->numbuckets = numbuckets; @@ -1568,7 +1570,7 @@ void simban_free(struct simBan *b) MyFree(b); } -int count_simlist(uBanEnt *bl, int *mem) +static int count_simlist(uBanEnt *bl, int *mem) { uBanEnt *bln; struct simBan *ban; @@ -1596,7 +1598,7 @@ int count_simlist(uBanEnt *bl, int *mem) return ucnt; } -int count_list(uBanEnt *bl, int *mem) +static int count_list(uBanEnt *bl, int *mem) { uBanEnt *bln; struct userBan *ban; diff --git a/src/whowas.c b/src/whowas.c index b6ff658..49193f6 100644 --- a/src/whowas.c +++ b/src/whowas.c @@ -24,6 +24,8 @@ #include "sys.h" #include "numeric.h" #include "h.h" +#include "hash.h" +#include "msg.h" /* externally defined functions */ unsigned int hash_whowas_name(char *); /* defined in hash.c */ diff --git a/src/zlink.c b/src/zlink.c index 7b5e4c2..acf01b9 100644 --- a/src/zlink.c +++ b/src/zlink.c @@ -29,6 +29,7 @@ #include #include #include "zlib.h" +#include "zlink.h" #define COMPRESSION_LEVEL 3 /* 0 to 9, 0 = none */ #define ZIP_MIN_BLOCK 1024 /* smallest block to compress */ diff --git a/tools/Makefile.in b/tools/Makefile.in index 2c9ca69..1bbe071 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -9,24 +9,28 @@ INCLUDEDIR=-I../include mkpasswd_SOURCES = mkpasswd.c mkpasswd_OBJECTS = mkpasswd.o -convert_conf_SOURCES = convert_conf.c -convert_conf_OBJECTS = convert_conf.o ../src/match.o -PROGRAMS = mkpasswd convert_conf +#convert_conf_SOURCES = convert_conf.c +#convert_conf_OBJECTS = convert_conf.o ../src/match.o +#PROGRAMS = mkpasswd convert_conf +PROGRAMS = mkpasswd -all_OBJECTS = $(mkpasswd_OBJECTS) $(convert_conf_OBJECTS) +#all_OBJECTS = $(mkpasswd_OBJECTS) $(convert_conf_OBJECTS) +all_OBJECTS = $(mkpasswd_OBJECTS) -all: mkpasswd convert_conf +#all: mkpasswd convert_conf +all: mkpasswd build: all mkpasswd: $(mkpasswd_OBJECTS) $(CC) -o mkpasswd $(mkpasswd_OBJECTS) $(IRCDLIBS) -convert_conf: $(convert_conf_OBJECTS) - $(CC) -o convert_conf $(convert_conf_OBJECTS) $(IRCDLIBS) +#convert_conf: $(convert_conf_OBJECTS) +# $(CC) -o convert_conf $(convert_conf_OBJECTS) $(IRCDLIBS) clean: - $(RM) -f $(all_OBJECTS) mkpasswd convert_conf *~ core + $(RM) -f $(all_OBJECTS) mkpasswd *~ core +# $(RM) -f $(all_OBJECTS) mkpasswd convert_conf *~ core distclean: clean $(RM) -f Makefile diff --git a/tools/convert_conf.c b/tools/convert_conf.c index f925b20..cf74d94 100644 --- a/tools/convert_conf.c +++ b/tools/convert_conf.c @@ -74,6 +74,42 @@ int do_tline = 0; char ProxyMonHost[HOSTLEN+1]; char ProxyMonURL[TOPICLEN+1]; +static int dgets(int fd, char *buf, int num); +static char *getfield(char *newline); +static aClass *make_class(void); +void free_class(aClass *); +static aOper *make_oper(void); +static SimBan *make_simban(void); +static HostBan *make_hostban(void); +static aConnect *make_connect(void); +static aAllow *make_allow(void); +static aPort *make_port(void); +static Conf_Me *make_me(void); +static aConnect *find_aConnect(char *name); +static aPort *find_port(int port); +static aConnect *find_aConnect_match(char *name, char *username, char *host); +static char *find_aUserver(char *name); +static aOper *find_oper(char *name, char *username, char *sockhost, char *hostip); +static aOper *find_oper_byname(char *name); +static aClass *find_class(char *name); +static void confadd_oper(char *name, char *host, char *passwd, char *flags, char + *class); +static void confadd_connect(char *name, char *host, char *apasswd, char *cpasswd, + int port, char *flags, char *source, char *class); +static void confadd_allow(char *ipmask, char *passwd, char *hostmask, int port, + char *class); +static void confadd_port(int port, char *allow, char *address); +static void confadd_me(char *servername, char *info, char *dpass, char *rpass, + char *aline1, char *aline2, char *aline3); +static void confadd_class(char *name, int ping, int connfreq, int maxlinks, + long sendq); +static void confadd_simban(int flags, char *mask, char *reason); +static void confadd_hostban(char *username, char *mask, char *reason); +static void confadd_uline(char *host); +static int openconf(char *filename); +static int initconf(int opt, int fd, aClient *rehasher); +static void printconf(void); +static int main(int argc, char *argv[]); int dgets(int fd, char *buf, int num) { @@ -217,8 +253,7 @@ aClass *make_class() return tmp; } -void free_class(tmp) - aClass *tmp; +void free_class(aClass *tmp) { MyFree(tmp); } -- 2.9.0