diff --git a/.gitignore b/.gitignore index 2cbbb52d4..471ec0ec4 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ Makefile *.orig *.log *.sw? +*.gch .deps .dirstamp .libs diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..2a3f21535 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "boost"] + path = boost + url = https://github.com/boostorg/boost.git diff --git a/Makefile.am b/Makefile.am index b6ed9c783..601047de5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,28 +1,23 @@ AUTOMAKE_OPTIONS = foreign ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = rb \ - ircd - +SUBDIRS = include/rb +SUBDIRS += rb +SUBDIRS += ircd if BUILD_LTDL SUBDIRS += libltdl endif +SUBDIRS += charybdis +SUBDIRS += authd +SUBDIRS += bandb +SUBDIRS += ssld +SUBDIRS += wsockd +SUBDIRS += modules +SUBDIRS += extensions +SUBDIRS += tools +SUBDIRS += help +SUBDIRS += doc -SUBDIRS += tools \ - help \ - doc \ - ssld \ - wsockd \ - authd \ - bandb \ - modules \ - extensions \ - charybdis - -logdir = @prefix@/var/log - -install-data-hook: - test -d ${DESTDIR}${logdir} || mkdir -p ${DESTDIR}${logdir} mrproper-local: rm -f aclocal.m4 @@ -39,6 +34,8 @@ mrproper-local: rm -f ylwrap rm -f */Makefile rm -f */Makefile.in + rm -f include/*/Makefile + rm -f include/*/Makefile.in rm -rf */.deps rm -f Makefile rm -f Makefile.in diff --git a/authd/Makefile.am b/authd/Makefile.am index cd66d96e2..0fbe5a282 100644 --- a/authd/Makefile.am +++ b/authd/Makefile.am @@ -1,23 +1,27 @@ bin_PROGRAMS = authd -AM_CFLAGS=$(WARNFLAGS) -AM_CPPFLAGS = -I$(top_srcdir)/include + +AM_CPPFLAGS = $(WARNFLAGS) +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -isystem $(top_srcdir)/boost/include +AM_LDFLAGS = -L$(top_srcdir)/boost/lib authd_SOURCES = \ - authd.c \ - dns.c \ - getaddrinfo.c \ - getnameinfo.c \ - notice.c \ - provider.c \ - res.c \ - reslib.c \ - reslist.c \ - providers/blacklist.c \ - providers/ident.c \ - providers/rdns.c \ - providers/opm.c + authd.cc \ + dns.cc \ + getaddrinfo.cc \ + getnameinfo.cc \ + notice.cc \ + provider.cc \ + res.cc \ + reslib.cc \ + reslist.cc \ + providers/blacklist.cc \ + providers/ident.cc \ + providers/rdns.cc \ + providers/opm.cc authd_LDADD = $(top_srcdir)/rb/librb.la +authd_LDADD += -lboost_system mrproper-local: rm -rf providers/.deps diff --git a/authd/authd.c b/authd/authd.cc similarity index 85% rename from authd/authd.c rename to authd/authd.cc index 974b6a020..050175644 100644 --- a/authd/authd.c +++ b/authd/authd.cc @@ -31,22 +31,31 @@ static void handle_stat(int parc, char *parv[]); static void handle_options(int parc, char *parv[]); rb_helper *authd_helper = NULL; -authd_cmd_handler authd_cmd_handlers[256] = { - ['C'] = handle_new_connection, - ['D'] = handle_resolve_dns, - ['E'] = handle_cancel_connection, - ['O'] = handle_options, - ['R'] = handle_reload, - ['S'] = handle_stat, -}; +std::array authd_cmd_handlers +{[]{ + std::array ret; + ret['C'] = handle_new_connection; + ret['D'] = handle_resolve_dns; + ret['E'] = handle_cancel_connection; + ret['O'] = handle_options; + ret['R'] = handle_reload; + ret['S'] = handle_stat; + return ret; +}()}; -authd_stat_handler authd_stat_handlers[256] = { - ['D'] = enumerate_nameservers, -}; +std::array authd_stat_handlers +{[]{ + std::array ret; + ret['D'] = enumerate_nameservers; + return ret; +}()}; -authd_reload_handler authd_reload_handlers[256] = { - ['D'] = reload_nameservers, -}; +std::array authd_reload_handlers +{[]{ + std::array ret; + ret['D'] = reload_nameservers; + return ret; +}()}; rb_dictionary *authd_option_handlers; @@ -85,7 +94,7 @@ handle_options(int parc, char *parv[]) return; } - if((handler = rb_dictionary_retrieve(authd_option_handlers, parv[1])) == NULL) + if((handler = (auth_opts_handler *)rb_dictionary_retrieve(authd_option_handlers, parv[1])) == NULL) { warn_opers(L_CRIT, "BUG: handle_options got a bad option type %s", parv[1]); return; @@ -203,7 +212,7 @@ main(int argc, char *argv[]) rb_set_time(); setup_signals(); - authd_option_handlers = rb_dictionary_create("authd options handlers", rb_strcasecmp); + authd_option_handlers = rb_dictionary_create("authd options handlers", reinterpret_cast(rb_strcasecmp)); init_resolver(); init_providers(); diff --git a/authd/authd.h b/authd/authd.h index 9ac3c179c..8d7c25dcb 100644 --- a/authd/authd.h +++ b/authd/authd.h @@ -45,9 +45,9 @@ typedef void (*authd_cmd_handler)(int parc, char *parv[]); typedef void (*authd_stat_handler)(uint32_t rid, const char letter); typedef void (*authd_reload_handler)(const char letter); -extern authd_cmd_handler authd_cmd_handlers[256]; -extern authd_stat_handler authd_stat_handlers[256]; -extern authd_reload_handler authd_reload_handlers[256]; +extern std::array authd_cmd_handlers; +extern std::array authd_stat_handlers; +extern std::array authd_reload_handlers; extern rb_dictionary *authd_option_handlers; diff --git a/authd/dns.c b/authd/dns.cc similarity index 93% rename from authd/dns.c rename to authd/dns.cc index b251dd636..d283cacc3 100644 --- a/authd/dns.c +++ b/authd/dns.cc @@ -35,7 +35,7 @@ uint64_t query_count = 0; struct dns_query * lookup_ip(const char *host, int aftype, DNSCB callback, void *data) { - struct dns_query *query = rb_malloc(sizeof(struct dns_query)); + struct dns_query *query = (dns_query *)rb_malloc(sizeof(struct dns_query)); int g_type; if(aftype == AF_INET) @@ -72,7 +72,7 @@ lookup_ip(const char *host, int aftype, DNSCB callback, void *data) struct dns_query * lookup_hostname(const char *ip, DNSCB callback, void *data) { - struct dns_query *query = rb_malloc(sizeof(struct dns_query)); + struct dns_query *query = (dns_query *)rb_malloc(sizeof(struct dns_query)); int aftype; if(!rb_inet_pton_sock(ip, (struct sockaddr *)&query->addr)) @@ -111,14 +111,15 @@ lookup_hostname(const char *ip, DNSCB callback, void *data) void cancel_query(struct dns_query *query) { - query->callback = query->data = NULL; + query->callback = NULL; + query->data = NULL; } /* Callback from gethost_byname_type */ static void handle_lookup_ip_reply(void *data, struct DNSReply *reply) { - struct dns_query *query = data; + struct dns_query *query = (dns_query *)data; char ip[HOSTIPLEN] = "*"; if(query == NULL) @@ -167,7 +168,7 @@ end: static void handle_lookup_hostname_reply(void *data, struct DNSReply *reply) { - struct dns_query *query = data; + struct dns_query *query = (dns_query *)data; char *hostname = NULL; if(query == NULL) @@ -217,7 +218,7 @@ end: static void submit_dns_answer(const char *reply, bool status, query_type type, void *data) { - char *id = data; + char *id = (char *)data; if(!id || type == QUERY_INVALID) { @@ -252,14 +253,14 @@ handle_resolve_dns(int parc, char *parv[]) #endif case '4': if(!lookup_ip(record, aftype, submit_dns_answer, id)) - submit_dns_answer(NULL, false, qtype, NULL); + submit_dns_answer(NULL, false, query_type(qtype), NULL); break; #ifdef RB_IPV6 case 'S': #endif case 'R': if(!lookup_hostname(record, submit_dns_answer, id)) - submit_dns_answer(NULL, false, qtype, NULL); + submit_dns_answer(NULL, false, query_type(qtype), NULL); break; default: warn_opers(L_CRIT, "DNS: handle_resolve_dns got an unknown query: %c", qtype); diff --git a/authd/getaddrinfo.c b/authd/getaddrinfo.cc similarity index 100% rename from authd/getaddrinfo.c rename to authd/getaddrinfo.cc diff --git a/authd/getnameinfo.c b/authd/getnameinfo.cc similarity index 100% rename from authd/getnameinfo.c rename to authd/getnameinfo.cc diff --git a/authd/notice.c b/authd/notice.cc similarity index 100% rename from authd/notice.c rename to authd/notice.cc diff --git a/authd/provider.c b/authd/provider.cc similarity index 93% rename from authd/provider.c rename to authd/provider.cc index ce412a0f2..24209bb82 100644 --- a/authd/provider.c +++ b/authd/provider.cc @@ -82,8 +82,10 @@ destroy_providers(void) struct auth_client *auth; /* Cancel outstanding connections */ - RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, auth_clients) { + auth = (auth_client *)elem; auth_client_ref(auth); /* TBD - is this the right thing? */ @@ -95,7 +97,7 @@ destroy_providers(void) RB_DLINK_FOREACH_SAFE(ptr, nptr, auth_providers.head) { - struct auth_provider *provider = ptr->data; + struct auth_provider *provider = (auth_provider *)ptr->data; if(provider->destroy) provider->destroy(); @@ -192,7 +194,7 @@ cancel_providers(struct auth_client *auth) RB_DLINK_FOREACH(ptr, auth_providers.head) { - struct auth_provider *provider = ptr->data; + struct auth_provider *provider = (auth_provider *)ptr->data; if(provider->cancel != NULL && is_provider_running(auth, provider->id)) /* Cancel if required */ @@ -222,7 +224,7 @@ provider_done(struct auth_client *auth, uint32_t id) RB_DLINK_FOREACH(ptr, auth_providers.head) { - struct auth_provider *provider = ptr->data; + struct auth_provider *provider = (auth_provider *)ptr->data; if(provider->completed != NULL && is_provider_running(auth, provider->id)) /* Notify pending clients who asked for it */ @@ -275,7 +277,7 @@ start_auth(const char *cid, const char *l_ip, const char *l_port, const char *c_ if(lcid == 0 || lcid > UINT32_MAX) return; - auth = rb_malloc(sizeof(struct auth_client)); + auth = (auth_client *)rb_malloc(sizeof(struct auth_client)); auth_client_ref(auth); auth->cid = (uint32_t)lcid; @@ -300,12 +302,12 @@ start_auth(const char *cid, const char *l_ip, const char *l_port, const char *c_ rb_strlcpy(auth->hostname, "*", sizeof(auth->hostname)); rb_strlcpy(auth->username, "*", sizeof(auth->username)); - auth->data = rb_malloc(allocated_pids * sizeof(struct auth_client_data)); + auth->data = (auth_client_data *)rb_malloc(allocated_pids * sizeof(struct auth_client_data)); auth->providers_starting = true; RB_DLINK_FOREACH(ptr, auth_providers.head) { - struct auth_provider *provider = ptr->data; + struct auth_provider *provider = (auth_provider *)ptr->data; auth->data[provider->id].provider = provider; @@ -361,7 +363,7 @@ handle_cancel_connection(int parc, char *parv[]) exit(EX_PROVIDER_ERROR); } - if((auth = rb_dictionary_retrieve(auth_clients, RB_UINT_TO_POINTER((uint32_t)lcid))) == NULL) + if((auth = (auth_client *)rb_dictionary_retrieve(auth_clients, RB_UINT_TO_POINTER((uint32_t)lcid))) == NULL) { /* This could happen as a race if we've accepted/rejected but they cancel, so don't die here. * --Elizafox */ @@ -380,15 +382,17 @@ provider_timeout_event(void *notused __unused) rb_dictionary_iter iter; const time_t curtime = rb_current_time(); - RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, auth_clients) { rb_dlink_node *ptr; + auth = (auth_client *)elem; auth_client_ref(auth); RB_DLINK_FOREACH(ptr, auth_providers.head) { - struct auth_provider *provider = ptr->data; + struct auth_provider *provider = (auth_provider *)ptr->data; const time_t timeout = get_provider_timeout(auth, provider->id); if(is_provider_running(auth, provider->id) && provider->timeout != NULL && diff --git a/authd/provider.h b/authd/provider.h index 97af1361d..3407d41a4 100644 --- a/authd/provider.h +++ b/authd/provider.h @@ -145,7 +145,7 @@ find_provider(const char *name) RB_DLINK_FOREACH(ptr, auth_providers.head) { - struct auth_provider *provider = ptr->data; + struct auth_provider *provider = (auth_provider *)ptr->data; if(strcasecmp(provider->name, name) == 0) return provider; diff --git a/authd/providers/blacklist.c b/authd/providers/blacklist.cc similarity index 90% rename from authd/providers/blacklist.c rename to authd/providers/blacklist.cc index 7dcb7fee9..6df5f44ff 100644 --- a/authd/providers/blacklist.c +++ b/authd/providers/blacklist.cc @@ -62,7 +62,7 @@ struct blacklist uint8_t iptype; /* IP types supported */ rb_dlink_list filters; /* Filters for queries */ - bool delete; /* If true delete when no clients */ + bool delete_; /* If true delete when no clients */ int refcount; /* When 0 and delete is set, remove this blacklist */ unsigned int hits; @@ -123,7 +123,7 @@ unref_blacklist(struct blacklist *bl) rb_dlink_node *ptr, *nptr; bl->refcount--; - if (bl->delete && bl->refcount <= 0) + if (bl->delete_ && bl->refcount <= 0) { RB_DLINK_FOREACH_SAFE(ptr, nptr, bl->filters.head) { @@ -146,11 +146,11 @@ new_blacklist(const char *name, const char *reason, uint8_t iptype, rb_dlink_lis if((bl = find_blacklist(name)) == NULL) { - bl = rb_malloc(sizeof(struct blacklist)); + bl = (blacklist *)rb_malloc(sizeof(struct blacklist)); rb_dlinkAddAlloc(bl, &blacklist_list); } else - bl->delete = false; + bl->delete_ = false; rb_strlcpy(bl->host, name, IRCD_RES_HOSTLEN + 1); rb_strlcpy(bl->reason, reason, BUFSIZE); @@ -196,7 +196,7 @@ blacklist_check_reply(struct blacklist_lookup *bllookup, const char *ipaddr) RB_DLINK_FOREACH(ptr, bl->filters.head) { - struct blacklist_filter *filter = ptr->data; + struct blacklist_filter *filter = (blacklist_filter *)ptr->data; const char *cmpstr; if (filter->type == FILTER_ALL) @@ -241,7 +241,7 @@ blacklist_dns_callback(const char *result, bool status, query_type type, void *d bl = bllookup->bl; auth = bllookup->auth; - if((bluser = get_provider_data(auth, SELF_PID)) == NULL) + if((bluser = (blacklist_user *)get_provider_data(auth, SELF_PID)) == NULL) return; if (result != NULL && status && blacklist_check_reply(bllookup, result)) @@ -275,8 +275,8 @@ blacklist_dns_callback(const char *result, bool status, query_type type, void *d static void initiate_blacklist_dnsquery(struct blacklist *bl, struct auth_client *auth) { - struct blacklist_lookup *bllookup = rb_malloc(sizeof(struct blacklist_lookup)); - struct blacklist_user *bluser = get_provider_data(auth, SELF_PID); + struct blacklist_lookup *bllookup = (blacklist_lookup *)rb_malloc(sizeof(struct blacklist_lookup)); + struct blacklist_user *bluser = (blacklist_user *)get_provider_data(auth, SELF_PID); char buf[IRCD_RES_HOSTLEN + 1]; int aftype; @@ -302,7 +302,7 @@ initiate_blacklist_dnsquery(struct blacklist *bl, struct auth_client *auth) static inline bool lookup_all_blacklists(struct auth_client *auth) { - struct blacklist_user *bluser = get_provider_data(auth, SELF_PID); + struct blacklist_user *bluser = (blacklist_user *)get_provider_data(auth, SELF_PID); rb_dlink_node *ptr; int iptype; @@ -323,7 +323,7 @@ lookup_all_blacklists(struct auth_client *auth) { struct blacklist *bl = (struct blacklist *)ptr->data; - if (!bl->delete && (bl->iptype & iptype)) + if (!bl->delete_ && (bl->iptype & iptype)) initiate_blacklist_dnsquery(bl, auth); } @@ -340,7 +340,7 @@ static inline void delete_blacklist(struct blacklist *bl) { if (bl->refcount > 0) - bl->delete = true; + bl->delete_ = true; else { rb_dlinkFindDestroy(bl, &blacklist_list); @@ -355,7 +355,7 @@ delete_all_blacklists(void) RB_DLINK_FOREACH_SAFE(ptr, nptr, blacklist_list.head) { - delete_blacklist(ptr->data); + delete_blacklist((blacklist *)ptr->data); } } @@ -394,7 +394,7 @@ blacklists_start(struct auth_client *auth) static void blacklists_initiate(struct auth_client *auth, uint32_t provider) { - struct blacklist_user *bluser = get_provider_data(auth, SELF_PID); + struct blacklist_user *bluser = (blacklist_user *)get_provider_data(auth, SELF_PID); uint32_t rdns_pid, ident_pid; lrb_assert(provider != SELF_PID); @@ -421,7 +421,7 @@ static inline void blacklists_generic_cancel(struct auth_client *auth, const char *message) { rb_dlink_node *ptr, *nptr; - struct blacklist_user *bluser = get_provider_data(auth, SELF_PID); + struct blacklist_user *bluser = (blacklist_user *)get_provider_data(auth, SELF_PID); if(bluser == NULL) return; @@ -432,7 +432,7 @@ blacklists_generic_cancel(struct auth_client *auth, const char *message) RB_DLINK_FOREACH_SAFE(ptr, nptr, bluser->queries.head) { - struct blacklist_lookup *bllookup = ptr->data; + struct blacklist_lookup *bllookup = (blacklist_lookup *)ptr->data; cancel_query(bllookup->query); unref_blacklist(bllookup->bl); @@ -474,8 +474,10 @@ blacklists_destroy(void) rb_dictionary_iter iter; struct auth_client *auth; - RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, auth_clients) { + auth = (auth_client *)elem; blacklists_cancel(auth); /* auth is now invalid as we have no reference */ } @@ -495,7 +497,7 @@ add_conf_blacklist(const char *key, int parc, const char **parv) for(char *elem = rb_strtok_r(elemlist, ",", &tmp); elem; elem = rb_strtok_r(NULL, ",", &tmp)) { - struct blacklist_filter *filter = rb_malloc(sizeof(struct blacklist_filter)); + struct blacklist_filter *filter = (blacklist_filter *)rb_malloc(sizeof(struct blacklist_filter)); int dot_c = 0; filter_t type = FILTER_LAST; @@ -584,7 +586,7 @@ blacklist_stats(uint32_t rid, char letter) RB_DLINK_FOREACH(ptr, blacklist_list.head) { - struct blacklist *bl = ptr->data; + struct blacklist *bl = (blacklist *)ptr->data; if(bl->delete) continue; @@ -606,14 +608,16 @@ struct auth_opts_handler blacklist_options[] = }; struct auth_provider blacklist_provider = -{ - .name = "blacklist", - .letter = 'B', - .destroy = blacklists_destroy, - .start = blacklists_start, - .cancel = blacklists_cancel, - .timeout = blacklists_timeout, - .completed = blacklists_initiate, - .opt_handlers = blacklist_options, +{[]{ + auth_provider ret {0}; + ret.name = "blacklist"; + ret.letter = 'B'; + ret.destroy = blacklists_destroy; + ret.start = blacklists_start; + ret.cancel = blacklists_cancel; + ret.timeout = blacklists_timeout; + ret.completed = blacklists_initiate; + ret.opt_handlers = blacklist_options; /* .stats_handler = { 'B', blacklist_stats }, */ -}; + return ret; +}()}; diff --git a/authd/providers/ident.c b/authd/providers/ident.cc similarity index 90% rename from authd/providers/ident.c rename to authd/providers/ident.cc index 8b2bedf68..885593326 100644 --- a/authd/providers/ident.c +++ b/authd/providers/ident.cc @@ -84,13 +84,13 @@ static bool ident_enable = true; static void ident_connected(rb_fde_t *F __unused, int error, void *data) { - struct auth_client *auth = data; + struct auth_client *auth = (auth_client *)data; struct ident_query *query; char authbuf[32]; int authlen; lrb_assert(auth != NULL); - query = get_provider_data(auth, SELF_PID); + query = (ident_query *)get_provider_data(auth, SELF_PID); lrb_assert(query != NULL); /* Check the error */ @@ -117,7 +117,7 @@ ident_connected(rb_fde_t *F __unused, int error, void *data) static void read_ident_reply(rb_fde_t *F, void *data) { - struct auth_client *auth = data; + struct auth_client *auth = (auth_client *)data; struct ident_query *query; char buf[IDENT_BUFSIZE + 1]; /* buffer to read auth reply into */ ident_message message = REPORT_FAIL; @@ -127,7 +127,7 @@ read_ident_reply(rb_fde_t *F, void *data) int count; lrb_assert(auth != NULL); - query = get_provider_data(auth, SELF_PID); + query = (ident_query *)get_provider_data(auth, SELF_PID); lrb_assert(query != NULL); len = rb_read(F, buf, IDENT_BUFSIZE); @@ -172,7 +172,7 @@ read_ident_reply(rb_fde_t *F, void *data) static void client_fail(struct auth_client *auth, ident_message report) { - struct ident_query *query = get_provider_data(auth, SELF_PID); + struct ident_query *query = (ident_query *)get_provider_data(auth, SELF_PID); lrb_assert(query != NULL); @@ -194,7 +194,7 @@ client_fail(struct auth_client *auth, ident_message report) static void client_success(struct auth_client *auth) { - struct ident_query *query = get_provider_data(auth, SELF_PID); + struct ident_query *query = (ident_query *)get_provider_data(auth, SELF_PID); lrb_assert(query != NULL); @@ -282,8 +282,10 @@ ident_destroy(void) rb_dictionary_iter iter; /* Nuke all ident queries */ - RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, auth_clients) { + auth = (auth_client *)elem; if(get_provider_data(auth, SELF_PID) != NULL) client_fail(auth, REPORT_FAIL); /* auth is now invalid as we have no reference */ @@ -293,7 +295,7 @@ ident_destroy(void) static bool ident_start(struct auth_client *auth) { - struct ident_query *query = rb_malloc(sizeof(struct ident_query)); + struct ident_query *query = (ident_query *)rb_malloc(sizeof(struct ident_query)); struct rb_sockaddr_storage l_addr, c_addr; int family = GET_SS_FAMILY(&auth->c_addr); @@ -341,7 +343,7 @@ ident_start(struct auth_client *auth) static void ident_cancel(struct auth_client *auth) { - struct ident_query *query = get_provider_data(auth, SELF_PID); + struct ident_query *query = (ident_query *)get_provider_data(auth, SELF_PID); if(query != NULL) client_fail(auth, REPORT_FAIL); @@ -375,13 +377,15 @@ struct auth_opts_handler ident_options[] = }; -struct auth_provider ident_provider = -{ - .name = "ident", - .letter = 'I', - .start = ident_start, - .destroy = ident_destroy, - .cancel = ident_cancel, - .timeout = ident_cancel, - .opt_handlers = ident_options, -}; +struct auth_provider ident_provider +{[]{ + auth_provider ap {0}; + ap.name = "ident"; + ap.letter = 'I'; + ap.start = ident_start; + ap.destroy = ident_destroy; + ap.cancel = ident_cancel; + ap.timeout = ident_cancel; + ap.opt_handlers = ident_options; + return ap; +}()}; diff --git a/authd/providers/opm.c b/authd/providers/opm.cc similarity index 90% rename from authd/providers/opm.c rename to authd/providers/opm.cc index b98124459..c8f4a1cac 100644 --- a/authd/providers/opm.c +++ b/authd/providers/opm.cc @@ -127,7 +127,7 @@ find_proxy_scanner(protocol_t proto, uint16_t port) RB_DLINK_FOREACH(ptr, proxy_scanners.head) { - struct opm_proxy *proxy = ptr->data; + struct opm_proxy *proxy = (opm_proxy *)ptr->data; if(proxy->proto == proto && proxy->port == port) return proxy; @@ -141,13 +141,13 @@ static void read_opm_reply(rb_fde_t *F, void *data) { rb_dlink_node *ptr; - struct auth_client *auth = data; + struct auth_client *auth = (auth_client *)data; struct opm_lookup *lookup; char readbuf[OPM_READSIZE]; ssize_t len; lrb_assert(auth != NULL); - lookup = get_provider_data(auth, SELF_PID); + lookup = (opm_lookup *)get_provider_data(auth, SELF_PID); lrb_assert(lookup != NULL); if((len = rb_read(F, readbuf, sizeof(readbuf))) < 0 && rb_ignore_errno(errno)) @@ -164,7 +164,7 @@ read_opm_reply(rb_fde_t *F, void *data) RB_DLINK_FOREACH(ptr, proxy_scanners.head) { - struct opm_proxy *proxy = ptr->data; + struct opm_proxy *proxy = (opm_proxy *)ptr->data; if(strncmp(proxy->note, readbuf, strlen(proxy->note)) == 0) { @@ -173,7 +173,7 @@ read_opm_reply(rb_fde_t *F, void *data) /* Cancel outstanding lookups */ RB_DLINK_FOREACH_SAFE(ptr, nptr, lookup->scans.head) { - struct opm_scan *scan = ptr->data; + struct opm_scan *scan = (opm_scan *)ptr->data; rb_close(scan->F); rb_free(scan); @@ -194,7 +194,7 @@ static void accept_opm(rb_fde_t *F, int status, struct sockaddr *addr, rb_socklen_t len, void *data) { struct auth_client *auth = NULL; - struct opm_listener *listener = data; + struct opm_listener *listener = (opm_listener *)data; struct rb_sockaddr_storage localaddr; unsigned int llen = sizeof(struct rb_sockaddr_storage); rb_dictionary_iter iter; @@ -213,8 +213,10 @@ accept_opm(rb_fde_t *F, int status, struct sockaddr *addr, rb_socklen_t len, voi } /* Correlate connection with client(s) */ - RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, auth_clients) { + auth = (auth_client *)elem; if(GET_SS_FAMILY(&auth->c_addr) != GET_SS_FAMILY(&localaddr)) continue; @@ -261,10 +263,10 @@ accept_opm(rb_fde_t *F, int status, struct sockaddr *addr, rb_socklen_t len, voi static void opm_connected(rb_fde_t *F, int error, void *data) { - struct opm_scan *scan = data; + struct opm_scan *scan = (opm_scan *)data; struct opm_proxy *proxy = scan->proxy; struct auth_client *auth = scan->auth; - struct opm_lookup *lookup = get_provider_data(auth, SELF_PID); + struct opm_lookup *lookup = (opm_lookup *)get_provider_data(auth, SELF_PID); if(error || !opm_enable) { @@ -308,7 +310,7 @@ static void socks4_connected(struct opm_scan *scan) { struct auth_client *auth = scan->auth; - struct opm_lookup *lookup = get_provider_data(auth, SELF_PID); + struct opm_lookup *lookup = (opm_lookup *)get_provider_data(auth, SELF_PID); uint8_t sendbuf[9]; /* Size we're building */ uint8_t *c = sendbuf; @@ -330,12 +332,12 @@ static void socks5_connected(struct opm_scan *scan) { struct auth_client *auth = scan->auth; - struct opm_lookup *lookup = get_provider_data(auth, SELF_PID); + struct opm_lookup *lookup = (opm_lookup *)get_provider_data(auth, SELF_PID); uint8_t sendbuf[25]; /* Size we're building */ uint8_t *c = sendbuf; auth = scan->auth; - lookup = get_provider_data(auth, SELF_PID); + lookup = (opm_lookup *)get_provider_data(auth, SELF_PID); /* Build the version header and socks request * version header (3 bytes): version, number of auth methods, auth type (0 for none) @@ -374,7 +376,7 @@ static void http_connect_connected(struct opm_scan *scan) { struct auth_client *auth = scan->auth; - struct opm_lookup *lookup = get_provider_data(auth, SELF_PID); + struct opm_lookup *lookup = (opm_lookup *)get_provider_data(auth, SELF_PID); char sendbuf[128]; /* A bit bigger than we need but better safe than sorry */ char *c = sendbuf; @@ -398,8 +400,8 @@ http_connect_connected(struct opm_scan *scan) static inline void establish_connection(struct auth_client *auth, struct opm_proxy *proxy) { - struct opm_lookup *lookup = get_provider_data(auth, SELF_PID); - struct opm_scan *scan = rb_malloc(sizeof(struct opm_scan)); + struct opm_lookup *lookup = (opm_lookup *)get_provider_data(auth, SELF_PID); + struct opm_scan *scan = (opm_scan *)rb_malloc(sizeof(struct opm_scan)); struct opm_listener *listener; struct rb_sockaddr_storage c_a, l_a; int opt = 1; @@ -557,8 +559,10 @@ create_listener(const char *ip, uint16_t port) /* Cancel clients that may be on old listener * XXX - should rescan clients that need it */ - RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, auth_clients) { + auth = (auth_client *)elem; opm_cancel(auth); /* auth is now invalid as we have no reference */ } @@ -581,14 +585,14 @@ opm_scan(struct auth_client *auth) lrb_assert(auth != NULL); - lookup = get_provider_data(auth, SELF_PID); + lookup = (opm_lookup *)get_provider_data(auth, SELF_PID); set_provider_timeout_relative(auth, SELF_PID, opm_timeout); lookup->in_progress = true; RB_DLINK_FOREACH(ptr, proxy_scanners.head) { - struct opm_proxy *proxy = ptr->data; + struct opm_proxy *proxy = (opm_proxy *)ptr->data; //notice_client(auth->cid, "*** Scanning for proxy type %s", proxy->note); establish_connection(auth, proxy); } @@ -600,7 +604,7 @@ opm_scan(struct auth_client *auth) static void opm_initiate(struct auth_client *auth, uint32_t provider) { - struct opm_lookup *lookup = get_provider_data(auth, SELF_PID); + struct opm_lookup *lookup = (opm_lookup *)get_provider_data(auth, SELF_PID); uint32_t rdns_pid, ident_pid; lrb_assert(provider != SELF_PID); @@ -647,7 +651,7 @@ opm_start(struct auth_client *auth) static void opm_cancel(struct auth_client *auth) { - struct opm_lookup *lookup = get_provider_data(auth, SELF_PID); + struct opm_lookup *lookup = (opm_lookup *)get_provider_data(auth, SELF_PID); if(lookup != NULL) { @@ -657,7 +661,7 @@ opm_cancel(struct auth_client *auth) RB_DLINK_FOREACH_SAFE(ptr, nptr, lookup->scans.head) { - struct opm_scan *scan = ptr->data; + struct opm_scan *scan = (struct opm_scan *)ptr->data; rb_close(scan->F); rb_free(scan); @@ -680,8 +684,10 @@ opm_destroy(void) rb_dictionary_iter iter; /* Nuke all opm lookups */ - RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, auth_clients) { + auth = (auth_client *)elem; opm_cancel(auth); /* auth is now invalid as we have no reference */ } @@ -723,8 +729,10 @@ set_opm_enabled(const char *key __unused, int parc __unused, const char **parv) listeners[LISTEN_IPV4].F = listeners[LISTEN_IPV6].F = NULL; - RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, auth_clients) { + auth = (auth_client *)elem; opm_cancel(auth); /* auth is now invalid as we have no reference */ } @@ -769,7 +777,7 @@ static void create_opm_scanner(const char *key __unused, int parc __unused, const char **parv) { int iport = atoi(parv[1]); - struct opm_proxy *proxy = rb_malloc(sizeof(struct opm_proxy)); + struct opm_proxy *proxy = (opm_proxy *)rb_malloc(sizeof(struct opm_proxy)); if(iport <= 0 || iport > 65535) { @@ -843,10 +851,12 @@ delete_opm_scanner(const char *key __unused, int parc __unused, const char **par } /* Abort remaining clients on this scanner */ - RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, auth_clients) { rb_dlink_node *ptr; - struct opm_lookup *lookup = get_provider_data(auth, SELF_PID); + auth = (auth_client *)elem; + struct opm_lookup *lookup = (opm_lookup *)get_provider_data(auth, SELF_PID); if(lookup == NULL) continue; @@ -855,7 +865,7 @@ delete_opm_scanner(const char *key __unused, int parc __unused, const char **par RB_DLINK_FOREACH(ptr, lookup->scans.head) { - struct opm_scan *scan = ptr->data; + struct opm_scan *scan = (struct opm_scan *)ptr->data; if(scan->proxy->port == proxy->port && scan->proxy->proto == proxy->proto) { @@ -893,8 +903,10 @@ delete_opm_scanner_all(const char *key __unused, int parc __unused, const char * rb_dlinkDelete(ptr, &proxy_scanners); } - RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, auth_clients) { + auth = (auth_client *)elem; opm_cancel(auth); /* auth is now invalid as we have no reference */ } @@ -929,14 +941,16 @@ struct auth_opts_handler opm_options[] = { NULL, 0, NULL }, }; -struct auth_provider opm_provider = -{ - .name = "opm", - .letter = 'O', - .destroy = opm_destroy, - .start = opm_start, - .cancel = opm_cancel, - .timeout = opm_cancel, - .completed = opm_initiate, - .opt_handlers = opm_options, -}; +struct auth_provider opm_provider +{[]{ + auth_provider ap {0}; + ap.name = "opm"; + ap.letter = 'O'; + ap.destroy = opm_destroy; + ap.start = opm_start; + ap.cancel = opm_cancel; + ap.timeout = opm_cancel; + ap.completed = opm_initiate; + ap.opt_handlers = opm_options; + return ap; +}()}; diff --git a/authd/providers/rdns.c b/authd/providers/rdns.cc similarity index 83% rename from authd/providers/rdns.c rename to authd/providers/rdns.cc index 5ac03511d..dd58990ed 100644 --- a/authd/providers/rdns.c +++ b/authd/providers/rdns.cc @@ -56,8 +56,8 @@ static int rdns_timeout = RDNS_TIMEOUT_DEFAULT; static void dns_answer_callback(const char *res, bool status, query_type type, void *data) { - struct auth_client *auth = data; - struct user_query *query = get_provider_data(auth, SELF_PID); + struct auth_client *auth = (auth_client *)data; + struct user_query *query = (user_query *)get_provider_data(auth, SELF_PID); lrb_assert(query != NULL); @@ -75,7 +75,7 @@ dns_answer_callback(const char *res, bool status, query_type type, void *data) static void client_fail(struct auth_client *auth, dns_message report) { - struct user_query *query = get_provider_data(auth, SELF_PID); + struct user_query *query = (user_query *)get_provider_data(auth, SELF_PID); lrb_assert(query != NULL); @@ -96,7 +96,7 @@ client_fail(struct auth_client *auth, dns_message report) static void client_success(struct auth_client *auth) { - struct user_query *query = get_provider_data(auth, SELF_PID); + struct user_query *query = (user_query *)get_provider_data(auth, SELF_PID); lrb_assert(query != NULL); @@ -118,8 +118,10 @@ rdns_destroy(void) struct auth_client *auth; rb_dictionary_iter iter; - RB_DICTIONARY_FOREACH(auth, &iter, auth_clients) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, auth_clients) { + auth = (auth_client *)elem; if(get_provider_data(auth, SELF_PID) != NULL) client_fail(auth, REPORT_FAIL); /* auth is now invalid as we have no reference */ @@ -129,7 +131,7 @@ rdns_destroy(void) static bool rdns_start(struct auth_client *auth) { - struct user_query *query = rb_malloc(sizeof(struct user_query)); + struct user_query *query = (user_query *)rb_malloc(sizeof(struct user_query)); auth_client_ref(auth); @@ -146,7 +148,7 @@ rdns_start(struct auth_client *auth) static void rdns_cancel(struct auth_client *auth) { - struct user_query *query = get_provider_data(auth, SELF_PID); + struct user_query *query = (user_query *)get_provider_data(auth, SELF_PID); if(query != NULL) client_fail(auth, REPORT_FAIL); @@ -172,13 +174,15 @@ struct auth_opts_handler rdns_options[] = { NULL, 0, NULL }, }; -struct auth_provider rdns_provider = -{ - .name = "rdns", - .letter = 'R', - .destroy = rdns_destroy, - .start = rdns_start, - .cancel = rdns_cancel, - .timeout = rdns_cancel, - .opt_handlers = rdns_options, -}; +struct auth_provider rdns_provider +{[]{ + auth_provider ap {0}; + ap.name = "rdns"; + ap.letter = 'R'; + ap.destroy = rdns_destroy; + ap.start = rdns_start; + ap.cancel = rdns_cancel; + ap.timeout = rdns_cancel; + ap.opt_handlers = rdns_options; + return ap; +}()}; diff --git a/authd/res.c b/authd/res.cc similarity index 99% rename from authd/res.c rename to authd/res.cc index f39507436..70efbe57e 100644 --- a/authd/res.c +++ b/authd/res.cc @@ -172,7 +172,7 @@ static time_t timeout_query_list(time_t now) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, request_list.head) { - request = ptr->data; + request = (reslist *)ptr->data; timeout = request->sentat + request->timeout; if (now >= timeout) @@ -287,7 +287,7 @@ static void rem_request(struct reslist *request) */ static struct reslist *make_request(struct DNSQuery *query) { - struct reslist *request = rb_malloc(sizeof(struct reslist)); + struct reslist *request = (reslist *)rb_malloc(sizeof(struct reslist)); request->sentat = rb_current_time(); request->retries = 3; @@ -386,7 +386,7 @@ static struct reslist *find_id(int id) RB_DLINK_FOREACH(ptr, request_list.head) { - request = ptr->data; + request = (reslist *)ptr->data; if (request->id == id) return (request); diff --git a/authd/reslib.c b/authd/reslib.cc similarity index 98% rename from authd/reslib.c rename to authd/reslib.cc index c33ae9d68..e52e795ed 100644 --- a/authd/reslib.c +++ b/authd/reslib.cc @@ -744,7 +744,7 @@ irc_ns_name_pton(const char *src, unsigned char *dst, size_t dstsiz) while ((c = *src++) != 0) { if (escaped) { if (c == '[') { /* start a bit string label */ - if ((cp = strchr(src, ']')) == NULL) { + if ((cp = (char *)strchr(src, ']')) == NULL) { errno = EINVAL; /* ??? */ return(-1); } @@ -767,16 +767,16 @@ irc_ns_name_pton(const char *src, unsigned char *dst, size_t dstsiz) } continue; } - else if ((cp = strchr(digits, c)) != NULL) { + else if ((cp = (char *)strchr(digits, c)) != NULL) { n = (cp - digits) * 100; if ((c = *src++) == 0 || - (cp = strchr(digits, c)) == NULL) { + (cp = (char *)strchr(digits, c)) == NULL) { errno = EMSGSIZE; return (-1); } n += (cp - digits) * 10; if ((c = *src++) == 0 || - (cp = strchr(digits, c)) == NULL) { + (cp = (char *)strchr(digits, c)) == NULL) { errno = EMSGSIZE; return (-1); } @@ -1174,7 +1174,7 @@ mklower(int ch) int irc_res_mkquery( const char *dname, /* domain name */ - int class, int type, /* class and type of query */ + int class_, int type, /* class and type of query */ unsigned char *buf, /* buffer to put query */ int buflen) /* size of buffer */ { @@ -1210,7 +1210,7 @@ irc_res_mkquery( cp += n; buflen -= n; IRC_NS_PUT16(type, cp); - IRC_NS_PUT16(class, cp); + IRC_NS_PUT16(class_, cp); hp->qdcount = htons(1); return (cp - buf); diff --git a/authd/reslib.h b/authd/reslib.h index e8917130c..85b7e65c9 100644 --- a/authd/reslib.h +++ b/authd/reslib.h @@ -119,7 +119,7 @@ extern unsigned int irc_ns_get16(const unsigned char *src); extern unsigned long irc_ns_get32(const unsigned char *src); extern void irc_ns_put16(unsigned int src, unsigned char *dst); extern void irc_ns_put32(unsigned long src, unsigned char *dst); -extern int irc_res_mkquery(const char *dname, int class, int type, unsigned char *buf, int buflen); +extern int irc_res_mkquery(const char *dname, int class_, int type, unsigned char *buf, int buflen); extern char irc_domain[IRCD_RES_HOSTLEN + 1]; diff --git a/authd/reslist.c b/authd/reslist.cc similarity index 98% rename from authd/reslist.c rename to authd/reslist.cc index 3df01c814..665fe3aec 100644 --- a/authd/reslist.c +++ b/authd/reslist.cc @@ -50,7 +50,7 @@ const char *get_windows_nameservers(void); static int get_iphlpapi_dns_info(char *ret_buf, size_t ret_size) { - FIXED_INFO *fi = alloca(sizeof(*fi)); + FIXED_INFO *fi = (FIXED_INFO *)alloca(sizeof(*fi)); DWORD size = sizeof(*fi); typedef DWORD(WINAPI * get_net_param_func) (FIXED_INFO *, DWORD *); get_net_param_func xxGetNetworkParams; /* available only on Win-98/2000+ */ @@ -78,7 +78,7 @@ get_iphlpapi_dns_info(char *ret_buf, size_t ret_size) if((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS)) goto quit; - fi = alloca(size); + fi = (FIXED_INFO *)alloca(size); if(!fi || (*xxGetNetworkParams) (fi, &size) != ERROR_SUCCESS) goto quit; @@ -134,7 +134,7 @@ get_res_nt(HKEY hKey, const char *subkey, char **obuf) result = RegQueryValueEx(hKey, subkey, 0, NULL, NULL, &size); if((result != ERROR_SUCCESS && result != ERROR_MORE_DATA) || !size) return 0; - *obuf = rb_malloc(size + 1); + *obuf = (char *)rb_malloc(size + 1); if(!*obuf) return 0; diff --git a/bandb/Makefile.am b/bandb/Makefile.am index 0d305cda9..5b5b205dd 100644 --- a/bandb/Makefile.am +++ b/bandb/Makefile.am @@ -1,15 +1,21 @@ bin_PROGRAMS = bandb bantool -AM_CFLAGS=$(WARNFLAGS) -AM_CPPFLAGS = -I$(top_srcdir)/include @SQLITE_INCLUDES@ +AM_CPPFLAGS = $(WARNFLAGS) +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -isystem $(top_srcdir)/boost/include +AM_CPPFLAGS += @SQLITE_INCLUDES@ AM_CPPFLAGS += -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -bandb_SOURCES = bandb.c rsdb_sqlite3.c rsdb_snprintf.c +AM_LDFLAGS = -L$(top_srcdir)/rb +AM_LDFLAGS += -L$(top_srcdir)/ircd +AM_LDFLAGS += -L$(top_srcdir)/boost/lib + +bandb_SOURCES = bandb.cc rsdb_sqlite3.c rsdb_snprintf.c EXTRA_bandb_SOURCES = sqlite3.c -bandb_LDADD = $(top_srcdir)/rb/librb.la @SQLITE_LD@ @SQLITE_OBJ@ +bandb_LDADD = -lrb @SQLITE_LD@ @SQLITE_OBJ@ -lboost_system bandb_DEPENDENCIES = @SQLITE_OBJ@ -bantool_SOURCES = bantool.c rsdb_sqlite3.c rsdb_snprintf.c +bantool_SOURCES = bantool.cc rsdb_sqlite3.c rsdb_snprintf.c EXTRA_bantool_SOURCES = sqlite3.c -bantool_LDADD = $(top_srcdir)/rb/librb.la @SQLITE_LD@ @SQLITE_OBJ@ +bantool_LDADD = -lrb @SQLITE_LD@ @SQLITE_OBJ@ -lboost_system bantool_DEPENDENCIES = @SQLITE_OBJ@ diff --git a/bandb/bandb.c b/bandb/bandb.cc similarity index 99% rename from bandb/bandb.c rename to bandb/bandb.cc index b17e647c3..8dc6cad55 100644 --- a/bandb/bandb.c +++ b/bandb/bandb.cc @@ -29,7 +29,7 @@ */ #include #include "rsdb.h" -#include +#include #define MAXPARA 10 diff --git a/bandb/bantool.c b/bandb/bantool.cc similarity index 98% rename from bandb/bantool.c rename to bandb/bantool.cc index 2a88c16ee..e3ab83891 100644 --- a/bandb/bantool.c +++ b/bandb/bantool.cc @@ -92,7 +92,7 @@ struct counter struct flags { bool none; - bool export; + bool export_; bool import; bool verify; bool vacuum; @@ -148,7 +148,7 @@ main(int argc, char *argv[]) break; case 'e': flag.none = false; - flag.export = true; + flag.export_ = true; break; case 'u': flag.none = false; @@ -179,11 +179,11 @@ main(int argc, char *argv[]) if(flag.none) print_help(EXIT_FAILURE); - if((flag.import && flag.export) || (flag.export && flag.wipe) - || (flag.verify && flag.pretend) || (flag.export && flag.pretend)) + if((flag.import && flag.export_) || (flag.export_ && flag.wipe) + || (flag.verify && flag.pretend) || (flag.export_ && flag.pretend)) { fprintf(stderr, "* Error: Conflicting flags.\n"); - if(flag.export && flag.pretend) + if(flag.export_ && flag.pretend) fprintf(stderr, "* There is nothing to 'pretend' when exporting.\n"); fprintf(stderr, "* For an explination of commands, run: %s -h\n", me); @@ -239,7 +239,7 @@ main(int argc, char *argv[]) if(flag.import) import_config(conf, i); - if(flag.export) + if(flag.export_) export_config(conf, i); if(flag.import && flag.pretend == false) diff --git a/bandb/rsdb.h b/bandb/rsdb.h index 5b55d5dd6..474fbe315 100644 --- a/bandb/rsdb.h +++ b/bandb/rsdb.h @@ -1,6 +1,10 @@ #ifndef INCLUDED_rsdb_h #define INCLUDED_rsdb_h +#ifdef __cplusplus +extern "C" { +#endif + /* error handler callback */ typedef void rsdb_error_cb(const char *); @@ -37,5 +41,8 @@ void rsdb_transaction(rsdb_transtype type); int rs_vsnprintf(char *dest, const size_t bytes, const char *format, va_list args); int rs_snprintf(char *dest, const size_t bytes, const char *format, ...); +#ifdef __cplusplus +} +#endif #endif diff --git a/boost b/boost new file mode 160000 index 000000000..ea0209516 --- /dev/null +++ b/boost @@ -0,0 +1 @@ +Subproject commit ea0209516426e4b358204b8b50d093d001c00f54 diff --git a/charybdis/Makefile.am b/charybdis/Makefile.am index 3dd0672d2..040d1083c 100644 --- a/charybdis/Makefile.am +++ b/charybdis/Makefile.am @@ -1,5 +1,7 @@ prefix = @prefix@ -AM_CPPFLAGS = @LTDLINCL@ -I$(top_srcdir)/include +AM_CPPFLAGS = @LTDLINCL@ +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -isystem $(top_srcdir)/boost/include if MINGW EXTRA_FLAGS = -Wl,--enable-runtime-pseudo-reloc -export-symbols-regex '*' @@ -7,6 +9,11 @@ endif bin_PROGRAMS = charybdis charybdis_SOURCES = charybdis.cc -charybdis_LDFLAGS = $(EXTRA_FLAGS) -dlopen self -charybdis_LDADD = -L$(top_srcdir)/ircd -lircd -charybdis_LDADD += -L$(top_srcdir)/rb -lrb + +charybdis_LDFLAGS = $(EXTRA_FLAGS) +charybdis_LDFLAGS += -dlopen self +charybdis_LDFLAGS += -L$(top_srcdir)/ircd +charybdis_LDFLAGS += -L$(top_srcdir)/rb +charybdis_LDFLAGS += -L$(top_srcdir)/boost/lib + +charybdis_LDADD = -lircd -lrb -lboost_system diff --git a/charybdis/charybdis.cc b/charybdis/charybdis.cc index 2e4919b18..34173933c 100644 --- a/charybdis/charybdis.cc +++ b/charybdis/charybdis.cc @@ -20,9 +20,10 @@ */ #include +#include -extern "C" int charybdis_main(int argc, char *argv[]); +extern int charybdis_main(int argc, char *const argv[]); int main(int argc, char *argv[]) { diff --git a/configure.ac b/configure.ac index f37ec8931..c0049f56a 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ dnl the most major changes have already been made and it looks like dnl said functions need to be just about as complex as they already are. AC_PREREQ(2.63) -AUTOMAKE_OPTIONS = 1.10 +AUTOMAKE_OPTIONS = 1.14 AC_INIT([charybdis], [5-dev]) AC_CONFIG_MACRO_DIR([m4]) @@ -38,20 +38,22 @@ AC_PATH_PROG(TOUCH, touch) LT_CONFIG_LTDL_DIR([libltdl]) LT_INIT([dlopen disable-static]) +LT_LANG([C++]) LTDL_INIT #LIBTOOL="$LIBTOOL --silent" AC_CONFIG_FILES(\ Makefile \ + include/rb/Makefile \ + rb/Makefile \ authd/Makefile \ - bandb/Makefile \ charybdis/Makefile \ + ircd/Makefile \ + bandb/Makefile \ doc/Makefile \ extensions/Makefile \ help/Makefile \ - ircd/Makefile \ modules/Makefile \ - rb/Makefile \ ssld/Makefile \ tools/Makefile \ tools/genssl \ @@ -59,7 +61,9 @@ AC_CONFIG_FILES(\ ) AM_INIT_AUTOMAKE([subdir-objects]) -AM_EXTRA_RECURSIVE_TARGETS([mrproper]) +AM_EXTRA_RECURSIVE_TARGETS([ + mrproper \ +]) VERSION_CMD="git describe --tags" DATESTR_CMD="date -R" @@ -69,9 +73,14 @@ RB_VERSION=`$VERSION_CMD` RB_DATESTR=`$DATESTR_CMD` RB_DATECODE=`$DATECODE_CMD` -AC_DEFINE_UNQUOTED([RB_VERSION], ["$RB_VERSION"], [Version generated at configuration time.]) -AC_DEFINE_UNQUOTED([RB_DATESTR], ["$RB_DATESTR"], [Readable date string of configuration time.]) -AC_DEFINE_UNQUOTED([RB_DATECODE], [$RB_DATECODE], [UNIX epoch time at configuration time.]) +AC_DEFUN([RB_DEFINE], [AC_DEFINE([RB_$1], [$2], [$3])]) +AC_DEFUN([RB_DEFINE_UNQUOTED], [AC_DEFINE_UNQUOTED([RB_$1], [$2], [$3])]) +AC_DEFUN([IRCD_DEFINE], [AC_DEFINE([IRCD_$1], [$2], [$3])]) +AC_DEFUN([IRCD_DEFINE_UNQUOTED], [AC_DEFINE_UNQUOTED([IRCD_$1], [$2], [$3])]) + +RB_DEFINE_UNQUOTED([VERSION], ["$RB_VERSION"], [Version generated at configuration time.]) +RB_DEFINE_UNQUOTED([DATESTR], ["$RB_DATESTR"], [Readable date string of configuration time.]) +RB_DEFINE_UNQUOTED([DATECODE], [$RB_DATECODE], [UNIX epoch time at configuration time.]) AC_DEFINE([NICKNAMEHISTORYLENGTH], 15000, [Size of the WHOWAS array.]) AC_DEFINE([CHANNEL_HEAP_SIZE], 8192, [Size of the channel heap.]) @@ -90,60 +99,6 @@ AC_DEFINE([MONITOR_HEAP_SIZE], 1024, [Size of the monitor heap.]) AC_DEFINE([FD_HEAP_SIZE], 1024, [Size of fd heap.]) AC_DEFINE([AWAY_HEAP_SIZE], 512, [Size of away heap.]) -dnl Checks for header files. -AC_DEFUN([RB_CHK_SYSHEADER], \ -[ - AC_CHECK_HEADER([$1], \ - [ - AC_DEFINE([HAVE_$2], [1], [ Indication $1 is available. ]) - AC_DEFINE_UNQUOTED([RB_INC_$2], [$1>], [ The computed-include location of $1. ]) - ],[ - AC_DEFINE_UNQUOTED([RB_INC_$2], [/dev/null>], [ The computed-include location of $1. ]) - ]) -]) - -RB_CHK_SYSHEADER([errno.h]) -#RB_CHK_SYSHEADER([errno.h], [ERRNO_H]) -RB_CHK_SYSHEADER([assert.h], [ASSERT_H]) -RB_CHK_SYSHEADER([stddef.h], [STDDEF_H]) -RB_CHK_SYSHEADER([stdarg.h], [STDARG_H]) -RB_CHK_SYSHEADER([stdint.h], [STDINT_H]) -RB_CHK_SYSHEADER([inttypes.h], [INTTYPES_H]) -RB_CHK_SYSHEADER([ctype.h], [CTYPE_H]) -RB_CHK_SYSHEADER([limits.h], [LIMITS_H]) -RB_CHK_SYSHEADER([stdlib.h], [STDLIB_H]) -RB_CHK_SYSHEADER([unistd.h], [UNISTD_H]) -RB_CHK_SYSHEADER([time.h], [TIME_H]) -RB_CHK_SYSHEADER([fcntl.h], [FCNTL_H]) -RB_CHK_SYSHEADER([signal.h], [SIGNAL_H]) -RB_CHK_SYSHEADER([sys/types.h], [SYS_TYPES_H]) -RB_CHK_SYSHEADER([sys/time.h], [SYS_TIME_H]) -RB_CHK_SYSHEADER([sys/stat.h], [SYS_STAT_H]) -RB_CHK_SYSHEADER([sys/socket.h], [SYS_SOCKET_H]) -RB_CHK_SYSHEADER([arpa/inet.h], [ARPA_INET_H]) -RB_CHK_SYSHEADER([netinet/in.h], [NETINET_IN_H]) -RB_CHK_SYSHEADER([netinet/tcp.h], [NETINET_TCP_H]) -RB_CHK_SYSHEADER([string.h], [STRING_H]) -RB_CHK_SYSHEADER([stdio.h], [STDIO_H]) -RB_CHK_SYSHEADER([crypt.h], [CRYPT_H]) -RB_CHK_SYSHEADER([sys/uio.h], [SYS_UIO_H]) -RB_CHK_SYSHEADER([spawn.h], [SPAWN_H]) -RB_CHK_SYSHEADER([sys/poll.h], [SYS_POLL_H]) -RB_CHK_SYSHEADER([sys/epoll.h], [SYS_EPOLL_H]) -RB_CHK_SYSHEADER([sys/select.h], [SYS_SELECT_H]) -RB_CHK_SYSHEADER([sys/devpoll.h], [SYS_DEVPOLL_H]) -RB_CHK_SYSHEADER([sys/event.h], [SYS_EVENT_H]) -RB_CHK_SYSHEADER([port.h], [PORT_H]) -RB_CHK_SYSHEADER([sys/signalfd.h], [SYS_SIGNALFD_H]) -RB_CHK_SYSHEADER([sys/timerfd.h], [SYS_TIMERFD_H]) -RB_CHK_SYSHEADER([execinfo.h], [EXECINFO_H]) -RB_CHK_SYSHEADER([windows.h], [WINDOWS_H]) -RB_CHK_SYSHEADER([winsock2.h], [WINSOCK2_H]) -RB_CHK_SYSHEADER([ws2tcpip.h], [WS2TCPIP_H]) -RB_CHK_SYSHEADER([iphlpapi.h], [IPHLPAPI_H]) - - -CFLAGS="$IRC_CFLAGS $CFLAGS" case "$host_os" in *cygwin*) @@ -161,10 +116,10 @@ case "$host_os" in is_mingw="yes" ;; *interix*) - CPPFLAGS="$CFLAGS -D_ALL_SOURCE -D_XOPEN_SOURCE=500" + CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE -D_XOPEN_SOURCE=500" ;; *solaris*) - CPPFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS -D_XPG4_2" + CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS -D_XPG4_2" ;; *) ;; @@ -173,6 +128,110 @@ esac AM_CONDITIONAL([MINGW], [test "$is_mingw" = "yes"]) +dnl Checks for system header files. +AC_DEFUN([RB_CHK_SYSHEADER], \ +[ + AC_CHECK_HEADER([$1], \ + [ + AC_DEFINE([HAVE_$2], [1], [ Indication $1 is available. ]) + RB_DEFINE_UNQUOTED([INC_$2], [$1>], [ The computed-include location of $1. ]) + ],[ + if test "$is_mingw" = "yes"; then + RB_DEFINE_UNQUOTED([INC_$2], [stdint.h>], [ The dead-header in place of $1. ]) + else + RB_DEFINE_UNQUOTED([INC_$2], [/dev/null>], [ The dead-header in place of $1. ]) + fi + ]) +]) + +RB_CHK_SYSHEADER([errno.h], [ERRNO_H]) +RB_CHK_SYSHEADER([assert.h], [ASSERT_H]) +RB_CHK_SYSHEADER([stddef.h], [STDDEF_H]) +RB_CHK_SYSHEADER([stdarg.h], [STDARG_H]) +RB_CHK_SYSHEADER([stdint.h], [STDINT_H]) +RB_CHK_SYSHEADER([inttypes.h], [INTTYPES_H]) +RB_CHK_SYSHEADER([ctype.h], [CTYPE_H]) +RB_CHK_SYSHEADER([limits.h], [LIMITS_H]) +RB_CHK_SYSHEADER([stdlib.h], [STDLIB_H]) +RB_CHK_SYSHEADER([unistd.h], [UNISTD_H]) +RB_CHK_SYSHEADER([time.h], [TIME_H]) +RB_CHK_SYSHEADER([fcntl.h], [FCNTL_H]) +RB_CHK_SYSHEADER([signal.h], [SIGNAL_H]) +RB_CHK_SYSHEADER([dirent.h], [DIRENT_H]) +RB_CHK_SYSHEADER([sys/types.h], [SYS_TYPES_H]) +RB_CHK_SYSHEADER([sys/time.h], [SYS_TIME_H]) +RB_CHK_SYSHEADER([sys/stat.h], [SYS_STAT_H]) +RB_CHK_SYSHEADER([sys/file.h], [SYS_FILE_H]) +RB_CHK_SYSHEADER([sys/param.h], [SYS_PARAM_H]) +RB_CHK_SYSHEADER([sys/resource.h], [SYS_RESOURCE_H]) +RB_CHK_SYSHEADER([sys/socket.h], [SYS_SOCKET_H]) +RB_CHK_SYSHEADER([arpa/inet.h], [ARPA_INET_H]) +RB_CHK_SYSHEADER([netinet/in.h], [NETINET_IN_H]) +RB_CHK_SYSHEADER([netinet/tcp.h], [NETINET_TCP_H]) +RB_CHK_SYSHEADER([string.h], [STRING_H]) +RB_CHK_SYSHEADER([strings.h], [STRINGS_H]) +RB_CHK_SYSHEADER([stdio.h], [STDIO_H]) +RB_CHK_SYSHEADER([crypt.h], [CRYPT_H]) +RB_CHK_SYSHEADER([sys/uio.h], [SYS_UIO_H]) +RB_CHK_SYSHEADER([spawn.h], [SPAWN_H]) +RB_CHK_SYSHEADER([sys/poll.h], [SYS_POLL_H]) +RB_CHK_SYSHEADER([sys/epoll.h], [SYS_EPOLL_H]) +RB_CHK_SYSHEADER([sys/select.h], [SYS_SELECT_H]) +RB_CHK_SYSHEADER([sys/devpoll.h], [SYS_DEVPOLL_H]) +RB_CHK_SYSHEADER([sys/event.h], [SYS_EVENT_H]) +RB_CHK_SYSHEADER([port.h], [PORT_H]) +RB_CHK_SYSHEADER([sys/signalfd.h], [SYS_SIGNALFD_H]) +RB_CHK_SYSHEADER([sys/timerfd.h], [SYS_TIMERFD_H]) +RB_CHK_SYSHEADER([execinfo.h], [EXECINFO_H]) + +RB_CHK_SYSHEADER([cstddef], [CSTDDEF]) +RB_CHK_SYSHEADER([cstdint], [CSTDINT]) +RB_CHK_SYSHEADER([limits], [LIMITS]) +RB_CHK_SYSHEADER([type_traits], [TYPE_TRAITS]) +RB_CHK_SYSHEADER([utility], [UTILITY]) +RB_CHK_SYSHEADER([functional], [FUNCTIONAL]) +RB_CHK_SYSHEADER([algorithm], [ALGORITHM]) +RB_CHK_SYSHEADER([memory], [MEMORY]) +RB_CHK_SYSHEADER([exception], [EXCEPTION]) +RB_CHK_SYSHEADER([cerrno], [CERRNO]) +RB_CHK_SYSHEADER([system_error], [SYSTEM_ERROR]) +RB_CHK_SYSHEADER([map], [MAP]) +RB_CHK_SYSHEADER([set], [SET]) +RB_CHK_SYSHEADER([list], [LIST]) +RB_CHK_SYSHEADER([deque], [DEQUE]) +RB_CHK_SYSHEADER([array], [ARRAY]) +RB_CHK_SYSHEADER([vector], [VECTOR]) +RB_CHK_SYSHEADER([forward_list], [FORWARD_LIST]) +RB_CHK_SYSHEADER([unordered_map], [UNORDERED_MAP]) +RB_CHK_SYSHEADER([string], [STRING]) +RB_CHK_SYSHEADER([sstream], [SSTREAM]) +RB_CHK_SYSHEADER([fstream], [FSTREAM]) +RB_CHK_SYSHEADER([iostream], [IOSTREAM]) +RB_CHK_SYSHEADER([cstdio], [CSTDIO]) + +RB_CHK_SYSHEADER([windows.h], [WINDOWS_H]) +RB_CHK_SYSHEADER([winsock2.h], [WINSOCK2_H]) +RB_CHK_SYSHEADER([ws2tcpip.h], [WS2TCPIP_H]) +RB_CHK_SYSHEADER([iphlpapi.h], [IPHLPAPI_H]) + + +dnl todo +AC_DEFINE([HAVE_BOOST_ASIO_HPP], [1], [ boost asio. ]) +RB_DEFINE_UNQUOTED([INC_BOOST_ASIO_HPP], [boost/asio.hpp>], [ boost asio. ]) + +AC_DEFINE([HAVE_BOOST_CONTEXT_ALL_HPP], [1], [ boost context. ]) +RB_DEFINE_UNQUOTED([INC_BOOST_CONTEXT_ALL_HPP], [boost/context/all.hpp>], [ boost context. ]) + +AC_DEFINE([HAVE_BOOST_ASIO_SPAWN_HPP], [1], [ boost asio spawn. ]) +RB_DEFINE_UNQUOTED([INC_BOOST_ASIO_SPAWN_HPP], [boost/asio/spawn.hpp>], [ boost asio spawn. ]) + +AC_DEFINE([HAVE_BOOST_LEXICAL_CAST_HPP], [1], [ boost asio. ]) +RB_DEFINE_UNQUOTED([INC_BOOST_LEXICAL_CAST_HPP], [boost/lexical_cast.hpp>], [ boost lexical_cast. ]) + +AC_DEFINE([HAVE_BOOST_TOKENIZER_HPP], [1], [ boost tokenizer. ]) +RB_DEFINE_UNQUOTED([INC_BOOST_TOKENIZER_HPP], [boost/tokenizer.hpp>], [ boost tokenizer. ]) + + dnl use directory structure of cached as default (hack) if test "$libexecdir" = '${exec_prefix}/libexec' && test "$localstatedir" = '${prefix}/var'; then @@ -577,7 +636,7 @@ AC_HELP_STRING([--enable-profile],[Enable profiling]), if test "$profile" = yes; then if test "$ac_cv_c_compiler_gnu" = yes; then - CFLAGS="$CFLAGS -pg -static" + CPPFLAGS="$CPPFLAGS -pg -static" AC_MSG_RESULT([yes, adding -pg -static]) AC_DEFINE(RB_PROFILE, 1, [Defined to mark profiling is enabled]) else @@ -589,11 +648,10 @@ fi AC_ARG_ENABLE(warnings, AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]), -[CFLAGS="$CFLAGS -Wall -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -W -Wno-unused -Wunused-function -Wunused-variable"],[]) +[CPPFLAGS="$CPPFLAGS -Wall -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wwrite-strings -W -Wno-unused -Wunused-function -Wunused-variable"],[]) AC_SUBST(LDFLAGS) AC_SUBST(PICFLAGS) -AC_SUBST(CFLAGS) AC_SUBST(SEDOBJ) AC_SUBST(SSL_CFLAGS) AC_SUBST(SSL_LIBS) @@ -604,7 +662,6 @@ AC_SUBST(MBEDTLS_LIBS) if test "$prefix" = "NONE"; then AC_DEFINE_UNQUOTED(RB_PREFIX, "$ac_default_prefix", [Prefix where librb is installed.]) - else dnl Don't get bitten by Cygwin's stupidity if the user specified @@ -640,15 +697,6 @@ esac AM_CONDITIONAL([MINGW], [test "$is_mingw" = "yes"]) -if test "$ac_cv_c_compiler_gnu" = yes; then - IRC_CFLAGS="$IRC_CFLAGS -O0 -Wall" -fi - -dnl If we support -g, use it! -if test "$ac_cv_prog_cc_g" = yes; then - IRC_CFLAGS="$IRC_CFLAGS -g" -fi - dnl check for /dev/null so we can use it to hold evil fd's AC_MSG_CHECKING([for /dev/null]) if test -c /dev/null ; then @@ -659,13 +707,6 @@ else AC_MSG_RESULT(no - using devnull.log) fi -dnl jdc -- If CFLAGS is defined, best use it everywhere... -dnl NOTE: jv says it must be added to the *END*, because things like -dnl "gcc -O9 -O2" will result in -O2 getting preference. How stupid. -if test ! -z "$CFLAGS"; then - IRC_CFLAGS="$IRC_CFLAGS $CFLAGS" -fi - AC_PROG_YACC dnl AC_PROG_YACC defaults to yacc unconditionally if nothing can be found @@ -949,8 +990,26 @@ AC_ARG_WITH([confdir], [AC_HELP_STRING([--with-confdir=DIR], [Directory to install config files [deprecated, use --sysconfdir instead].])], [ sysconfdir=`echo $withval | sed 's/\/$//'` ], - [ confdir='${sysconfdir}' ]) -AC_DEFINE_DIR([ETC_DIR], [sysconfdir], [Prefix where config files are installed.]) + [ confdir='etc' ]) +RB_DEFINE_UNQUOTED([ETC_DIR], ["${prefix}/${confdir}"], [Prefix where config files are installed.]) + +dnl ********************************************************************** +dnl Check for --with-bindir +dnl ********************************************************************** + +AC_MSG_CHECKING([whether to modify binary directory]) +AC_ARG_WITH(bindir, +AC_HELP_STRING([--with-bindir=DIR], + [Directory where binary executables are placed.]), + [ logdir=`echo $withval | sed 's/\/$//'` + AC_MSG_RESULT(yes)], + [ AS_IF([test "x$enable_fhs_paths" = "xyes"], + [bindir="${prefix}/bin"], + [bindir="${prefix}/bin"]) + AC_MSG_RESULT(no)]) +RB_DEFINE_UNQUOTED([BIN_DIR], ["${bindir}"], [Directory where binary executables are to be found.]) +AC_SUBST_DIR([bindir]) + dnl ********************************************************************** dnl Check for --with-logdir @@ -963,10 +1022,10 @@ AC_HELP_STRING([--with-logdir=DIR], [ logdir=`echo $withval | sed 's/\/$//'` AC_MSG_RESULT(yes)], [ AS_IF([test "x$enable_fhs_paths" = "xyes"], - [logdir='${localstatedir}/log/${PACKAGE_TARNAME}'], - [logdir='${prefix}/logs']) + [logdir="${prefix}/var/log"], + [logdir="${prefix}/var/${PACKAGE_TARNAME}/log"]) AC_MSG_RESULT(no)]) -AC_DEFINE_DIR([LOG_DIR], [logdir], [Prefix where to write logfiles.]) +RB_DEFINE_UNQUOTED([LOG_DIR], ["${logdir}"], [Prefix where to write logfiles.]) AC_SUBST_DIR([logdir]) dnl ********************************************************************** @@ -980,10 +1039,10 @@ AC_HELP_STRING([--with-helpdir=DIR], [ helpdir=`echo $withval | sed 's/\/$//'` AC_MSG_RESULT(yes) ], [ AS_IF([test "x$enable_fhs_paths" = "xyes"], - [helpdir='${datadir}/${PACKAGE_TARNAME}/help'], - [helpdir='${prefix}/help']) + [helpdir="${prefix}/share/help"], + [helpdir="${prefix}/share/${PACKAGE_TARNAME}/help"]) AC_MSG_RESULT(no) ]) -AC_DEFINE_DIR([HELP_DIR], [helpdir], [Prefix where help files are installed.]) +RB_DEFINE_UNQUOTED([HELP_DIR], ["${helpdir}"], [Prefix where help files are installed.]) AC_SUBST_DIR([helpdir]) dnl ********************************************************************** @@ -997,11 +1056,11 @@ AC_ARG_WITH(moduledir, [ moduledir=`echo $withval | sed 's/\/$//'` AC_MSG_RESULT(yes)], [ AS_IF([test "x$enable_fhs_paths" = "xyes"], - [moduledir='${pkglibdir}/modules'], - [moduledir='${prefix}/modules']) + [moduledir="${prefix}/lib/modules"], + [moduledir="${prefix}/lib/${PACKAGE_TARNAME}/modules"]) AC_MSG_RESULT(no) ]) -AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.]) +RB_DEFINE_UNQUOTED([MODULE_DIR], ["${moduledir}"], [Prefix where modules are installed.]) AC_SUBST_DIR([moduledir]) dnl Check for --with-rundir @@ -1014,10 +1073,10 @@ AC_ARG_WITH([rundir], rundir=`echo $withval | sed 's/\/$//'`], [AC_MSG_RESULT([no]) AS_IF([test "x$enable_fhs_paths" = "xyes"], - [rundir='${prefix}/run'], - [rundir='${sysconfdir}'])]) + [rundir="${prefix}/var/run"], + [rundir="${prefix}/${PACKAGE_TARNAME}/run"])]) AC_SUBST([rundir]) -AC_DEFINE_DIR([PKGRUNDIR], [pkgrundir], [Directory to store pidfile in.]) +AC_DEFINE_DIR([PKGRUNDIR], ["${rundir}"], [Directory to store pidfile in.]) dnl Installed utility program prefixes (does not affect binaries dnl installed into pkglibexecdir) @@ -1097,7 +1156,7 @@ AC_HELP_STRING([--enable-profile],[Enable profiling]), if test "$profile" = yes; then if test "$ac_cv_c_compiler_gnu" = yes; then - IRC_CFLAGS="$IRC_CFLAGS -pg" + CPPFLAGS="$CPPFLAGS -pg" AC_MSG_RESULT([yes, adding -pg]) AC_DEFINE(CHARYBDIS_PROFILE, 1, [Define this if you are profiling.]) else @@ -1140,14 +1199,14 @@ AC_DEFINE_UNQUOTED(NICKLEN, (${NICKLEN}+1), [Nickname length]) # rpath, for finding librb.so at run time hold_ldflags=$LDFLAGS -AC_MSG_CHECKING(for the ld -rpath flag) -LDFLAGS="${LDFLAGS} -Wl,-rpath=${libdir}" -AC_LINK_IFELSE([AC_LANG_PROGRAM([],[int i;])], found=yes, found=no) -LDFLAGS=$hold_ldflags -AC_MSG_RESULT($found) -if test "$found" = yes; then - LDFLAGS="${LDFLAGS} -Wl,-rpath=\${libdir}" -fi +#AC_MSG_CHECKING(for the ld -rpath flag) +#LDFLAGS="${LDFLAGS} -Wl,-rpath=${prefix}/${libdir}" +#AC_LINK_IFELSE([AC_LANG_PROGRAM([],[int i;])], found=yes, found=no) +#LDFLAGS=$hold_ldflags +#AC_MSG_RESULT($found) +#if test "$found" = yes; then +# LDFLAGS="${LDFLAGS} -Wl,-rpath=${prefix}/${libdir}" +#fi # This must be down here, or it will mess up checks like the ones # for -Wl,-export-dynamic @@ -1156,9 +1215,6 @@ CWARNS="" AC_ARG_ENABLE(warnings, AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]), [ -IRC_CFLAGS="$IRC_CFLAGS -O0" -CFLAGS="$IRC_CFLAGS" - CHARYBDIS_C_GCC_TRY_FLAGS([-Wall], charybdis_cv_c_gcc_w_all) CHARYBDIS_C_GCC_TRY_FLAGS([-Wpointer-arith], charybdis_cv_c_gcc_w_pointer_arith) CHARYBDIS_C_GCC_TRY_FLAGS([-Wimplicit -Wnested-externs], charybdis_cv_c_gcc_w_implicit) @@ -1178,12 +1234,11 @@ CHARYBDIS_C_GCC_TRY_FLAGS([-Wnested-externs], charybdis_cv_c_gcc_w_nested_extern CHARYBDIS_C_GCC_TRY_FLAGS([-Wunused-function -Wunused-label -Wunused-value -Wunused-variable], charybdis_cv_c_gcc_w_unused) CHARYBDIS_C_GCC_TRY_FLAGS([-Wredundant-decls], charybdis_cv_c_gcc_w_redundant_decls) CHARYBDIS_C_GCC_TRY_FLAGS([-Wfloat-equal], charybdis_cv_c_gcc_w_float_equal) +CHARYBDIS_C_GCC_TRY_FLAGS([-Winvalid-pch], charybdis_cv_c_gcc_w_invalid_pch) CHARYBDIS_C_GCC_TRY_FLAGS([-Wformat -Wformat-y2k -Wno-format-security], charybdis_cv_c_gcc_w_format) - -IRC_CFLAGS="$CFLAGS" ],[]) -IRC_CFLAGS="$IRC_CFLAGS $CWARNS" +CPPFLAGS="$CPPFLAGS $CWARNS" AC_SUBST(MODULES_LIBS) AC_SUBST(MOD_TARGET) @@ -1192,9 +1247,10 @@ AC_SUBST(SSL_SRCS_ENABLE) AC_SUBST(SSL_INCLUDES) AC_SUBST(SSL_LIBS) +AC_SUBST(CFLAGS) +AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(PICFLAGS) -AC_SUBST(IRC_CFLAGS) AC_SUBST(SEDOBJ) diff --git a/extensions/Makefile.am b/extensions/Makefile.am index 087cd91e7..c16debaa0 100644 --- a/extensions/Makefile.am +++ b/extensions/Makefile.am @@ -1,10 +1,83 @@ AM_CPPFLAGS = -I$(top_srcdir)/include $(LTDLINCL) +AM_CPPFLAGS += -isystem $(top_srcdir)/boost/include AM_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined -shared AM_LDFLAGS += -export-symbols-regex _mheader -LIBS += $(top_srcdir)/rb/librb.la $(top_srcdir)/ircd/libircd.la +AM_LDFLAGS += -L$(top_srcdir)/boost/lib -lboost_system +AM_LDFLAGS += -L$(top_srcdir)/ircd -lircd +AM_LDFLAGS += -L$(top_srcdir)/rb -lrb + extensiondir=@moduledir@/extensions +chm_adminonly_la_SOURCES = chm_adminonly.cc +chm_operonly_la_SOURCES = chm_operonly.cc +chm_operonly_compat_la_SOURCES = chm_operonly_compat.cc +chm_insecure_la_SOURCES = chm_insecure.cc +chm_nonotice_la_SOURCES = chm_nonotice.cc +chm_operpeace_la_SOURCES = chm_operpeace.cc +chm_quietunreg_compat_la_SOURCES = chm_quietunreg_compat.cc +chm_spamfilter_la_SOURCES = chm_spamfilter.cc +chm_sslonly_la_SOURCES = chm_sslonly.cc +chm_sslonly_compat_la_SOURCES = chm_sslonly_compat.cc +createauthonly_la_SOURCES = createauthonly.cc +createoperonly_la_SOURCES = createoperonly.cc +extb_account_la_SOURCES = extb_account.cc +extb_canjoin_la_SOURCES = extb_canjoin.cc +extb_channel_la_SOURCES = extb_channel.cc +extb_hostmask_la_SOURCES = extb_hostmask.cc +extb_oper_la_SOURCES = extb_oper.cc +extb_server_la_SOURCES = extb_server.cc +extb_ssl_la_SOURCES = extb_ssl.cc +extb_realname_la_SOURCES = extb_realname.cc +extb_usermode_la_SOURCES = extb_usermode.cc +extb_extgecos_la_SOURCES = extb_extgecos.cc +extb_combi_la_SOURCES = extb_combi.cc +force_user_invis_la_SOURCES = force_user_invis.cc +helpops_la_SOURCES = helpops.cc +hurt_la_SOURCES = hurt.cc +ip_cloaking_la_SOURCES = ip_cloaking.cc +ip_cloaking_old_la_SOURCES = ip_cloaking_old.cc +ip_cloaking_3_0_la_SOURCES = ip_cloaking_3.0.cc +ip_cloaking_4_0_la_SOURCES = ip_cloaking_4.0.cc +override_la_SOURCES = override.cc +restrict_unauthenticated_la_SOURCES = restrict-unauthenticated.cc +sno_channelcreate_la_SOURCES = sno_channelcreate.cc +sno_farconnect_la_SOURCES = sno_farconnect.cc +sno_globalkline_la_SOURCES = sno_globalkline.cc +sno_globalnickchange_la_SOURCES = sno_globalnickchange.cc +sno_globaloper_la_SOURCES = sno_globaloper.cc +sno_whois_la_SOURCES = sno_whois.cc +umode_noctcp_la_SOURCES = umode_noctcp.cc +m_adminwall_la_SOURCES = m_adminwall.cc +m_echotags_la_SOURCES = m_echotags.cc +m_extendchans_la_SOURCES = m_extendchans.cc +m_findforwards_la_SOURCES = m_findforwards.cc +m_identify_la_SOURCES = m_identify.cc +m_locops_la_SOURCES = m_locops.cc +m_mkpasswd_la_SOURCES = m_mkpasswd.cc +m_ojoin_la_SOURCES = m_ojoin.cc +m_okick_la_SOURCES = m_okick.cc +m_omode_la_SOURCES = m_omode.cc +m_opme_la_SOURCES = m_opme.cc +m_sendbans_la_SOURCES = m_sendbans.cc +m_webirc_la_SOURCES = m_webirc.cc +m_remove_la_SOURCES = m_remove.cc +m_roleplay_la_SOURCES = m_roleplay.cc +hide_uncommon_channels_la_SOURCES = hide_uncommon_channels.cc +no_kill_services_la_SOURCES = no_kill_services.cc +no_locops_la_SOURCES = no_locops.cc +no_oper_invis_la_SOURCES = no_oper_invis.cc +spamfilter_nicks_la_SOURCES = spamfilter_nicks.cc +spy_admin_notice_la_SOURCES = spy_admin_notice.cc +spy_info_notice_la_SOURCES = spy_info_notice.cc +spy_links_notice_la_SOURCES = spy_links_notice.cc +spy_motd_notice_la_SOURCES = spy_motd_notice.cc +spy_stats_notice_la_SOURCES = spy_stats_notice.cc +spy_stats_p_notice_la_SOURCES = spy_stats_p_notice.cc +spy_trace_notice_la_SOURCES = spy_trace_notice.cc +example_module_la_SOURCES = example_module.cc + + extension_LTLIBRARIES = \ chm_adminonly.la \ chm_operonly.la \ @@ -77,6 +150,7 @@ extension_LTLIBRARIES = \ if PCRE extension_LTLIBRARIES += spamfilter_expr.la +spamfilter_expr_la_SOURCES = spamfilter_expr.cc spamfilter_expr_la_CPPFLAGS = $(AM_CPPFLAGS) $(PCRE_CFLAGS) spamfilter_expr_la_LIBADD = $(PCRE_LIBS) diff --git a/extensions/chm_adminonly.c b/extensions/chm_adminonly.cc similarity index 100% rename from extensions/chm_adminonly.c rename to extensions/chm_adminonly.cc diff --git a/extensions/chm_insecure.c b/extensions/chm_insecure.cc similarity index 100% rename from extensions/chm_insecure.c rename to extensions/chm_insecure.cc diff --git a/extensions/chm_nonotice.c b/extensions/chm_nonotice.cc similarity index 100% rename from extensions/chm_nonotice.c rename to extensions/chm_nonotice.cc diff --git a/extensions/chm_operonly.c b/extensions/chm_operonly.cc similarity index 100% rename from extensions/chm_operonly.c rename to extensions/chm_operonly.cc diff --git a/extensions/chm_operonly_compat.c b/extensions/chm_operonly_compat.cc similarity index 93% rename from extensions/chm_operonly_compat.c rename to extensions/chm_operonly_compat.cc index 51c5d8adf..a51579dfc 100644 --- a/extensions/chm_operonly_compat.c +++ b/extensions/chm_operonly_compat.cc @@ -25,7 +25,7 @@ _modinit(void) { chmode_table['O'].set_func = chm_operonly; chmode_table['O'].mode_type = 0; - chmode_table['O'].mode_class = CHM_D; + chmode_table['O'].mode_class = ChmClass{CHM_D}; return 0; } @@ -35,7 +35,7 @@ _moddeinit(void) { chmode_table['O'].set_func = chm_nosuch; chmode_table['O'].mode_type = 0; - chmode_table['O'].mode_class = 0; + chmode_table['O'].mode_class = ChmClass(0); } static void diff --git a/extensions/chm_operpeace.c b/extensions/chm_operpeace.cc similarity index 100% rename from extensions/chm_operpeace.c rename to extensions/chm_operpeace.cc diff --git a/extensions/chm_quietunreg_compat.c b/extensions/chm_quietunreg_compat.cc similarity index 96% rename from extensions/chm_quietunreg_compat.c rename to extensions/chm_quietunreg_compat.cc index 906322d4d..d0b8e03bf 100644 --- a/extensions/chm_quietunreg_compat.c +++ b/extensions/chm_quietunreg_compat.cc @@ -36,7 +36,7 @@ _moddeinit(void) { chmode_table['R'].set_func = chm_nosuch; chmode_table['R'].mode_type = 0; - chmode_table['R'].mode_class = 0; + chmode_table['R'].mode_class = ChmClass(0); } static void diff --git a/extensions/chm_spamfilter.c b/extensions/chm_spamfilter.cc similarity index 98% rename from extensions/chm_spamfilter.c rename to extensions/chm_spamfilter.cc index a6162ccc2..fe1ceff21 100644 --- a/extensions/chm_spamfilter.c +++ b/extensions/chm_spamfilter.cc @@ -100,7 +100,7 @@ void substitute_reject_reason(void) static void set_reject_reason(void *const str) { - rb_strlcpy(reject_reason, str, sizeof(reject_reason)); + rb_strlcpy(reject_reason, (const char *)str, sizeof(reject_reason)); substitute_reject_reason(); } diff --git a/extensions/chm_sslonly.c b/extensions/chm_sslonly.cc similarity index 100% rename from extensions/chm_sslonly.c rename to extensions/chm_sslonly.cc diff --git a/extensions/chm_sslonly_compat.c b/extensions/chm_sslonly_compat.cc similarity index 93% rename from extensions/chm_sslonly_compat.c rename to extensions/chm_sslonly_compat.cc index 1b059d5b6..51d38745a 100644 --- a/extensions/chm_sslonly_compat.c +++ b/extensions/chm_sslonly_compat.cc @@ -25,7 +25,7 @@ _modinit(void) { chmode_table['S'].set_func = chm_sslonly; chmode_table['S'].mode_type = 0; - chmode_table['S'].mode_class = CHM_D; + chmode_table['S'].mode_class = ChmClass{CHM_D}; return 0; } @@ -35,7 +35,7 @@ _moddeinit(void) { chmode_table['S'].set_func = chm_nosuch; chmode_table['S'].mode_type = 0; - chmode_table['S'].mode_class = 0; + chmode_table['S'].mode_class = ChmClass(0); } static void diff --git a/extensions/createauthonly.c b/extensions/createauthonly.cc similarity index 100% rename from extensions/createauthonly.c rename to extensions/createauthonly.cc diff --git a/extensions/createoperonly.c b/extensions/createoperonly.cc similarity index 100% rename from extensions/createoperonly.c rename to extensions/createoperonly.cc diff --git a/extensions/example_module.c b/extensions/example_module.cc similarity index 100% rename from extensions/example_module.c rename to extensions/example_module.cc diff --git a/extensions/extb_account.c b/extensions/extb_account.cc similarity index 100% rename from extensions/extb_account.c rename to extensions/extb_account.cc diff --git a/extensions/extb_canjoin.c b/extensions/extb_canjoin.cc similarity index 100% rename from extensions/extb_canjoin.c rename to extensions/extb_canjoin.cc diff --git a/extensions/extb_channel.c b/extensions/extb_channel.cc similarity index 100% rename from extensions/extb_channel.c rename to extensions/extb_channel.cc diff --git a/extensions/extb_combi.c b/extensions/extb_combi.cc similarity index 100% rename from extensions/extb_combi.c rename to extensions/extb_combi.cc diff --git a/extensions/extb_extgecos.c b/extensions/extb_extgecos.cc similarity index 100% rename from extensions/extb_extgecos.c rename to extensions/extb_extgecos.cc diff --git a/extensions/extb_hostmask.c b/extensions/extb_hostmask.cc similarity index 100% rename from extensions/extb_hostmask.c rename to extensions/extb_hostmask.cc diff --git a/extensions/extb_oper.c b/extensions/extb_oper.cc similarity index 100% rename from extensions/extb_oper.c rename to extensions/extb_oper.cc diff --git a/extensions/extb_realname.c b/extensions/extb_realname.cc similarity index 100% rename from extensions/extb_realname.c rename to extensions/extb_realname.cc diff --git a/extensions/extb_server.c b/extensions/extb_server.cc similarity index 100% rename from extensions/extb_server.c rename to extensions/extb_server.cc diff --git a/extensions/extb_ssl.c b/extensions/extb_ssl.cc similarity index 100% rename from extensions/extb_ssl.c rename to extensions/extb_ssl.cc diff --git a/extensions/extb_usermode.c b/extensions/extb_usermode.cc similarity index 100% rename from extensions/extb_usermode.c rename to extensions/extb_usermode.cc diff --git a/extensions/force_user_invis.c b/extensions/force_user_invis.cc similarity index 100% rename from extensions/force_user_invis.c rename to extensions/force_user_invis.cc diff --git a/extensions/helpops.c b/extensions/helpops.cc similarity index 99% rename from extensions/helpops.c rename to extensions/helpops.cc index 9d49579b8..4b9a32bdb 100644 --- a/extensions/helpops.c +++ b/extensions/helpops.cc @@ -132,7 +132,7 @@ h_hdl_stats_request(hook_data_int *hdata) RB_DLINK_FOREACH (helper_ptr, helper_list.head) { - target_p = helper_ptr->data; + target_p = (Client *)helper_ptr->data; if(target_p->user->away) continue; diff --git a/extensions/hide_uncommon_channels.c b/extensions/hide_uncommon_channels.cc similarity index 100% rename from extensions/hide_uncommon_channels.c rename to extensions/hide_uncommon_channels.cc diff --git a/extensions/hurt.c b/extensions/hurt.cc similarity index 98% rename from extensions/hurt.c rename to extensions/hurt.cc index 30d4c8708..e150e6b0c 100644 --- a/extensions/hurt.c +++ b/extensions/hurt.cc @@ -123,11 +123,8 @@ DECLARE_MODULE_AV2( ); /* }}} */ -hurt_state_t hurt_state = { - .cutoff = HURT_CUTOFF, - .default_expire = HURT_DEFAULT_EXPIRE, - .exit_reason = HURT_EXIT_REASON, -}; + +hurt_state_t hurt_state; /* * Module constructor/destructor. @@ -143,6 +140,9 @@ modinit(void) { /* set-up hurt_state. */ hurt_state.start_time = rb_current_time(); + hurt_state.cutoff = HURT_CUTOFF; + hurt_state.default_expire = HURT_DEFAULT_EXPIRE; + hurt_state.exit_reason = HURT_EXIT_REASON; /* add our event handlers. */ hurt_expire_ev = rb_event_add("hurt_expire", hurt_expire_event, NULL, 60); @@ -390,7 +390,7 @@ hurt_check_event(void *arg) struct Client *client_p; RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head) { - client_p = ptr->data; + client_p = (Client *)ptr->data; if (!EmptyString(client_p->user->suser)) { rb_dlinkDestroy(ptr, &hurt_state.hurt_clients); @@ -534,7 +534,7 @@ hurt_new(time_t expire, const char *ip, const char *reason) { hurt_t *hurt; - hurt = rb_malloc(sizeof(hurt_t)); + hurt = (hurt_t *)rb_malloc(sizeof(hurt_t)); hurt->ip = rb_strdup(ip); hurt->reason = rb_strdup(reason); diff --git a/extensions/ip_cloaking.c b/extensions/ip_cloaking.cc similarity index 98% rename from extensions/ip_cloaking.c rename to extensions/ip_cloaking.cc index f4ce078e0..9f6c169b6 100644 --- a/extensions/ip_cloaking.c +++ b/extensions/ip_cloaking.cc @@ -203,14 +203,14 @@ check_umode_change(void *vdata) static void check_new_user(void *vdata) { - struct Client *source_p = (void *)vdata; + struct Client *source_p = (Client *)vdata; if (IsIPSpoof(source_p)) { source_p->umodes &= ~user_modes['h']; return; } - source_p->localClient->mangledhost = rb_malloc(HOSTLEN + 1); + source_p->localClient->mangledhost = (char *)rb_malloc(HOSTLEN + 1); if (!irccmp(source_p->orighost, source_p->sockhost)) do_host_cloak_ip(source_p->orighost, source_p->localClient->mangledhost); else diff --git a/extensions/ip_cloaking_3.0.c b/extensions/ip_cloaking_3.0.cc similarity index 98% rename from extensions/ip_cloaking_3.0.c rename to extensions/ip_cloaking_3.0.cc index 80a339002..ef5f2a2a4 100644 --- a/extensions/ip_cloaking_3.0.c +++ b/extensions/ip_cloaking_3.0.cc @@ -209,14 +209,14 @@ check_umode_change(void *vdata) static void check_new_user(void *vdata) { - struct Client *source_p = (void *)vdata; + struct Client *source_p = (Client *)vdata; if (IsIPSpoof(source_p)) { source_p->umodes &= ~user_modes['h']; return; } - source_p->localClient->mangledhost = rb_malloc(HOSTLEN); + source_p->localClient->mangledhost = (char *)rb_malloc(HOSTLEN); if (!irccmp(source_p->orighost, source_p->sockhost)) do_host_cloak_ip(source_p->orighost, source_p->localClient->mangledhost); else diff --git a/extensions/ip_cloaking_4.0.c b/extensions/ip_cloaking_4.0.cc similarity index 98% rename from extensions/ip_cloaking_4.0.c rename to extensions/ip_cloaking_4.0.cc index cd9abac4d..740e90d64 100644 --- a/extensions/ip_cloaking_4.0.c +++ b/extensions/ip_cloaking_4.0.cc @@ -203,14 +203,14 @@ check_umode_change(void *vdata) static void check_new_user(void *vdata) { - struct Client *source_p = (void *)vdata; + struct Client *source_p = (Client *)vdata; if (IsIPSpoof(source_p)) { source_p->umodes &= ~user_modes['x']; return; } - source_p->localClient->mangledhost = rb_malloc(HOSTLEN + 1); + source_p->localClient->mangledhost = (char *)rb_malloc(HOSTLEN + 1); if (!irccmp(source_p->orighost, source_p->sockhost)) do_host_cloak_ip(source_p->orighost, source_p->localClient->mangledhost); else diff --git a/extensions/ip_cloaking_old.c b/extensions/ip_cloaking_old.cc similarity index 97% rename from extensions/ip_cloaking_old.c rename to extensions/ip_cloaking_old.cc index 38d45b6b4..bcbd18882 100644 --- a/extensions/ip_cloaking_old.c +++ b/extensions/ip_cloaking_old.cc @@ -151,14 +151,14 @@ check_umode_change(void *vdata) static void check_new_user(void *vdata) { - struct Client *source_p = (void *)vdata; + struct Client *source_p = (Client *)vdata; if (IsIPSpoof(source_p)) { source_p->umodes &= ~user_modes['h']; return; } - source_p->localClient->mangledhost = rb_malloc(HOSTLEN); + source_p->localClient->mangledhost = (char *)rb_malloc(HOSTLEN); if (!irccmp(source_p->orighost, source_p->sockhost)) do_host_cloak(source_p->orighost, source_p->localClient->mangledhost, 1); else diff --git a/extensions/m_adminwall.c b/extensions/m_adminwall.cc similarity index 100% rename from extensions/m_adminwall.c rename to extensions/m_adminwall.cc diff --git a/extensions/m_echotags.c b/extensions/m_echotags.cc similarity index 100% rename from extensions/m_echotags.c rename to extensions/m_echotags.cc diff --git a/extensions/m_extendchans.c b/extensions/m_extendchans.cc similarity index 100% rename from extensions/m_extendchans.c rename to extensions/m_extendchans.cc diff --git a/extensions/m_findforwards.c b/extensions/m_findforwards.cc similarity index 99% rename from extensions/m_findforwards.c rename to extensions/m_findforwards.cc index a30ea7598..dcabf562c 100644 --- a/extensions/m_findforwards.c +++ b/extensions/m_findforwards.cc @@ -92,7 +92,7 @@ m_findforwards(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client * RB_DLINK_FOREACH(ptr, global_channel_list.head) { - chptr = ptr->data; + chptr = (Channel *)ptr->data; if(!irccmp(chptr->mode.forward, parv[1])) { if(p + strlen(chptr->chname) >= end - 13) diff --git a/extensions/m_identify.c b/extensions/m_identify.cc similarity index 100% rename from extensions/m_identify.c rename to extensions/m_identify.cc diff --git a/extensions/m_locops.c b/extensions/m_locops.cc similarity index 100% rename from extensions/m_locops.c rename to extensions/m_locops.cc diff --git a/extensions/m_mkpasswd.c b/extensions/m_mkpasswd.cc similarity index 99% rename from extensions/m_mkpasswd.c rename to extensions/m_mkpasswd.cc index 41140558e..46d289c12 100644 --- a/extensions/m_mkpasswd.c +++ b/extensions/m_mkpasswd.cc @@ -206,7 +206,7 @@ generate_random_salt(char *salt, int length) { return (generate_poor_salt(salt, length)); } - buf = calloc(1, length); + buf = (char *)calloc(1, length); if(read(fd, buf, length) != length) { free(buf); diff --git a/extensions/m_ojoin.c b/extensions/m_ojoin.cc similarity index 100% rename from extensions/m_ojoin.c rename to extensions/m_ojoin.cc diff --git a/extensions/m_okick.c b/extensions/m_okick.cc similarity index 98% rename from extensions/m_okick.c rename to extensions/m_okick.cc index c00c423ee..59d26871b 100644 --- a/extensions/m_okick.c +++ b/extensions/m_okick.cc @@ -85,7 +85,7 @@ mo_okick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source comment[TOPICLEN] = '\0'; *buf = '\0'; - if((p = strchr(parv[1], ','))) + if((p = (char *)strchr(parv[1], ','))) *p = '\0'; name = LOCAL_COPY(parv[1]); @@ -98,7 +98,7 @@ mo_okick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source } - if((p = strchr(parv[2], ','))) + if((p = (char *)strchr(parv[2], ','))) *p = '\0'; user = LOCAL_COPY(parv[2]); // strtoken(&p2, parv[2], ","); if(!(who = find_chasing(source_p, user, &chasing))) diff --git a/extensions/m_omode.c b/extensions/m_omode.cc similarity index 100% rename from extensions/m_omode.c rename to extensions/m_omode.cc diff --git a/extensions/m_opme.c b/extensions/m_opme.cc similarity index 98% rename from extensions/m_opme.c rename to extensions/m_opme.cc index 10f440e71..e416c65c2 100644 --- a/extensions/m_opme.c +++ b/extensions/m_opme.cc @@ -74,7 +74,7 @@ mo_opme(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ RB_DLINK_FOREACH(ptr, chptr->members.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; if(is_chanop(msptr)) { diff --git a/extensions/m_remove.c b/extensions/m_remove.cc similarity index 98% rename from extensions/m_remove.c rename to extensions/m_remove.cc index a0e68aaae..6431e5408 100644 --- a/extensions/m_remove.c +++ b/extensions/m_remove.cc @@ -81,7 +81,7 @@ m_remove(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source flood_endgrace(source_p); *buf = '\0'; - if((p = strchr(parv[1], ','))) + if((p = (char *)strchr(parv[1], ','))) *p = '\0'; name = parv[1]; @@ -144,7 +144,7 @@ m_remove(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source */ } - if((p = strchr(parv[2], ','))) + if((p = (char *)strchr(parv[2], ','))) *p = '\0'; user = parv[2]; /* strtoken(&p2, parv[2], ","); */ diff --git a/extensions/m_roleplay.c b/extensions/m_roleplay.cc similarity index 100% rename from extensions/m_roleplay.c rename to extensions/m_roleplay.cc diff --git a/extensions/m_sendbans.c b/extensions/m_sendbans.cc similarity index 96% rename from extensions/m_sendbans.c rename to extensions/m_sendbans.cc index 1e39f6bda..3cd98688d 100644 --- a/extensions/m_sendbans.c +++ b/extensions/m_sendbans.cc @@ -117,7 +117,7 @@ mo_sendbans(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou count = 0; RB_DLINK_FOREACH(ptr, global_serv_list.head) { - server_p = ptr->data; + server_p = (Client *)ptr->data; if (IsMe(server_p)) continue; if (match(target, server_p->name)) @@ -137,7 +137,7 @@ mo_sendbans(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou RB_DLINK_FOREACH(ptr, resv_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if (aconf->hold) continue; sendto_match_servs(source_p, target, @@ -146,8 +146,10 @@ mo_sendbans(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou target, aconf->host, aconf->passwd); } - RB_RADIXTREE_FOREACH(aconf, &state, resv_tree) + void *elem; + RB_RADIXTREE_FOREACH(elem, &state, resv_tree) { + aconf = (ConfItem *)elem; if (aconf->hold) continue; sendto_match_servs(source_p, target, @@ -158,7 +160,7 @@ mo_sendbans(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou RB_DLINK_FOREACH(ptr, xline_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if (aconf->hold) continue; mask2 = expand_xline(aconf->host); diff --git a/extensions/m_webirc.c b/extensions/m_webirc.cc similarity index 100% rename from extensions/m_webirc.c rename to extensions/m_webirc.cc diff --git a/extensions/no_kill_services.c b/extensions/no_kill_services.cc similarity index 100% rename from extensions/no_kill_services.c rename to extensions/no_kill_services.cc diff --git a/extensions/no_locops.c b/extensions/no_locops.cc similarity index 100% rename from extensions/no_locops.c rename to extensions/no_locops.cc diff --git a/extensions/no_oper_invis.c b/extensions/no_oper_invis.cc similarity index 100% rename from extensions/no_oper_invis.c rename to extensions/no_oper_invis.cc diff --git a/extensions/override.c b/extensions/override.cc similarity index 95% rename from extensions/override.c rename to extensions/override.cc index f1751c377..c68218d17 100644 --- a/extensions/override.c +++ b/extensions/override.cc @@ -63,7 +63,7 @@ update_session_deadline(struct Client *source_p, struct OverrideSession *session RB_DLINK_FOREACH(n, overriding_opers.head) { - struct OverrideSession *s = n->data; + struct OverrideSession *s = (OverrideSession *)n->data; if (s->client == source_p) { @@ -75,7 +75,7 @@ update_session_deadline(struct Client *source_p, struct OverrideSession *session if (session_p == NULL) { - session_p = rb_malloc(sizeof(struct OverrideSession)); + session_p = (OverrideSession *)rb_malloc(sizeof(struct OverrideSession)); session_p->client = source_p; } @@ -92,7 +92,7 @@ expire_override_deadlines(void *unused) RB_DLINK_FOREACH_SAFE(n, tn, overriding_opers.head) { - struct OverrideSession *session_p = n->data; + struct OverrideSession *session_p = (OverrideSession *)n->data; if (session_p->deadline > rb_current_time()) break; @@ -140,7 +140,7 @@ check_umode_change(void *vdata) RB_DLINK_FOREACH_SAFE(n, tn, overriding_opers.head) { - struct OverrideSession *session_p = n->data; + struct OverrideSession *session_p = (OverrideSession *)n->data; if (session_p->client != source_p) continue; @@ -246,7 +246,7 @@ handle_client_exit(void *vdata) RB_DLINK_FOREACH_SAFE(n, tn, overriding_opers.head) { - struct OverrideSession *session_p = n->data; + struct OverrideSession *session_p = (OverrideSession *)n->data; if (session_p->client != source_p) continue; diff --git a/extensions/restrict-unauthenticated.c b/extensions/restrict-unauthenticated.cc similarity index 100% rename from extensions/restrict-unauthenticated.c rename to extensions/restrict-unauthenticated.cc diff --git a/extensions/sno_channelcreate.c b/extensions/sno_channelcreate.cc similarity index 100% rename from extensions/sno_channelcreate.c rename to extensions/sno_channelcreate.cc diff --git a/extensions/sno_farconnect.c b/extensions/sno_farconnect.cc similarity index 100% rename from extensions/sno_farconnect.c rename to extensions/sno_farconnect.cc diff --git a/extensions/sno_globalkline.c b/extensions/sno_globalkline.cc similarity index 100% rename from extensions/sno_globalkline.c rename to extensions/sno_globalkline.cc diff --git a/extensions/sno_globalnickchange.c b/extensions/sno_globalnickchange.cc similarity index 91% rename from extensions/sno_globalnickchange.c rename to extensions/sno_globalnickchange.cc index a32f15c4c..f59e51dcd 100644 --- a/extensions/sno_globalnickchange.c +++ b/extensions/sno_globalnickchange.cc @@ -37,8 +37,8 @@ static void h_gnc_nick_change(hook_data *data) { struct Client *source_p = data->client; - const char *oldnick = data->arg1; - const char *newnick = data->arg2; + const char *oldnick = (const char *)data->arg1; + const char *newnick = (const char *)data->arg2; sendto_realops_snomask_from(SNO_NCHANGE, L_ALL, source_p->servptr, "Nick change: From %s to %s [%s@%s]", diff --git a/extensions/sno_globaloper.c b/extensions/sno_globaloper.cc similarity index 100% rename from extensions/sno_globaloper.c rename to extensions/sno_globaloper.cc diff --git a/extensions/sno_whois.c b/extensions/sno_whois.cc similarity index 100% rename from extensions/sno_whois.c rename to extensions/sno_whois.cc diff --git a/extensions/spamfilter_expr.c b/extensions/spamfilter_expr.cc similarity index 96% rename from extensions/spamfilter_expr.c rename to extensions/spamfilter_expr.cc index cd2630127..eb915c7ba 100644 --- a/extensions/spamfilter_expr.c +++ b/extensions/spamfilter_expr.cc @@ -152,7 +152,7 @@ struct Expr *new_expr(const char *const pattern, int *const errcode, PCRE2_SIZE *const erroff) { - struct Expr *const ret = rb_malloc(sizeof(struct Expr)); + const auto ret((Expr *)rb_malloc(sizeof(Expr))); ret->id = hash_pattern(pattern); ret->comp_opts = comp_opts; ret->match_opts = match_opts; @@ -199,7 +199,7 @@ struct Expr *new_expr(const char *const pattern, static struct Expr *find_expr(const unsigned int id) { - return rb_dictionary_retrieve(exprs, &id); + return (Expr *)rb_dictionary_retrieve(exprs, &id); } @@ -257,7 +257,7 @@ int activate_expr(struct Expr *const expr, static struct Expr *deactivate_expr(const unsigned int id) { - return rb_dictionary_delete(exprs, &id); + return (Expr *)rb_dictionary_delete(exprs, &id); } @@ -295,7 +295,7 @@ struct Expr *activate_new_expr(const char *const pattern, static int deactivate_and_free_expr(const unsigned int id) { - struct Expr *const expr = rb_dictionary_delete(exprs, &id); + struct Expr *const expr = (Expr *)rb_dictionary_delete(exprs, &id); free_expr(expr); return expr != NULL; } @@ -607,10 +607,11 @@ struct Expr *match_any_expr(const char *const text, const size_t off, const unsigned int options) { - struct Expr *expr; + void *elem; rb_dictionary_iter state; - RB_DICTIONARY_FOREACH(expr, &state, exprs) + RB_DICTIONARY_FOREACH(elem, &state, exprs) { + auto *const expr(reinterpret_cast(elem)); if(match_expr(expr, text, len, off, options) > 0) return expr; } @@ -637,7 +638,7 @@ int dump_pcre_config(struct Client *client_p, struct Client *source_p, int parc, if((v.v_ulong = pcre2_config(PCRE2_CONFIG_VERSION, NULL)) > 0) { v.v_ulong *= (PCRE2_CODE_UNIT_WIDTH / 8); - v.v_buf = rb_malloc(v.v_ulong); + v.v_buf = (char *)rb_malloc(v.v_ulong); pcre2_config(PCRE2_CONFIG_VERSION, v.v_buf); sendto_one_notice(source_p, ":\2%-30s\2: (%s)", "PCRE2 VERSION", v.v_buf); rb_free(v.v_buf); @@ -658,7 +659,7 @@ int dump_pcre_config(struct Client *client_p, struct Client *source_p, int parc, if((v.v_ulong = pcre2_config(PCRE2_CONFIG_JITTARGET, NULL)) > 0) { v.v_ulong *= (PCRE2_CODE_UNIT_WIDTH / 8); - v.v_buf = rb_malloc(v.v_ulong); + v.v_buf = (char *)rb_malloc(v.v_ulong); pcre2_config(PCRE2_CONFIG_JITTARGET, v.v_buf); sendto_one_notice(source_p, ":\2%-30s\2: (%s)", "PCRE2 JITTARGET", v.v_buf); rb_free(v.v_buf); @@ -697,7 +698,7 @@ int dump_pcre_config(struct Client *client_p, struct Client *source_p, int parc, if((v.v_ulong = pcre2_config(PCRE2_CONFIG_UNICODE_VERSION, NULL)) > 0) { v.v_ulong *= (PCRE2_CODE_UNIT_WIDTH / 8); - v.v_buf = rb_malloc(v.v_ulong); + v.v_buf = (char *)rb_malloc(v.v_ulong); pcre2_config(PCRE2_CONFIG_UNICODE_VERSION, v.v_buf); sendto_one_notice(source_p, ":\2%-30s\2: (%s)", "PCRE2 UNICODE_VERSION", v.v_buf); rb_free(v.v_buf); @@ -774,10 +775,11 @@ int spamexpr_list(struct Client *client_p, struct Client *source_p, int parc, co for(size_t i = 0; i < parc; i++) nparv[i+1] = parv[i]; - struct Expr *expr; + void *elem; rb_dictionary_iter state; - RB_DICTIONARY_FOREACH(expr, &state, exprs) + RB_DICTIONARY_FOREACH(elem, &state, exprs) { + auto *const expr(reinterpret_cast(elem)); snprintf(id, sizeof(id), "%u", expr->id); spamexpr_info(client_p, source_p, parc+1, nparv); } @@ -926,10 +928,11 @@ int spamexpr_test(struct Client *client_p, struct Client *source_p, int parc, co return 0; } - struct Expr *expr; + void *elem; rb_dictionary_iter state; - RB_DICTIONARY_FOREACH(expr, &state, exprs) + RB_DICTIONARY_FOREACH(elem, &state, exprs) { + auto *const expr(reinterpret_cast(elem)); const int ret = match_expr(expr, parv[1], len, 0, 0); sendto_one_notice(source_p, ":#%-2d: (%d) %s", id, ret, ret > 0? "POSITIVE" : "NEGATIVE"); } @@ -947,10 +950,11 @@ int spamexpr_sync(struct Client *client_p, struct Client *source_p, int parc, co return 0; } - struct Expr *expr; + void *elem; rb_dictionary_iter state; - RB_DICTIONARY_FOREACH(expr, &state, exprs) + RB_DICTIONARY_FOREACH(elem, &state, exprs) { + auto *const expr(reinterpret_cast(elem)); char comp_opts[128] = {0}, match_opts[128] = {0}, jit_opts[128] = {0}; strlcat_pcre_opts(expr->comp_opts, comp_opts, sizeof(comp_opts), str_pcre_comp); strlcat_pcre_opts(expr->match_opts, match_opts, sizeof(match_opts), str_pcre_match); @@ -1060,10 +1064,11 @@ void hook_doing_stats(hook_data_int *const data) if(statchar != STATCHAR_SPAMFILTER) return; - struct Expr *expr; + void *elem; rb_dictionary_iter state; - RB_DICTIONARY_FOREACH(expr, &state, exprs) + RB_DICTIONARY_FOREACH(elem, &state, exprs) { + auto *const expr(reinterpret_cast(elem)); char comp_opts[128] = {0}, match_opts[128] = {0}; strlcat_pcre_opts(expr->comp_opts, comp_opts, sizeof(comp_opts), str_pcre_comp); strlcat_pcre_opts(expr->match_opts, match_opts, sizeof(match_opts), str_pcre_match); @@ -1105,15 +1110,15 @@ void hook_server_introduced(hook_data_client *const data) */ static -int exprs_comparator(const unsigned int *const a, const unsigned int *const b) +int exprs_comparator(const void *const a, const void *const b) { - return *b - *a; + return *reinterpret_cast(b) - *reinterpret_cast(a); } static void exprs_destructor(rb_dictionary_element *const ptr, void *const priv) { - free_expr(ptr->data); + free_expr((Expr *)ptr->data); } @@ -1137,12 +1142,12 @@ int set_parm_opt(const conf_parm_t *const parm, static -void set_parm_opts(const conf_parm_t *const val, +void set_parm_opts(const void *const val, unsigned int *const dest, long (*const reflector)(const char *), const char *const optname) { - for(const conf_parm_t *parm = val; parm; parm = parm->next) + for(const auto *parm((conf_parm_t *)val); parm; parm = parm->next) if(!set_parm_opt(parm, dest, reflector)) conf_report_error("Unrecognized PCRE %s option: %s", optname, parm->v.string); } @@ -1214,7 +1219,7 @@ void conf_spamexpr_jit_opts(void *const val) static void conf_spamexpr_pattern(void *const val) { - const char *const pattern = val; + const char *const pattern = (const char *)val; rb_strlcpy(conf_spamexpr_cur.pattern, pattern, sizeof(conf_spamexpr_cur.pattern)); } diff --git a/extensions/spamfilter_nicks.c b/extensions/spamfilter_nicks.cc similarity index 98% rename from extensions/spamfilter_nicks.c rename to extensions/spamfilter_nicks.cc index cb9fd5710..5dc328b22 100644 --- a/extensions/spamfilter_nicks.c +++ b/extensions/spamfilter_nicks.cc @@ -96,7 +96,7 @@ void bloom_destroy(void) { for(size_t i = 0; i < NUM_HASHES; i++) { - rb_free(bloom[i]); + delete bloom[i]; bloom[i] = NULL; } @@ -111,7 +111,7 @@ void bloom_create(const size_t size) return; for(size_t i = 0; i < NUM_HASHES; i++) - bloom[i] = rb_malloc(size); + bloom[i] = new uint8_t[size]; bloom_size = size; bloom_flush(); @@ -171,7 +171,7 @@ int chans_add(struct Channel *const chptr) rb_dlink_node *ptr; RB_DLINK_FOREACH(ptr, chptr->members.head) { - const struct membership *const msptr = ptr->data; + const auto msptr(reinterpret_cast(ptr->data)); bloom_add_str(msptr->client_p->name); } diff --git a/extensions/spy_admin_notice.c b/extensions/spy_admin_notice.cc similarity index 100% rename from extensions/spy_admin_notice.c rename to extensions/spy_admin_notice.cc diff --git a/extensions/spy_info_notice.c b/extensions/spy_info_notice.cc similarity index 100% rename from extensions/spy_info_notice.c rename to extensions/spy_info_notice.cc diff --git a/extensions/spy_links_notice.c b/extensions/spy_links_notice.cc similarity index 97% rename from extensions/spy_links_notice.c rename to extensions/spy_links_notice.cc index 78b7d357b..09d72e314 100644 --- a/extensions/spy_links_notice.c +++ b/extensions/spy_links_notice.cc @@ -40,7 +40,7 @@ DECLARE_MODULE_AV2(links_spy, NULL, NULL, NULL, NULL, links_hfnlist, NULL, NULL, void show_links(hook_data *data) { - const char *mask = data->arg1; + const char *mask = (const char *)data->arg1; sendto_realops_snomask(SNO_SPY, L_ALL, "LINKS '%s' requested by %s (%s@%s) [%s]", diff --git a/extensions/spy_motd_notice.c b/extensions/spy_motd_notice.cc similarity index 100% rename from extensions/spy_motd_notice.c rename to extensions/spy_motd_notice.cc diff --git a/extensions/spy_stats_notice.c b/extensions/spy_stats_notice.cc similarity index 97% rename from extensions/spy_stats_notice.c rename to extensions/spy_stats_notice.cc index c90236ec6..fe7d0f49f 100644 --- a/extensions/spy_stats_notice.c +++ b/extensions/spy_stats_notice.cc @@ -44,7 +44,7 @@ show_stats(hook_data_int *data) if(statchar == 'L' || statchar == 'l') { - const char *name = data->arg1; + const char *name = (const char *)data->arg1; if(!EmptyString(name)) sendto_realops_snomask(SNO_SPY, L_ALL, diff --git a/extensions/spy_stats_p_notice.c b/extensions/spy_stats_p_notice.cc similarity index 100% rename from extensions/spy_stats_p_notice.c rename to extensions/spy_stats_p_notice.cc diff --git a/extensions/spy_trace_notice.c b/extensions/spy_trace_notice.cc similarity index 100% rename from extensions/spy_trace_notice.c rename to extensions/spy_trace_notice.cc diff --git a/extensions/umode_noctcp.c b/extensions/umode_noctcp.cc similarity index 100% rename from extensions/umode_noctcp.c rename to extensions/umode_noctcp.cc diff --git a/include/ircd/bandbi.h b/include/ircd/bandbi.h index aad0cf6b1..325cca4a9 100644 --- a/include/ircd/bandbi.h +++ b/include/ircd/bandbi.h @@ -16,4 +16,5 @@ void bandb_add(bandb_type, struct Client *source_p, const char *mask1, const char *mask2, const char *reason, const char *oper_reason, int perm); void bandb_del(bandb_type, const char *mask1, const char *mask2); void bandb_rehash_bans(void); + #endif diff --git a/include/ircd/cache.h b/include/ircd/cache.h index fd609411b..75fc8b261 100644 --- a/include/ircd/cache.h +++ b/include/ircd/cache.h @@ -45,5 +45,5 @@ void cache_user_motd(void); extern rb_dictionary *help_dict_oper; extern rb_dictionary *help_dict_user; -#endif +#endif diff --git a/include/ircd/defaults.h b/include/ircd/defaults.h index ff95af06b..bf6bb95ec 100644 --- a/include/ircd/defaults.h +++ b/include/ircd/defaults.h @@ -202,5 +202,4 @@ ircd_path_t; extern const char *ircd_paths[IRCD_PATH_COUNT]; - #endif // _IRCD_SYSTEM_H diff --git a/include/ircd/hostmask.h b/include/ircd/hostmask.h index 8e97cf74b..31cd5ce13 100644 --- a/include/ircd/hostmask.h +++ b/include/ircd/hostmask.h @@ -25,6 +25,7 @@ #ifndef INCLUDE_hostmask_h #define INCLUDE_hostmask_h 1 + enum { HM_HOST, @@ -104,5 +105,4 @@ struct AddressRec struct AddressRec *next; }; - #endif /* INCLUDE_hostmask_h */ diff --git a/include/ircd/ircd.h b/include/ircd/ircd.h index dbd13434b..cf79287a0 100644 --- a/include/ircd/ircd.h +++ b/include/ircd/ircd.h @@ -22,8 +22,8 @@ * USA */ -#ifndef INCLUDED_ircd_h -#define INCLUDED_ircd_h +#ifndef _IRCD_H +#define _IRCD_H #include "defaults.h" @@ -104,4 +104,4 @@ extern int maxconnections; void ircd_shutdown(const char *reason) __attribute__((noreturn)); -#endif +#endif // _IRCD_H diff --git a/include/ircd/logger.h b/include/ircd/logger.h index f537ecc37..01d237f05 100644 --- a/include/ircd/logger.h +++ b/include/ircd/logger.h @@ -29,8 +29,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef INCLUDED_s_log_h -#define INCLUDED_s_log_h +#ifndef _IRCD_LOGGER_H +#define _IRCD_LOGGER_H #include "defaults.h" @@ -66,4 +66,4 @@ extern void ilog_error(const char *); void vslog(ilogfile dest, unsigned int snomask, const char *fmt, va_list ap); void slog(ilogfile dest, unsigned int snomask, const char *fmt, ...) AFP(3, 4); -#endif +#endif // _IRCD_LOGGER_H diff --git a/include/ircd/m_info.h b/include/ircd/m_info.h index d0ff6417e..cd0ade851 100644 --- a/include/ircd/m_info.h +++ b/include/ircd/m_info.h @@ -157,5 +157,4 @@ Info MyInformation[] = { {0, 0, 0, 0} }; - #endif /* INCLUDED_m_info_h */ diff --git a/include/ircd/reject.h b/include/ircd/reject.h index 6fabb2cb4..35c77f86a 100644 --- a/include/ircd/reject.h +++ b/include/ircd/reject.h @@ -41,6 +41,4 @@ int is_throttle_ip(struct sockaddr *addr); unsigned long throttle_size(void); void flush_throttle(void); - #endif - diff --git a/include/ircd/sslproc.h b/include/ircd/sslproc.h index 61c6695a1..7afb9916e 100644 --- a/include/ircd/sslproc.h +++ b/include/ircd/sslproc.h @@ -43,4 +43,3 @@ int get_ssld_count(void); void ssld_foreach_info(void (*func)(void *data, pid_t pid, int cli_count, enum ssld_status status, const char *version), void *data); #endif - diff --git a/include/ircd/stdinc.h b/include/ircd/stdinc.h index c06ffbd3b..9ac6bde8d 100644 --- a/include/ircd/stdinc.h +++ b/include/ircd/stdinc.h @@ -78,8 +78,8 @@ extern int errno; #define LOCAL_COPY(s) strdupa(s) #else #if defined(__INTEL_COMPILER) || defined(__GNUC__) -# define LOCAL_COPY(s) __extension__({ char *_s = alloca(strlen(s) + 1); strcpy(_s, s); _s; }) +# define LOCAL_COPY(s) __extension__({ char *_s = (char *)alloca(strlen(s) + 1); strcpy(_s, s); _s; }) #else -# define LOCAL_COPY(s) strcpy(alloca(strlen(s) + 1), s) /* XXX Is that allowed? */ +# define LOCAL_COPY(s) strcpy((char *)alloca(strlen(s) + 1), s) #endif /* defined(__INTEL_COMPILER) || defined(__GNUC__) */ #endif /* strdupa */ diff --git a/include/ircd/wsproc.h b/include/ircd/wsproc.h index 3d8181468..3c801304c 100644 --- a/include/ircd/wsproc.h +++ b/include/ircd/wsproc.h @@ -41,4 +41,3 @@ int get_wsockd_count(void); void wsockd_foreach_info(void (*func)(void *data, pid_t pid, int cli_count, enum wsockd_status status), void *data); #endif - diff --git a/include/rb/Makefile.am b/include/rb/Makefile.am new file mode 100644 index 000000000..2343a5990 --- /dev/null +++ b/include/rb/Makefile.am @@ -0,0 +1,17 @@ +AUTOMAKE_OPTIONS = foreign + +AM_CPPFLAGS = -isystem $(top_srcdir)/boost/include +AM_LDFLAGS = -L$(top_srcdir)/boost/lib + +BUILT_SOURCES = rb.h.gch + +rb.h.gch: + $(CXX) -o rb.h.gch $(CPPFLAGS) rb.h + +clean-local: + rm -f rb.h.gch + +mrproper-local: + rm -f config.h + rm -f config.h.in + rm -f stamp-h1 diff --git a/include/rb/arc4random.h b/include/rb/arc4random.h index 6bdd701fd..6a96b1856 100644 --- a/include/rb/arc4random.h +++ b/include/rb/arc4random.h @@ -1,3 +1,8 @@ +#pragma once +#define HAVE_RB_ARC4RANDOM_H +#ifdef __cplusplus +extern "C" { +#endif #if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS) && !defined(HAVE_ARC4RANDOM) @@ -5,3 +10,8 @@ void arc4random_stir(void); uint32_t arc4random(void); void arc4random_addrandom(uint8_t *dat, int datlen); #endif + + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/include/rb/balloc.h b/include/rb/balloc.h index fc15d0027..cbcbaba61 100644 --- a/include/rb/balloc.h +++ b/include/rb/balloc.h @@ -29,6 +29,9 @@ #ifndef _RB_BALLOC_H #define _RB_BALLOC_H 1 +#ifdef __cplusplus +extern "C" { +#endif struct rb_bh; typedef struct rb_bh rb_bh; @@ -46,4 +49,7 @@ void rb_bh_usage(rb_bh *bh, size_t *bused, size_t *bfree, size_t *bmemusage, con void rb_bh_usage_all(rb_bh_usage_cb *cb, void *data); void rb_bh_total_usage(size_t *total_alloc, size_t *total_used); +#ifdef __cplusplus +} // extern "C" +#endif #endif // _RB_BALLOC_H diff --git a/include/rb/commio.h b/include/rb/commio.h index 58b08c3a5..c4d3f11b5 100644 --- a/include/rb/commio.h +++ b/include/rb/commio.h @@ -29,7 +29,9 @@ #ifndef INCLUDED_commio_h #define INCLUDED_commio_h - +#ifdef __cplusplus +extern "C" { +#endif struct sockaddr; struct _fde; @@ -193,4 +195,7 @@ const char *rb_ssl_get_cipher(rb_fde_t *F); int rb_ipv4_from_ipv6(const struct sockaddr_in6 *__restrict__ ip6, struct sockaddr_in *__restrict__ ip4); +#ifdef __cplusplus +} // extern "C" +#endif #endif /* INCLUDED_commio_h */ diff --git a/include/rb/commio_int.h b/include/rb/commio_int.h index 9ea36c96f..dad2391f4 100644 --- a/include/rb/commio_int.h +++ b/include/rb/commio_int.h @@ -25,6 +25,9 @@ #ifndef _RB_COMMIO_INT_H #define _RB_COMMIO_INT_H 1 +#ifdef __cplusplus +extern "C" { +#endif #define RB_FD_HASH_BITS 12 #define RB_FD_HASH_SIZE (1UL << RB_FD_HASH_BITS) @@ -117,7 +120,7 @@ rb_find_fd(rb_platform_fd_t fd) RB_DLINK_FOREACH(ptr, hlist->head) { - rb_fde_t *F = ptr->data; + rb_fde_t *F = (rb_fde_t *)ptr->data; if(F->fd == fd) return F; } @@ -206,5 +209,8 @@ int rb_init_netio_win32(void); int rb_select_win32(long); int rb_setup_fd_win32(rb_fde_t *F); +#ifdef __cplusplus +} // extern "C" +#endif #endif // _RB_COMMIO_INT_H diff --git a/include/rb/dictionary.h b/include/rb/dictionary.h index 119eb65a4..38c2fbeb3 100644 --- a/include/rb/dictionary.h +++ b/include/rb/dictionary.h @@ -24,6 +24,9 @@ #ifndef __RB_DICTIONARY_H__ #define __RB_DICTIONARY_H__ +#ifdef __cplusplus +extern "C" { +#endif typedef struct rb_dictionary rb_dictionary; typedef struct rb_dictionary_element rb_dictionary_element; @@ -31,12 +34,16 @@ typedef struct rb_dictionary_iter rb_dictionary_iter; struct rb_dictionary; -// This comparator could be based on a union of function types emulating a -// quasi-template, shutting up a lot of warnings. For now it gets The Treatment. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-prototypes" -typedef int (*DCF)(/* const void *a, const void *b */); -#pragma GCC diagnostic pop +#ifndef __cplusplus + // This comparator could be based on a union of function types emulating a + // quasi-template, shutting up a lot of warnings. For now it gets The Treatment. + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-prototypes" + typedef int (*DCF)(/* const void *a, const void *b */); + #pragma GCC diagnostic pop +#else + typedef int (*DCF)(const void *a, const void *b); +#endif struct rb_dictionary_element { @@ -188,4 +195,7 @@ static inline int rb_uint32cmp(const void *a, const void *b) return RB_POINTER_TO_UINT(b) - RB_POINTER_TO_UINT(a); } +#ifdef __cplusplus +} // extern "C" +#endif #endif diff --git a/include/rb/dlink.h b/include/rb/dlink.h index 4a7359c3c..0d75af300 100644 --- a/include/rb/dlink.h +++ b/include/rb/dlink.h @@ -23,13 +23,11 @@ * */ -#ifndef RB_LIB_H - #error "Do not use rb_dlink.h directly" -#endif - #ifndef __DLINK_H__ #define __DLINK_H__ - +#ifdef __cplusplus +extern "C" { +#endif typedef struct rb_dlink_node { @@ -337,4 +335,7 @@ rb_dlinkMoveList(rb_dlink_list *from, rb_dlink_list *to) from->length = 0; } +#ifdef __cplusplus +} // extern "C" +#endif #endif /* __DLINK_H__ */ diff --git a/include/rb/event.h b/include/rb/event.h index a99e485df..bc6ac9a17 100644 --- a/include/rb/event.h +++ b/include/rb/event.h @@ -23,12 +23,11 @@ * */ -#ifndef RB_LIB_H -# error "Do not use event.h directly" -#endif - #ifndef INCLUDED_event_h #define INCLUDED_event_h +#ifdef __cplusplus +extern "C" { +#endif struct ev_entry; typedef void EVH(void *); @@ -46,4 +45,7 @@ void rb_dump_events(void (*func) (char *, void *), void *ptr); void rb_run_one_event(struct ev_entry *); time_t rb_event_next(void); +#ifdef __cplusplus +} // extern "C" +#endif #endif /* INCLUDED_event_h */ diff --git a/include/rb/event_int.h b/include/rb/event_int.h index 311252fb6..0f50dbbc4 100644 --- a/include/rb/event_int.h +++ b/include/rb/event_int.h @@ -24,6 +24,9 @@ #ifndef _RB_EVENT_INT_H #define _RB_EVENT_INT_H 1 +#ifdef __cplusplus +extern "C" { +#endif struct ev_entry { @@ -39,4 +42,7 @@ struct ev_entry }; void rb_event_io_register_all(void); +#ifdef __cplusplus +} // extern "C" +#endif #endif // _RB_EVENT_INT_H diff --git a/include/rb/helper.h b/include/rb/helper.h index 01868b678..ff0716202 100644 --- a/include/rb/helper.h +++ b/include/rb/helper.h @@ -21,12 +21,11 @@ * */ -#ifndef RB_LIB_H -# error "Do not use helper.h directly" -#endif - #ifndef INCLUDED_helper_h #define INCLUDED_helper_h +#ifdef __cplusplus +extern "C" { +#endif struct _rb_helper; typedef struct _rb_helper rb_helper; @@ -59,4 +58,8 @@ void rb_helper_run(rb_helper *helper); void rb_helper_close(rb_helper *helper); int rb_helper_read(rb_helper *helper, void *buf, size_t bufsize); void rb_helper_loop(rb_helper *helper, long delay) __attribute__((noreturn)); + +#ifdef __cplusplus +} // extern "C" +#endif #endif diff --git a/include/rb/linebuf.h b/include/rb/linebuf.h index d0e0b9883..597ee46b1 100644 --- a/include/rb/linebuf.h +++ b/include/rb/linebuf.h @@ -23,12 +23,11 @@ * */ -#ifndef RB_LIB_H -# error "Do not use linebuf.h directly" -#endif - #ifndef __LINEBUF_H__ #define __LINEBUF_H__ +#ifdef __cplusplus +extern "C" { +#endif #define LINEBUF_COMPLETE 0 #define LINEBUF_PARTIAL 1 @@ -79,5 +78,7 @@ void rb_linebuf_attach(buf_head_t *, buf_head_t *); void rb_count_rb_linebuf_memory(size_t *, size_t *); int rb_linebuf_flush(rb_fde_t *F, buf_head_t *); - +#ifdef __cplusplus +} // extern "C" +#endif #endif diff --git a/include/rb/memory.h b/include/rb/memory.h index eaba9bfda..ae3afd3d3 100644 --- a/include/rb/memory.h +++ b/include/rb/memory.h @@ -23,12 +23,11 @@ * */ -#ifndef RB_LIB_H -#error "Do not use rb_memory.h directly" -#endif - #ifndef _RB_MEMORY_H #define _RB_MEMORY_H +#ifdef __cplusplus +extern "C" { +#endif #define RB_UNIQUE_PTR(deleter) __attribute__((cleanup(deleter))) #define RB_AUTO_PTR RB_UNIQUE_PTR(rb_raii_free) @@ -111,4 +110,7 @@ rb_raii_free(const void *const ptr) rb_free(_ptr); } -#endif /* _I_MEMORY_H */ +#ifdef __cplusplus +} // extern "C" +#endif +#endif /* _RB_MEMORY_H */ diff --git a/include/rb/patricia.h b/include/rb/patricia.h index 79b9fecb4..a465d3065 100644 --- a/include/rb/patricia.h +++ b/include/rb/patricia.h @@ -13,6 +13,9 @@ #ifndef _RB_PATRICIA_H #define _RB_PATRICIA_H +#ifdef __cplusplus +extern "C" { +#endif #ifndef FALSE #define FALSE 0 @@ -137,4 +140,8 @@ do { \ } \ } while (0) + +#ifdef __cplusplus +} // extern "C" +#endif #endif /* _RB_PATRICIA_H */ diff --git a/include/rb/radixtree.h b/include/rb/radixtree.h index 0b5d1bcc9..3dcc84259 100644 --- a/include/rb/radixtree.h +++ b/include/rb/radixtree.h @@ -34,6 +34,9 @@ #ifndef __rb_radixtree_H__ #define __rb_radixtree_H__ +#ifdef __cplusplus +extern "C" { +#endif struct rb_radixtree; /* defined in src/rb_radixtree.c */ @@ -154,4 +157,7 @@ unsigned int rb_radixtree_size(rb_radixtree *dict); void rb_radixtree_stats(rb_radixtree *dict, void (*cb)(const char *line, void *privdata), void *privdata); void rb_radixtree_stats_walk(void (*cb)(const char *line, void *privdata), void *privdata); +#ifdef __cplusplus +} // extern "C" +#endif #endif diff --git a/include/rb/rawbuf.h b/include/rb/rawbuf.h index 91242e82a..c0a1d5f37 100644 --- a/include/rb/rawbuf.h +++ b/include/rb/rawbuf.h @@ -22,14 +22,11 @@ * */ -#ifndef RB_LIB_H -# error "Do not use rawbuf.h directly" -#endif - #ifndef INCLUDED_RAWBUF_H__ #define INCLUDED_RAWBUF_H__ - - +#ifdef __cplusplus +extern "C" { +#endif typedef struct _rawbuf rawbuf_t; typedef struct _rawbuf_head rawbuf_head_t; @@ -42,4 +39,7 @@ void rb_rawbuf_append(rawbuf_head_t *, void *data, int len); int rb_rawbuf_flush(rawbuf_head_t *, rb_fde_t *F); int rb_rawbuf_length(rawbuf_head_t * rb); +#ifdef __cplusplus +} // extern "C" +#endif #endif diff --git a/include/rb/rb.h b/include/rb/rb.h index 2b1280810..be0c402a4 100644 --- a/include/rb/rb.h +++ b/include/rb/rb.h @@ -2,15 +2,14 @@ #define _RB_H #define RB_LIB_H +#include "config.h" +#include "requires.h" +#include "system.h" + #ifdef __cplusplus extern "C" { #endif -#include "config.h" -#include "include.h" -#include "system.h" - - typedef socklen_t rb_socklen_t; typedef void log_cb(const char *buffer); typedef void restart_cb(const char *buffer); @@ -44,6 +43,9 @@ void *const *rb_backtrace(int *len); // writes to and returns st const char *const *rb_backtrace_symbols(int *len); // translates rb_backtrace(), all static void rb_backtrace_log_symbols(void); // rb_backtrace_symbols piped to rb_lib_log() +#ifdef __cplusplus +} // extern "C" +#endif #include "tools.h" #include "dlink.h" @@ -58,11 +60,4 @@ void rb_backtrace_log_symbols(void); // rb_backtrace_symbols pip #include "dictionary.h" #include "radixtree.h" -#ifdef __cplusplus -} // extern "C" -#endif - -#include "cpp.h" - - #endif // _RB_H diff --git a/include/rb/requires.h b/include/rb/requires.h new file mode 100644 index 000000000..95447c844 --- /dev/null +++ b/include/rb/requires.h @@ -0,0 +1,83 @@ +#ifndef _RB_REQUIRES_H +#define _RB_REQUIRES_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +// This is exactly how they recommend doing it in the docs by Alan Smithee, +// but the gcc docs on the other hand, with tongue in cheek, tell the tale +// by metaphor: https://gcc.gnu.org/onlinedocs/cpp/Computed-Includes.html + +#include +// #include + +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN 1 +#include authd_cmd_tab +{[] { - ['A'] = { cmd_accept_client, 4 }, - ['E'] = { cmd_dns_result, 5 }, - ['N'] = { cmd_notice_client, 3 }, - ['R'] = { cmd_reject_client, 7 }, - ['W'] = { cmd_oper_warn, 3 }, - ['X'] = { cmd_stats_results, 3 }, - ['Y'] = { cmd_stats_results, 3 }, - ['Z'] = { cmd_stats_results, 3 }, + std::array ret {0}; + ret['A'] = { cmd_accept_client, 4 }; + ret['E'] = { cmd_dns_result, 5 }; + ret['N'] = { cmd_notice_client, 3 }; + ret['R'] = { cmd_reject_client, 7 }; + ret['W'] = { cmd_oper_warn, 3 }; + ret['X'] = { cmd_stats_results, 3 }; + ret['Y'] = { cmd_stats_results, 3 }; + ret['Z'] = { cmd_stats_results, 3 }; + return ret; +}() }; static int @@ -156,9 +160,9 @@ cid_to_client(uint32_t ncid, bool del) struct Client *client_p; if(del) - client_p = rb_dictionary_delete(cid_clients, RB_UINT_TO_POINTER(ncid)); + client_p = (Client *)rb_dictionary_delete(cid_clients, RB_UINT_TO_POINTER(ncid)); else - client_p = rb_dictionary_retrieve(cid_clients, RB_UINT_TO_POINTER(ncid)); + client_p = (Client *)rb_dictionary_retrieve(cid_clients, RB_UINT_TO_POINTER(ncid)); /* If the client's not found, that's okay, it may have already gone away. * --Elizafox */ @@ -341,7 +345,7 @@ configure_authd(void) RB_DLINK_FOREACH(ptr, opm_list.head) { - struct OPMScanner *scanner = ptr->data; + struct OPMScanner *scanner = (OPMScanner *)ptr->data; rb_helper_write(authd_helper, "O opm_scanner %s %hu", scanner->type, scanner->port); } @@ -371,7 +375,7 @@ authd_free_client(struct Client *client_p) static void authd_free_client_cb(rb_dictionary_element *delem, void *unused) { - struct Client *client_p = delem->data; + struct Client *client_p = (Client *)delem->data; authd_free_client(client_p); } @@ -562,8 +566,10 @@ timeout_dead_authd_clients(void *notused __unused) rb_dlink_list freelist = { NULL, NULL, 0 }; rb_dlink_node *ptr, *nptr; - RB_DICTIONARY_FOREACH(client_p, &iter, cid_clients) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, cid_clients) { + client_p = (Client *)elem; if(client_p->preClient->auth.timeout < rb_current_time()) { authd_free_client(client_p); @@ -574,7 +580,7 @@ timeout_dead_authd_clients(void *notused __unused) /* RB_DICTIONARY_FOREACH is not safe for deletion, so we do this crap */ RB_DLINK_FOREACH_SAFE(ptr, nptr, freelist.head) { - client_p = ptr->data; + client_p = (Client *)ptr->data; rb_dictionary_delete(cid_clients, RB_UINT_TO_POINTER(client_p->preClient->auth.cid)); } } @@ -584,19 +590,19 @@ void add_blacklist(const char *host, const char *reason, uint8_t iptype, rb_dlink_list *filters) { rb_dlink_node *ptr; - struct BlacklistStats *stats = rb_malloc(sizeof(struct BlacklistStats)); + struct BlacklistStats *stats = (BlacklistStats *)rb_malloc(sizeof(struct BlacklistStats)); char filterbuf[BUFSIZE] = "*"; size_t s = 0; if(bl_stats == NULL) - bl_stats = rb_dictionary_create("blacklist statistics", rb_strcasecmp); + bl_stats = rb_dictionary_create("blacklist statistics", reinterpret_cast(rb_strcasecmp)); /* Build a list of comma-separated values for authd. * We don't check for validity - do it elsewhere. */ RB_DLINK_FOREACH(ptr, filters->head) { - char *filter = ptr->data; + char *filter = (char *)ptr->data; size_t filterlen = strlen(filter) + 1; if(s + filterlen > sizeof(filterbuf)) @@ -622,7 +628,7 @@ add_blacklist(const char *host, const char *reason, uint8_t iptype, rb_dlink_lis void del_blacklist(const char *host) { - struct BlacklistStats *stats = rb_dictionary_retrieve(bl_stats, host); + struct BlacklistStats *stats = (BlacklistStats *)rb_dictionary_retrieve(bl_stats, host); if(stats != NULL) { rb_dictionary_delete(bl_stats, host); @@ -636,7 +642,7 @@ del_blacklist(const char *host) static void blacklist_delete(rb_dictionary_element *delem, void *unused) { - struct BlacklistStats *stats = delem->data; + struct BlacklistStats *stats = (BlacklistStats *)delem->data; rb_free(stats->host); rb_free(stats); @@ -732,7 +738,7 @@ opm_check_enable(bool enabled) void conf_create_opm_proxy_scanner(const char *type, uint16_t port) { - struct OPMScanner *scanner = rb_malloc(sizeof(struct OPMScanner)); + struct OPMScanner *scanner = (OPMScanner *)rb_malloc(sizeof(struct OPMScanner)); rb_strlcpy(scanner->type, type, sizeof(scanner->type)); scanner->port = port; @@ -753,7 +759,7 @@ delete_opm_proxy_scanner(const char *type, uint16_t port) RB_DLINK_FOREACH_SAFE(ptr, nptr, opm_list.head) { - struct OPMScanner *scanner = ptr->data; + struct OPMScanner *scanner = (OPMScanner *)ptr->data; if(rb_strncasecmp(scanner->type, type, sizeof(scanner->type)) == 0 && scanner->port == port) @@ -774,7 +780,7 @@ delete_opm_proxy_scanner_all(void) RB_DLINK_FOREACH_SAFE(ptr, nptr, opm_list.head) { - struct OPMScanner *scanner = ptr->data; + struct OPMScanner *scanner = (OPMScanner *)ptr->data; rb_dlinkDelete(ptr, &opm_list); rb_free(scanner); diff --git a/ircd/bandbi.c b/ircd/bandbi.cc similarity index 99% rename from ircd/bandbi.c rename to ircd/bandbi.cc index 82cefefae..8d6255a16 100644 --- a/ircd/bandbi.c +++ b/ircd/bandbi.cc @@ -317,7 +317,7 @@ bandb_handle_clear(void) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, bandb_pending.head) { - free_conf(ptr->data); + free_conf((ConfItem *)ptr->data); rb_dlinkDestroy(ptr, &bandb_pending); } } @@ -333,7 +333,7 @@ bandb_handle_finish(void) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, bandb_pending.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; rb_dlinkDestroy(ptr, &bandb_pending); diff --git a/ircd/cache.c b/ircd/cache.cc similarity index 91% rename from ircd/cache.c rename to ircd/cache.cc index 76b97af02..a7514fae0 100644 --- a/ircd/cache.c +++ b/ircd/cache.cc @@ -57,7 +57,7 @@ void init_cache(void) { /* allocate the emptyline */ - emptyline = rb_malloc(sizeof(struct cacheline)); + emptyline = (cacheline *)rb_malloc(sizeof(struct cacheline)); emptyline->data = rb_strdup(" "); user_motd_changed[0] = '\0'; @@ -66,8 +66,8 @@ init_cache(void) oper_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_OMOTD], "opers.motd", 0); memset(&links_cache_list, 0, sizeof(links_cache_list)); - help_dict_oper = rb_dictionary_create("oper help", rb_strcasecmp); - help_dict_user = rb_dictionary_create("user help", rb_strcasecmp); + help_dict_oper = rb_dictionary_create("oper help", reinterpret_cast(rb_strcasecmp)); + help_dict_user = rb_dictionary_create("user help", reinterpret_cast(rb_strcasecmp)); } /* @@ -118,7 +118,7 @@ cache_file(const char *filename, const char *shortname, int flags) return NULL; - cacheptr = rb_malloc(sizeof(struct cachefile)); + cacheptr = (cachefile *)rb_malloc(sizeof(struct cachefile)); rb_strlcpy(cacheptr->name, shortname, sizeof(cacheptr->name)); cacheptr->flags = flags; @@ -133,7 +133,7 @@ cache_file(const char *filename, const char *shortname, int flags) { char untabline[BUFSIZE]; - lineptr = rb_malloc(sizeof(struct cacheline)); + lineptr = (cacheline *)rb_malloc(sizeof(struct cacheline)); untabify(untabline, line, sizeof(untabline)); lineptr->data = rb_strdup(untabline); @@ -174,7 +174,7 @@ cache_links(void *unused) RB_DLINK_FOREACH(ptr, global_serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; /* skip ourselves (done in /links) and hidden servers */ if(IsMe(target_p) || @@ -182,7 +182,7 @@ cache_links(void *unused) continue; /* if the below is ever modified, change LINKSLINELEN */ - links_line = rb_malloc(LINKSLINELEN); + links_line = (char *)rb_malloc(LINKSLINELEN); snprintf(links_line, LINKSLINELEN, "%s %s :1 %s", target_p->name, me.name, target_p->info[0] ? target_p->info : @@ -211,7 +211,7 @@ free_cachefile(struct cachefile *cacheptr) { if(ptr->data != emptyline) { - struct cacheline *line = ptr->data; + struct cacheline *line = (cacheline *)ptr->data; rb_free(line->data); rb_free(line); } @@ -240,13 +240,16 @@ load_help(void) struct stat sb; #endif - RB_DICTIONARY_FOREACH(cacheptr, &iter, help_dict_oper) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, help_dict_oper) { + const auto cacheptr(reinterpret_cast(elem)); rb_dictionary_delete(help_dict_oper, cacheptr->name); free_cachefile(cacheptr); } - RB_DICTIONARY_FOREACH(cacheptr, &iter, help_dict_user) + RB_DICTIONARY_FOREACH(elem, &iter, help_dict_user) { + const auto cacheptr(reinterpret_cast(elem)); rb_dictionary_delete(help_dict_user, cacheptr->name); free_cachefile(cacheptr); } @@ -326,7 +329,7 @@ send_user_motd(struct Client *source_p) RB_DLINK_FOREACH(ptr, user_motd->contents.head) { - lineptr = ptr->data; + lineptr = (cacheline *)ptr->data; sendto_one(source_p, form_str(RPL_MOTD), myname, nick, lineptr->data); } @@ -377,7 +380,7 @@ send_oper_motd(struct Client *source_p) RB_DLINK_FOREACH(ptr, oper_motd->contents.head) { - lineptr = ptr->data; + lineptr = (cacheline *)ptr->data; sendto_one(source_p, form_str(RPL_OMOTD), me.name, source_p->name, lineptr->data); } diff --git a/ircd/capability.c b/ircd/capability.cc similarity index 82% rename from ircd/capability.c rename to ircd/capability.cc index 423337af2..87e96220e 100644 --- a/ircd/capability.c +++ b/ircd/capability.cc @@ -31,7 +31,7 @@ capability_find(struct CapabilityIndex *idx, const char *cap) if (cap == NULL) return NULL; - return rb_dictionary_retrieve(idx->cap_dict, cap); + return (CapabilityEntry *)rb_dictionary_retrieve(idx->cap_dict, cap); } unsigned int @@ -43,7 +43,7 @@ capability_get(struct CapabilityIndex *idx, const char *cap, void **ownerdata) if (cap == NULL) return 0; - entry = rb_dictionary_retrieve(idx->cap_dict, cap); + entry = (CapabilityEntry *)rb_dictionary_retrieve(idx->cap_dict, cap); if (entry != NULL && !(entry->flags & CAP_ORPHANED)) { if (ownerdata != NULL) @@ -63,13 +63,13 @@ capability_put(struct CapabilityIndex *idx, const char *cap, void *ownerdata) if (!idx->highest_bit) return 0xFFFFFFFF; - if ((entry = rb_dictionary_retrieve(idx->cap_dict, cap)) != NULL) + if ((entry = (CapabilityEntry *)rb_dictionary_retrieve(idx->cap_dict, cap)) != NULL) { entry->flags &= ~CAP_ORPHANED; return (1 << entry->value); } - entry = rb_malloc(sizeof(struct CapabilityEntry)); + entry = (CapabilityEntry *)rb_malloc(sizeof(struct CapabilityEntry)); entry->cap = rb_strdup(cap); entry->flags = 0; entry->value = idx->highest_bit; @@ -106,7 +106,7 @@ capability_orphan(struct CapabilityIndex *idx, const char *cap) s_assert(idx != NULL); - entry = rb_dictionary_retrieve(idx->cap_dict, cap); + entry = (CapabilityEntry *)rb_dictionary_retrieve(idx->cap_dict, cap); if (entry != NULL) { entry->flags &= ~CAP_REQUIRED; @@ -122,7 +122,7 @@ capability_require(struct CapabilityIndex *idx, const char *cap) s_assert(idx != NULL); - entry = rb_dictionary_retrieve(idx->cap_dict, cap); + entry = (CapabilityEntry *)rb_dictionary_retrieve(idx->cap_dict, cap); if (entry != NULL) entry->flags |= CAP_REQUIRED; } @@ -132,7 +132,7 @@ capability_destroy(rb_dictionary_element *delem, void *privdata) { s_assert(delem != NULL); - struct CapabilityEntry *entry = delem->data; + struct CapabilityEntry *entry = (CapabilityEntry *)delem->data; rb_free((char *)entry->cap); rb_free(entry); } @@ -142,9 +142,9 @@ capability_index_create(const char *name) { struct CapabilityIndex *idx; - idx = rb_malloc(sizeof(struct CapabilityIndex)); + idx = (CapabilityIndex *)rb_malloc(sizeof(struct CapabilityIndex)); idx->name = name; - idx->cap_dict = rb_dictionary_create(name, rb_strcasecmp); + idx->cap_dict = rb_dictionary_create(name, reinterpret_cast(rb_strcasecmp)); idx->highest_bit = 1; rb_dlinkAdd(idx, &idx->node, &capability_indexes); @@ -176,8 +176,10 @@ capability_index_list(struct CapabilityIndex *idx, unsigned int cap_mask) *t = '\0'; - RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, idx->cap_dict) { + entry = (CapabilityEntry *)elem; if ((1 << entry->value) & cap_mask) { tl = sprintf(t, "%s ", entry->cap); @@ -200,8 +202,10 @@ capability_index_mask(struct CapabilityIndex *idx) s_assert(idx != NULL); - RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, idx->cap_dict) { + entry = (CapabilityEntry *)elem; if (!(entry->flags & CAP_ORPHANED)) mask |= (1 << entry->value); } @@ -218,8 +222,10 @@ capability_index_get_required(struct CapabilityIndex *idx) s_assert(idx != NULL); - RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, idx->cap_dict) { + entry = (CapabilityEntry *)elem; if (!(entry->flags & CAP_ORPHANED) && (entry->flags & CAP_REQUIRED)) mask |= (1 << entry->value); } @@ -235,15 +241,17 @@ capability_index_stats(void (*cb)(const char *line, void *privdata), void *privd RB_DLINK_FOREACH(node, capability_indexes.head) { - struct CapabilityIndex *idx = node->data; + struct CapabilityIndex *idx = (CapabilityIndex *)node->data; rb_dictionary_iter iter; struct CapabilityEntry *entry; snprintf(buf, sizeof buf, "'%s': allocated bits - %d", idx->name, (idx->highest_bit - 1)); cb(buf, privdata); - RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, idx->cap_dict) { + entry = (CapabilityEntry *)elem; snprintf(buf, sizeof buf, "bit %d: '%s'", entry->value, entry->cap); cb(buf, privdata); } diff --git a/ircd/channel.c b/ircd/channel.cc similarity index 98% rename from ircd/channel.c rename to ircd/channel.cc index 01c22be5c..1aa898869 100644 --- a/ircd/channel.c +++ b/ircd/channel.cc @@ -79,7 +79,7 @@ struct Channel * allocate_channel(const char *chname) { struct Channel *chptr; - chptr = rb_bh_alloc(channel_heap); + chptr = (Channel *)rb_bh_alloc(channel_heap); chptr->chname = rb_strdup(chname); return (chptr); } @@ -96,7 +96,7 @@ struct Ban * allocate_ban(const char *banstr, const char *who, const char *forward) { struct Ban *bptr; - bptr = rb_bh_alloc(ban_heap); + bptr = (Ban *)rb_bh_alloc(ban_heap); bptr->banstr = rb_strdup(banstr); bptr->who = rb_strdup(who); bptr->forward = forward ? rb_strdup(forward) : NULL; @@ -163,7 +163,7 @@ find_channel_membership(struct Channel *chptr, struct Client *client_p) { RB_DLINK_FOREACH(ptr, chptr->members.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; if(msptr->client_p == client_p) return msptr; @@ -173,7 +173,7 @@ find_channel_membership(struct Channel *chptr, struct Client *client_p) { RB_DLINK_FOREACH(ptr, client_p->user->channel.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; if(msptr->chptr == chptr) return msptr; @@ -226,7 +226,7 @@ add_user_to_channel(struct Channel *chptr, struct Client *client_p, int flags) if(client_p->user == NULL) return; - msptr = rb_bh_alloc(member_heap); + msptr = (membership *)rb_bh_alloc(member_heap); msptr->chptr = chptr; msptr->client_p = client_p; @@ -290,7 +290,7 @@ remove_user_from_channels(struct Client *client_p) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->user->channel.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; chptr = msptr->chptr; rb_dlinkDelete(&msptr->channode, &chptr->members); @@ -326,7 +326,7 @@ invalidate_bancache_user(struct Client *client_p) RB_DLINK_FOREACH(ptr, client_p->user->channel.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; msptr->bants = 0; msptr->flags &= ~CHFL_BANNED; } @@ -369,7 +369,7 @@ free_channel_list(rb_dlink_list * list) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) { - actualBan = ptr->data; + actualBan = (Ban *)ptr->data; free_ban(actualBan); } @@ -390,7 +390,7 @@ destroy_channel(struct Channel *chptr) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->invites.head) { - del_invite(chptr, ptr->data); + del_invite(chptr, (Client *)ptr->data); } /* free all bans/exceptions/denies */ @@ -455,7 +455,7 @@ channel_member_names(struct Channel *chptr, struct Client *client_p, int show_eo RB_DLINK_FOREACH(ptr, chptr->members.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; target_p = msptr->client_p; if(IsInvisible(target_p) && !is_member) @@ -592,7 +592,7 @@ is_banned_list(struct Channel *chptr, rb_dlink_list *list, RB_DLINK_FOREACH(ptr, list->head) { - actualBan = ptr->data; + actualBan = (Ban *)ptr->data; if(match(actualBan->banstr, s) || match(actualBan->banstr, s2) || match_cidr(actualBan->banstr, s2) || @@ -612,7 +612,7 @@ is_banned_list(struct Channel *chptr, rb_dlink_list *list, { RB_DLINK_FOREACH(ptr, chptr->exceptlist.head) { - actualExcept = ptr->data; + actualExcept = (Ban *)ptr->data; /* theyre exempted.. */ if(match(actualExcept->banstr, s) || @@ -780,7 +780,7 @@ can_join(struct Client *source_p, struct Channel *chptr, const char *key, const moduledata.approved = ERR_INVITEONLYCHAN; RB_DLINK_FOREACH(ptr, chptr->invexlist.head) { - invex = ptr->data; + invex = (Ban *)ptr->data; if(match(invex->banstr, src_host) || match(invex->banstr, src_iphost) || match_cidr(invex->banstr, src_iphost) @@ -972,7 +972,7 @@ find_bannickchange_channel(struct Client *client_p) RB_DLINK_FOREACH(ptr, client_p->user->channel.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; chptr = msptr->chptr; if (is_chanop_voiced(msptr)) continue; @@ -1109,7 +1109,7 @@ allocate_topic(struct Channel *chptr) * the topic info. We then split it up into two and shove it * in the chptr */ - chptr->topic = ptr; + chptr->topic = (char *)ptr; chptr->topic_info = (char *) ptr + TOPICLEN + 1; *chptr->topic = '\0'; *chptr->topic_info = '\0'; @@ -1366,7 +1366,7 @@ resv_chan_forcepart(const char *name, const char *reason, int temp_time) { RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; target_p = msptr->client_p; if(IsExemptResv(target_p)) diff --git a/ircd/chmode.c b/ircd/chmode.cc similarity index 94% rename from ircd/chmode.c rename to ircd/chmode.cc index 89ae452b0..5081d8986 100644 --- a/ircd/chmode.c +++ b/ircd/chmode.cc @@ -70,37 +70,40 @@ extern int h_get_channel_access; int chmode_flags[256]; // Table of mode flag integers char chmode_arity[2][256]; // RPL_MYINFO (note that [0] is for 0 OR MORE params) char chmode_class[4][256]; // RPL_ISUPPORT classification -struct Chm chmode_table[256] = +struct Chm chmode_table[256]; + +static +void chmode_table_init() { // Leading tab only please: - // ['X'] = {handler,class,flag}, + // chmode_table['X'] = {handler,class,flag}; - ['C'] = { 0, CHM_D, 0 }, - ['F'] = { chm_simple, CHM_D, MODE_FREETARGET }, - ['I'] = { chm_ban, CHM_A, CHFL_INVEX }, - ['L'] = { chm_staff, CHM_D, MODE_EXLIMIT }, - ['P'] = { chm_staff, CHM_D, MODE_PERMANENT }, - ['Q'] = { chm_simple, CHM_D, MODE_DISFORWARD }, + chmode_table['C'] = { 0, CHM_D, 0 }; + chmode_table['F'] = { chm_simple, CHM_D, MODE_FREETARGET }; + chmode_table['I'] = { chm_ban, CHM_A, CHFL_INVEX }; + chmode_table['L'] = { chm_staff, CHM_D, MODE_EXLIMIT }; + chmode_table['P'] = { chm_staff, CHM_D, MODE_PERMANENT }; + chmode_table['Q'] = { chm_simple, CHM_D, MODE_DISFORWARD }; - ['b'] = { chm_ban, CHM_A, CHFL_BAN }, - ['e'] = { chm_ban, CHM_A, CHFL_EXCEPTION }, - ['f'] = { chm_forward, CHM_C, 0 }, - ['g'] = { chm_simple, CHM_D, MODE_FREEINVITE }, - ['i'] = { chm_simple, CHM_D, MODE_INVITEONLY }, - ['j'] = { chm_throttle, CHM_C, 0 }, - ['k'] = { chm_key, CHM_B, 0 }, - ['l'] = { chm_limit, CHM_C, 0 }, - ['m'] = { chm_simple, CHM_D, MODE_MODERATED }, - ['n'] = { chm_simple, CHM_D, MODE_NOPRIVMSGS }, - ['o'] = { chm_op, CHM_B, 0 }, - ['p'] = { chm_simple, CHM_D, MODE_PRIVATE }, - ['q'] = { chm_ban, CHM_A, CHFL_QUIET }, - ['r'] = { chm_simple, CHM_D, MODE_REGONLY }, - ['s'] = { chm_simple, CHM_D, MODE_SECRET }, - ['t'] = { chm_simple, CHM_D, MODE_TOPICLIMIT }, - ['v'] = { chm_voice, CHM_B, 0 }, - ['z'] = { chm_simple, CHM_D, MODE_OPMODERATE }, -}; + chmode_table['b'] = { chm_ban, CHM_A, CHFL_BAN }; + chmode_table['e'] = { chm_ban, CHM_A, CHFL_EXCEPTION }; + chmode_table['f'] = { chm_forward, CHM_C, 0 }; + chmode_table['g'] = { chm_simple, CHM_D, MODE_FREEINVITE }; + chmode_table['i'] = { chm_simple, CHM_D, MODE_INVITEONLY }; + chmode_table['j'] = { chm_throttle, CHM_C, 0 }; + chmode_table['k'] = { chm_key, CHM_B, 0 }; + chmode_table['l'] = { chm_limit, CHM_C, 0 }; + chmode_table['m'] = { chm_simple, CHM_D, MODE_MODERATED }; + chmode_table['n'] = { chm_simple, CHM_D, MODE_NOPRIVMSGS }; + chmode_table['o'] = { chm_op, CHM_B, 0 }; + chmode_table['p'] = { chm_simple, CHM_D, MODE_PRIVATE }; + chmode_table['q'] = { chm_ban, CHM_A, CHFL_QUIET }; + chmode_table['r'] = { chm_simple, CHM_D, MODE_REGONLY }; + chmode_table['s'] = { chm_simple, CHM_D, MODE_SECRET }; + chmode_table['t'] = { chm_simple, CHM_D, MODE_TOPICLIMIT }; + chmode_table['v'] = { chm_voice, CHM_B, 0 }; + chmode_table['z'] = { chm_simple, CHM_D, MODE_OPMODERATE }; +} /* OPTIMIZE ME! -- dwr @@ -108,6 +111,8 @@ struct Chm chmode_table[256] = void chmode_init(void) { + chmode_table_init(); + /* Reset the state generated by earlier calls to this function */ memset(chmode_flags, '\0', sizeof(chmode_flags)); @@ -137,7 +142,7 @@ chmode_init(void) if(chmode_table[i].mode_type & disabled || chmode_table[i].set_func == chm_nosuch) continue; - const char ch[2] = {i, 0}; + const char ch[2] = {char(i), '\0'}; chmode_flags[i] = chmode_table[i].mode_type; rb_strlcat(chmode_class[chmode_table[i].mode_class], ch, 256); rb_strlcat(chmode_arity[0], ch, 256); @@ -285,7 +290,7 @@ add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const RB_DLINK_FOREACH(ptr, list->head) { - actualBan = ptr->data; + actualBan = (Ban *)ptr->data; if(mask_match(actualBan->banstr, realban)) return false; } @@ -295,7 +300,7 @@ add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const { RB_DLINK_FOREACH(ptr, list->head) { - actualBan = ptr->data; + actualBan = (Ban *)ptr->data; if(!irccmp(actualBan->banstr, realban)) return false; } @@ -336,7 +341,7 @@ del_id(struct Channel *chptr, const char *banid, rb_dlink_list * list, long mode RB_DLINK_FOREACH(ptr, list->head) { - banptr = ptr->data; + banptr = (Ban *)ptr->data; if(irccmp(banid, banptr->banstr) == 0) { @@ -428,14 +433,14 @@ pretty_mask(const char *idmask) } at = ex = NULL; - if((t = memchr(mask, '@', masklen)) != NULL) + if((t = (char *)memchr(mask, '@', masklen)) != NULL) { at = t; t++; if(*t != '\0') host = t, hl = strlen(t); - if((t = memchr(mask, '!', at - mask)) != NULL) + if((t = (char *)memchr(mask, '!', at - mask)) != NULL) { ex = t; t++; @@ -450,8 +455,8 @@ pretty_mask(const char *idmask) user = mask, ul = at - mask; } - if((t = memchr(host, '!', hl)) != NULL || - (t = memchr(host, '$', hl)) != NULL) + if((t = (char *)memchr(host, '!', hl)) != NULL || + (t = (char *)memchr(host, '$', hl)) != NULL) { t++; if (host + hl != t) @@ -459,7 +464,7 @@ pretty_mask(const char *idmask) hl = t - 1 - host; } } - else if((t = memchr(mask, '!', masklen)) != NULL) + else if((t = (char *)memchr(mask, '!', masklen)) != NULL) { ex = t; t++; @@ -868,7 +873,7 @@ chm_ban(struct Client *source_p, struct Channel *chptr, RB_DLINK_FOREACH(ptr, list->head) { char buf[BANLEN]; - banptr = ptr->data; + banptr = (Ban *)ptr->data; if(banptr->forward) snprintf(buf, sizeof(buf), "%s$%s", banptr->banstr, banptr->forward); else @@ -922,7 +927,7 @@ chm_ban(struct Client *source_p, struct Channel *chptr, * As the first character, it marks an extban; afterwards * it delimits a forward channel. */ - if ((forward = strchr(mask+1, '$')) != NULL) + if ((forward = (char *)strchr(mask+1, '$')) != NULL) { *forward++ = '\0'; if (*forward == '\0') diff --git a/ircd/class.c b/ircd/class.cc similarity index 97% rename from ircd/class.c rename to ircd/class.cc index 290562968..7fcb60776 100644 --- a/ircd/class.c +++ b/ircd/class.cc @@ -43,7 +43,7 @@ make_class(void) { struct Class *tmp; - tmp = rb_malloc(sizeof(struct Class)); + tmp = (Class *)rb_malloc(sizeof(struct Class)); ConFreq(tmp) = DEFAULT_CONNECTFREQUENCY; PingFreq(tmp) = DEFAULT_PINGFREQUENCY; @@ -220,7 +220,7 @@ find_class(const char *classname) RB_DLINK_FOREACH(ptr, class_list.head) { - cltmp = ptr->data; + cltmp = (Class *)ptr->data; if(!strcmp(ClassName(cltmp), classname)) return cltmp; @@ -245,7 +245,7 @@ check_class() RB_DLINK_FOREACH_SAFE(ptr, next_ptr, class_list.head) { - cltmp = ptr->data; + cltmp = (Class *)ptr->data; if(MaxUsers(cltmp) < 0) { @@ -285,7 +285,7 @@ report_classes(struct Client *source_p) RB_DLINK_FOREACH(ptr, class_list.head) { - cltmp = ptr->data; + cltmp = (Class *)ptr->data; sendto_one_numeric(source_p, RPL_STATSYLINE, form_str(RPL_STATSYLINE), diff --git a/ircd/client.c b/ircd/client.cc similarity index 97% rename from ircd/client.c rename to ircd/client.cc index 3cf830491..a2572efec 100644 --- a/ircd/client.c +++ b/ircd/client.cc @@ -23,7 +23,6 @@ * USA */ #include -#include #include #include @@ -125,7 +124,7 @@ init_client(void) rb_event_addish("exit_aborted_clients", exit_aborted_clients, NULL, 1); rb_event_add("flood_recalc", flood_recalc, NULL, 1); - nd_dict = rb_dictionary_create("nickdelay", irccmp); + nd_dict = rb_dictionary_create("nickdelay", reinterpret_cast(irccmp)); } /* @@ -216,16 +215,14 @@ client_release_connids(struct Client *client_p) struct Client * make_client(struct Client *from) { - struct Client *client_p = NULL; struct LocalUser *localClient; - - client_p = rb_bh_alloc(client_heap); + struct Client *client_p(reinterpret_cast(rb_bh_alloc(client_heap))); if(from == NULL) { client_p->from = client_p; /* 'from' of local client is self! */ - localClient = rb_bh_alloc(lclient_heap); + localClient = reinterpret_cast(rb_bh_alloc(lclient_heap)); SetMyConnect(client_p); client_p->localClient = localClient; @@ -233,7 +230,7 @@ make_client(struct Client *from) client_p->localClient->F = NULL; - client_p->preClient = rb_bh_alloc(pclient_heap); + client_p->preClient = reinterpret_cast(rb_bh_alloc(pclient_heap)); /* as good a place as any... */ rb_dlinkAdd(client_p, &client_p->localClient->tnode, &unknown_list); @@ -385,7 +382,7 @@ check_pings_list(rb_dlink_list * list) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) { - client_p = ptr->data; + client_p = reinterpret_cast(ptr->data); if(!MyConnect(client_p) || IsDead(client_p)) continue; @@ -451,7 +448,7 @@ check_unknowns_list(rb_dlink_list * list) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) { - client_p = ptr->data; + client_p = reinterpret_cast(ptr->data); if(IsDead(client_p) || IsClosing(client_p)) continue; @@ -556,7 +553,7 @@ check_klines(void) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, lclient_list.head) { - client_p = ptr->data; + client_p = reinterpret_cast(ptr->data); if(IsMe(client_p) || !IsPerson(client_p)) continue; @@ -598,7 +595,7 @@ check_dlines(void) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, lclient_list.head) { - client_p = ptr->data; + client_p = reinterpret_cast(ptr->data); if(IsMe(client_p)) continue; @@ -620,7 +617,7 @@ check_dlines(void) /* dlines need to be checked against unknowns too */ RB_DLINK_FOREACH_SAFE(ptr, next_ptr, unknown_list.head) { - client_p = ptr->data; + client_p = reinterpret_cast(ptr->data); if((aconf = find_dline((struct sockaddr *)&client_p->localClient->ip, GET_SS_FAMILY(&client_p->localClient->ip))) != NULL) { @@ -648,7 +645,7 @@ check_xlines(void) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, lclient_list.head) { - client_p = ptr->data; + client_p = reinterpret_cast(ptr->data); if(IsMe(client_p) || !IsPerson(client_p)) continue; @@ -693,7 +690,7 @@ resv_nick_fnc(const char *mask, const char *reason, int temp_time) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, lclient_list.head) { - client_p = ptr->data; + client_p = reinterpret_cast(ptr->data); if(IsMe(client_p) || !IsPerson(client_p) || IsExemptResv(client_p)) continue; @@ -750,7 +747,7 @@ resv_nick_fnc(const char *mask, const char *reason, int temp_time) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head) { - target_p = ptr->data; + target_p = reinterpret_cast(ptr->data); rb_dlinkFindDestroy(client_p, &target_p->localClient->allow_list); rb_dlinkDestroy(ptr, &client_p->on_allow_list); } @@ -1063,7 +1060,7 @@ free_exited_clients(void *unused) RB_DLINK_FOREACH_SAFE(ptr, next, dead_list.head) { - target_p = ptr->data; + target_p = reinterpret_cast(ptr->data); #ifdef DEBUG_EXITED_CLIENTS { @@ -1073,7 +1070,7 @@ free_exited_clients(void *unused) RB_DLINK_FOREACH(aptr, abort_list.head) { - abt = aptr->data; + abt = reinterpret_cast(aptr->data); if(abt->client == target_p) { s_assert(0); @@ -1110,7 +1107,7 @@ free_exited_clients(void *unused) #ifdef DEBUG_EXITED_CLIENTS RB_DLINK_FOREACH_SAFE(ptr, next, dead_remote_list.head) { - target_p = ptr->data; + target_p = reinterpret_cast(ptr->data); if(ptr->data == NULL) { @@ -1153,7 +1150,7 @@ recurse_remove_clients(struct Client *source_p, const char *comment) { RB_DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->serv->users.head) { - target_p = ptr->data; + target_p = reinterpret_cast(ptr->data); target_p->flags |= FLAGS_KILLED; add_nd_entry(target_p->name); @@ -1165,7 +1162,7 @@ recurse_remove_clients(struct Client *source_p, const char *comment) { RB_DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->serv->users.head) { - target_p = ptr->data; + target_p = reinterpret_cast(ptr->data); target_p->flags |= FLAGS_KILLED; if(!IsDead(target_p) && !IsClosing(target_p)) @@ -1175,7 +1172,7 @@ recurse_remove_clients(struct Client *source_p, const char *comment) RB_DLINK_FOREACH_SAFE(ptr, ptr_next, source_p->serv->servers.head) { - target_p = ptr->data; + target_p = reinterpret_cast(ptr->data); recurse_remove_clients(target_p, comment); qs_server(NULL, target_p, &me, comment); } @@ -1196,7 +1193,7 @@ remove_dependents(struct Client *client_p, RB_DLINK_FOREACH_SAFE(ptr, next, serv_list.head) { - to = ptr->data; + to = reinterpret_cast(ptr->data); if(IsMe(to) || to == source_p->from || to == client_p) continue; @@ -1214,7 +1211,7 @@ exit_aborted_clients(void *unused) rb_dlink_node *ptr, *next; RB_DLINK_FOREACH_SAFE(ptr, next, abort_list.head) { - abt = ptr->data; + abt = reinterpret_cast(ptr->data); #ifdef DEBUG_EXITED_CLIENTS { @@ -1299,7 +1296,7 @@ exit_generic_client(struct Client *client_p, struct Client *source_p, struct Cli /* Clean up invitefield */ RB_DLINK_FOREACH_SAFE(ptr, next_ptr, source_p->user->invited.head) { - del_invite(ptr->data, source_p); + del_invite(reinterpret_cast(ptr->data), source_p); } /* Clean up allow lists */ @@ -1728,7 +1725,7 @@ del_all_accepts(struct Client *client_p) */ RB_DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->allow_list.head) { - target_p = ptr->data; + target_p = reinterpret_cast(ptr->data); rb_dlinkFindDestroy(client_p, &target_p->on_allow_list); rb_dlinkDestroy(ptr, &client_p->localClient->allow_list); } @@ -1737,7 +1734,7 @@ del_all_accepts(struct Client *client_p) /* remove this client from everyones accept list */ RB_DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head) { - target_p = ptr->data; + target_p = reinterpret_cast(ptr->data); rb_dlinkFindDestroy(client_p, &target_p->localClient->allow_list); rb_dlinkDestroy(ptr, &client_p->on_allow_list); } @@ -1894,7 +1891,7 @@ void allocate_away(struct Client *client_p) { if(client_p->user->away == NULL) - client_p->user->away = rb_bh_alloc(away_heap); + client_p->user->away = reinterpret_cast(rb_bh_alloc(away_heap)); } diff --git a/ircd/dns.c b/ircd/dns.cc similarity index 89% rename from ircd/dns.c rename to ircd/dns.cc index 82b59d049..dfaf714a7 100644 --- a/ircd/dns.c +++ b/ircd/dns.cc @@ -77,7 +77,7 @@ assign_id(uint32_t *id) static void handle_dns_failure(uint32_t xid) { - struct dnsreq *req = rb_dictionary_retrieve(query_dict, RB_UINT_TO_POINTER(xid)); + struct dnsreq *req = (dnsreq *)rb_dictionary_retrieve(query_dict, RB_UINT_TO_POINTER(xid)); s_assert(req); if(req->callback == NULL) @@ -91,7 +91,7 @@ handle_dns_failure(uint32_t xid) static void handle_dns_stat_failure(uint32_t xid) { - struct dnsstatreq *req = rb_dictionary_retrieve(stat_dict, RB_UINT_TO_POINTER(xid)); + struct dnsstatreq *req = (dnsstatreq *)rb_dictionary_retrieve(stat_dict, RB_UINT_TO_POINTER(xid)); s_assert(req); if(req->callback == NULL) @@ -106,7 +106,7 @@ handle_dns_stat_failure(uint32_t xid) void cancel_lookup(uint32_t xid) { - struct dnsreq *req = rb_dictionary_retrieve(query_dict, RB_UINT_TO_POINTER(xid)); + struct dnsreq *req = (dnsreq *)rb_dictionary_retrieve(query_dict, RB_UINT_TO_POINTER(xid)); s_assert(req); req->callback = NULL; req->data = NULL; @@ -115,7 +115,7 @@ cancel_lookup(uint32_t xid) void cancel_dns_stats(uint32_t xid) { - struct dnsstatreq *req = rb_dictionary_retrieve(stat_dict, RB_UINT_TO_POINTER(xid)); + struct dnsstatreq *req = (dnsstatreq *)rb_dictionary_retrieve(stat_dict, RB_UINT_TO_POINTER(xid)); s_assert(req); req->callback = NULL; req->data = NULL; @@ -125,7 +125,7 @@ cancel_dns_stats(uint32_t xid) uint32_t lookup_hostname(const char *hostname, int aftype, DNSCB callback, void *data) { - struct dnsreq *req = rb_malloc(sizeof(struct dnsreq)); + struct dnsreq *req = (dnsreq *)rb_malloc(sizeof(struct dnsreq)); int aft; uint32_t rid = assign_id(&query_id); @@ -150,7 +150,7 @@ lookup_hostname(const char *hostname, int aftype, DNSCB callback, void *data) uint32_t lookup_ip(const char *addr, int aftype, DNSCB callback, void *data) { - struct dnsreq *req = rb_malloc(sizeof(struct dnsreq)); + struct dnsreq *req = (dnsreq *)rb_malloc(sizeof(struct dnsreq)); int aft; uint32_t rid = assign_id(&query_id); @@ -175,7 +175,7 @@ lookup_ip(const char *addr, int aftype, DNSCB callback, void *data) static uint32_t get_nameservers(DNSLISTCB callback, void *data) { - struct dnsstatreq *req = rb_malloc(sizeof(struct dnsstatreq)); + struct dnsstatreq *req = (dnsstatreq *)rb_malloc(sizeof(struct dnsstatreq)); uint32_t qid = assign_id(&stat_id); check_authd(); @@ -203,7 +203,7 @@ dns_results_callback(const char *callid, const char *status, const char *type, c return; rid = (uint32_t)lrid; - req = rb_dictionary_retrieve(query_dict, RB_UINT_TO_POINTER(rid)); + req = (dnsreq *)rb_dictionary_retrieve(query_dict, RB_UINT_TO_POINTER(rid)); if(req == NULL) return; @@ -240,7 +240,7 @@ dns_stats_results_callback(const char *callid, const char *status, int resc, con return; qid = (uint32_t)lqid; - req = rb_dictionary_retrieve(stat_dict, RB_UINT_TO_POINTER(qid)); + req = (dnsstatreq *)rb_dictionary_retrieve(stat_dict, RB_UINT_TO_POINTER(qid)); s_assert(req); diff --git a/ircd/extban.c b/ircd/extban.cc similarity index 100% rename from ircd/extban.c rename to ircd/extban.cc diff --git a/ircd/getopt.c b/ircd/getopt.cc similarity index 88% rename from ircd/getopt.c rename to ircd/getopt.cc index b7d30f8b7..99a213529 100644 --- a/ircd/getopt.c +++ b/ircd/getopt.cc @@ -27,6 +27,8 @@ # define OPTCHAR '-' +using argtype = decltype(lgetopt::argtype); + void parseargs(int *argc, char * const **argv, struct lgetopt *opts) { @@ -62,10 +64,10 @@ parseargs(int *argc, char * const **argv, struct lgetopt *opts) switch (opts[i].argtype) { - case YESNO: + case argtype::YESNO: *((int *) opts[i].argloc) = 1; break; - case INTEGER: + case argtype::INTEGER: if(*argc < 2) { fprintf(stderr, @@ -79,7 +81,7 @@ parseargs(int *argc, char * const **argv, struct lgetopt *opts) (*argc)--; (*argv)++; break; - case STRING: + case argtype::STRING: if(*argc < 2) { fprintf(stderr, @@ -89,14 +91,14 @@ parseargs(int *argc, char * const **argv, struct lgetopt *opts) } *((char **) opts[i].argloc) = - malloc(strlen((*argv)[1]) + 1); + (char *)malloc(strlen((*argv)[1]) + 1); strcpy(*((char **) opts[i].argloc), (*argv)[1]); (*argc)--; (*argv)++; break; - case USAGE: + case argtype::USAGE: usage(progname); /*NOTREACHED*/ default: fprintf(stderr, @@ -125,10 +127,10 @@ usage(const char *name) for (i = 0; myopts[i].opt; i++) { fprintf(stderr, "\t%c%-10s %-20s%s\n", OPTCHAR, - myopts[i].opt, (myopts[i].argtype == YESNO + myopts[i].opt, (myopts[i].argtype == argtype::YESNO || myopts[i].argtype == - USAGE) ? "" : myopts[i].argtype == - INTEGER ? "" : "", myopts[i].desc); + argtype::USAGE) ? "" : myopts[i].argtype == + argtype::INTEGER ? "" : "", myopts[i].desc); } exit(EXIT_FAILURE); diff --git a/ircd/hash.c b/ircd/hash.cc similarity index 91% rename from ircd/hash.c rename to ircd/hash.cc index dee174952..7e9bfc74c 100644 --- a/ircd/hash.c +++ b/ircd/hash.cc @@ -167,14 +167,14 @@ add_to_hostname_hash(const char *hostname, struct Client *client_p) if(EmptyString(hostname) || (client_p == NULL)) return; - list = rb_radixtree_retrieve(hostname_tree, hostname); + list = (rb_dlink_list *)rb_radixtree_retrieve(hostname_tree, hostname); if (list != NULL) { rb_dlinkAddAlloc(client_p, list); return; } - list = rb_malloc(sizeof(*list)); + list = (rb_dlink_list *)rb_malloc(sizeof(*list)); rb_radixtree_add(hostname_tree, hostname, list); rb_dlinkAddAlloc(client_p, list); } @@ -253,7 +253,7 @@ del_from_hostname_hash(const char *hostname, struct Client *client_p) if(hostname == NULL || client_p == NULL) return; - list = rb_radixtree_retrieve(hostname_tree, hostname); + list = (rb_dlink_list *)rb_radixtree_retrieve(hostname_tree, hostname); if (list == NULL) return; @@ -291,7 +291,7 @@ find_id(const char *name) if(EmptyString(name)) return NULL; - return rb_radixtree_retrieve(client_id_tree, name); + return (Client *)rb_radixtree_retrieve(client_id_tree, name); } /* find_client() @@ -309,7 +309,7 @@ find_client(const char *name) if(IsDigit(*name)) return (find_id(name)); - return rb_radixtree_retrieve(client_name_tree, name); + return (Client *)rb_radixtree_retrieve(client_name_tree, name); } /* find_named_client() @@ -323,7 +323,7 @@ find_named_client(const char *name) if(EmptyString(name)) return NULL; - return rb_radixtree_retrieve(client_name_tree, name); + return (Client *)rb_radixtree_retrieve(client_name_tree, name); } /* find_server() @@ -345,7 +345,7 @@ find_server(struct Client *source_p, const char *name) return(target_p); } - target_p = rb_radixtree_retrieve(client_name_tree, name); + target_p = (Client *)rb_radixtree_retrieve(client_name_tree, name); if (target_p != NULL) { if(IsServer(target_p) || IsMe(target_p)) @@ -369,7 +369,7 @@ find_hostname(const char *hostname) if(EmptyString(hostname)) return NULL; - hlist = rb_radixtree_retrieve(hostname_tree, hostname); + hlist = (rb_dlink_list *)rb_radixtree_retrieve(hostname_tree, hostname); if (hlist == NULL) return NULL; @@ -387,7 +387,7 @@ find_channel(const char *name) if(EmptyString(name)) return NULL; - return rb_radixtree_retrieve(channel_tree, name); + return (Channel *)rb_radixtree_retrieve(channel_tree, name); } /* @@ -427,7 +427,7 @@ get_or_create_channel(struct Client *client_p, const char *chname, bool *isnew) s = t; } - chptr = rb_radixtree_retrieve(channel_tree, s); + chptr = (Channel *)rb_radixtree_retrieve(channel_tree, s); if (chptr != NULL) { if (isnew != NULL) @@ -460,7 +460,7 @@ hash_find_resv(const char *name) if(EmptyString(name)) return NULL; - aconf = rb_radixtree_retrieve(resv_tree, name); + aconf = (ConfItem *)rb_radixtree_retrieve(resv_tree, name); if (aconf != NULL) { aconf->port++; @@ -476,8 +476,10 @@ clear_resv_hash(void) struct ConfItem *aconf; rb_radixtree_iteration_state iter; - RB_RADIXTREE_FOREACH(aconf, &iter, resv_tree) + void *elem; + RB_RADIXTREE_FOREACH(elem, &iter, resv_tree) { + aconf = (ConfItem *)elem; /* skip temp resvs */ if(aconf->hold) continue; @@ -502,5 +504,5 @@ del_from_cli_connid_hash(uint32_t id) struct Client * find_cli_connid_hash(uint32_t connid) { - return rb_dictionary_retrieve(client_connid_tree, RB_UINT_TO_POINTER(connid)); + return (Client *)rb_dictionary_retrieve(client_connid_tree, RB_UINT_TO_POINTER(connid)); } diff --git a/ircd/hook.c b/ircd/hook.cc similarity index 94% rename from ircd/hook.c rename to ircd/hook.cc index 2354fb2f2..dd1314f62 100644 --- a/ircd/hook.c +++ b/ircd/hook.cc @@ -67,7 +67,7 @@ int h_rehash; void init_hook(void) { - hooks = rb_malloc(sizeof(hook) * HOOK_INCREMENT); + hooks = (hook *)rb_malloc(sizeof(hook) * HOOK_INCREMENT); h_burst_client = register_hook("burst_client"); h_burst_channel = register_hook("burst_channel"); @@ -96,7 +96,7 @@ grow_hooktable(void) { hook *newhooks; - newhooks = rb_malloc(sizeof(hook) * (max_hooks + HOOK_INCREMENT)); + newhooks = (hook *)rb_malloc(sizeof(hook) * (max_hooks + HOOK_INCREMENT)); memcpy(newhooks, hooks, sizeof(hook) * num_hooks); rb_free(hooks); @@ -176,7 +176,7 @@ add_hook(const char *name, hookfn fn) i = register_hook(name); - rb_dlinkAddAlloc(fn, &hooks[i].hooks); + rb_dlinkAddAlloc(reinterpret_cast(fn), &hooks[i].hooks); } /* remove_hook() @@ -190,7 +190,7 @@ remove_hook(const char *name, hookfn fn) if((i = find_hook(name)) < 0) return; - rb_dlinkFindDestroy(fn, &hooks[i].hooks); + rb_dlinkFindDestroy(reinterpret_cast(fn), &hooks[i].hooks); } /* call_hook() @@ -207,7 +207,7 @@ call_hook(int id, void *arg) */ RB_DLINK_FOREACH(ptr, hooks[id].hooks.head) { - fn = ptr->data; + fn = (hookfn)ptr->data; fn(arg); } } diff --git a/ircd/hostmask.c b/ircd/hostmask.cc similarity index 99% rename from ircd/hostmask.c rename to ircd/hostmask.cc index 3a892e4b3..9c6c76da0 100644 --- a/ircd/hostmask.c +++ b/ircd/hostmask.cc @@ -536,7 +536,7 @@ add_conf_by_address(const char *address, int type, const char *username, const c if(address == NULL) address = "/NOMATCH!/"; - arec = rb_malloc(sizeof(struct AddressRec)); + arec = (AddressRec *)rb_malloc(sizeof(struct AddressRec)); masktype = parse_netmask(address, &arec->Mask.ipa.addr, &bits); arec->Mask.ipa.bits = bits; arec->masktype = masktype; diff --git a/ircd/ircd.c b/ircd/ircd.cc similarity index 97% rename from ircd/ircd.c rename to ircd/ircd.cc index 156f47506..c0078f412 100644 --- a/ircd/ircd.c +++ b/ircd/ircd.cc @@ -23,8 +23,8 @@ * USA */ -#include -#include + +#include #include #include #include @@ -63,6 +63,7 @@ #include #include + static void ircd_die_cb(const char *str) __attribute__((noreturn)); @@ -163,7 +164,7 @@ ircd_shutdown(const char *reason) RB_DLINK_FOREACH(ptr, lclient_list.head) { - target_p = ptr->data; + target_p = (struct Client *)ptr->data; sendto_one(target_p, ":%s NOTICE %s :Server Terminating. %s", me.name, target_p->name, reason); @@ -171,7 +172,7 @@ ircd_shutdown(const char *reason) RB_DLINK_FOREACH(ptr, serv_list.head) { - target_p = ptr->data; + target_p = (struct Client *)ptr->data; sendto_one(target_p, ":%s ERROR :Terminated by %s", me.name, reason); @@ -302,19 +303,19 @@ static int printVersion = 0; struct lgetopt myopts[] = { {"configfile", &ConfigFileEntry.configfile, - STRING, "File to use for ircd.conf"}, + lgetopt::STRING, "File to use for ircd.conf"}, {"logfile", &logFileName, - STRING, "File to use for ircd.log"}, + lgetopt::STRING, "File to use for ircd.log"}, {"pidfile", &pidFileName, - STRING, "File to use for process ID"}, + lgetopt::STRING, "File to use for process ID"}, {"foreground", &server_state_foreground, - YESNO, "Run in foreground (don't detach)"}, + lgetopt::YESNO, "Run in foreground (don't detach)"}, {"version", &printVersion, - YESNO, "Print version and exit"}, + lgetopt::YESNO, "Print version and exit"}, {"conftest", &testing_conf, - YESNO, "Test the configuration files and exit"}, - {"help", NULL, USAGE, "Print this text"}, - {NULL, NULL, STRING, NULL}, + lgetopt::YESNO, "Test the configuration files and exit"}, + {"help", NULL, lgetopt::USAGE, "Print this text"}, + {NULL, NULL, lgetopt::STRING, NULL}, }; static void diff --git a/ircd/ircd_signal.c b/ircd/ircd_signal.cc similarity index 100% rename from ircd/ircd_signal.c rename to ircd/ircd_signal.cc diff --git a/ircd/listener.c b/ircd/listener.cc similarity index 99% rename from ircd/listener.c rename to ircd/listener.cc index bfd03acc8..6ea63ff99 100644 --- a/ircd/listener.c +++ b/ircd/listener.cc @@ -601,7 +601,7 @@ accept_precallback(rb_fde_t *F, struct sockaddr *addr, rb_socklen_t addrlen, voi static void accept_callback(rb_fde_t *F, int status, struct sockaddr *addr, rb_socklen_t addrlen, void *data) { - struct Listener *listener = data; + struct Listener *listener(reinterpret_cast(data)); struct rb_sockaddr_storage lip; unsigned int locallen = sizeof(struct rb_sockaddr_storage); diff --git a/ircd/logger.c b/ircd/logger.cc similarity index 100% rename from ircd/logger.c rename to ircd/logger.cc diff --git a/ircd/match.c b/ircd/match.cc similarity index 100% rename from ircd/match.c rename to ircd/match.cc diff --git a/ircd/modules.c b/ircd/modules.cc similarity index 95% rename from ircd/modules.c rename to ircd/modules.cc index 6f27a7091..09f4c49b8 100644 --- a/ircd/modules.c +++ b/ircd/modules.cc @@ -35,7 +35,6 @@ #include #include #include - #include #ifndef LT_MODULE_EXT @@ -93,7 +92,7 @@ mod_find_path(const char *path) RB_DLINK_FOREACH(ptr, mod_paths.head) { - mpath = ptr->data; + mpath = (char *)ptr->data; if(!strcmp(path, mpath)) return mpath; @@ -158,7 +157,7 @@ findmodule_byname(const char *name) RB_DLINK_FOREACH(ptr, module_list.head) { - struct module *mod = ptr->data; + struct module *mod = (struct module *)ptr->data; if(!irccmp(mod->name, name)) return mod; @@ -231,6 +230,12 @@ load_core_modules(bool warn) ilog(L_MAIN, "Error loading core module %s: terminating ircd", core_module_table[i]); + + fprintf(stderr, + "Error loading core module %s (%s): terminating ircd\n", + core_module_table[i], + module_name); + exit(EXIT_FAILURE); } } @@ -257,7 +262,7 @@ load_one_module(const char *path, int origin, bool coremodule) RB_DLINK_FOREACH(pathst, mod_paths.head) { struct stat statbuf; - const char *mpath = pathst->data; + const char *mpath = (const char *)pathst->data; snprintf(modpath, sizeof(modpath), "%s%c%s%s", mpath, RB_PATH_SEPARATOR, path, LT_MODULE_EXT); if((strstr(modpath, "../") == NULL) && (strstr(modpath, "/..") == NULL)) @@ -332,7 +337,7 @@ bool init_module_v1(struct module *const mod) static void fini_module_v1(struct module *const mod) { - struct mapi_mheader_av1 *mheader = mod->mapi_header; + struct mapi_mheader_av1 *mheader = (mapi_mheader_av1 *)mod->mapi_header; if(mheader->mapi_command_list) { struct Message **m; @@ -548,7 +553,7 @@ bool init_v3_module_attr(struct module *const mod, if(!require_value(mod, attr)) return false; - struct Message *const v = attr->value; + struct Message *const v = (Message *)attr->value; mod_add_cmd(v); return true; } @@ -558,7 +563,7 @@ bool init_v3_module_attr(struct module *const mod, if(!require_value(mod, attr)) return false; - mapi_hlist_av1 *const v = attr->value; + mapi_hlist_av1 *const v = (mapi_hlist_av1 *)attr->value; *v->hapi_id = register_hook(v->hapi_name); return true; } @@ -568,7 +573,7 @@ bool init_v3_module_attr(struct module *const mod, if(!require_value(mod, attr)) return false; - mapi_hfn_list_av1 *const v = attr->value; + mapi_hfn_list_av1 *const v = (mapi_hfn_list_av1 *)attr->value; add_hook(v->hapi_name, v->fn); return true; } @@ -578,7 +583,7 @@ bool init_v3_module_attr(struct module *const mod, if(!require_value(mod, attr)) return false; - mapi_cap_list_av2 *const v = attr->value; + mapi_cap_list_av2 *const v = (mapi_cap_list_av2 *)attr->value; return init_module__cap(mod, v); } @@ -621,7 +626,7 @@ void fini_v3_module_attr(struct module *const mod, if(strncmp(attr->key, "mtab", MAPI_V3_KEY_MAXLEN) == 0) { if(attr->value) - mod_del_cmd(attr->value); + mod_del_cmd((Message *)attr->value); return; } @@ -637,7 +642,7 @@ void fini_v3_module_attr(struct module *const mod, if(!attr->value) return; - mapi_hfn_list_av1 *const v = attr->value; + mapi_hfn_list_av1 *const v = (mapi_hfn_list_av1 *)attr->value; remove_hook(v->hapi_name, v->fn); return; } @@ -645,7 +650,7 @@ void fini_v3_module_attr(struct module *const mod, if(strncmp(attr->key, "cap", MAPI_V3_KEY_MAXLEN) == 0) { if(attr->value) - fini_module__cap(mod, attr->value); + fini_module__cap(mod, (mapi_cap_list_av2 *)attr->value); return; } @@ -796,7 +801,7 @@ load_a_module(const char *path, bool warn, int origin, bool core) return false; } - struct module *mod RB_UNIQUE_PTR(free_module) = rb_malloc(sizeof(struct module)); + struct module *mod RB_UNIQUE_PTR(free_module) = (module *)rb_malloc(sizeof(struct module)); mod->name = rb_strdup(name); mod->path = rb_strdup(path); mod->address = handle; diff --git a/ircd/monitor.c b/ircd/monitor.cc similarity index 96% rename from ircd/monitor.c rename to ircd/monitor.cc index 8125784e4..9a0af4a39 100644 --- a/ircd/monitor.c +++ b/ircd/monitor.cc @@ -49,13 +49,13 @@ find_monitor(const char *name, int add) { struct monitor *monptr; - monptr = rb_radixtree_retrieve(monitor_tree, name); + monptr = (monitor *)rb_radixtree_retrieve(monitor_tree, name); if (monptr != NULL) return monptr; if(add) { - monptr = rb_malloc(sizeof(*monptr)); + monptr = (monitor *)rb_malloc(sizeof(*monptr)); rb_strlcpy(monptr->name, name, sizeof(monptr->name)); rb_radixtree_add(monitor_tree, monptr->name, monptr); @@ -125,7 +125,7 @@ clear_monitor(struct Client *client_p) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->monitor_list.head) { - monptr = ptr->data; + monptr = (monitor *)ptr->data; rb_dlinkFindDestroy(client_p, &monptr->users); rb_free_rb_dlink_node(ptr); diff --git a/ircd/msgbuf.c b/ircd/msgbuf.cc similarity index 100% rename from ircd/msgbuf.c rename to ircd/msgbuf.cc diff --git a/ircd/newconf.c b/ircd/newconf.cc similarity index 95% rename from ircd/newconf.c rename to ircd/newconf.cc index bfc29ee90..36d41e20d 100644 --- a/ircd/newconf.c +++ b/ircd/newconf.cc @@ -94,7 +94,7 @@ add_top_conf(const char *name, int (*sfunc) (struct TopConf *), { struct TopConf *tc; - tc = rb_malloc(sizeof(struct TopConf)); + tc = (TopConf *)rb_malloc(sizeof(struct TopConf)); tc->tc_name = name; tc->tc_sfunc = sfunc; @@ -113,7 +113,7 @@ find_top_conf(const char *name) RB_DLINK_FOREACH(d, conf_items.head) { - tc = d->data; + tc = (TopConf *)d->data; if(rb_strcasecmp(tc->tc_name, name) == 0) return tc; } @@ -143,7 +143,7 @@ find_conf_item(const struct TopConf *top, const char *name) RB_DLINK_FOREACH(d, top->tc_items.head) { - cf = d->data; + cf = (ConfEntry *)d->data; if(rb_strcasecmp(cf->cf_name, name) == 0) return cf; } @@ -177,7 +177,7 @@ conf_set_serverinfo_name(void *data) const char *s; int dots = 0; - for(s = data; *s != '\0'; s++) + for(s = (char *)data; *s != '\0'; s++) { if(!IsServChar(*s)) { @@ -195,7 +195,7 @@ conf_set_serverinfo_name(void *data) return; } - s = data; + s = (char *)data; if(IsDigit(*s)) { @@ -212,7 +212,7 @@ conf_set_serverinfo_name(void *data) static void conf_set_serverinfo_sid(void *data) { - char *sid = data; + char *sid = (char *)data; if(ServerInfo.sid[0] == '\0') { @@ -245,7 +245,7 @@ conf_set_serverinfo_vhost(void *data) { struct rb_sockaddr_storage addr; - if(rb_inet_pton_sock(data, (struct sockaddr *)&addr) <= 0 || GET_SS_FAMILY(&addr) != AF_INET) + if(rb_inet_pton_sock((const char *)data, (struct sockaddr *)&addr) <= 0 || GET_SS_FAMILY(&addr) != AF_INET) { conf_report_error("Invalid IPv4 address for server vhost (%s)", (char *) data); return; @@ -261,7 +261,7 @@ conf_set_serverinfo_vhost6(void *data) #ifdef RB_IPV6 struct rb_sockaddr_storage addr; - if(rb_inet_pton_sock(data, (struct sockaddr *)&addr) <= 0 || GET_SS_FAMILY(&addr) != AF_INET6) + if(rb_inet_pton_sock((const char *)data, (struct sockaddr *)&addr) <= 0 || GET_SS_FAMILY(&addr) != AF_INET6) { conf_report_error("Invalid IPv6 address for server vhost (%s)", (char *) data); return; @@ -475,7 +475,7 @@ static void conf_set_privset_privs(void *data) { char *privs = NULL; - conf_parm_t *args = data; + conf_parm_t *args = (conf_parm_t *)data; for (; args; args = args->next) { @@ -485,7 +485,7 @@ conf_set_privset_privs(void *data) { char *privs_old = privs; - privs = rb_malloc(strlen(privs_old) + 1 + strlen(args->v.string) + 1); + privs = (char *)rb_malloc(strlen(privs_old) + 1 + strlen(args->v.string) + 1); strcpy(privs, privs_old); strcat(privs, " "); strcat(privs, args->v.string); @@ -533,7 +533,7 @@ conf_begin_oper(struct TopConf *tc) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head) { - free_oper_conf(ptr->data); + free_oper_conf((oper_conf *)ptr->data); rb_dlinkDestroy(ptr, &yy_oper_list); } @@ -585,7 +585,7 @@ conf_end_oper(struct TopConf *tc) */ RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_oper_list.head) { - yy_tmpoper = ptr->data; + yy_tmpoper = (oper_conf *)ptr->data; yy_tmpoper->name = rb_strdup(yy_oper->name); @@ -643,7 +643,7 @@ conf_end_oper(struct TopConf *tc) static void conf_set_oper_flags(void *data) { - conf_parm_t *args = data; + conf_parm_t *args = (conf_parm_t *)data; set_modes_from_table(&yy_oper->flags, "flag", oper_table, args); } @@ -721,7 +721,7 @@ conf_set_oper_rsa_public_key_file(void *data) static void conf_set_oper_umodes(void *data) { - set_modes_from_table(&yy_oper->umodes, "umode", umode_table, data); + set_modes_from_table(&yy_oper->umodes, "umode", umode_table, (conf_parm_t *)data); } static void @@ -871,7 +871,7 @@ conf_set_listen_wsock(void *data) static void conf_set_listen_port_both(void *data, int ssl) { - conf_parm_t *args = data; + conf_parm_t *args = (conf_parm_t *)data; for (; args; args = args->next) { if(CF_TYPE(args->type) != CF_INT) @@ -929,7 +929,7 @@ static void conf_set_listen_address(void *data) { rb_free(listener_address); - listener_address = rb_strdup(data); + listener_address = rb_strdup((const char *)data); } static int @@ -943,7 +943,7 @@ conf_begin_auth(struct TopConf *tc) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head) { - free_conf(ptr->data); + free_conf((ConfItem *)ptr->data); rb_dlinkDestroy(ptr, &yy_aconf_list); } @@ -986,7 +986,7 @@ conf_end_auth(struct TopConf *tc) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head) { - yy_tmp = ptr->data; + yy_tmp = (ConfItem *)ptr->data; if(yy_aconf->passwd) yy_tmp->passwd = rb_strdup(yy_aconf->passwd); @@ -1039,17 +1039,17 @@ conf_set_auth_user(void *data) else yy_tmp = yy_aconf; - if((p = strchr(data, '@'))) + if((p = (char *)strchr((const char *)data, '@'))) { *p++ = '\0'; - yy_tmp->user = rb_strdup(data); + yy_tmp->user = rb_strdup((const char *)data); yy_tmp->host = rb_strdup(p); } else { yy_tmp->user = rb_strdup("*"); - yy_tmp->host = rb_strdup(data); + yy_tmp->host = rb_strdup((const char *)data); } if(yy_aconf != yy_tmp) @@ -1062,7 +1062,7 @@ conf_set_auth_auth_user(void *data) if(yy_aconf->spasswd) memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd)); rb_free(yy_aconf->spasswd); - yy_aconf->spasswd = rb_strdup(data); + yy_aconf->spasswd = rb_strdup((const char *)data); } static void @@ -1071,7 +1071,7 @@ conf_set_auth_passwd(void *data) if(yy_aconf->passwd) memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd)); rb_free(yy_aconf->passwd); - yy_aconf->passwd = rb_strdup(data); + yy_aconf->passwd = rb_strdup((const char *)data); } static void @@ -1081,13 +1081,13 @@ conf_set_auth_spoof(void *data) char *user = NULL; char *host = NULL; - host = data; + host = (char *)data; /* user@host spoof */ if((p = strchr(host, '@')) != NULL) { *p = '\0'; - user = data; + user = (char *)data; host = p+1; if(EmptyString(user)) @@ -1131,14 +1131,14 @@ conf_set_auth_spoof(void *data) } rb_free(yy_aconf->info.name); - yy_aconf->info.name = rb_strdup(data); + yy_aconf->info.name = rb_strdup((const char *)data); yy_aconf->flags |= CONF_FLAGS_SPOOF_IP; } static void conf_set_auth_flags(void *data) { - conf_parm_t *args = data; + conf_parm_t *args = (conf_parm_t *)data; set_modes_from_table((int *) &yy_aconf->flags, "flag", auth_table, args); } @@ -1148,7 +1148,7 @@ conf_set_auth_redir_serv(void *data) { yy_aconf->flags |= CONF_FLAGS_REDIR; rb_free(yy_aconf->info.name); - yy_aconf->info.name = rb_strdup(data); + yy_aconf->info.name = rb_strdup((const char *)data); } static void @@ -1164,7 +1164,7 @@ static void conf_set_auth_class(void *data) { rb_free(yy_aconf->className); - yy_aconf->className = rb_strdup(data); + yy_aconf->className = rb_strdup((const char *)data); } /* ok, shared_oper handles the stacking, shared_flags handles adding @@ -1178,7 +1178,7 @@ conf_cleanup_shared(struct TopConf *tc) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head) { - free_remote_conf(ptr->data); + free_remote_conf((remote_conf *)ptr->data); rb_dlinkDestroy(ptr, &yy_shared_list); } @@ -1194,7 +1194,7 @@ conf_cleanup_shared(struct TopConf *tc) static void conf_set_shared_oper(void *data) { - conf_parm_t *args = data; + conf_parm_t *args = (conf_parm_t *)data; const char *username; char *p; @@ -1249,7 +1249,7 @@ conf_set_shared_oper(void *data) static void conf_set_shared_flags(void *data) { - conf_parm_t *args = data; + conf_parm_t *args = (conf_parm_t *)data; int flags = 0; rb_dlink_node *ptr, *next_ptr; @@ -1260,7 +1260,7 @@ conf_set_shared_flags(void *data) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head) { - yy_shared = ptr->data; + yy_shared = (remote_conf *)ptr->data; yy_shared->flags = flags; rb_dlinkDestroy(ptr, &yy_shared_list); @@ -1348,10 +1348,10 @@ conf_set_connect_host(void *data) { struct rb_sockaddr_storage addr; - if(rb_inet_pton_sock(data, (struct sockaddr *)&addr) <= 0) + if(rb_inet_pton_sock((const char *)data, (struct sockaddr *)&addr) <= 0) { rb_free(yy_server->connect_host); - yy_server->connect_host = rb_strdup(data); + yy_server->connect_host = rb_strdup((const char *)data); } else if(GET_SS_FAMILY(&addr) == AF_INET) { @@ -1376,10 +1376,10 @@ conf_set_connect_vhost(void *data) { struct rb_sockaddr_storage addr; - if(rb_inet_pton_sock(data, (struct sockaddr *)&addr) <= 0) + if(rb_inet_pton_sock((const char *)data, (struct sockaddr *)&addr) <= 0) { rb_free(yy_server->bind_host); - yy_server->bind_host = rb_strdup(data); + yy_server->bind_host = rb_strdup((const char *)data); } else if(GET_SS_FAMILY(&addr) == AF_INET) { @@ -1408,7 +1408,7 @@ conf_set_connect_send_password(void *data) rb_free(yy_server->spasswd); } - yy_server->spasswd = rb_strdup(data); + yy_server->spasswd = rb_strdup((const char *)data); } static void @@ -1419,7 +1419,7 @@ conf_set_connect_accept_password(void *data) memset(yy_server->passwd, 0, strlen(yy_server->passwd)); rb_free(yy_server->passwd); } - yy_server->passwd = rb_strdup(data); + yy_server->passwd = rb_strdup((const char *)data); } static void @@ -1447,7 +1447,7 @@ conf_set_connect_port(void *data) static void conf_set_connect_aftype(void *data) { - char *aft = data; + char *aft = (char *)data; if(rb_strcasecmp(aft, "ipv4") == 0) yy_server->aftype = AF_INET; @@ -1462,7 +1462,7 @@ conf_set_connect_aftype(void *data) static void conf_set_connect_flags(void *data) { - conf_parm_t *args = data; + conf_parm_t *args = (conf_parm_t *)data; /* note, we allow them to set compressed, then remove it later if * they do and LIBZ isnt available @@ -1481,7 +1481,7 @@ conf_set_connect_hub_mask(void *data) yy_hub = make_remote_conf(); yy_hub->flags = CONF_HUB; - yy_hub->host = rb_strdup(data); + yy_hub->host = rb_strdup((const char *)data); yy_hub->server = rb_strdup(yy_server->name); rb_dlinkAdd(yy_hub, &yy_hub->node, &hubleaf_conf_list); } @@ -1497,7 +1497,7 @@ conf_set_connect_leaf_mask(void *data) yy_leaf = make_remote_conf(); yy_leaf->flags = CONF_LEAF; - yy_leaf->host = rb_strdup(data); + yy_leaf->host = rb_strdup((const char *)data); yy_leaf->server = rb_strdup(yy_server->name); rb_dlinkAdd(yy_leaf, &yy_leaf->node, &hubleaf_conf_list); } @@ -1506,7 +1506,7 @@ static void conf_set_connect_class(void *data) { rb_free(yy_server->class_name); - yy_server->class_name = rb_strdup(data); + yy_server->class_name = rb_strdup((const char *)data); } static void @@ -1514,7 +1514,7 @@ conf_set_exempt_ip(void *data) { struct ConfItem *yy_tmp; - if(parse_netmask(data, NULL, NULL) == HM_HOST) + if(parse_netmask((const char *)data, NULL, NULL) == HM_HOST) { conf_report_error("Ignoring exempt -- invalid exempt::ip."); return; @@ -1522,7 +1522,7 @@ conf_set_exempt_ip(void *data) yy_tmp = make_conf(); yy_tmp->passwd = rb_strdup("*"); - yy_tmp->host = rb_strdup(data); + yy_tmp->host = rb_strdup((const char *)data); yy_tmp->status = CONF_EXEMPTDLINE; add_conf_by_address(yy_tmp->host, CONF_EXEMPTDLINE, NULL, NULL, yy_tmp); } @@ -1534,7 +1534,7 @@ conf_cleanup_cluster(struct TopConf *tc) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head) { - free_remote_conf(ptr->data); + free_remote_conf((remote_conf *)ptr->data); rb_dlinkDestroy(ptr, &yy_cluster_list); } @@ -1554,7 +1554,7 @@ conf_set_cluster_name(void *data) free_remote_conf(yy_shared); yy_shared = make_remote_conf(); - yy_shared->server = rb_strdup(data); + yy_shared->server = rb_strdup((const char *)data); rb_dlinkAddAlloc(yy_shared, &yy_cluster_list); yy_shared = NULL; @@ -1563,7 +1563,7 @@ conf_set_cluster_name(void *data) static void conf_set_cluster_flags(void *data) { - conf_parm_t *args = data; + conf_parm_t *args = (conf_parm_t *)data; int flags = 0; rb_dlink_node *ptr, *next_ptr; @@ -1574,7 +1574,7 @@ conf_set_cluster_flags(void *data) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_cluster_list.head) { - yy_shared = ptr->data; + yy_shared = (remote_conf *)ptr->data; yy_shared->flags = flags; rb_dlinkAddTail(yy_shared, &yy_shared->node, &cluster_conf_list); rb_dlinkDestroy(ptr, &yy_cluster_list); @@ -1601,7 +1601,7 @@ conf_set_general_havent_read_conf(void *data) static void conf_set_general_hide_error_messages(void *data) { - char *val = data; + char *val = (char *)data; if(rb_strcasecmp(val, "yes") == 0) ConfigFileEntry.hide_error_messages = 2; @@ -1625,7 +1625,7 @@ conf_set_general_kline_delay(void *data) static void conf_set_general_stats_k_oper_only(void *data) { - char *val = data; + char *val = (char *)data; if(rb_strcasecmp(val, "yes") == 0) ConfigFileEntry.stats_k_oper_only = 2; @@ -1640,7 +1640,7 @@ conf_set_general_stats_k_oper_only(void *data) static void conf_set_general_stats_i_oper_only(void *data) { - char *val = data; + char *val = (char *)data; if(rb_strcasecmp(val, "yes") == 0) ConfigFileEntry.stats_i_oper_only = 2; @@ -1713,13 +1713,13 @@ conf_set_general_default_umodes(void *data) static void conf_set_general_oper_umodes(void *data) { - set_modes_from_table(&ConfigFileEntry.oper_umodes, "umode", umode_table, data); + set_modes_from_table(&ConfigFileEntry.oper_umodes, "umode", umode_table, (conf_parm_t *)data); } static void conf_set_general_certfp_method(void *data) { - char *method = data; + char *method = (char *)data; if (!rb_strcasecmp(method, CERTFP_NAME_CERT_SHA1)) ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_CERT_SHA1; @@ -1741,7 +1741,7 @@ conf_set_general_certfp_method(void *data) static void conf_set_general_oper_only_umodes(void *data) { - set_modes_from_table(&ConfigFileEntry.oper_only_umodes, "umode", umode_table, data); + set_modes_from_table(&ConfigFileEntry.oper_only_umodes, "umode", umode_table, (conf_parm_t *)data); } static void @@ -1790,7 +1790,7 @@ conf_set_service_name(void *data) char *tmp; int dots = 0; - for(s = data; *s != '\0'; s++) + for(s = (char *)data; *s != '\0'; s++) { if(!IsServChar(*s)) { @@ -1808,14 +1808,14 @@ conf_set_service_name(void *data) return; } - tmp = rb_strdup(data); + tmp = rb_strdup((const char *)data); rb_dlinkAddAlloc(tmp, &service_list); } static int conf_begin_alias(struct TopConf *tc) { - yy_alias = rb_malloc(sizeof(struct alias_entry)); + yy_alias = (alias_entry *)rb_malloc(sizeof(struct alias_entry)); if (conf_cur_block_name != NULL) yy_alias->name = rb_strdup(conf_cur_block_name); @@ -1860,7 +1860,7 @@ conf_set_alias_name(void *data) if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */ return; - yy_alias->name = rb_strdup(data); + yy_alias->name = rb_strdup((const char *)data); } static void @@ -1869,7 +1869,7 @@ conf_set_alias_target(void *data) if (data == NULL || yy_alias == NULL) /* this shouldn't ever happen */ return; - yy_alias->target = rb_strdup(data); + yy_alias->target = rb_strdup((const char *)data); } static void @@ -1928,13 +1928,13 @@ conf_set_blacklist_host(void *data) } yy_blacklist_iptype |= IPTYPE_IPV4; - yy_blacklist_host = rb_strdup(data); + yy_blacklist_host = rb_strdup((const char *)data); } static void conf_set_blacklist_type(void *data) { - conf_parm_t *args = data; + conf_parm_t *args = (conf_parm_t *)data; /* Don't assume we have either if we got here */ yy_blacklist_iptype = 0; @@ -1961,7 +1961,7 @@ conf_set_blacklist_type(void *data) static void conf_set_blacklist_matches(void *data) { - conf_parm_t *args = data; + conf_parm_t *args = (conf_parm_t *)data; enum filter_t { FILTER_NONE, FILTER_ALL, FILTER_LAST }; for (; args; args = args->next) @@ -2040,7 +2040,7 @@ conf_set_blacklist_reason(void *data) if (yy_blacklist_host && data) { - yy_blacklist_reason = rb_strdup(data); + yy_blacklist_reason = rb_strdup((const char *)data); if (yy_blacklist_iptype & IPTYPE_IPV6) { /* Make sure things fit (magic number 64 = alnum count + dots) @@ -2159,7 +2159,7 @@ conf_end_opm(struct TopConf *tc) end: RB_DLINK_FOREACH_SAFE(ptr, nptr, yy_opm_scanner_list.head) { - struct opm_scanner *scanner = ptr->data; + struct opm_scanner *scanner = (opm_scanner *)ptr->data; if(!fail) create_opm_proxy_scanner(scanner->type, scanner->port); @@ -2195,7 +2195,7 @@ conf_set_opm_listen_address_both(void *data, bool ipv6) { struct rb_sockaddr_storage addr; const char *confstr = (ipv6 ? "opm::listen_ipv6" : "opm::listen_ipv4"); - char *ip = data; + char *ip = (char *)data; if(!rb_inet_pton_sock(ip, (struct sockaddr *)&addr)) { @@ -2320,7 +2320,7 @@ conf_set_opm_listen_port(void *data) static void conf_set_opm_scan_ports_all(void *data, const char *node, const char *type) { - conf_parm_t *args = data; + conf_parm_t *args = (conf_parm_t *)data; for (; args; args = args->next) { rb_dlink_node *ptr; @@ -2341,7 +2341,7 @@ conf_set_opm_scan_ports_all(void *data, const char *node, const char *type) /* Check for duplicates */ RB_DLINK_FOREACH(ptr, yy_opm_scanner_list.head) { - struct opm_scanner *scanner = ptr->data; + struct opm_scanner *scanner = (opm_scanner *)ptr->data; if(scanner->port == args->v.number && strcmp(type, scanner->type) == 0) { @@ -2353,7 +2353,7 @@ conf_set_opm_scan_ports_all(void *data, const char *node, const char *type) if(!dup) { - struct opm_scanner *scanner = rb_malloc(sizeof(struct opm_scanner)); + struct opm_scanner *scanner = (opm_scanner *)rb_malloc(sizeof(struct opm_scanner)); scanner->port = args->v.number; scanner->type = type; rb_dlinkAdd(scanner, &scanner->node, &yy_opm_scanner_list); @@ -2470,8 +2470,8 @@ conf_set_generic_int(void *data, void *location) static void conf_set_generic_string(void *data, int len, void *location) { - char **loc = location; - char *input = data; + char **loc = (char **)location; + char *input = (char *)data; if(len && strlen(input) > (unsigned int)len) input[len] = '\0'; @@ -2589,7 +2589,7 @@ add_conf_item(const char *topconf, const char *name, int type, void (*func) (voi if(find_conf_item(tc, name) != NULL) return -1; - cf = rb_malloc(sizeof(struct ConfEntry)); + cf = (ConfEntry *)rb_malloc(sizeof(struct ConfEntry)); cf->cf_name = name; cf->cf_type = type; diff --git a/ircd/operhash.c b/ircd/operhash.cc similarity index 91% rename from ircd/operhash.c rename to ircd/operhash.cc index fbee05786..9116b5ada 100644 --- a/ircd/operhash.c +++ b/ircd/operhash.cc @@ -65,7 +65,7 @@ operhash_add(const char *name) } len = strlen(name) + 1; - ohash = rb_malloc(sizeof(struct operhash_entry) + len); + ohash = (operhash_entry *)rb_malloc(sizeof(struct operhash_entry) + len); ohash->refcount = 1; memcpy(ohash->name, name, len); rb_radixtree_add(operhash_tree, ohash->name, ohash); @@ -75,13 +75,13 @@ operhash_add(const char *name) const char * operhash_find(const char *name) { - return rb_radixtree_retrieve(operhash_tree, name); + return (const char *)rb_radixtree_retrieve(operhash_tree, name); } void operhash_delete(const char *name) { - struct operhash_entry *ohash = rb_radixtree_retrieve(operhash_tree, name); + struct operhash_entry *ohash = (operhash_entry *)rb_radixtree_retrieve(operhash_tree, name); if(ohash == NULL) return; diff --git a/ircd/packet.c b/ircd/packet.cc similarity index 98% rename from ircd/packet.c rename to ircd/packet.cc index 77210418e..a32a8e11f 100644 --- a/ircd/packet.c +++ b/ircd/packet.cc @@ -185,7 +185,7 @@ flood_recalc(void *unused) RB_DLINK_FOREACH_SAFE(ptr, next, lclient_list.head) { - client_p = ptr->data; + client_p = (Client *)ptr->data; if(rb_unlikely(IsMe(client_p))) continue; @@ -210,7 +210,7 @@ flood_recalc(void *unused) RB_DLINK_FOREACH_SAFE(ptr, next, unknown_list.head) { - client_p = ptr->data; + client_p = (Client *)ptr->data; if(client_p->localClient == NULL) continue; @@ -230,7 +230,7 @@ flood_recalc(void *unused) void read_packet(rb_fde_t * F, void *data) { - struct Client *client_p = data; + struct Client *client_p = (Client *)data; int length = 0; int binary = 0; diff --git a/ircd/parse.c b/ircd/parse.cc similarity index 98% rename from ircd/parse.c rename to ircd/parse.cc index d8f34d615..bed288ae5 100644 --- a/ircd/parse.c +++ b/ircd/parse.cc @@ -131,7 +131,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend) } else { - mptr = rb_dictionary_retrieve(cmd_dict, msgbuf.cmd); + mptr = (Message *)rb_dictionary_retrieve(cmd_dict, msgbuf.cmd); /* no command or its encap only, error */ if(!mptr || !mptr->cmd) @@ -250,7 +250,7 @@ handle_encap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so struct MessageEntry ehandler; MessageHandler handler = 0; - mptr = rb_dictionary_retrieve(cmd_dict, command); + mptr = (Message *)rb_dictionary_retrieve(cmd_dict, command); if(mptr == NULL || mptr->cmd == NULL) return; @@ -276,7 +276,7 @@ handle_encap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so void clear_hash_parse() { - cmd_dict = rb_dictionary_create("command", rb_strcasecmp); + cmd_dict = rb_dictionary_create("command", reinterpret_cast(rb_strcasecmp)); } /* mod_add_cmd diff --git a/ircd/privilege.c b/ircd/privilege.cc similarity index 94% rename from ircd/privilege.c rename to ircd/privilege.cc index 6c3216504..f2fb61203 100644 --- a/ircd/privilege.c +++ b/ircd/privilege.cc @@ -73,7 +73,7 @@ privilegeset_set_new(const char *name, const char *privs, PrivilegeFlags flags) } else { - set = rb_malloc(sizeof(struct PrivilegeSet)); + set = (PrivilegeSet *)rb_malloc(sizeof(struct PrivilegeSet)); set->status = 0; set->refs = 0; set->name = rb_strdup(name); @@ -105,7 +105,7 @@ privilegeset_extend(struct PrivilegeSet *parent, const char *name, const char *p } else { - set = rb_malloc(sizeof(struct PrivilegeSet)); + set = (PrivilegeSet *)rb_malloc(sizeof(struct PrivilegeSet)); set->status = 0; set->refs = 0; set->name = rb_strdup(name); @@ -113,7 +113,7 @@ privilegeset_extend(struct PrivilegeSet *parent, const char *name, const char *p rb_dlinkAdd(set, &set->node, &privilegeset_list); } set->flags = flags; - set->privs = rb_malloc(strlen(parent->privs) + 1 + strlen(privs) + 1); + set->privs = (char *)rb_malloc(strlen(parent->privs) + 1 + strlen(privs) + 1); strcpy(set->privs, parent->privs); strcat(set->privs, " "); strcat(set->privs, privs); @@ -203,7 +203,7 @@ privilegeset_report(struct Client *source_p) RB_DLINK_FOREACH(ptr, privilegeset_list.head) { - struct PrivilegeSet *set = ptr->data; + struct PrivilegeSet *set = (PrivilegeSet *)ptr->data; /* use RPL_STATSDEBUG for now -- jilles */ sendto_one_numeric(source_p, RPL_STATSDEBUG, diff --git a/ircd/ratelimit.c b/ircd/ratelimit.cc similarity index 100% rename from ircd/ratelimit.c rename to ircd/ratelimit.cc diff --git a/ircd/reject.c b/ircd/reject.cc similarity index 90% rename from ircd/reject.c rename to ircd/reject.cc index 081d86c43..6a9e20528 100644 --- a/ircd/reject.c +++ b/ircd/reject.cc @@ -78,7 +78,7 @@ reject_exit(void *unused) RB_DLINK_FOREACH_SAFE(ptr, ptr_next, delay_exit.head) { - ddata = ptr->data; + ddata = (delay_t *)ptr->data; rb_write(ddata->F, errbuf, strlen(errbuf)); rb_close(ddata->F); @@ -98,8 +98,8 @@ reject_expires(void *unused) RB_DLINK_FOREACH_SAFE(ptr, next, reject_list.head) { - pnode = ptr->data; - rdata = pnode->data; + pnode = (rb_patricia_node_t *)ptr->data; + rdata = (reject_t *)pnode->data; if(rdata->time + ConfigFileEntry.reject_duration > rb_current_time()) continue; @@ -131,8 +131,8 @@ throttle_size(void) count = 0; RB_DLINK_FOREACH(ptr, throttle_list.head) { - pnode = ptr->data; - t = pnode->data; + pnode = (rb_patricia_node_t *)ptr->data; + t = (throttle_t *)pnode->data; if (t->count > ConfigFileEntry.throttle_count) count++; } @@ -159,7 +159,7 @@ add_reject(struct Client *client_p, const char *mask1, const char *mask2) if((pnode = rb_match_ip(reject_tree, (struct sockaddr *)&client_p->localClient->ip)) != NULL) { - rdata = pnode->data; + rdata = (reject_t *)pnode->data; rdata->time = rb_current_time(); rdata->count++; } @@ -171,7 +171,7 @@ add_reject(struct Client *client_p, const char *mask1, const char *mask2) bitlen = 128; #endif pnode = make_and_lookup_ip(reject_tree, (struct sockaddr *)&client_p->localClient->ip, bitlen); - pnode->data = rdata = rb_malloc(sizeof(reject_t)); + pnode->data = rdata = (reject_t *)rb_malloc(sizeof(reject_t)); rb_dlinkAddTail(pnode, &rdata->rnode, &reject_list); rdata->time = rb_current_time(); rdata->count = 1; @@ -192,12 +192,12 @@ check_reject(rb_fde_t *F, struct sockaddr *addr) pnode = rb_match_ip(reject_tree, addr); if(pnode != NULL) { - rdata = pnode->data; + rdata = (reject_t *)pnode->data; rdata->time = rb_current_time(); if(rdata->count > (unsigned long)ConfigFileEntry.reject_after_count) { - ddata = rb_malloc(sizeof(delay_t)); + ddata = (delay_t *)rb_malloc(sizeof(delay_t)); ServerStats.is_rej++; rb_setselect(F, RB_SELECT_WRITE | RB_SELECT_READ, NULL, NULL); ddata->F = F; @@ -223,7 +223,7 @@ is_reject_ip(struct sockaddr *addr) pnode = rb_match_ip(reject_tree, addr); if(pnode != NULL) { - rdata = pnode->data; + rdata = (reject_t *)pnode->data; if(rdata->count > (unsigned long)ConfigFileEntry.reject_after_count) { @@ -243,8 +243,8 @@ flush_reject(void) RB_DLINK_FOREACH_SAFE(ptr, next, reject_list.head) { - pnode = ptr->data; - rdata = pnode->data; + pnode = (rb_patricia_node_t *)ptr->data; + rdata = (reject_t *)pnode->data; rb_dlinkDelete(ptr, &reject_list); rb_free(rdata); rb_patricia_remove(reject_tree, pnode); @@ -262,7 +262,7 @@ remove_reject_ip(const char *ip) if((pnode = rb_match_string(reject_tree, ip)) != NULL) { - reject_t *rdata = pnode->data; + reject_t *rdata = (reject_t *)pnode->data; rb_dlinkDelete(&rdata->rnode, &reject_list); rb_free(rdata); rb_patricia_remove(reject_tree, pnode); @@ -287,8 +287,8 @@ remove_reject_mask(const char *mask1, const char *mask2) hashv ^= fnv_hash_upper((const unsigned char *)mask2, 32); RB_DLINK_FOREACH_SAFE(ptr, next, reject_list.head) { - pnode = ptr->data; - rdata = pnode->data; + pnode = (rb_patricia_node_t *)ptr->data; + rdata = (reject_t *)pnode->data; if (rdata->mask_hashv == hashv) { rb_dlinkDelete(ptr, &reject_list); @@ -308,7 +308,7 @@ throttle_add(struct sockaddr *addr) if((pnode = rb_match_ip(throttle_tree, addr)) != NULL) { - t = pnode->data; + t = (throttle_t *)pnode->data; if(t->count > ConfigFileEntry.throttle_count) { @@ -325,7 +325,7 @@ throttle_add(struct sockaddr *addr) if(GET_SS_FAMILY(addr) == AF_INET6) bitlen = 128; #endif - t = rb_malloc(sizeof(throttle_t)); + t = (throttle_t *)rb_malloc(sizeof(throttle_t)); t->last = rb_current_time(); t->count = 1; pnode = make_and_lookup_ip(throttle_tree, addr, bitlen); @@ -344,7 +344,7 @@ is_throttle_ip(struct sockaddr *addr) if((pnode = rb_match_ip(throttle_tree, addr)) != NULL) { - t = pnode->data; + t = (throttle_t *)pnode->data; if(t->count > ConfigFileEntry.throttle_count) { duration = t->last + ConfigFileEntry.throttle_duration - rb_current_time(); @@ -363,8 +363,8 @@ flush_throttle(void) RB_DLINK_FOREACH_SAFE(ptr, next, throttle_list.head) { - pnode = ptr->data; - t = pnode->data; + pnode = (rb_patricia_node_t *)ptr->data; + t = (throttle_t *)pnode->data; rb_dlinkDelete(ptr, &throttle_list); rb_free(t); @@ -381,8 +381,8 @@ throttle_expires(void *unused) RB_DLINK_FOREACH_SAFE(ptr, next, throttle_list.head) { - pnode = ptr->data; - t = pnode->data; + pnode = (rb_patricia_node_t *)ptr->data; + t = (throttle_t *)pnode->data; if(t->last + ConfigFileEntry.throttle_duration > rb_current_time()) continue; diff --git a/ircd/restart.c b/ircd/restart.cc similarity index 95% rename from ircd/restart.c rename to ircd/restart.cc index 9bbf60244..b66957633 100644 --- a/ircd/restart.c +++ b/ircd/restart.cc @@ -72,11 +72,11 @@ server_reboot(void) close(i); unlink(pidFileName); - execv(ircd_paths[IRCD_PATH_IRCD_EXEC], (void *)myargv); + execv(ircd_paths[IRCD_PATH_IRCD_EXEC], (char *const *)myargv); /* use this if execv of SPATH fails */ snprintf(path, sizeof(path), "%s%cbin%circd", ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR); - execv(path, (void *)myargv); + execv(path, (char *const *)myargv); exit(-1); } diff --git a/ircd/s_conf.c b/ircd/s_conf.cc similarity index 98% rename from ircd/s_conf.c rename to ircd/s_conf.cc index f07745c7a..b1b07510e 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.cc @@ -54,7 +54,7 @@ struct config_server_hide ConfigServerHide; -extern int yyparse(void); /* defined in y.tab.c */ +extern "C" int yyparse(void); /* defined in y.tab.c */ extern char yy_linebuf[16384]; /* defined in ircd_lexer.l */ static rb_bh *confitem_heap = NULL; @@ -118,7 +118,7 @@ make_conf() { struct ConfItem *aconf; - aconf = rb_bh_alloc(confitem_heap); + aconf = (ConfItem *)rb_bh_alloc(confitem_heap); aconf->status = CONF_ILLEGAL; return (aconf); } @@ -498,7 +498,7 @@ attach_iline(struct Client *client_p, struct ConfItem *aconf) /* find_hostname() returns the head of the list to search */ RB_DLINK_FOREACH(ptr, find_hostname(client_p->host)) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(irccmp(client_p->host, target_p->orighost) != 0) continue; @@ -812,7 +812,7 @@ set_default_conf(void) ConfigFileEntry.hide_opers_in_whois = 0; if (!alias_dict) - alias_dict = rb_dictionary_create("alias", rb_strcasecmp); + alias_dict = rb_dictionary_create("alias", reinterpret_cast(rb_strcasecmp)); } /* @@ -1052,7 +1052,7 @@ find_prop_ban(unsigned int status, const char *user, const char *host) RB_DLINK_FOREACH(ptr, prop_bans.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if((aconf->status & ~CONF_ILLEGAL) == status && (!user || !aconf->user || @@ -1125,7 +1125,7 @@ replace_old_ban(struct ConfItem *aconf) ptr = find_prop_ban(aconf->status, aconf->user, aconf->host); if(ptr != NULL) { - oldconf = ptr->data; + oldconf = (ConfItem *)ptr->data; /* Remember at least as long as the old one. */ if(oldconf->lifetime > aconf->lifetime) aconf->lifetime = oldconf->lifetime; @@ -1154,7 +1154,7 @@ expire_prop_bans(void *list) now = rb_current_time(); RB_DLINK_FOREACH_SAFE(ptr, next_ptr, ((rb_dlink_list *) list)->head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(aconf->lifetime <= now || (aconf->hold <= now && @@ -1184,15 +1184,16 @@ expire_prop_bans(void *list) * side effects - expire tklines and moves them between lists */ static void -expire_temp_kd(void *list) +expire_temp_kd(void *list_) { rb_dlink_node *ptr; rb_dlink_node *next_ptr; struct ConfItem *aconf; - RB_DLINK_FOREACH_SAFE(ptr, next_ptr, ((rb_dlink_list *) list)->head) + rb_dlink_list *list = (rb_dlink_list *)list_; + RB_DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(aconf->hold <= rb_current_time()) { @@ -1210,14 +1211,15 @@ expire_temp_kd(void *list) } static void -reorganise_temp_kd(void *list) +reorganise_temp_kd(void *list_) { struct ConfItem *aconf; rb_dlink_node *ptr, *next_ptr; - RB_DLINK_FOREACH_SAFE(ptr, next_ptr, ((rb_dlink_list *) list)->head) + rb_dlink_list *list = (rb_dlink_list *)list_; + RB_DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(aconf->hold < (rb_current_time() + (60 * 60))) { @@ -1420,7 +1422,7 @@ read_conf_files(bool cold) static void free_alias_cb(rb_dictionary_element *ptr, void *unused) { - struct alias_entry *aptr = ptr->data; + struct alias_entry *aptr = (alias_entry *)ptr->data; rb_free(aptr->name); rb_free(aptr->target); @@ -1447,7 +1449,7 @@ clear_out_old_conf(void) */ RB_DLINK_FOREACH(ptr, class_list.head) { - cltmp = ptr->data; + cltmp = (Class *)ptr->data; MaxUsers(cltmp) = -1; } diff --git a/ircd/s_newconf.c b/ircd/s_newconf.cc similarity index 93% rename from ircd/s_newconf.c rename to ircd/s_newconf.cc index 8ff1ab795..825917e08 100644 --- a/ircd/s_newconf.c +++ b/ircd/s_newconf.cc @@ -83,35 +83,35 @@ clear_s_newconf(void) { /* ptr here is ptr->data->node */ rb_dlinkDelete(ptr, &shared_conf_list); - free_remote_conf(ptr->data); + free_remote_conf((remote_conf *)ptr->data); } RB_DLINK_FOREACH_SAFE(ptr, next_ptr, cluster_conf_list.head) { rb_dlinkDelete(ptr, &cluster_conf_list); - free_remote_conf(ptr->data); + free_remote_conf((remote_conf *)ptr->data); } RB_DLINK_FOREACH_SAFE(ptr, next_ptr, hubleaf_conf_list.head) { rb_dlinkDelete(ptr, &hubleaf_conf_list); - free_remote_conf(ptr->data); + free_remote_conf((remote_conf *)ptr->data); } RB_DLINK_FOREACH_SAFE(ptr, next_ptr, oper_conf_list.head) { - free_oper_conf(ptr->data); + free_oper_conf((oper_conf *)ptr->data); rb_dlinkDestroy(ptr, &oper_conf_list); } RB_DLINK_FOREACH_SAFE(ptr, next_ptr, server_conf_list.head) { - server_p = ptr->data; + server_p = (server_conf *)ptr->data; if(!server_p->servers) { rb_dlinkDelete(ptr, &server_conf_list); - free_server_conf(ptr->data); + free_server_conf((server_conf *)ptr->data); } else server_p->flags |= SERVER_ILLEGAL; @@ -126,7 +126,7 @@ clear_s_newconf_bans(void) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, xline_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(aconf->hold) continue; @@ -137,7 +137,7 @@ clear_s_newconf_bans(void) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, resv_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; /* temporary resv */ if(aconf->hold) @@ -153,7 +153,7 @@ clear_s_newconf_bans(void) struct remote_conf * make_remote_conf(void) { - struct remote_conf *remote_p = rb_malloc(sizeof(struct remote_conf)); + struct remote_conf *remote_p = (remote_conf *)rb_malloc(sizeof(struct remote_conf)); return remote_p; } @@ -179,7 +179,7 @@ find_shared_conf(const char *username, const char *host, RB_DLINK_FOREACH(ptr, shared_conf_list.head) { - shared_p = ptr->data; + shared_p = (remote_conf *)ptr->data; if(match(shared_p->username, username) && match(shared_p->host, host) && @@ -229,7 +229,7 @@ cluster_generic(struct Client *source_p, const char *command, RB_DLINK_FOREACH(ptr, cluster_conf_list.head) { - shared_p = ptr->data; + shared_p = (remote_conf *)ptr->data; if(!(shared_p->flags & cltype)) continue; @@ -246,7 +246,7 @@ cluster_generic(struct Client *source_p, const char *command, struct oper_conf * make_oper_conf(void) { - struct oper_conf *oper_p = rb_malloc(sizeof(struct oper_conf)); + struct oper_conf *oper_p = (oper_conf *)rb_malloc(sizeof(struct oper_conf)); return oper_p; } @@ -291,7 +291,7 @@ find_oper_conf(const char *username, const char *host, const char *locip, const RB_DLINK_FOREACH(ptr, oper_conf_list.head) { - oper_p = ptr->data; + oper_p = (oper_conf *)ptr->data; /* name/username doesnt match.. */ if(irccmp(oper_p->name, name) || !match(oper_p->username, username)) @@ -320,7 +320,7 @@ find_oper_conf(const char *username, const char *host, const char *locip, const struct server_conf * make_server_conf(void) { - struct server_conf *server_p = rb_malloc(sizeof(struct server_conf)); + struct server_conf *server_p = (server_conf *)rb_malloc(sizeof(struct server_conf)); SET_SS_FAMILY(&server_p->connect4, AF_UNSPEC); SET_SS_LEN(&server_p->connect4, sizeof(struct sockaddr_in)); @@ -380,7 +380,7 @@ free_server_conf(struct server_conf *server_p) static void conf_connect_dns_callback(const char *result, int status, int aftype, void *data) { - struct server_conf *server_p = data; + struct server_conf *server_p = (server_conf *)data; if(aftype == AF_INET) { @@ -413,7 +413,7 @@ conf_connect_dns_callback(const char *result, int status, int aftype, void *data static void conf_bind_dns_callback(const char *result, int status, int aftype, void *data) { - struct server_conf *server_p = data; + struct server_conf *server_p = (server_conf *)data; if(aftype == AF_INET) { @@ -483,7 +483,7 @@ find_server_conf(const char *name) RB_DLINK_FOREACH(ptr, server_conf_list.head) { - server_p = ptr->data; + server_p = (server_conf *)ptr->data; if(ServerConfIllegal(server_p)) continue; @@ -583,7 +583,7 @@ find_xline(const char *gecos, int counter) RB_DLINK_FOREACH(ptr, xline_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(match_esc(aconf->host, gecos)) { @@ -604,7 +604,7 @@ find_xline_mask(const char *gecos) RB_DLINK_FOREACH(ptr, xline_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(!irccmp(aconf->host, gecos)) return aconf; @@ -621,7 +621,7 @@ find_nick_resv(const char *name) RB_DLINK_FOREACH(ptr, resv_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(match_esc(aconf->host, name)) { @@ -641,7 +641,7 @@ find_nick_resv_mask(const char *name) RB_DLINK_FOREACH(ptr, resv_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(!irccmp(aconf->host, name)) return aconf; @@ -759,8 +759,11 @@ expire_temp_rxlines(void *unused) rb_dlink_node *next_ptr; rb_radixtree_iteration_state state; - RB_RADIXTREE_FOREACH(aconf, &state, resv_tree) + void *elem; + RB_RADIXTREE_FOREACH(elem, &state, resv_tree) { + aconf = (ConfItem *)elem; + if(aconf->lifetime != 0) continue; if(aconf->hold && aconf->hold <= rb_current_time()) @@ -777,7 +780,7 @@ expire_temp_rxlines(void *unused) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, resv_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(aconf->lifetime != 0) continue; @@ -794,7 +797,7 @@ expire_temp_rxlines(void *unused) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, xline_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(aconf->lifetime != 0) continue; @@ -824,7 +827,7 @@ add_nd_entry(const char *name) if(rb_dictionary_find(nd_dict, name) != NULL) return; - nd = rb_bh_alloc(nd_heap); + nd = (nd_entry *)rb_bh_alloc(nd_heap); rb_strlcpy(nd->name, name, sizeof(nd->name)); nd->expire = rb_current_time() + ConfigFileEntry.nick_delay; @@ -853,7 +856,7 @@ expire_nd_entries(void *unused) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, nd_list.head) { - nd = ptr->data; + nd = (nd_entry *)ptr->data; /* this list is ordered - we can stop when we hit the first * entry that doesnt expire.. @@ -874,7 +877,7 @@ add_tgchange(const char *host) if(find_tgchange(host)) return; - target = rb_malloc(sizeof(tgchange)); + target = (tgchange *)rb_malloc(sizeof(tgchange)); pnode = make_and_lookup(tgchange_tree, host); pnode->data = target; @@ -892,7 +895,7 @@ find_tgchange(const char *host) rb_patricia_node_t *pnode; if((pnode = rb_match_exact_string(tgchange_tree, host))) - return pnode->data; + return (tgchange *)pnode->data; return NULL; } diff --git a/ircd/s_serv.c b/ircd/s_serv.cc similarity index 98% rename from ircd/s_serv.c rename to ircd/s_serv.cc index 132ad581a..3a35567d4 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.cc @@ -176,7 +176,7 @@ hunt_server(struct Client *client_p, struct Client *source_p, int wilds; rb_dlink_node *ptr; const char *old; - char *new; + char *new_; /* * Assume it's me, if no server @@ -185,7 +185,7 @@ hunt_server(struct Client *client_p, struct Client *source_p, match(parv[server], me.name) || (strcmp(parv[server], me.id) == 0)) return (HUNTED_ISME); - new = LOCAL_COPY(parv[server]); + new_ = LOCAL_COPY(parv[server]); /* * These are to pickup matches that would cause the following @@ -193,16 +193,16 @@ hunt_server(struct Client *client_p, struct Client *source_p, * non-matching lookups. */ if(MyClient(source_p)) - target_p = find_named_client(new); + target_p = find_named_client(new_); else - target_p = find_client(new); + target_p = find_client(new_); if(target_p) if(target_p->from == source_p->from && !MyConnect(target_p)) target_p = NULL; - collapse(new); - wilds = (strchr(new, '?') || strchr(new, '*')); + collapse(new_); + wilds = (strchr(new_, '?') || strchr(new_, '*')); /* * Again, if there are no wild cards involved in the server @@ -212,9 +212,9 @@ hunt_server(struct Client *client_p, struct Client *source_p, { RB_DLINK_FOREACH(ptr, global_serv_list.head) { - if(match(new, ((struct Client *) (ptr->data))->name)) + if(match(new_, ((struct Client *) (ptr->data))->name)) { - target_p = ptr->data; + target_p = (Client *)ptr->data; break; } } @@ -263,7 +263,7 @@ try_connections(void *unused) RB_DLINK_FOREACH(ptr, server_conf_list.head) { - tmp_p = ptr->data; + tmp_p = (server_conf *)ptr->data; if(ServerConfIllegal(tmp_p) || !ServerConfAutoconn(tmp_p)) continue; @@ -362,7 +362,7 @@ check_server(const char *name, struct Client *client_p) { struct rb_sockaddr_storage client_addr; - tmp_p = ptr->data; + tmp_p = (server_conf *)ptr->data; if(ServerConfIllegal(tmp_p)) continue; @@ -479,7 +479,7 @@ burst_ban(struct Client *client_p) melen = strlen(me.name); RB_DLINK_FOREACH(ptr, prop_bans.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; /* Skip expired stuff. */ if(aconf->lifetime < rb_current_time()) @@ -549,7 +549,7 @@ burst_modes_TS6(struct Client *client_p, struct Channel *chptr, RB_DLINK_FOREACH(ptr, list->head) { - banptr = ptr->data; + banptr = (Ban *)ptr->data; tlen = strlen(banptr->banstr) + (banptr->forward ? strlen(banptr->forward) + 1 : 0) + 1; @@ -612,7 +612,7 @@ burst_TS6(struct Client *client_p) RB_DLINK_FOREACH(ptr, global_client_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(!IsPerson(target_p)) continue; @@ -669,7 +669,7 @@ burst_TS6(struct Client *client_p) RB_DLINK_FOREACH(ptr, global_channel_list.head) { - chptr = ptr->data; + chptr = (Channel *)ptr->data; if(*chptr->chname != '#') continue; @@ -682,7 +682,7 @@ burst_TS6(struct Client *client_p) RB_DLINK_FOREACH(uptr, chptr->members.head) { - msptr = uptr->data; + msptr = (membership *)uptr->data; tlen = strlen(use_id(msptr->client_p)) + 1; if(is_chanop(msptr)) @@ -905,7 +905,7 @@ server_estab(struct Client *client_p) */ RB_DLINK_FOREACH(ptr, serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(target_p == client_p) continue; @@ -952,7 +952,7 @@ server_estab(struct Client *client_p) */ RB_DLINK_FOREACH(ptr, global_serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; /* target_p->from == target_p for target_p == client_p */ if(IsMe(target_p) || target_p->from == client_p) @@ -1160,7 +1160,7 @@ serv_connect(struct server_conf *server_p, struct Client *by) static void serv_connect_ssl_callback(rb_fde_t *F, int status, void *data) { - struct Client *client_p = data; + struct Client *client_p = (Client *)data; rb_fde_t *xF[2]; rb_connect_sockaddr(F, (struct sockaddr *)&client_p->localClient->ip, sizeof(client_p->localClient->ip)); if(status != RB_OK) @@ -1207,7 +1207,7 @@ serv_connect_ssl_open_callback(struct Client *client_p, int status) static void serv_connect_callback(rb_fde_t *F, int status, void *data) { - struct Client *client_p = data; + struct Client *client_p = (Client *)data; struct server_conf *server_p; char *errstr; diff --git a/ircd/s_user.c b/ircd/s_user.cc similarity index 99% rename from ircd/s_user.c rename to ircd/s_user.cc index 610709d22..d4ae3ea7e 100644 --- a/ircd/s_user.c +++ b/ircd/s_user.cc @@ -219,7 +219,7 @@ authd_check(struct Client *client_p, struct Client *source_p) char *blacklist = source_p->preClient->auth.data; if(bl_stats != NULL) - if((stats = rb_dictionary_retrieve(bl_stats, blacklist)) != NULL) + if((stats = (BlacklistStats *)rb_dictionary_retrieve(bl_stats, blacklist)) != NULL) stats->hits++; if(IsExemptKline(source_p) || IsConfExemptDNSBL(aconf)) @@ -1313,7 +1313,7 @@ send_umode_out(struct Client *client_p, struct Client *source_p, int old) RB_DLINK_FOREACH(ptr, serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if((target_p != client_p) && (target_p != source_p) && (*buf)) { @@ -1529,7 +1529,7 @@ change_nick_user_host(struct Client *target_p, const char *nick, const char *use RB_DLINK_FOREACH(ptr, target_p->user->channel.head) { - mscptr = ptr->data; + mscptr = (membership *)ptr->data; chptr = mscptr->chptr; mptr = mode; diff --git a/ircd/scache.c b/ircd/scache.cc similarity index 93% rename from ircd/scache.c rename to ircd/scache.cc index c42edf473..3fe74ba5c 100644 --- a/ircd/scache.c +++ b/ircd/scache.cc @@ -73,7 +73,7 @@ find_or_add(const char *name) { struct scache_entry *ptr; - ptr = rb_radixtree_retrieve(scache_tree, name); + ptr = (scache_entry *)rb_radixtree_retrieve(scache_tree, name); if (ptr != NULL) return ptr; @@ -135,8 +135,11 @@ scache_send_flattened_links(struct Client *source_p) rb_radixtree_iteration_state iter; int show; - RB_RADIXTREE_FOREACH(scache_ptr, &iter, scache_tree) + void *elem; + RB_RADIXTREE_FOREACH(elem, &iter, scache_tree) { + scache_ptr = (scache_entry *)elem; + if (!irccmp(scache_ptr->name, me.name)) show = FALSE; else if (scache_ptr->flags & SC_HIDDEN && @@ -170,8 +173,11 @@ scache_send_missing(struct Client *source_p) struct scache_entry *scache_ptr; rb_radixtree_iteration_state iter; - RB_RADIXTREE_FOREACH(scache_ptr, &iter, scache_tree) + void *elem; + RB_RADIXTREE_FOREACH(elem, &iter, scache_tree) { + scache_ptr = (scache_entry *)elem; + if (!(scache_ptr->flags & SC_ONLINE) && scache_ptr->last_split > rb_current_time() - MISSING_TIMEOUT) sendto_one_numeric(source_p, RPL_MAP, "** %s (recently split)", scache_ptr->name); @@ -194,8 +200,11 @@ count_scache(size_t * number_servers_cached, size_t * mem_servers_cached) *number_servers_cached = 0; *mem_servers_cached = 0; - RB_RADIXTREE_FOREACH(scache_ptr, &iter, scache_tree) + void *elem; + RB_RADIXTREE_FOREACH(elem, &iter, scache_tree) { + scache_ptr = (scache_entry *)elem; + *number_servers_cached = *number_servers_cached + 1; *mem_servers_cached = *mem_servers_cached + sizeof(struct scache_entry); diff --git a/ircd/send.c b/ircd/send.cc similarity index 97% rename from ircd/send.c rename to ircd/send.cc index ce36b3a7a..619d2194a 100644 --- a/ircd/send.c +++ b/ircd/send.cc @@ -201,7 +201,7 @@ send_pop_queue(struct Client *to) static void send_queued_write(rb_fde_t *F, void *data) { - struct Client *to = data; + struct Client *to = (Client *)data; ClearFlush(to); send_queued(to); } @@ -464,7 +464,7 @@ sendto_server(struct Client *one, struct Channel *chptr, unsigned long caps, RB_DLINK_FOREACH_SAFE(ptr, next_ptr, serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; /* check against 'one' */ if(one != NULL && (target_p == one->from)) @@ -521,7 +521,7 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p, RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->members.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; target_p = msptr->client_p; if(!MyClient(source_p) && (IsIOError(target_p->from) || target_p->from == one)) @@ -621,7 +621,7 @@ sendto_channel_opmod(struct Client *one, struct Client *source_p, RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->members.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; target_p = msptr->client_p; if(!MyClient(source_p) && (IsIOError(target_p->from) || target_p->from == one)) @@ -686,7 +686,7 @@ sendto_channel_local(int type, struct Channel *chptr, const char *pattern, ...) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; target_p = msptr->client_p; if(IsIOError(target_p)) @@ -726,7 +726,7 @@ _sendto_channel_local_with_capability_butone(struct Client *one, int type, int c RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; target_p = msptr->client_p; if (target_p == one) @@ -809,7 +809,7 @@ sendto_channel_local_butone(struct Client *one, int type, struct Channel *chptr, RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; target_p = msptr->client_p; if(target_p == one) @@ -863,12 +863,12 @@ sendto_common_channels_local(struct Client *user, int cap, int negcap, const cha RB_DLINK_FOREACH_SAFE(ptr, next_ptr, user->user->channel.head) { - mscptr = ptr->data; + mscptr = (membership *)ptr->data; chptr = mscptr->chptr; RB_DLINK_FOREACH_SAFE(uptr, next_uptr, chptr->locmembers.head) { - msptr = uptr->data; + msptr = (membership *)uptr->data; target_p = msptr->client_p; if(IsIOError(target_p) || @@ -928,12 +928,12 @@ sendto_common_channels_local_butone(struct Client *user, int cap, int negcap, co RB_DLINK_FOREACH_SAFE(ptr, next_ptr, user->user->channel.head) { - mscptr = ptr->data; + mscptr = (membership *)ptr->data; chptr = mscptr->chptr; RB_DLINK_FOREACH_SAFE(uptr, next_uptr, chptr->locmembers.head) { - msptr = uptr->data; + msptr = (membership *)uptr->data; target_p = msptr->client_p; if(IsIOError(target_p) || @@ -990,7 +990,7 @@ sendto_match_butone(struct Client *one, struct Client *source_p, { RB_DLINK_FOREACH_SAFE(ptr, next_ptr, lclient_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(match(mask, target_p->host)) _send_linebuf(target_p, &rb_linebuf_local); @@ -1001,14 +1001,14 @@ sendto_match_butone(struct Client *one, struct Client *source_p, { RB_DLINK_FOREACH_SAFE(ptr, next_ptr, lclient_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; _send_linebuf(target_p, &rb_linebuf_local); } } RB_DLINK_FOREACH(ptr, serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(target_p == one) continue; @@ -1052,7 +1052,7 @@ sendto_match_servs(struct Client *source_p, const char *mask, int cap, RB_DLINK_FOREACH(ptr, global_serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; /* dont send to ourselves, or back to where it came from.. */ if(IsMe(target_p) || target_p->from == source_p->from) @@ -1103,7 +1103,7 @@ sendto_local_clients_with_capability(int cap, const char *pattern, ...) RB_DLINK_FOREACH(ptr, lclient_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(IsIOError(target_p) || !IsCapable(target_p, cap)) continue; @@ -1137,7 +1137,7 @@ sendto_monitor(struct monitor *monptr, const char *pattern, ...) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, monptr->users.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(IsIOError(target_p)) continue; @@ -1251,7 +1251,7 @@ sendto_realops_snomask(int flags, int level, const char *pattern, ...) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, local_oper_list.head) { - client_p = ptr->data; + client_p = (Client *)ptr->data; /* If we're sending it to opers and theyre an admin, skip. * If we're sending it to admins, and theyre not, skip. @@ -1291,7 +1291,7 @@ sendto_realops_snomask_from(int flags, int level, struct Client *source_p, RB_DLINK_FOREACH_SAFE(ptr, next_ptr, local_oper_list.head) { - client_p = ptr->data; + client_p = (Client *)ptr->data; /* If we're sending it to opers and theyre an admin, skip. * If we're sending it to admins, and theyre not, skip. @@ -1340,7 +1340,7 @@ sendto_wallops_flags(int flags, struct Client *source_p, const char *pattern, .. RB_DLINK_FOREACH_SAFE(ptr, next_ptr, IsPerson(source_p) && flags == UMODE_WALLOP ? lclient_list.head : local_oper_list.head) { - client_p = ptr->data; + client_p = (Client *)ptr->data; if(client_p->umodes & flags) _send_linebuf(client_p, &linebuf); @@ -1405,7 +1405,7 @@ kill_client_serv_butone(struct Client *one, struct Client *target_p, const char RB_DLINK_FOREACH_SAFE(ptr, next_ptr, serv_list.head) { - client_p = ptr->data; + client_p = (Client *)ptr->data; /* ok, if the client we're supposed to not send to has an * ID, then we still want to issue the kill there.. diff --git a/ircd/snomask.c b/ircd/snomask.cc similarity index 100% rename from ircd/snomask.c rename to ircd/snomask.cc diff --git a/ircd/sslproc.c b/ircd/sslproc.cc similarity index 94% rename from ircd/sslproc.c rename to ircd/sslproc.cc index 370b2b1a7..144dc3aed 100644 --- a/ircd/sslproc.c +++ b/ircd/sslproc.cc @@ -96,7 +96,7 @@ allocate_ssl_daemon(rb_fde_t * F, rb_fde_t * P, int pid) if(F == NULL || pid < 0) return NULL; - ctl = rb_malloc(sizeof(ssl_ctl_t)); + ctl = (ssl_ctl_t *)rb_malloc(sizeof(ssl_ctl_t)); ctl->F = F; ctl->P = P; ctl->pid = pid; @@ -116,7 +116,7 @@ free_ssl_daemon(ssl_ctl_t * ctl) RB_DLINK_FOREACH(ptr, ctl->readq.head) { - ctl_buf = ptr->data; + ctl_buf = (ssl_ctl_buf_t *)ptr->data; for(x = 0; x < ctl_buf->nfds; x++) rb_close(ctl_buf->F[x]); @@ -126,7 +126,7 @@ free_ssl_daemon(ssl_ctl_t * ctl) RB_DLINK_FOREACH(ptr, ctl->writeq.head) { - ctl_buf = ptr->data; + ctl_buf = (ssl_ctl_buf_t *)ptr->data; for(x = 0; x < ctl_buf->nfds; x++) rb_close(ctl_buf->F[x]); @@ -154,7 +154,7 @@ restart_ssld(void) RB_DLINK_FOREACH_SAFE(ptr, next, ssl_daemons.head) { - ctl = ptr->data; + ctl = (ssl_ctl_t *)ptr->data; if(ctl->dead) continue; if(ctl->shutdown) @@ -181,7 +181,7 @@ ssl_killall(void) ssl_ctl_t *ctl; RB_DLINK_FOREACH_SAFE(ptr, next, ssl_daemons.head) { - ctl = ptr->data; + ctl = (ssl_ctl_t *)ptr->data; if(ctl->dead) continue; ctl->dead = 1; @@ -215,7 +215,7 @@ static void ssl_do_pipe(rb_fde_t * F, void *data) { int retlen; - ssl_ctl_t *ctl = data; + ssl_ctl_t *ctl = (ssl_ctl_t *)data; retlen = rb_write(F, "0", 1); if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno))) { @@ -358,7 +358,7 @@ ssl_process_zipstats(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf) if(server == NULL || server->localClient == NULL || !IsCapable(server, CAP_ZIP)) return; if(server->localClient->zipstats == NULL) - server->localClient->zipstats = rb_malloc(sizeof(struct ZipStats)); + server->localClient->zipstats = (ZipStats *)rb_malloc(sizeof(struct ZipStats)); zips = server->localClient->zipstats; @@ -520,7 +520,7 @@ ssl_process_certfp(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf) method_len = strlen(method_string); rb_free(client_p->certfp); - certfp_string = rb_malloc(method_len + len * 2 + 1); + certfp_string = (char *)rb_malloc(method_len + len * 2 + 1); rb_strlcpy(certfp_string, method_string, method_len + len * 2 + 1); for(uint32_t i = 0; i < len; i++) snprintf(certfp_string + method_len + 2 * i, 3, "%02x", @@ -542,7 +542,7 @@ ssl_process_cmd_recv(ssl_ctl_t * ctl) RB_DLINK_FOREACH_SAFE(ptr, next, ctl->readq.head) { - ctl_buf = ptr->data; + ctl_buf = (ssl_ctl_buf_t *)ptr->data; switch (*ctl_buf->buf) { case 'N': @@ -600,15 +600,15 @@ static void ssl_read_ctl(rb_fde_t * F, void *data) { ssl_ctl_buf_t *ctl_buf; - ssl_ctl_t *ctl = data; + ssl_ctl_t *ctl = (ssl_ctl_t *)data; int retlen; if(ctl->dead) return; do { - ctl_buf = rb_malloc(sizeof(ssl_ctl_buf_t)); - ctl_buf->buf = rb_malloc(READSIZE); + ctl_buf = (ssl_ctl_buf_t *)rb_malloc(sizeof(ssl_ctl_buf_t)); + ctl_buf->buf = (char *)rb_malloc(READSIZE); retlen = rb_recv_fd_buf(ctl->F, ctl_buf->buf, READSIZE, ctl_buf->F, 4); ctl_buf->buflen = retlen; if(retlen <= 0) @@ -638,7 +638,7 @@ which_ssld(void) RB_DLINK_FOREACH(ptr, ssl_daemons.head) { - ctl = ptr->data; + ctl = (ssl_ctl_t *)ptr->data; if(ctl->dead) continue; if(ctl->shutdown) @@ -657,7 +657,7 @@ which_ssld(void) static void ssl_write_ctl(rb_fde_t * F, void *data) { - ssl_ctl_t *ctl = data; + ssl_ctl_t *ctl = (ssl_ctl_t *)data; ssl_ctl_buf_t *ctl_buf; rb_dlink_node *ptr, *next; int retlen, x; @@ -667,7 +667,7 @@ ssl_write_ctl(rb_fde_t * F, void *data) RB_DLINK_FOREACH_SAFE(ptr, next, ctl->writeq.head) { - ctl_buf = ptr->data; + ctl_buf = (ssl_ctl_buf_t *)ptr->data; /* in theory unix sock_dgram shouldn't ever short write this.. */ retlen = rb_send_fd_buf(ctl->F, ctl_buf->F, ctl_buf->nfds, ctl_buf->buf, ctl_buf->buflen, ctl->pid); if(retlen > 0) @@ -701,8 +701,8 @@ ssl_cmd_write_queue(ssl_ctl_t * ctl, rb_fde_t ** F, int count, const void *buf, if(ctl->dead) return; - ctl_buf = rb_malloc(sizeof(ssl_ctl_buf_t)); - ctl_buf->buf = rb_malloc(buflen); + ctl_buf = (ssl_ctl_buf_t *)rb_malloc(sizeof(ssl_ctl_buf_t)); + ctl_buf->buf = (char *)rb_malloc(buflen); memcpy(ctl_buf->buf, buf, buflen); ctl_buf->buflen = buflen; @@ -780,7 +780,7 @@ ssld_update_config(void) RB_DLINK_FOREACH(ptr, ssl_daemons.head) { - ssl_ctl_t *ctl = ptr->data; + ssl_ctl_t *ctl = (ssl_ctl_t *)ptr->data; if (ctl->dead || ctl->shutdown) continue; @@ -888,21 +888,21 @@ start_zlib_session(void *data) return; } - buf = rb_malloc(len); + buf = (char *)rb_malloc(len); level = ConfigFileEntry.compression_level; uint32_to_buf(&buf[1], rb_get_fd(server->localClient->F)); buf[5] = (char) level; recvq_start = &buf[6]; - server->localClient->zipstats = rb_malloc(sizeof(struct ZipStats)); + server->localClient->zipstats = (ZipStats *)rb_malloc(sizeof(struct ZipStats)); xbuf = recvq_start; left = recvqlen; do { - cpylen = rb_linebuf_get(&server->localClient->buf_recvq, xbuf, left, LINEBUF_PARTIAL, LINEBUF_RAW); + cpylen = rb_linebuf_get(&server->localClient->buf_recvq, (char *)xbuf, left, LINEBUF_PARTIAL, LINEBUF_RAW); left -= cpylen; xbuf = (void *) (((uintptr_t) xbuf) + cpylen); } @@ -952,15 +952,15 @@ collect_zipstats(void *unused) RB_DLINK_FOREACH(ptr, serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(IsCapable(target_p, CAP_ZIP)) { len = sizeof(uint8_t) + sizeof(uint32_t); id = rb_get_fd(target_p->localClient->F); uint32_to_buf(&buf[1], id); - rb_strlcpy(odata, target_p->name, (sizeof(buf) - len)); - len += strlen(odata) + 1; /* Get the \0 as well */ + rb_strlcpy((char *)odata, target_p->name, (sizeof(buf) - len)); + len += strlen((const char *)odata) + 1; /* Get the \0 as well */ ssl_cmd_write_queue(target_p->localClient->z_ctl, NULL, 0, buf, len); } } @@ -973,7 +973,7 @@ cleanup_dead_ssl(void *unused) ssl_ctl_t *ctl; RB_DLINK_FOREACH_SAFE(ptr, next, ssl_daemons.head) { - ctl = ptr->data; + ctl = (ssl_ctl_t *)ptr->data; if(ctl->dead && !ctl->cli_count) { free_ssl_daemon(ctl); @@ -994,7 +994,7 @@ ssld_foreach_info(void (*func)(void *data, pid_t pid, int cli_count, enum ssld_s ssl_ctl_t *ctl; RB_DLINK_FOREACH_SAFE(ptr, next, ssl_daemons.head) { - ctl = ptr->data; + ctl = (ssl_ctl_t *)ptr->data; func(data, ctl->pid, ctl->cli_count, ctl->dead ? SSLD_DEAD : (ctl->shutdown ? SSLD_SHUTDOWN : SSLD_ACTIVE), diff --git a/ircd/substitution.c b/ircd/substitution.cc similarity index 97% rename from ircd/substitution.c rename to ircd/substitution.cc index 316ed727a..266eaded6 100644 --- a/ircd/substitution.c +++ b/ircd/substitution.cc @@ -58,7 +58,7 @@ struct substitution_variable */ void substitution_append_var(rb_dlink_list *varlist, const char *name, const char *value) { - struct substitution_variable *tmp = rb_malloc(sizeof(struct substitution_variable)); + struct substitution_variable *tmp = (substitution_variable *)rb_malloc(sizeof(struct substitution_variable)); tmp->name = rb_strdup(name); tmp->value = rb_strdup(value); diff --git a/ircd/supported.c b/ircd/supported.cc similarity index 97% rename from ircd/supported.c rename to ircd/supported.cc index 29b447253..1b6113cf0 100644 --- a/ircd/supported.c +++ b/ircd/supported.cc @@ -95,7 +95,7 @@ add_isupport(const char *name, const char *(*func)(const void *), const void *pa { struct isupportitem *item; - item = rb_malloc(sizeof(struct isupportitem)); + item = (isupportitem *)rb_malloc(sizeof(struct isupportitem)); item->name = name; item->func = func; item->param = param; @@ -111,7 +111,7 @@ change_isupport(const char *name, const char *(*func)(const void *), const void RB_DLINK_FOREACH(ptr, isupportlist.head) { - item = ptr->data; + item = (isupportitem *)ptr->data; if (!strcmp(item->name, name)) { @@ -136,7 +136,7 @@ delete_isupport(const char *name) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, isupportlist.head) { - item = ptr->data; + item = (isupportitem *)ptr->data; if (!strcmp(item->name, name)) { @@ -169,7 +169,7 @@ show_isupport(struct Client *client_p) nchars = extra_space, nparams = 0, buf[0] = '\0'; RB_DLINK_FOREACH(ptr, isupportlist.head) { - item = ptr->data; + item = (isupportitem *)ptr->data; value = (*item->func)(item->param); if (value == NULL) continue; @@ -227,7 +227,7 @@ isupport_umode(const void *ptr) { const char *str; - str = ptr; + str = (const char *)ptr; return ConfigFileEntry.oper_only_umodes & user_modes[(unsigned char)*str] ? NULL : str; } diff --git a/ircd/tgchange.c b/ircd/tgchange.cc similarity index 99% rename from ircd/tgchange.c rename to ircd/tgchange.cc index 201847174..5d65830a7 100644 --- a/ircd/tgchange.c +++ b/ircd/tgchange.cc @@ -43,7 +43,7 @@ find_allowing_channel(struct Client *source_p, struct Client *target_p) RB_DLINK_FOREACH(ptr, source_p->user->channel.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; if (is_chanop_voiced(msptr) && IsMember(target_p, msptr->chptr)) return msptr->chptr; } diff --git a/ircd/version.c b/ircd/version.cc similarity index 98% rename from ircd/version.c rename to ircd/version.cc index 14c99a115..564145fa3 100644 --- a/ircd/version.c +++ b/ircd/version.cc @@ -21,6 +21,7 @@ */ #include +#include const char *ircd_version = RB_VERSION; const char *ircd_datestr = RB_DATESTR; diff --git a/ircd/whowas.c b/ircd/whowas.cc similarity index 92% rename from ircd/whowas.c rename to ircd/whowas.cc index eec2e0e04..60f2b7cb2 100644 --- a/ircd/whowas.c +++ b/ircd/whowas.cc @@ -66,11 +66,11 @@ whowas_get_top(const char *name) { struct whowas_top *wtop; - wtop = rb_radixtree_retrieve(whowas_tree, name); + wtop = (whowas_top *)rb_radixtree_retrieve(whowas_tree, name); if (wtop != NULL) return wtop; - wtop = rb_malloc(sizeof(struct whowas_top)); + wtop = (whowas_top *)rb_malloc(sizeof(struct whowas_top)); wtop->name = rb_strdup(name); rb_radixtree_add(whowas_tree, wtop->name, wtop); @@ -81,7 +81,7 @@ rb_dlink_list * whowas_get_list(const char *name) { struct whowas_top *wtop; - wtop = rb_radixtree_retrieve(whowas_tree, name); + wtop = (whowas_top *)rb_radixtree_retrieve(whowas_tree, name); if(wtop == NULL) return NULL; return &wtop->wwlist; @@ -102,7 +102,7 @@ whowas_add_history(struct Client *client_p, int online) whowas_trim(NULL); wtop = whowas_get_top(client_p->name); - who = rb_malloc(sizeof(struct Whowas)); + who = (Whowas *)rb_malloc(sizeof(struct Whowas)); who->wtop = wtop; who->logoff = rb_current_time(); @@ -138,7 +138,7 @@ whowas_off_history(struct Client *client_p) RB_DLINK_FOREACH_SAFE(ptr, next, client_p->whowas_clist.head) { - struct Whowas *who = ptr->data; + struct Whowas *who = (Whowas *)ptr->data; who->online = NULL; rb_dlinkDelete(&who->cnode, &client_p->whowas_clist); } @@ -150,7 +150,7 @@ whowas_get_history(const char *nick, time_t timelimit) struct whowas_top *wtop; rb_dlink_node *ptr; - wtop = rb_radixtree_retrieve(whowas_tree, nick); + wtop = (whowas_top *)rb_radixtree_retrieve(whowas_tree, nick); if(wtop == NULL) return NULL; @@ -158,7 +158,7 @@ whowas_get_history(const char *nick, time_t timelimit) RB_DLINK_FOREACH_PREV(ptr, wtop->wwlist.tail) { - struct Whowas *who = ptr->data; + struct Whowas *who = (Whowas *)ptr->data; if(who->logoff >= timelimit) { return who->online; @@ -182,7 +182,7 @@ whowas_trim(void *unused) { if(whowas_list.tail != NULL && whowas_list.tail->data != NULL) { - struct Whowas *twho = whowas_list.tail->data; + struct Whowas *twho = (Whowas *)whowas_list.tail->data; if(twho->online != NULL) rb_dlinkDelete(&twho->cnode, &twho->online->whowas_clist); rb_dlinkDelete(&twho->wnode, &twho->wtop->wwlist); diff --git a/ircd/wsproc.c b/ircd/wsproc.cc similarity index 94% rename from ircd/wsproc.c rename to ircd/wsproc.cc index c6fb7f404..fd1eddca9 100644 --- a/ircd/wsproc.c +++ b/ircd/wsproc.cc @@ -86,7 +86,7 @@ allocate_ws_daemon(rb_fde_t * F, rb_fde_t * P, int pid) if(F == NULL || pid < 0) return NULL; - ctl = rb_malloc(sizeof(ws_ctl_t)); + ctl = (ws_ctl_t *)rb_malloc(sizeof(ws_ctl_t)); ctl->F = F; ctl->P = P; ctl->pid = pid; @@ -106,7 +106,7 @@ free_ws_daemon(ws_ctl_t * ctl) RB_DLINK_FOREACH(ptr, ctl->readq.head) { - ctl_buf = ptr->data; + ctl_buf = (ws_ctl_buf_t *)ptr->data; for(x = 0; x < ctl_buf->nfds; x++) rb_close(ctl_buf->F[x]); @@ -116,7 +116,7 @@ free_ws_daemon(ws_ctl_t * ctl) RB_DLINK_FOREACH(ptr, ctl->writeq.head) { - ctl_buf = ptr->data; + ctl_buf = (ws_ctl_buf_t *)ptr->data; for(x = 0; x < ctl_buf->nfds; x++) rb_close(ctl_buf->F[x]); @@ -143,7 +143,7 @@ restart_wsockd(void) RB_DLINK_FOREACH_SAFE(ptr, next, wsock_daemons.head) { - ctl = ptr->data; + ctl = (ws_ctl_t *)ptr->data; if(ctl->dead) continue; if(ctl->shutdown) @@ -203,7 +203,7 @@ static void ws_do_pipe(rb_fde_t * F, void *data) { int retlen; - ws_ctl_t *ctl = data; + ws_ctl_t *ctl = (ws_ctl_t *)data; retlen = rb_write(F, "0", 1); if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno))) { @@ -373,7 +373,7 @@ ws_process_cmd_recv(ws_ctl_t * ctl) RB_DLINK_FOREACH_SAFE(ptr, next, ctl->readq.head) { - ctl_buf = ptr->data; + ctl_buf = (ws_ctl_buf_t *)ptr->data; switch (*ctl_buf->buf) { case 'D': @@ -396,15 +396,15 @@ static void ws_read_ctl(rb_fde_t * F, void *data) { ws_ctl_buf_t *ctl_buf; - ws_ctl_t *ctl = data; + ws_ctl_t *ctl = (ws_ctl_t *)data; int retlen; if(ctl->dead) return; do { - ctl_buf = rb_malloc(sizeof(ws_ctl_buf_t)); - ctl_buf->buf = rb_malloc(READSIZE); + ctl_buf = (ws_ctl_buf_t *)rb_malloc(sizeof(ws_ctl_buf_t)); + ctl_buf->buf = (char *)rb_malloc(READSIZE); retlen = rb_recv_fd_buf(ctl->F, ctl_buf->buf, READSIZE, ctl_buf->F, 4); ctl_buf->buflen = retlen; if(retlen <= 0) @@ -434,7 +434,7 @@ which_wsockd(void) RB_DLINK_FOREACH(ptr, wsock_daemons.head) { - ctl = ptr->data; + ctl = (ws_ctl_t *)ptr->data; if(ctl->dead) continue; if(ctl->shutdown) @@ -454,7 +454,7 @@ which_wsockd(void) static void ws_write_ctl(rb_fde_t * F, void *data) { - ws_ctl_t *ctl = data; + ws_ctl_t *ctl = (ws_ctl_t *)data; ws_ctl_buf_t *ctl_buf; rb_dlink_node *ptr, *next; int retlen, x; @@ -464,7 +464,7 @@ ws_write_ctl(rb_fde_t * F, void *data) RB_DLINK_FOREACH_SAFE(ptr, next, ctl->writeq.head) { - ctl_buf = ptr->data; + ctl_buf = (ws_ctl_buf_t *)ptr->data; /* in theory unix sock_dgram shouldn't ever short write this.. */ retlen = rb_send_fd_buf(ctl->F, ctl_buf->F, ctl_buf->nfds, ctl_buf->buf, ctl_buf->buflen, ctl->pid); if(retlen > 0) @@ -498,8 +498,8 @@ ws_cmd_write_queue(ws_ctl_t * ctl, rb_fde_t ** F, int count, const void *buf, si if(ctl->dead) return; - ctl_buf = rb_malloc(sizeof(ws_ctl_buf_t)); - ctl_buf->buf = rb_malloc(buflen); + ctl_buf = (ws_ctl_buf_t *)rb_malloc(sizeof(ws_ctl_buf_t)); + ctl_buf->buf = (char *)rb_malloc(buflen); memcpy(ctl_buf->buf, buf, buflen); ctl_buf->buflen = buflen; @@ -556,7 +556,7 @@ cleanup_dead_ws(void *unused) ws_ctl_t *ctl; RB_DLINK_FOREACH_SAFE(ptr, next, wsock_daemons.head) { - ctl = ptr->data; + ctl = (ws_ctl_t *)ptr->data; if(ctl->dead && !ctl->cli_count) { free_ws_daemon(ctl); @@ -577,7 +577,7 @@ wsockd_foreach_info(void (*func)(void *data, pid_t pid, int cli_count, enum wsoc ws_ctl_t *ctl; RB_DLINK_FOREACH_SAFE(ptr, next, wsock_daemons.head) { - ctl = ptr->data; + ctl = (ws_ctl_t *)ptr->data; func(data, ctl->pid, ctl->cli_count, ctl->dead ? WSOCKD_DEAD : (ctl->shutdown ? WSOCKD_SHUTDOWN : WSOCKD_ACTIVE)); diff --git a/modules/Makefile.am b/modules/Makefile.am index dd152e4cc..49f4acce8 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -1,13 +1,86 @@ AUTOMAKE_OPTIONS = subdir-objects -AM_CPPFLAGS = -I$(top_srcdir)/include $(LTDLINCL) +AM_CPPFLAGS = $(LTDLINCL) +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -isystem $(top_srcdir)/boost/include AM_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined -shared AM_LDFLAGS += -export-symbols-regex _mheader -LIBS += $(top_srcdir)/ircd/libircd.la -LIBS += $(top_srcdir)/rb/librb.la +AM_LDFLAGS += -L$(top_srcdir)/boost/lib -lboost_system +AM_LDFLAGS += -L$(top_srcdir)/ircd -lircd +AM_LDFLAGS += -L$(top_srcdir)/rb -lrb auto_load_moddir=@moduledir@/autoload +cap_account_tag_la_SOURCES = cap_account_tag.cc +cap_server_time_la_SOURCES = cap_server_time.cc +chm_nocolour_la_SOURCES = chm_nocolour.cc +chm_noctcp_la_SOURCES = chm_noctcp.cc +m_accept_la_SOURCES = m_accept.cc +m_admin_la_SOURCES = m_admin.cc +m_alias_la_SOURCES = m_alias.cc +m_away_la_SOURCES = m_away.cc +m_cap_la_SOURCES = m_cap.cc +m_capab_la_SOURCES = m_capab.cc +m_certfp_la_SOURCES = m_certfp.cc +m_challenge_la_SOURCES = m_challenge.cc +m_chghost_la_SOURCES = m_chghost.cc +m_close_la_SOURCES = m_close.cc +m_connect_la_SOURCES = m_connect.cc +m_dline_la_SOURCES = m_dline.cc +m_encap_la_SOURCES = m_encap.cc +m_etrace_la_SOURCES = m_etrace.cc +m_grant_la_SOURCES = m_grant.cc +m_help_la_SOURCES = m_help.cc +m_info_la_SOURCES = m_info.cc +m_invite_la_SOURCES = m_invite.cc +m_ison_la_SOURCES = m_ison.cc +m_kline_la_SOURCES = m_kline.cc +m_knock_la_SOURCES = m_knock.cc +m_links_la_SOURCES = m_links.cc +m_list_la_SOURCES = m_list.cc +m_lusers_la_SOURCES = m_lusers.cc +m_map_la_SOURCES = m_map.cc +m_monitor_la_SOURCES = m_monitor.cc +m_motd_la_SOURCES = m_motd.cc +m_names_la_SOURCES = m_names.cc +m_oper_la_SOURCES = m_oper.cc +m_operspy_la_SOURCES = m_operspy.cc +m_pass_la_SOURCES = m_pass.cc +m_ping_la_SOURCES = m_ping.cc +m_pong_la_SOURCES = m_pong.cc +m_post_la_SOURCES = m_post.cc +m_privs_la_SOURCES = m_privs.cc +m_rehash_la_SOURCES = m_rehash.cc +m_restart_la_SOURCES = m_restart.cc +m_resv_la_SOURCES = m_resv.cc +m_sasl_la_SOURCES = m_sasl.cc +m_scan_la_SOURCES = m_scan.cc +m_services_la_SOURCES = m_services.cc +m_set_la_SOURCES = m_set.cc +m_signon_la_SOURCES = m_signon.cc +m_snote_la_SOURCES = m_snote.cc +m_starttls_la_SOURCES = m_starttls.cc +m_stats_la_SOURCES = m_stats.cc +m_svinfo_la_SOURCES = m_svinfo.cc +m_tb_la_SOURCES = m_tb.cc +m_testline_la_SOURCES = m_testline.cc +m_testmask_la_SOURCES = m_testmask.cc +m_tginfo_la_SOURCES = m_tginfo.cc +m_time_la_SOURCES = m_time.cc +m_topic_la_SOURCES = m_topic.cc +m_trace_la_SOURCES = m_trace.cc +m_unreject_la_SOURCES = m_unreject.cc +m_user_la_SOURCES = m_user.cc +m_userhost_la_SOURCES = m_userhost.cc +m_users_la_SOURCES = m_users.cc +m_version_la_SOURCES = m_version.cc +m_wallops_la_SOURCES = m_wallops.cc +m_who_la_SOURCES = m_who.cc +m_whois_la_SOURCES = m_whois.cc +m_whowas_la_SOURCES = m_whowas.cc +m_xline_la_SOURCES = m_xline.cc +sno_routing_la_SOURCES = sno_routing.cc + auto_load_mod_LTLIBRARIES = \ cap_account_tag.la \ cap_server_time.la \ @@ -79,6 +152,23 @@ auto_load_mod_LTLIBRARIES = \ m_xline.la \ sno_routing.la + +core_m_ban_la_SOURCES = core/m_ban.cc +core_m_die_la_SOURCES = core/m_die.cc +core_m_error_la_SOURCES = core/m_error.cc +core_m_join_la_SOURCES = core/m_join.cc +core_m_kick_la_SOURCES = core/m_kick.cc +core_m_kill_la_SOURCES = core/m_kill.cc +core_m_message_la_SOURCES = core/m_message.cc +core_m_mode_la_SOURCES = core/m_mode.cc +core_m_modules_la_SOURCES = core/m_modules.cc +core_m_nick_la_SOURCES = core/m_nick.cc +core_m_part_la_SOURCES = core/m_part.cc +core_m_quit_la_SOURCES = core/m_quit.cc +core_m_server_la_SOURCES = core/m_server.cc +core_m_squit_la_SOURCES = core/m_squit.cc + + module_LTLIBRARIES = \ core/m_ban.la \ core/m_die.la \ diff --git a/modules/cap_account_tag.c b/modules/cap_account_tag.cc similarity index 97% rename from modules/cap_account_tag.c rename to modules/cap_account_tag.cc index 718ac69db..612b0fdd1 100644 --- a/modules/cap_account_tag.c +++ b/modules/cap_account_tag.cc @@ -51,7 +51,7 @@ mapi_cap_list_av2 cap_account_tag_cap_list[] = { static void cap_account_tag_process(hook_data *data) { - struct MsgBuf *msgbuf = data->arg1; + struct MsgBuf *msgbuf = (MsgBuf *)data->arg1; if (data->client != NULL && IsPerson(data->client) && *data->client->user->suser) msgbuf_append_tag(msgbuf, "account", data->client->user->suser, CLICAP_ACCOUNT_TAG); diff --git a/modules/cap_server_time.c b/modules/cap_server_time.cc similarity index 97% rename from modules/cap_server_time.c rename to modules/cap_server_time.cc index 42085c980..f9b71aa57 100644 --- a/modules/cap_server_time.c +++ b/modules/cap_server_time.cc @@ -54,7 +54,7 @@ cap_server_time_process(hook_data *data) { static char buf[BUFSIZE]; time_t ts = rb_current_time(); - struct MsgBuf *msgbuf = data->arg1; + struct MsgBuf *msgbuf = (MsgBuf *)data->arg1; strftime(buf, sizeof buf, "%Y-%m-%dT%H:%M:%S.000Z", gmtime(&ts)); diff --git a/modules/chm_nocolour.c b/modules/chm_nocolour.cc similarity index 100% rename from modules/chm_nocolour.c rename to modules/chm_nocolour.cc diff --git a/modules/chm_noctcp.c b/modules/chm_noctcp.cc similarity index 100% rename from modules/chm_noctcp.c rename to modules/chm_noctcp.cc diff --git a/modules/core/m_ban.c b/modules/core/m_ban.cc similarity index 98% rename from modules/core/m_ban.c rename to modules/core/m_ban.cc index 1a76395dc..4def1819b 100644 --- a/modules/core/m_ban.c +++ b/modules/core/m_ban.cc @@ -131,7 +131,7 @@ ms_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p if (ptr != NULL) { /* We already know about this ban mask. */ - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if (aconf->created > created || (aconf->created == created && aconf->lifetime >= lifetime)) @@ -186,7 +186,7 @@ ms_ban(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p aconf->info.oper = operhash_add(oper); aconf->created = created; aconf->hold = hold; - if (ntype != CONF_KILL || (p = strchr(parv[parc - 1], '|')) == NULL) + if (ntype != CONF_KILL || (p = (char *)strchr(parv[parc - 1], '|')) == NULL) aconf->passwd = rb_strdup(parv[parc - 1]); else { diff --git a/modules/core/m_die.c b/modules/core/m_die.cc similarity index 100% rename from modules/core/m_die.c rename to modules/core/m_die.cc diff --git a/modules/core/m_error.c b/modules/core/m_error.cc similarity index 100% rename from modules/core/m_error.c rename to modules/core/m_error.cc diff --git a/modules/core/m_join.c b/modules/core/m_join.cc similarity index 99% rename from modules/core/m_join.c rename to modules/core/m_join.cc index bbaa901eb..10f07b139 100644 --- a/modules/core/m_join.c +++ b/modules/core/m_join.cc @@ -466,7 +466,7 @@ ms_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ remove_our_modes(chptr, source_p); RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->invites.head) { - del_invite(chptr, ptr->data); + del_invite(chptr, (Client *)ptr->data); } /* If setting -j, clear join throttle state -- jilles */ chptr->join_count = chptr->join_delta = 0; @@ -651,7 +651,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; who = msptr->client_p; sendto_one(who, ":%s KICK %s %s :Net Rider", me.name, chptr->chname, who->name); @@ -714,7 +714,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source remove_our_modes(chptr, fakesource_p); RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->invites.head) { - del_invite(chptr, ptr->data); + del_invite(chptr, (Client *)ptr->data); } if(rb_dlink_list_length(&chptr->banlist) > 0) @@ -766,7 +766,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source * first space to \0, so s is just the first nick, and point p to the * second nick */ - if((p = strchr(s, ' ')) != NULL) + if((p = (char *)strchr(s, ' ')) != NULL) { *p++ = '\0'; } @@ -900,7 +900,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source * we cant check it for spaces.. if there are no spaces, then when * we next get here, s will be NULL */ - if(s && ((p = strchr(s, ' ')) != NULL)) + if(s && ((p = (char *)strchr(s, ' ')) != NULL)) { *p++ = '\0'; } @@ -959,7 +959,7 @@ do_join_0(struct Client *client_p, struct Client *source_p) !IsOper(source_p) && !IsExemptSpambot(source_p)) check_spambot_warning(source_p, NULL); - msptr = ptr->data; + msptr = (membership *)ptr->data; chptr = msptr->chptr; sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s", source_p->name, @@ -1185,7 +1185,7 @@ remove_our_modes(struct Channel *chptr, struct Client *source_p) RB_DLINK_FOREACH(ptr, chptr->members.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; if(is_chanop(msptr)) { @@ -1284,7 +1284,7 @@ remove_ban_list(struct Channel *chptr, struct Client *source_p, RB_DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) { - banptr = ptr->data; + banptr = (Ban *)ptr->data; /* trailing space, and the mode letter itself */ plen = strlen(banptr->banstr) + diff --git a/modules/core/m_kick.c b/modules/core/m_kick.cc similarity index 98% rename from modules/core/m_kick.c rename to modules/core/m_kick.cc index 7284388eb..7468cf872 100644 --- a/modules/core/m_kick.c +++ b/modules/core/m_kick.cc @@ -74,7 +74,7 @@ m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p flood_endgrace(source_p); *buf = '\0'; - if((p = strchr(parv[1], ','))) + if((p = (char *)strchr(parv[1], ','))) *p = '\0'; name = parv[1]; @@ -117,7 +117,7 @@ m_kick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p } - if((p = strchr(parv[2], ','))) + if((p = (char *)strchr(parv[2], ','))) *p = '\0'; user = parv[2]; /* strtoken(&p2, parv[2], ","); */ diff --git a/modules/core/m_kill.c b/modules/core/m_kill.cc similarity index 99% rename from modules/core/m_kill.c rename to modules/core/m_kill.cc index 1ec664532..14ed61753 100644 --- a/modules/core/m_kill.c +++ b/modules/core/m_kill.cc @@ -304,7 +304,7 @@ relay_kill(struct Client *one, struct Client *source_p, RB_DLINK_FOREACH(ptr, serv_list.head) { - client_p = ptr->data; + client_p = (Client *)ptr->data; if(!client_p || client_p == one) continue; diff --git a/modules/core/m_message.c b/modules/core/m_message.cc similarity index 99% rename from modules/core/m_message.c rename to modules/core/m_message.cc index cb6190436..0258b1e35 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.cc @@ -146,9 +146,11 @@ static void handle_special(enum message_type msgtype, ** -db Nov 13, 2000 ** */ -const char *cmdname[MESSAGE_TYPE_COUNT] = { - [MESSAGE_TYPE_PRIVMSG] = "PRIVMSG", - [MESSAGE_TYPE_NOTICE] = "NOTICE", +const char *cmdname[MESSAGE_TYPE_COUNT] +{ + "NOTICE", + "PRIVMSG", + nullptr, }; static void @@ -699,7 +701,7 @@ expire_tgchange(void *unused) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, tgchange_list.head) { - target = ptr->data; + target = (tgchange *)ptr->data; if(target->expiry < rb_current_time()) { @@ -974,7 +976,7 @@ handle_special(enum message_type msgtype, struct Client *client_p, * NOTE: users can send to user@server, but not user%host@server * or opers@server */ - if((server = strchr(nick, '@')) != NULL) + if((server = (char *)strchr(nick, '@')) != NULL) { if((target_p = find_server(source_p, server + 1)) == NULL) { @@ -1045,7 +1047,7 @@ handle_special(enum message_type msgtype, struct Client *client_p, return; } - if((s = strrchr(nick, '.')) == NULL) + if((s = (char *)strrchr(nick, '.')) == NULL) { sendto_one_numeric(source_p, ERR_NOTOPLEVEL, form_str(ERR_NOTOPLEVEL), nick); diff --git a/modules/core/m_mode.c b/modules/core/m_mode.cc similarity index 99% rename from modules/core/m_mode.c rename to modules/core/m_mode.cc index 7dd708d50..06a3e94f3 100644 --- a/modules/core/m_mode.c +++ b/modules/core/m_mode.cc @@ -243,7 +243,7 @@ possibly_remove_lower_forward(struct Client *fakesource_p, int mems, RB_DLINK_FOREACH(ptr, banlist->head) { - actualBan = ptr->data; + actualBan = (Ban *)ptr->data; if(!irccmp(actualBan->banstr, mask) && (actualBan->forward == NULL || irccmp(actualBan->forward, forward) < 0)) diff --git a/modules/core/m_modules.c b/modules/core/m_modules.cc similarity index 99% rename from modules/core/m_modules.c rename to modules/core/m_modules.cc index f28f0b756..10370cba3 100644 --- a/modules/core/m_modules.c +++ b/modules/core/m_modules.cc @@ -335,7 +335,7 @@ do_modrestart(struct Client *source_p) RB_DLINK_FOREACH_SAFE(ptr, nptr, module_list.head) { - struct module *mod = ptr->data; + struct module *mod = (module *)ptr->data; if(!unload_one_module(mod->name, false)) { ilog(L_MAIN, "Module Restart: %s was not unloaded %s", @@ -370,7 +370,7 @@ do_modlist(struct Client *source_p, const char *pattern) RB_DLINK_FOREACH(ptr, module_list.head) { - struct module *mod = ptr->data; + struct module *mod = (module *)ptr->data; bool display = false; const char *origin; diff --git a/modules/core/m_nick.c b/modules/core/m_nick.cc similarity index 99% rename from modules/core/m_nick.c rename to modules/core/m_nick.cc index 481300ddd..e2a15b509 100644 --- a/modules/core/m_nick.c +++ b/modules/core/m_nick.cc @@ -695,7 +695,7 @@ change_local_nick(struct Client *client_p, struct Client *source_p, */ RB_DLINK_FOREACH_SAFE(ptr, next_ptr, source_p->on_allow_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; rb_dlinkFindDestroy(source_p, &target_p->localClient->allow_list); rb_dlinkDestroy(ptr, &source_p->on_allow_list); @@ -740,7 +740,7 @@ change_remote_nick(struct Client *client_p, struct Client *source_p, del_from_client_hash(source_p->name, source_p); /* invalidate nick delay when a remote client uses the nick.. */ - if((nd = rb_dictionary_retrieve(nd_dict, nick))) + if((nd = (nd_entry *)rb_dictionary_retrieve(nd_dict, nick))) free_nd_entry(nd); rb_strlcpy(source_p->name, nick, sizeof(source_p->name)); @@ -1056,7 +1056,7 @@ register_client(struct Client *client_p, struct Client *server, } /* remove any nd entries for this nick */ - if((nd = rb_dictionary_retrieve(nd_dict, nick))) + if((nd = (nd_entry *)rb_dictionary_retrieve(nd_dict, nick))) free_nd_entry(nd); add_to_client_hash(nick, source_p); diff --git a/modules/core/m_part.c b/modules/core/m_part.cc similarity index 100% rename from modules/core/m_part.c rename to modules/core/m_part.cc diff --git a/modules/core/m_quit.c b/modules/core/m_quit.cc similarity index 100% rename from modules/core/m_quit.c rename to modules/core/m_quit.cc diff --git a/modules/core/m_server.c b/modules/core/m_server.cc similarity index 99% rename from modules/core/m_server.c rename to modules/core/m_server.cc index 3629acd40..15bebb433 100644 --- a/modules/core/m_server.c +++ b/modules/core/m_server.cc @@ -395,7 +395,7 @@ ms_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc */ RB_DLINK_FOREACH(ptr, hubleaf_conf_list.head) { - hub_p = ptr->data; + hub_p = (remote_conf *)ptr->data; if(match(hub_p->server, client_p->name) && match(hub_p->host, name)) { @@ -587,7 +587,7 @@ ms_sid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p */ RB_DLINK_FOREACH(ptr, hubleaf_conf_list.head) { - hub_p = ptr->data; + hub_p = (remote_conf *)ptr->data; if(match(hub_p->server, client_p->name) && match(hub_p->host, parv[1])) { diff --git a/modules/core/m_squit.c b/modules/core/m_squit.cc similarity index 99% rename from modules/core/m_squit.c rename to modules/core/m_squit.cc index 7c691fa70..21463e6c1 100644 --- a/modules/core/m_squit.c +++ b/modules/core/m_squit.cc @@ -177,7 +177,7 @@ find_squit(struct Client *client_p, struct Client *source_p, const char *server) RB_DLINK_FOREACH(ptr, global_serv_list.head) { - p = ptr->data; + p = (Client *)ptr->data; if(IsServer(p) || IsMe(p)) { if(match(server, p->name)) diff --git a/modules/m_accept.c b/modules/m_accept.cc similarity index 99% rename from modules/m_accept.c rename to modules/m_accept.cc index c626db491..c660039b8 100644 --- a/modules/m_accept.c +++ b/modules/m_accept.cc @@ -231,7 +231,7 @@ list_accepts(struct Client *source_p) RB_DLINK_FOREACH(ptr, source_p->localClient->allow_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(target_p) { diff --git a/modules/m_admin.c b/modules/m_admin.cc similarity index 100% rename from modules/m_admin.c rename to modules/m_admin.cc diff --git a/modules/m_alias.c b/modules/m_alias.cc similarity index 92% rename from modules/m_alias.c rename to modules/m_alias.cc index 0b26ffe7d..da6c3652b 100644 --- a/modules/m_alias.c +++ b/modules/m_alias.cc @@ -54,14 +54,15 @@ static inline void create_aliases(void) { rb_dictionary_iter iter; - struct alias_entry *alias; s_assert(rb_dlink_list_length(&alias_messages) == 0); - RB_DICTIONARY_FOREACH(alias, &iter, alias_dict) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, alias_dict) { - struct Message *message = rb_malloc(sizeof(*message) + strlen(alias->name) + 1); - char *cmd = (void*)message + sizeof(*message); + const auto alias(reinterpret_cast(elem)); + struct Message *message = (Message *)rb_malloc(sizeof(*message) + strlen(alias->name) + 1); + char *cmd = (char*)message + sizeof(*message); /* copy the alias name as it will be freed early on a rehash */ strcpy(cmd, alias->name); @@ -112,7 +113,7 @@ static void m_alias(struct MsgBuf *msgbuf, struct Client *client_p, struct Client *source_p, int parc, const char **parv) { struct Client *target_p; - struct alias_entry *aptr = rb_dictionary_retrieve(alias_dict, msgbuf->cmd); + struct alias_entry *aptr = (alias_entry *)rb_dictionary_retrieve(alias_dict, msgbuf->cmd); char *p, *str; if(aptr == NULL) diff --git a/modules/m_away.c b/modules/m_away.cc similarity index 100% rename from modules/m_away.c rename to modules/m_away.cc diff --git a/modules/m_cap.c b/modules/m_cap.cc similarity index 96% rename from modules/m_cap.c rename to modules/m_cap.cc index bb35d129a..9b7a821bc 100644 --- a/modules/m_cap.c +++ b/modules/m_cap.cc @@ -74,7 +74,7 @@ clicap_visible(struct Client *client_p, const struct CapabilityEntry *cap) if (cap->ownerdata == NULL) return 1; - clicap = cap->ownerdata; + clicap = (ClientCapability *)cap->ownerdata; if (clicap->visible == NULL) return 1; @@ -156,7 +156,6 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags) char capbuf[BUFSIZE] = { 0 }; int buflen = 0; int mlen; - struct CapabilityEntry *entry; rb_dictionary_iter iter; mlen = snprintf(buf, sizeof buf, ":%s CAP %s %s", @@ -171,10 +170,12 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags) return; } - RB_DICTIONARY_FOREACH(entry, &iter, cli_capindex->cap_dict) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, cli_capindex->cap_dict) { size_t caplen = 0; - struct ClientCapability *clicap = entry->ownerdata; + const auto entry(reinterpret_cast(elem)); + const auto clicap(reinterpret_cast(entry->ownerdata)); const char *data = NULL; if(flags && !IsCapableEntry(source_p, entry)) @@ -405,7 +406,7 @@ m_cap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, { struct clicap_cmd *cmd; - if(!(cmd = bsearch(parv[1], clicap_cmdlist, + if(!(cmd = (clicap_cmd *)bsearch(parv[1], clicap_cmdlist, sizeof(clicap_cmdlist) / sizeof(struct clicap_cmd), sizeof(struct clicap_cmd), (bqcmp) clicap_cmd_search))) { diff --git a/modules/m_capab.c b/modules/m_capab.cc similarity index 100% rename from modules/m_capab.c rename to modules/m_capab.cc diff --git a/modules/m_certfp.c b/modules/m_certfp.cc similarity index 100% rename from modules/m_certfp.c rename to modules/m_certfp.cc diff --git a/modules/m_challenge.c b/modules/m_challenge.cc similarity index 99% rename from modules/m_challenge.c rename to modules/m_challenge.cc index edcb2592e..c3d043f9e 100644 --- a/modules/m_challenge.c +++ b/modules/m_challenge.cc @@ -296,11 +296,11 @@ generate_challenge(char **r_challenge, char **r_response, RSA * rsa) { SHA1_Init(&ctx); SHA1_Update(&ctx, (uint8_t *)secret, CHALLENGE_SECRET_LENGTH); - *r_response = malloc(SHA_DIGEST_LENGTH); + *r_response = (char *)malloc(SHA_DIGEST_LENGTH); SHA1_Final((uint8_t *)*r_response, &ctx); length = RSA_size(rsa); - tmp = rb_malloc(length); + tmp = (unsigned char *)rb_malloc(length); ret = RSA_public_encrypt(CHALLENGE_SECRET_LENGTH, secret, tmp, rsa, RSA_PKCS1_OAEP_PADDING); if(ret >= 0) diff --git a/modules/m_chghost.c b/modules/m_chghost.cc similarity index 100% rename from modules/m_chghost.c rename to modules/m_chghost.cc diff --git a/modules/m_close.c b/modules/m_close.cc similarity index 98% rename from modules/m_close.c rename to modules/m_close.cc index 262b649e2..7aee1a34d 100644 --- a/modules/m_close.c +++ b/modules/m_close.cc @@ -58,7 +58,7 @@ mo_close(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source RB_DLINK_FOREACH_SAFE(ptr, ptr_next, unknown_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; sendto_one(source_p, form_str(RPL_CLOSING), me.name, source_p->name, get_client_name(target_p, SHOW_IP), target_p->status); diff --git a/modules/m_connect.c b/modules/m_connect.cc similarity index 100% rename from modules/m_connect.c rename to modules/m_connect.cc diff --git a/modules/m_dline.c b/modules/m_dline.cc similarity index 100% rename from modules/m_dline.c rename to modules/m_dline.cc diff --git a/modules/m_encap.c b/modules/m_encap.cc similarity index 100% rename from modules/m_encap.c rename to modules/m_encap.cc diff --git a/modules/m_etrace.c b/modules/m_etrace.cc similarity index 98% rename from modules/m_etrace.c rename to modules/m_etrace.cc index a22466aed..39b97b24f 100644 --- a/modules/m_etrace.c +++ b/modules/m_etrace.cc @@ -161,7 +161,7 @@ do_etrace(struct Client *source_p, int ipv4, int ipv6) /* report all direct connections */ RB_DLINK_FOREACH(ptr, lclient_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; #ifdef RB_IPV6 if((!ipv4 && GET_SS_FAMILY(&target_p->localClient->ip) == AF_INET) || @@ -188,7 +188,7 @@ do_etrace_full(struct Client *source_p) RB_DLINK_FOREACH(ptr, lclient_list.head) { - do_single_etrace(source_p, ptr->data); + do_single_etrace(source_p, (Client *)ptr->data); } sendto_one_numeric(source_p, RPL_ENDOFTRACE, form_str(RPL_ENDOFTRACE), me.name); @@ -270,7 +270,7 @@ m_chantrace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou RB_DLINK_FOREACH(ptr, chptr->members.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; target_p = msptr->client_p; if(EmptyString(target_p->sockhost)) @@ -303,7 +303,7 @@ match_masktrace(struct Client *source_p, rb_dlink_list *list, RB_DLINK_FOREACH(ptr, list->head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(!IsPerson(target_p)) continue; diff --git a/modules/m_grant.c b/modules/m_grant.cc similarity index 100% rename from modules/m_grant.c rename to modules/m_grant.cc diff --git a/modules/m_help.c b/modules/m_help.cc similarity index 95% rename from modules/m_help.c rename to modules/m_help.cc index 411ec2898..faa97fb04 100644 --- a/modules/m_help.c +++ b/modules/m_help.cc @@ -96,7 +96,7 @@ dohelp(struct Client *source_p, int flags, const char *topic) if(EmptyString(topic)) topic = ntopic; - hptr = rb_dictionary_retrieve(flags & HELP_OPER ? help_dict_oper : help_dict_user, topic); + hptr = (cachefile *)rb_dictionary_retrieve(flags & HELP_OPER ? help_dict_oper : help_dict_user, topic); if(hptr == NULL || !(hptr->flags & flags)) { @@ -106,7 +106,7 @@ dohelp(struct Client *source_p, int flags, const char *topic) } fptr = hptr->contents.head; - lineptr = fptr->data; + lineptr = (cacheline *)fptr->data; /* first line cant be empty */ sendto_one(source_p, form_str(RPL_HELPSTART), @@ -114,7 +114,7 @@ dohelp(struct Client *source_p, int flags, const char *topic) RB_DLINK_FOREACH(ptr, fptr->next) { - lineptr = ptr->data; + lineptr = (cacheline *)ptr->data; sendto_one(source_p, form_str(RPL_HELPTXT), me.name, source_p->name, topic, lineptr->data); diff --git a/modules/m_info.c b/modules/m_info.cc similarity index 100% rename from modules/m_info.c rename to modules/m_info.cc diff --git a/modules/m_invite.c b/modules/m_invite.cc similarity index 99% rename from modules/m_invite.c rename to modules/m_invite.cc index 5addcfd77..e6f2f646d 100644 --- a/modules/m_invite.c +++ b/modules/m_invite.cc @@ -261,7 +261,7 @@ add_invite(struct Channel *chptr, struct Client *who) ConfigChannel.max_chans_per_user) { ptr = who->user->invited.tail; - del_invite(ptr->data, who); + del_invite((Channel *)ptr->data, who); } /* add user to channel invite list */ diff --git a/modules/m_ison.c b/modules/m_ison.cc similarity index 100% rename from modules/m_ison.c rename to modules/m_ison.cc diff --git a/modules/m_kline.c b/modules/m_kline.cc similarity index 99% rename from modules/m_kline.c rename to modules/m_kline.cc index 0301236ac..d8b877990 100644 --- a/modules/m_kline.c +++ b/modules/m_kline.cc @@ -631,7 +631,7 @@ find_user_host(struct Client *source_p, const char *userhost, char *luser, char { char *hostp; - hostp = strchr(userhost, '@'); + hostp = (char *)strchr(userhost, '@'); if(hostp != NULL) /* I'm a little user@host */ { diff --git a/modules/m_knock.c b/modules/m_knock.cc similarity index 100% rename from modules/m_knock.c rename to modules/m_knock.cc diff --git a/modules/m_links.c b/modules/m_links.cc similarity index 99% rename from modules/m_links.c rename to modules/m_links.cc index 28722536a..fe94ba008 100644 --- a/modules/m_links.c +++ b/modules/m_links.cc @@ -110,7 +110,7 @@ mo_links(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source RB_DLINK_FOREACH(ptr, global_serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(*mask && !match(mask, target_p->name)) continue; diff --git a/modules/m_list.c b/modules/m_list.cc similarity index 98% rename from modules/m_list.c rename to modules/m_list.cc index 7726af212..2a453644f 100644 --- a/modules/m_list.c +++ b/modules/m_list.cc @@ -196,7 +196,7 @@ mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ } /* Multiple channels, possibly with parameters. */ - params = rb_malloc(sizeof(struct ListClient)); + params = (ListClient *)rb_malloc(sizeof(struct ListClient)); params->users_min = ConfigChannel.displayed_usercount; params->users_max = INT_MAX; @@ -396,7 +396,7 @@ static void safelist_channel_named(struct Client *source_p, const char *name, in sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name); - if ((p = strchr(name, ','))) + if ((p = (char *)strchr(name, ','))) *p = '\0'; if (*name == '\0') @@ -469,11 +469,12 @@ static void safelist_one_channel(struct Client *source_p, struct Channel *chptr, */ static void safelist_iterate_client(struct Client *source_p) { - struct Channel *chptr; rb_radixtree_iteration_state iter; - RB_RADIXTREE_FOREACH_FROM(chptr, &iter, channel_tree, source_p->localClient->safelist_data->chname) + void *elem; + RB_RADIXTREE_FOREACH_FROM(elem, &iter, channel_tree, source_p->localClient->safelist_data->chname) { + const auto chptr(reinterpret_cast(elem)); if (safelist_sendq_exceeded(source_p->from)) { rb_free(source_p->localClient->safelist_data->chname); diff --git a/modules/m_lusers.c b/modules/m_lusers.cc similarity index 100% rename from modules/m_lusers.c rename to modules/m_lusers.cc diff --git a/modules/m_map.c b/modules/m_map.cc similarity index 98% rename from modules/m_map.c rename to modules/m_map.cc index afdfe12a8..b0e8ce7b7 100644 --- a/modules/m_map.c +++ b/modules/m_map.cc @@ -131,7 +131,7 @@ dump_map(struct Client *client_p, struct Client *root_p, char *pbuf) i = 1; RB_DLINK_FOREACH(ptr, root_p->serv->servers.head) { - server_p = ptr->data; + server_p = (Client *)ptr->data; *pbuf = ' '; if(i < cnt) *(pbuf + 1) = '|'; @@ -181,7 +181,7 @@ flattened_map(struct Client *client_p) /* Next, we run through every other server and list them */ RB_DLINK_FOREACH(ptr, global_serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; cnt++; diff --git a/modules/m_monitor.c b/modules/m_monitor.cc similarity index 99% rename from modules/m_monitor.c rename to modules/m_monitor.cc index 1a96c02c3..db417ddaa 100644 --- a/modules/m_monitor.c +++ b/modules/m_monitor.cc @@ -227,7 +227,7 @@ list_monitor(struct Client *client_p) RB_DLINK_FOREACH(ptr, client_p->localClient->monitor_list.head) { - monptr = ptr->data; + monptr = (monitor *)ptr->data; if(cur_len + strlen(monptr->name) + 1 >= BUFSIZE-3) { @@ -273,7 +273,7 @@ show_monitor_status(struct Client *client_p) RB_DLINK_FOREACH(ptr, client_p->localClient->monitor_list.head) { - monptr = ptr->data; + monptr = (monitor *)ptr->data; if((target_p = find_named_person(monptr->name)) != NULL) { diff --git a/modules/m_motd.c b/modules/m_motd.cc similarity index 100% rename from modules/m_motd.c rename to modules/m_motd.cc diff --git a/modules/m_names.c b/modules/m_names.cc similarity index 97% rename from modules/m_names.c rename to modules/m_names.cc index 81c3a7c69..8d539e929 100644 --- a/modules/m_names.c +++ b/modules/m_names.cc @@ -132,7 +132,7 @@ names_global(struct Client *source_p) /* first do all visible channels */ RB_DLINK_FOREACH(ptr, global_channel_list.head) { - chptr = ptr->data; + chptr = (Channel *)ptr->data; channel_member_names(chptr, source_p, 0); } cur_len = mlen = sprintf(buf, form_str(RPL_NAMREPLY), @@ -142,7 +142,7 @@ names_global(struct Client *source_p) /* Second, do all clients in one big sweep */ RB_DLINK_FOREACH(ptr, global_client_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; dont_show = false; if(!IsPerson(target_p) || IsInvisible(target_p)) @@ -157,7 +157,7 @@ names_global(struct Client *source_p) */ RB_DLINK_FOREACH(lp, target_p->user->channel.head) { - msptr = lp->data; + msptr = (membership *)lp->data; chptr = msptr->chptr; if(PubChannel(chptr) || IsMember(source_p, chptr) || diff --git a/modules/m_oper.c b/modules/m_oper.cc similarity index 100% rename from modules/m_oper.c rename to modules/m_oper.cc diff --git a/modules/m_operspy.c b/modules/m_operspy.cc similarity index 100% rename from modules/m_operspy.c rename to modules/m_operspy.cc diff --git a/modules/m_pass.c b/modules/m_pass.cc similarity index 100% rename from modules/m_pass.c rename to modules/m_pass.cc diff --git a/modules/m_ping.c b/modules/m_ping.cc similarity index 100% rename from modules/m_ping.c rename to modules/m_ping.cc diff --git a/modules/m_pong.c b/modules/m_pong.cc similarity index 100% rename from modules/m_pong.c rename to modules/m_pong.cc diff --git a/modules/m_post.c b/modules/m_post.cc similarity index 100% rename from modules/m_post.c rename to modules/m_post.cc diff --git a/modules/m_privs.c b/modules/m_privs.cc similarity index 100% rename from modules/m_privs.c rename to modules/m_privs.cc diff --git a/modules/m_rehash.c b/modules/m_rehash.cc similarity index 97% rename from modules/m_rehash.c rename to modules/m_rehash.cc index 375b971ec..93ed778fe 100644 --- a/modules/m_rehash.c +++ b/modules/m_rehash.cc @@ -135,7 +135,7 @@ rehash_tklines(struct Client *source_p) { RB_DLINK_FOREACH_SAFE(ptr, next_ptr, temp_klines[i].head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; delete_one_address_conf(aconf->host, aconf); rb_dlinkDestroy(ptr, &temp_klines[i]); @@ -159,7 +159,7 @@ rehash_tdlines(struct Client *source_p) { RB_DLINK_FOREACH_SAFE(ptr, next_ptr, temp_dlines[i].head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; delete_one_address_conf(aconf->host, aconf); rb_dlinkDestroy(ptr, &temp_dlines[i]); @@ -181,7 +181,7 @@ rehash_txlines(struct Client *source_p) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, xline_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(!aconf->hold || aconf->lifetime) continue; @@ -204,8 +204,10 @@ rehash_tresvs(struct Client *source_p) if (!MyConnect(source_p)) remote_rehash_oper_p = source_p; - RB_RADIXTREE_FOREACH(aconf, &iter, resv_tree) + void *elem; + RB_RADIXTREE_FOREACH(elem, &iter, resv_tree) { + const auto aconf(reinterpret_cast(elem)); if(!aconf->hold || aconf->lifetime) continue; @@ -215,7 +217,7 @@ rehash_tresvs(struct Client *source_p) RB_DLINK_FOREACH_SAFE(ptr, next_ptr, resv_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(!aconf->hold || aconf->lifetime) continue; @@ -273,7 +275,7 @@ rehash_nickdelay(struct Client *source_p) RB_DLINK_FOREACH_SAFE(ptr, safe_ptr, nd_list.head) { - nd = ptr->data; + nd = (nd_entry *)ptr->data; free_nd_entry(nd); } diff --git a/modules/m_restart.c b/modules/m_restart.cc similarity index 98% rename from modules/m_restart.c rename to modules/m_restart.cc index 613ea9161..894e1c040 100644 --- a/modules/m_restart.c +++ b/modules/m_restart.cc @@ -119,14 +119,14 @@ do_restart(struct Client *source_p, const char *servername) RB_DLINK_FOREACH(ptr, lclient_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; sendto_one_notice(target_p, ":Server Restarting. %s", get_client_name(source_p, HIDE_IP)); } RB_DLINK_FOREACH(ptr, serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; sendto_one(target_p, ":%s ERROR :Restart by %s", me.name, get_client_name(source_p, HIDE_IP)); diff --git a/modules/m_resv.c b/modules/m_resv.cc similarity index 99% rename from modules/m_resv.c rename to modules/m_resv.cc index 1d89f4b3e..0d381e9f2 100644 --- a/modules/m_resv.c +++ b/modules/m_resv.cc @@ -388,7 +388,7 @@ cluster_resv(struct Client *source_p, int temp_time, const char *name, const cha RB_DLINK_FOREACH(ptr, cluster_conf_list.head) { - shared_p = ptr->data; + shared_p = (remote_conf *)ptr->data; /* old protocol cant handle temps, and we dont really want * to convert them to perm.. --fl @@ -573,7 +573,7 @@ remove_resv(struct Client *source_p, const char *name, int propagated) { RB_DLINK_FOREACH(ptr, resv_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(irccmp(aconf->host, name)) aconf = NULL; diff --git a/modules/m_sasl.c b/modules/m_sasl.cc similarity index 100% rename from modules/m_sasl.c rename to modules/m_sasl.cc diff --git a/modules/m_scan.c b/modules/m_scan.cc similarity index 99% rename from modules/m_scan.c rename to modules/m_scan.cc index 5770a75c6..07fc9140f 100644 --- a/modules/m_scan.c +++ b/modules/m_scan.cc @@ -213,7 +213,7 @@ scan_umodes(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou unsigned int working_umodes = 0; char maskbuf[BUFSIZE]; - target_p = tn->data; + target_p = (Client *)tn->data; if (!IsClient(target_p)) continue; diff --git a/modules/m_services.c b/modules/m_services.cc similarity index 98% rename from modules/m_services.c rename to modules/m_services.cc index bb7b8ecf8..0cb8200ee 100644 --- a/modules/m_services.c +++ b/modules/m_services.cc @@ -276,7 +276,7 @@ me_nickdelay(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so duration = atoi(parv[1]); if (duration <= 0) { - nd = rb_dictionary_retrieve(nd_dict, parv[2]); + nd = (nd_entry *)rb_dictionary_retrieve(nd_dict, parv[2]); if (nd != NULL) free_nd_entry(nd); } @@ -285,7 +285,7 @@ me_nickdelay(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so if (duration > 86400) duration = 86400; add_nd_entry(parv[2]); - nd = rb_dictionary_retrieve(nd_dict, parv[2]); + nd = (nd_entry *)rb_dictionary_retrieve(nd_dict, parv[2]); if (nd != NULL) nd->expire = rb_current_time() + duration; } @@ -358,7 +358,7 @@ unmark_services(void) RB_DLINK_FOREACH(ptr, global_serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; target_p->flags &= ~FLAGS_SERVICE; } diff --git a/modules/m_set.c b/modules/m_set.cc similarity index 100% rename from modules/m_set.c rename to modules/m_set.cc diff --git a/modules/m_signon.c b/modules/m_signon.cc similarity index 100% rename from modules/m_signon.c rename to modules/m_signon.cc diff --git a/modules/m_snote.c b/modules/m_snote.cc similarity index 100% rename from modules/m_snote.c rename to modules/m_snote.cc diff --git a/modules/m_starttls.c b/modules/m_starttls.cc similarity index 100% rename from modules/m_starttls.c rename to modules/m_starttls.cc diff --git a/modules/m_stats.c b/modules/m_stats.cc similarity index 89% rename from modules/m_stats.c rename to modules/m_stats.cc index e84e8b934..7de3ddc10 100644 --- a/modules/m_stats.c +++ b/modules/m_stats.cc @@ -91,6 +91,26 @@ struct stats_cmd bool need_parv; bool need_oper; bool need_admin; + + stats_cmd(const handler_t &handler = nullptr, + const bool &need_oper = true, + const bool &need_admin = true) + :handler{handler} + ,need_parv{false} + ,need_oper{need_oper} + ,need_admin{need_admin} + { + } + + stats_cmd(const handler_parv_t &handler_parv, + const bool &need_oper, + const bool &need_admin) + :handler_parv{handler_parv} + ,need_parv{true} + ,need_oper{need_oper} + ,need_admin{need_admin} + { + } }; static void stats_dns_servers(struct Client *); @@ -130,8 +150,6 @@ static void stats_ziplinks(struct Client *); static void stats_comm(struct Client *); static void stats_capability(struct Client *); -#define HANDLER_NORM(fn, oper, admin) { { .handler = fn }, false, oper, admin } -#define HANDLER_PARV(fn, oper, admin) { { .handler_parv = fn }, true, oper, admin } /* This table contains the possible stats items, in order: * stats letter, function to call, operonly? adminonly? --fl_ @@ -140,57 +158,66 @@ static void stats_capability(struct Client *); * C initalisers so we don't have to iterate anymore * --Elizafox */ -static struct stats_cmd stats_cmd_table[256] = { -/* letter handler oper admin */ - ['a'] = HANDLER_NORM(stats_dns_servers, true, true), - ['A'] = HANDLER_NORM(stats_dns_servers, true, true), - ['b'] = HANDLER_NORM(stats_delay, true, true), - ['B'] = HANDLER_NORM(stats_hash, true, true), - ['c'] = HANDLER_NORM(stats_connect, false, false), - ['C'] = HANDLER_NORM(stats_capability, true, false), - ['d'] = HANDLER_NORM(stats_tdeny, true, false), - ['D'] = HANDLER_NORM(stats_deny, true, false), - ['e'] = HANDLER_NORM(stats_exempt, true, false), - ['E'] = HANDLER_NORM(stats_events, true, true), - ['f'] = HANDLER_NORM(stats_comm, true, true), - ['F'] = HANDLER_NORM(stats_comm, true, true), - ['g'] = HANDLER_NORM(stats_prop_klines, true, false), - ['h'] = HANDLER_NORM(stats_hubleaf, false, false), - ['H'] = HANDLER_NORM(stats_hubleaf, false, false), - ['i'] = HANDLER_NORM(stats_auth, false, false), - ['I'] = HANDLER_NORM(stats_auth, false, false), - ['k'] = HANDLER_NORM(stats_tklines, false, false), - ['K'] = HANDLER_NORM(stats_klines, false, false), - ['l'] = HANDLER_PARV(stats_ltrace, false, false), - ['L'] = HANDLER_PARV(stats_ltrace, false, false), - ['m'] = HANDLER_NORM(stats_messages, false, false), - ['M'] = HANDLER_NORM(stats_messages, false, false), - ['n'] = HANDLER_NORM(stats_dnsbl, false, false), - ['o'] = HANDLER_NORM(stats_oper, false, false), - ['O'] = HANDLER_NORM(stats_privset, true, false), - ['p'] = HANDLER_NORM(stats_operedup, false, false), - ['P'] = HANDLER_NORM(stats_ports, false, false), - ['q'] = HANDLER_NORM(stats_tresv, true, false), - ['Q'] = HANDLER_NORM(stats_resv, true, false), - ['r'] = HANDLER_NORM(stats_usage, true, false), - ['R'] = HANDLER_NORM(stats_usage, true, false), - ['s'] = HANDLER_NORM(stats_ssld, true, true), - ['S'] = HANDLER_NORM(stats_ssld, true, true), - ['t'] = HANDLER_NORM(stats_tstats, true, false), - ['T'] = HANDLER_NORM(stats_tstats, true, false), - ['u'] = HANDLER_NORM(stats_uptime, false, false), - ['U'] = HANDLER_NORM(stats_shared, true, false), - ['v'] = HANDLER_NORM(stats_servers, false, false), - ['V'] = HANDLER_NORM(stats_servers, false, false), - ['x'] = HANDLER_NORM(stats_tgecos, true, false), - ['X'] = HANDLER_NORM(stats_gecos, true, false), - ['y'] = HANDLER_NORM(stats_class, false, false), - ['Y'] = HANDLER_NORM(stats_class, false, false), - ['z'] = HANDLER_NORM(stats_memory, true, false), - ['Z'] = HANDLER_NORM(stats_ziplinks, true, false), - ['?'] = HANDLER_NORM(stats_servlinks, false, false), +std::array stats_cmd_table +{[] +{ + std::array ret; + + //letter handler oper admin + ret['a'] = stats_cmd { stats_dns_servers, true, true }; + ret['a'] = stats_cmd { stats_dns_servers, true, true }; + ret['A'] = stats_cmd { stats_dns_servers, true, true }; + ret['b'] = stats_cmd { stats_delay, true, true }; + ret['B'] = stats_cmd { stats_hash, true, true }; + ret['c'] = stats_cmd { stats_connect, false, false }; + ret['C'] = stats_cmd { stats_capability, true, false }; + ret['d'] = stats_cmd { stats_tdeny, true, false }; + ret['D'] = stats_cmd { stats_deny, true, false }; + ret['e'] = stats_cmd { stats_exempt, true, false }; + ret['E'] = stats_cmd { stats_events, true, true }; + ret['f'] = stats_cmd { stats_comm, true, true }; + ret['F'] = stats_cmd { stats_comm, true, true }; + ret['g'] = stats_cmd { stats_prop_klines, true, false }; + ret['h'] = stats_cmd { stats_hubleaf, false, false }; + ret['H'] = stats_cmd { stats_hubleaf, false, false }; + ret['i'] = stats_cmd { stats_auth, false, false }; + ret['I'] = stats_cmd { stats_auth, false, false }; + ret['k'] = stats_cmd { stats_tklines, false, false }; + ret['K'] = stats_cmd { stats_klines, false, false }; + ret['l'] = stats_cmd { stats_ltrace, false, false }; + ret['L'] = stats_cmd { stats_ltrace, false, false }; + ret['m'] = stats_cmd { stats_messages, false, false }; + ret['M'] = stats_cmd { stats_messages, false, false }; + ret['n'] = stats_cmd { stats_dnsbl, false, false }; + ret['o'] = stats_cmd { stats_oper, false, false }; + ret['O'] = stats_cmd { stats_privset, true, false }; + ret['p'] = stats_cmd { stats_operedup, false, false }; + ret['P'] = stats_cmd { stats_ports, false, false }; + ret['q'] = stats_cmd { stats_tresv, true, false }; + ret['Q'] = stats_cmd { stats_resv, true, false }; + ret['r'] = stats_cmd { stats_usage, true, false }; + ret['R'] = stats_cmd { stats_usage, true, false }; + ret['s'] = stats_cmd { stats_ssld, true, true }; + ret['S'] = stats_cmd { stats_ssld, true, true }; + ret['t'] = stats_cmd { stats_tstats, true, false }; + ret['T'] = stats_cmd { stats_tstats, true, false }; + ret['u'] = stats_cmd { stats_uptime, false, false }; + ret['U'] = stats_cmd { stats_shared, true, false }; + ret['v'] = stats_cmd { stats_servers, false, false }; + ret['V'] = stats_cmd { stats_servers, false, false }; + ret['x'] = stats_cmd { stats_tgecos, true, false }; + ret['X'] = stats_cmd { stats_gecos, true, false }; + ret['y'] = stats_cmd { stats_class, false, false }; + ret['Y'] = stats_cmd { stats_class, false, false }; + ret['z'] = stats_cmd { stats_memory, true, false }; + ret['Z'] = stats_cmd { stats_ziplinks, true, false }; + ret['?'] = stats_cmd { stats_servlinks, false, false }; + + return ret; +}() }; + /* * m_stats by fl_ * Modified heavily by Elizafox @@ -287,8 +314,10 @@ stats_delay(struct Client *source_p) struct nd_entry *nd; rb_dictionary_iter iter; - RB_DICTIONARY_FOREACH(nd, &iter, nd_dict) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, nd_dict) { + nd = (nd_entry *)elem; sendto_one_notice(source_p, ":Delaying: %s for %ld", nd->name, (long) nd->expire); } @@ -297,7 +326,7 @@ stats_delay(struct Client *source_p) static void stats_hash_cb(const char *buf, void *client_p) { - sendto_one_numeric(client_p, RPL_STATSDEBUG, "B :%s", buf); + sendto_one_numeric((Client *)client_p, RPL_STATSDEBUG, "B :%s", buf); } static void @@ -329,7 +358,7 @@ stats_connect(struct Client *source_p) RB_DLINK_FOREACH(ptr, server_conf_list.head) { - server_p = ptr->data; + server_p = (server_conf *)ptr->data; if(ServerConfIllegal(server_p)) continue; @@ -480,7 +509,7 @@ stats_exempt(struct Client *source_p) static void stats_events_cb(char *str, void *ptr) { - sendto_one_numeric(ptr, RPL_STATSDEBUG, "E :%s", str); + sendto_one_numeric((Client *)ptr, RPL_STATSDEBUG, "E :%s", str); } static void @@ -498,7 +527,7 @@ stats_prop_klines(struct Client *source_p) RB_DLINK_FOREACH(ptr, prop_bans.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; /* Skip non-klines and deactivated klines. */ if(aconf->status != CONF_KILL) @@ -532,7 +561,7 @@ stats_hubleaf(struct Client *source_p) RB_DLINK_FOREACH(ptr, hubleaf_conf_list.head) { - hub_p = ptr->data; + hub_p = (remote_conf *)ptr->data; if(hub_p->flags & CONF_HUB) sendto_one_numeric(source_p, RPL_STATSHLINE, @@ -640,7 +669,7 @@ stats_tklines(struct Client *source_p) { RB_DLINK_FOREACH(ptr, temp_klines[i].head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; get_printable_kline(source_p, aconf, &host, &pass, &user, &oper_reason); @@ -736,11 +765,12 @@ static void stats_messages(struct Client *source_p) { rb_dictionary_iter iter; - struct Message *msg; struct alias_entry *amsg; - RB_DICTIONARY_FOREACH(msg, &iter, cmd_dict) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, cmd_dict) { + const auto msg(reinterpret_cast(elem)); s_assert(msg->cmd != NULL); sendto_one_numeric(source_p, RPL_STATSCOMMANDS, form_str(RPL_STATSCOMMANDS), @@ -758,8 +788,11 @@ stats_dnsbl(struct Client *source_p) if(bl_stats == NULL) return; - RB_DICTIONARY_FOREACH(stats, &iter, bl_stats) + void *elem; + RB_DICTIONARY_FOREACH(elem, &iter, bl_stats) { + stats = (BlacklistStats *)elem; + /* use RPL_STATSDEBUG for now -- jilles */ sendto_one_numeric(source_p, RPL_STATSDEBUG, "n :%d %s", stats->hits, (const char *)iter.cur->key); @@ -781,7 +814,7 @@ stats_oper(struct Client *source_p) RB_DLINK_FOREACH(ptr, oper_conf_list.head) { - oper_p = ptr->data; + oper_p = (oper_conf *)ptr->data; sendto_one_numeric(source_p, RPL_STATSOLINE, form_str(RPL_STATSOLINE), @@ -793,7 +826,7 @@ stats_oper(struct Client *source_p) static void stats_capability_walk(const char *line, void *data) { - struct Client *client_p = data; + struct Client *client_p = (Client *)data; sendto_one_numeric(client_p, RPL_STATSDEBUG, "C :%s", line); } @@ -825,7 +858,7 @@ stats_operedup (struct Client *source_p) RB_DLINK_FOREACH (oper_ptr, oper_list.head) { - target_p = oper_ptr->data; + target_p = (Client *)oper_ptr->data; if(IsOperInvis(target_p) && !IsOper(source_p)) continue; @@ -866,15 +899,17 @@ stats_tresv(struct Client *source_p) RB_DLINK_FOREACH(ptr, resv_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(aconf->hold) sendto_one_numeric(source_p, RPL_STATSQLINE, form_str(RPL_STATSQLINE), 'q', aconf->port, aconf->host, aconf->passwd); } - RB_RADIXTREE_FOREACH(aconf, &state, resv_tree) + void *elem; + RB_RADIXTREE_FOREACH(elem, &state, resv_tree) { + aconf = (ConfItem *)elem; if(aconf->hold) sendto_one_numeric(source_p, RPL_STATSQLINE, form_str(RPL_STATSQLINE), @@ -892,15 +927,17 @@ stats_resv(struct Client *source_p) RB_DLINK_FOREACH(ptr, resv_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(!aconf->hold) sendto_one_numeric(source_p, RPL_STATSQLINE, form_str(RPL_STATSQLINE), 'Q', aconf->port, aconf->host, aconf->passwd); } - RB_RADIXTREE_FOREACH(aconf, &state, resv_tree) + void *elem; + RB_RADIXTREE_FOREACH(elem, &state, resv_tree) { + aconf = (ConfItem *)elem; if(!aconf->hold) sendto_one_numeric(source_p, RPL_STATSQLINE, form_str(RPL_STATSQLINE), @@ -911,7 +948,7 @@ stats_resv(struct Client *source_p) static void stats_ssld_foreach(void *data, pid_t pid, int cli_count, enum ssld_status status, const char *version) { - struct Client *source_p = data; + struct Client *source_p = (Client *)data; sendto_one_numeric(source_p, RPL_STATSDEBUG, "S :%u %c %u :%s", @@ -996,7 +1033,7 @@ stats_tstats (struct Client *source_p) RB_DLINK_FOREACH(ptr, serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; sp.is_sbs += target_p->localClient->sendB; sp.is_sbr += target_p->localClient->receiveB; @@ -1006,7 +1043,7 @@ stats_tstats (struct Client *source_p) RB_DLINK_FOREACH(ptr, lclient_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; sp.is_cbs += target_p->localClient->sendB; sp.is_cbr += target_p->localClient->receiveB; @@ -1121,7 +1158,7 @@ stats_shared (struct Client *source_p) RB_DLINK_FOREACH(ptr, shared_conf_list.head) { - shared_p = ptr->data; + shared_p = (remote_conf *)ptr->data; p = buf; @@ -1143,7 +1180,7 @@ stats_shared (struct Client *source_p) RB_DLINK_FOREACH(ptr, cluster_conf_list.head) { - shared_p = ptr->data; + shared_p = (remote_conf *)ptr->data; p = buf; @@ -1188,7 +1225,7 @@ stats_servers (struct Client *source_p) RB_DLINK_FOREACH (ptr, serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; j++; seconds = rb_current_time() - target_p->localClient->firsttime; @@ -1223,7 +1260,7 @@ stats_tgecos(struct Client *source_p) RB_DLINK_FOREACH(ptr, xline_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(aconf->hold) sendto_one_numeric(source_p, RPL_STATSXLINE, @@ -1241,7 +1278,7 @@ stats_gecos(struct Client *source_p) RB_DLINK_FOREACH(ptr, xline_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(!aconf->hold) sendto_one_numeric(source_p, RPL_STATSXLINE, @@ -1316,7 +1353,7 @@ stats_memory (struct Client *source_p) RB_DLINK_FOREACH(ptr, global_client_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(MyConnect(target_p)) { local_client_conf_count++; @@ -1338,7 +1375,7 @@ stats_memory (struct Client *source_p) /* Count up all channels, ban lists, except lists, Invex lists */ RB_DLINK_FOREACH(ptr, global_channel_list.head) { - chptr = ptr->data; + chptr = (Channel *)ptr->data; channel_count++; channel_memory += (strlen(chptr->chname) + sizeof(struct Channel)); @@ -1489,7 +1526,7 @@ stats_ziplinks (struct Client *source_p) char buf[128], buf1[128]; RB_DLINK_FOREACH (ptr, serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(IsCapable (target_p, CAP_ZIP)) { zipstats = target_p->localClient->zipstats; @@ -1533,7 +1570,7 @@ stats_servlinks (struct Client *source_p) RB_DLINK_FOREACH (ptr, serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; j++; sendK += target_p->localClient->sendK; @@ -1684,7 +1721,7 @@ stats_l_list(struct Client *source_p, const char *name, bool doall, bool wilds, */ RB_DLINK_FOREACH(ptr, list->head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(!doall && wilds && !match(name, target_p->name)) continue; @@ -1736,7 +1773,7 @@ stats_l_client(struct Client *source_p, struct Client *target_p, static void rb_dump_fd_callback(int fd, const char *desc, void *data) { - struct Client *source_p = data; + struct Client *source_p = (Client *)data; sendto_one_numeric(source_p, RPL_STATSDEBUG, "F :fd %-3d desc '%s'", fd, desc); } diff --git a/modules/m_svinfo.c b/modules/m_svinfo.cc similarity index 100% rename from modules/m_svinfo.c rename to modules/m_svinfo.cc diff --git a/modules/m_tb.c b/modules/m_tb.cc similarity index 100% rename from modules/m_tb.c rename to modules/m_tb.cc diff --git a/modules/m_testline.c b/modules/m_testline.cc similarity index 100% rename from modules/m_testline.c rename to modules/m_testline.cc diff --git a/modules/m_testmask.c b/modules/m_testmask.cc similarity index 99% rename from modules/m_testmask.c rename to modules/m_testmask.cc index 1c61f6228..743b6f783 100644 --- a/modules/m_testmask.c +++ b/modules/m_testmask.cc @@ -109,7 +109,7 @@ mo_testmask(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou RB_DLINK_FOREACH(ptr, global_client_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(!IsPerson(target_p)) continue; diff --git a/modules/m_tginfo.c b/modules/m_tginfo.cc similarity index 100% rename from modules/m_tginfo.c rename to modules/m_tginfo.cc diff --git a/modules/m_time.c b/modules/m_time.cc similarity index 100% rename from modules/m_time.c rename to modules/m_time.cc diff --git a/modules/m_topic.c b/modules/m_topic.cc similarity index 99% rename from modules/m_topic.c rename to modules/m_topic.cc index 6ab17c291..7df2a25a9 100644 --- a/modules/m_topic.c +++ b/modules/m_topic.cc @@ -69,7 +69,7 @@ m_topic(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ const char *name; int operspy = 0; - if((p = strchr(parv[1], ','))) + if((p = (char *)strchr(parv[1], ','))) *p = '\0'; name = parv[1]; diff --git a/modules/m_trace.c b/modules/m_trace.cc similarity index 97% rename from modules/m_trace.c rename to modules/m_trace.cc index 570231704..c6f2077f7 100644 --- a/modules/m_trace.c +++ b/modules/m_trace.cc @@ -113,7 +113,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ { RB_DLINK_FOREACH(ptr, global_serv_list.head) { - ac2ptr = ptr->data; + ac2ptr = (Client *)ptr->data; if(match(tname, ac2ptr->name)) break; @@ -199,7 +199,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ RB_DLINK_FOREACH(ptr, local_oper_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(!doall && wilds && (match(tname, target_p->name) == 0)) continue; @@ -211,7 +211,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ { RB_DLINK_FOREACH(ptr, serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(!doall && wilds && !match(tname, target_p->name)) continue; @@ -230,7 +230,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ /* report all direct connections */ RB_DLINK_FOREACH(ptr, lclient_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; /* dont show invisible users to remote opers */ if(IsInvisible(target_p) && dow && !MyConnect(source_p) && !IsOper(target_p)) @@ -249,7 +249,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ RB_DLINK_FOREACH(ptr, serv_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(!doall && wilds && !match(tname, target_p->name)) continue; @@ -261,7 +261,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ { RB_DLINK_FOREACH(ptr, unknown_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(!doall && wilds && !match(tname, target_p->name)) continue; @@ -287,7 +287,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ { RB_DLINK_FOREACH(ptr, class_list.head) { - cltmp = ptr->data; + cltmp = (Class *)ptr->data; if(CurrUsers(cltmp) > 0) sendto_one_numeric(source_p, RPL_TRACECLASS, @@ -316,7 +316,7 @@ count_downlinks(struct Client *server_p, int *pservcount, int *pusercount) *pusercount += rb_dlink_list_length(&server_p->serv->users); RB_DLINK_FOREACH(ptr, server_p->serv->servers.head) { - count_downlinks(ptr->data, pservcount, pusercount); + count_downlinks((Client *)ptr->data, pservcount, pusercount); } } diff --git a/modules/m_unreject.c b/modules/m_unreject.cc similarity index 100% rename from modules/m_unreject.c rename to modules/m_unreject.cc diff --git a/modules/m_user.c b/modules/m_user.cc similarity index 98% rename from modules/m_user.c rename to modules/m_user.cc index f727b67c2..5ee025934 100644 --- a/modules/m_user.c +++ b/modules/m_user.cc @@ -72,7 +72,7 @@ mr_user(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ if(source_p->flags & FLAGS_SENTUSER) return; - if((p = strchr(parv[1], '@'))) + if((p = (char *)strchr(parv[1], '@'))) *p = '\0'; snprintf(buf, sizeof(buf), "%s %s", parv[2], parv[3]); diff --git a/modules/m_userhost.c b/modules/m_userhost.cc similarity index 100% rename from modules/m_userhost.c rename to modules/m_userhost.cc diff --git a/modules/m_users.c b/modules/m_users.cc similarity index 100% rename from modules/m_users.c rename to modules/m_users.cc diff --git a/modules/m_version.c b/modules/m_version.cc similarity index 100% rename from modules/m_version.c rename to modules/m_version.cc diff --git a/modules/m_wallops.c b/modules/m_wallops.cc similarity index 100% rename from modules/m_wallops.c rename to modules/m_wallops.cc diff --git a/modules/m_who.c b/modules/m_who.cc similarity index 98% rename from modules/m_who.c rename to modules/m_who.cc index 786de814a..5f5a77599 100644 --- a/modules/m_who.c +++ b/modules/m_who.cc @@ -162,7 +162,7 @@ m_who(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, if((lp = source_p->user->channel.head) != NULL) { - msptr = lp->data; + msptr = (membership *)lp->data; do_who_on_channel(source_p, msptr->chptr, server_oper, true, &fmt); } @@ -225,7 +225,7 @@ m_who(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, isinvis = IsInvisible(target_p); RB_DLINK_FOREACH(lp, target_p->user->channel.head) { - msptr = lp->data; + msptr = (membership *)lp->data; chptr = msptr->chptr; member = IsMember(source_p, chptr); @@ -241,7 +241,7 @@ m_who(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, * target_p of chptr */ if(lp != NULL) - do_who(source_p, target_p, lp->data, &fmt); + do_who(source_p, target_p, (membership *)lp->data, &fmt); else do_who(source_p, target_p, NULL, &fmt); @@ -308,7 +308,7 @@ who_common_channel(struct Client *source_p, struct Channel *chptr, RB_DLINK_FOREACH(ptr, chptr->members.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; target_p = msptr->client_p; if(!IsInvisible(target_p) || IsMarked(target_p)) @@ -363,7 +363,7 @@ who_global(struct Client *source_p, const char *mask, int server_oper, int opers { RB_DLINK_FOREACH(lp, source_p->user->channel.head) { - msptr = lp->data; + msptr = (membership *)lp->data; who_common_channel(source_p, msptr->chptr, mask, server_oper, &maxmatches, fmt); } } @@ -377,7 +377,7 @@ who_global(struct Client *source_p, const char *mask, int server_oper, int opers */ RB_DLINK_FOREACH(ptr, global_client_list.head) { - target_p = ptr->data; + target_p = (Client *)ptr->data; if(!IsPerson(target_p)) continue; @@ -432,7 +432,7 @@ do_who_on_channel(struct Client *source_p, struct Channel *chptr, RB_DLINK_FOREACH(ptr, chptr->members.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; target_p = msptr->client_p; if(server_oper && !IsOper(target_p)) diff --git a/modules/m_whois.c b/modules/m_whois.cc similarity index 99% rename from modules/m_whois.c rename to modules/m_whois.cc index e95fc9c1c..91c4a3ef2 100644 --- a/modules/m_whois.c +++ b/modules/m_whois.cc @@ -273,7 +273,7 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy) { RB_DLINK_FOREACH(ptr, target_p->user->channel.head) { - msptr = ptr->data; + msptr = (membership *)ptr->data; chptr = msptr->chptr; hdata.chptr = chptr; diff --git a/modules/m_whowas.c b/modules/m_whowas.cc similarity index 98% rename from modules/m_whowas.c rename to modules/m_whowas.cc index ce04e1c49..17a1cb909 100644 --- a/modules/m_whowas.c +++ b/modules/m_whowas.cc @@ -96,7 +96,7 @@ m_whowas(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source if(!MyClient(source_p) && (max <= 0 || max > 20)) max = 20; - if((p = strchr(parv[1], ','))) + if((p = (char *)strchr(parv[1], ','))) *p = '\0'; nick = parv[1]; @@ -113,7 +113,7 @@ m_whowas(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source RB_DLINK_FOREACH(ptr, whowas_list->head) { - struct Whowas *temp = ptr->data; + struct Whowas *temp = (Whowas *)ptr->data; if(cur > 0 && rb_linebuf_len(&client_p->localClient->buf_sendq) > sendq_limit) { sendto_one(source_p, form_str(ERR_TOOMANYMATCHES), diff --git a/modules/m_xline.c b/modules/m_xline.cc similarity index 99% rename from modules/m_xline.c rename to modules/m_xline.cc index d58592e99..12827d311 100644 --- a/modules/m_xline.c +++ b/modules/m_xline.cc @@ -354,7 +354,7 @@ cluster_xline(struct Client *source_p, int temp_time, const char *name, const ch RB_DLINK_FOREACH(ptr, cluster_conf_list.head) { - shared_p = ptr->data; + shared_p = (remote_conf *)ptr->data; /* old protocol cant handle temps, and we dont really want * to convert them to perm.. --fl @@ -463,7 +463,7 @@ remove_xline(struct Client *source_p, const char *name, bool propagated) RB_DLINK_FOREACH(ptr, xline_conf_list.head) { - aconf = ptr->data; + aconf = (ConfItem *)ptr->data; if(!irccmp(aconf->host, name)) { diff --git a/modules/sno_routing.c b/modules/sno_routing.cc similarity index 98% rename from modules/sno_routing.c rename to modules/sno_routing.cc index 6e58d8240..c1af285d7 100644 --- a/modules/sno_routing.c +++ b/modules/sno_routing.cc @@ -68,7 +68,7 @@ count_mark_downlinks(struct Client *server_p, int *pservcount, int *pusercount) *pusercount += rb_dlink_list_length(&server_p->serv->users); RB_DLINK_FOREACH(ptr, server_p->serv->servers.head) { - count_mark_downlinks(ptr->data, pservcount, pusercount); + count_mark_downlinks((Client *)ptr->data, pservcount, pusercount); } } diff --git a/rb/Makefile.am b/rb/Makefile.am index e5b7b39a1..1a1dc693b 100644 --- a/rb/Makefile.am +++ b/rb/Makefile.am @@ -3,7 +3,13 @@ AUTOMAKE_OPTIONS = foreign pkgconfigdir = $(libdir)/pkgconfig #pkgconfig_DATA = librb.pc -AM_CPPFLAGS = -I$(top_srcdir)/include @SSL_CFLAGS@ @GNUTLS_CFLAGS@ @MBEDTLS_CFLAGS@ +librbdir = @libdir@ +AM_CPPFLAGS = @SSL_CFLAGS@ @GNUTLS_CFLAGS@ @MBEDTLS_CFLAGS@ +AM_CPPFLAGS += -isystem $(top_srcdir)/boost/include +AM_CPPFLAGS += -I$(top_srcdir)/include + +# This is temp since all remaining C is circling the drain. +AM_CFLAGS = -std=gnu99 librb_la_SOURCES = \ unix.c \ @@ -16,8 +22,6 @@ librb_la_SOURCES = \ gnutls.c \ nossl.c \ event.c \ - rb.c \ - rb_memory.c \ linebuf.c \ tools.c \ helper.c \ @@ -33,14 +37,13 @@ librb_la_SOURCES = \ dictionary.c \ radixtree.c \ arc4random.c \ - version.c + version.c \ + terminate.cc \ + rb.cc librb_la_LDFLAGS = @SSL_LIBS@ @GNUTLS_LIBS@ @MBEDTLS_LIBS@ -avoid-version -no-undefined -export-symbols export-syms.txt +librb_la_LDFLAGS += -L$(top_srcdir)/boost/lib + librb_la_LIBADD = @SSL_LIBS@ @GNUTLS_LIBS@ @MBEDTLS_LIBS@ +librb_la_LIBADD += -lboost_system lib_LTLIBRARIES = librb.la - - -mrproper-local: - rm -f $(top_srcdir)/include/rb/config.h - rm -f $(top_srcdir)/include/rb/config.h.in - rm -f $(top_srcdir)/include/rb/stamp-h1 diff --git a/rb/rb.c b/rb/rb.cc similarity index 95% rename from rb/rb.c rename to rb/rb.cc index a9e5e09fd..8df5dd288 100644 --- a/rb/rb.c +++ b/rb/rb.cc @@ -23,8 +23,13 @@ */ #include +extern "C" +{ #include +#include #include +} + #ifdef HAVE_EXECINFO_H #include #endif @@ -222,35 +227,11 @@ rb_lib_loop(long delay) time_t next; rb_set_time(); - if(rb_io_supports_event()) - { - if(delay == 0) - delay = -1; - while(1) - rb_select(-1); - } - + if(delay == 0) + delay = -1; while(1) - { - if(delay == 0) - { - if((next = rb_event_next()) > 0) - { - next -= rb_current_time(); - if(next <= 0) - next = 1000; - else - next *= 1000; - } - else - next = -1; - rb_select(next); - } - else - rb_select(delay); - rb_event_run(); - } + rb_select(-1); } #ifndef HAVE_STRTOK_R @@ -333,7 +314,7 @@ rb_base64_encode(const unsigned char *str, int length) return NULL; } - result = rb_malloc(((length + 2) / 3) * 5); + result = (unsigned char *)rb_malloc(((length + 2) / 3) * 5); p = result; while(length > 2) @@ -374,7 +355,7 @@ rb_base64_decode(const unsigned char *str, int length, int *ret) int ch, i = 0, j = 0, k; unsigned char *result; - result = rb_malloc(length + 1); + result = (unsigned char *)rb_malloc(length + 1); while((ch = *current++) != '\0' && length-- > 0) { diff --git a/rb/rb_memory.c b/rb/rb_memory.c deleted file mode 100644 index b1db79d94..000000000 --- a/rb/rb_memory.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * ircd-ratbox: A slightly useful ircd. - * memory.c: Memory utilities. - * - * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center - * Copyright (C) 1996-2002 Hybrid Development Team - * Copyright (C) 2002-2005 ircd-ratbox development team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - * - */ - -#include - -void -rb_outofmemory(void) -{ - static int was_here = 0; - - if(was_here) - abort(); - - was_here = 1; - - rb_lib_log("Out of memory: restarting server..."); - rb_lib_restart("Out of Memory"); -} diff --git a/rb/terminate.cc b/rb/terminate.cc new file mode 100644 index 000000000..a0c02e37d --- /dev/null +++ b/rb/terminate.cc @@ -0,0 +1,38 @@ +/* + * ratbox 2: hyperratbox + * terminate.cc: Death is the possibility of the absolute impossibility of Dasein. + * + * Copyright (C) 2016 Jason Volk + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice is present in all copies. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +void +rb_outofmemory(void) +{ + rb_lib_log("Out of memory: restarting server..."); + abort(); +} + +/* +void rb::terminate(void) +{ + abort(); +} +*/ diff --git a/ssld/Makefile.am b/ssld/Makefile.am index 8c3109685..d74b8682c 100644 --- a/ssld/Makefile.am +++ b/ssld/Makefile.am @@ -1,7 +1,12 @@ bin_PROGRAMS = ssld -AM_CFLAGS=$(WARNFLAGS) -AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CPPFLAGS = $(WARNFLAGS) +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -I$(top_srcdir)/boost/include -ssld_SOURCES = ssld.c -ssld_LDADD = $(top_srcdir)/rb/librb.la @ZLIB_LD@ +AM_LDFLAGS = -L$(top_srcdir)/ircd +AM_LDFLAGS += -L$(top_srcdir)/rb +AM_LDFLAGS += -L$(top_srcdir)/boost/lib + +ssld_SOURCES = ssld.cc +ssld_LDADD = -lrb -lboost_system @ZLIB_LD@ diff --git a/ssld/ssld.c b/ssld/ssld.cc similarity index 96% rename from ssld/ssld.c rename to ssld/ssld.cc index 5d29671aa..a75ade820 100644 --- a/ssld/ssld.c +++ b/ssld/ssld.cc @@ -177,7 +177,7 @@ conn_find_by_id(uint32_t id) RB_DLINK_FOREACH(ptr, (connid_hash(id))->head) { - conn = ptr->data; + conn = (conn_t *)ptr->data; if(conn->id == id && !IsDead(conn)) return conn; } @@ -199,7 +199,7 @@ free_conn(conn_t * conn) #ifdef HAVE_LIBZ if(IsZip(conn)) { - zlib_stream_t *stream = conn->stream; + zlib_stream_t *stream = (zlib_stream_t *)conn->stream; inflateEnd(&stream->instream); deflateEnd(&stream->outstream); rb_free(stream); @@ -215,7 +215,7 @@ clean_dead_conns(void *unused) rb_dlink_node *ptr, *next; RB_DLINK_FOREACH_SAFE(ptr, next, dead_list.head) { - conn = ptr->data; + conn = (conn_t *)ptr->data; free_conn(conn); } dead_list.tail = dead_list.head = NULL; @@ -262,7 +262,7 @@ close_conn(conn_t * conn, int wait_plain, const char *fmt, ...) static conn_t * make_conn(mod_ctl_t * ctl, rb_fde_t *mod_fd, rb_fde_t *plain_fd) { - conn_t *conn = rb_malloc(sizeof(conn_t)); + conn_t *conn = (conn_t *)rb_malloc(sizeof(conn_t)); conn->ctl = ctl; conn->modbuf_out = rb_new_rawbuffer(); conn->plainbuf_out = rb_new_rawbuffer(); @@ -284,7 +284,7 @@ check_handshake_flood(void *unused) int i; HASH_WALK_SAFE(i, CONN_HASH_SIZE, ptr, next, connid_hash_table) { - conn = ptr->data; + conn = (conn_t *)ptr->data; if(!IsSSL(conn)) continue; @@ -300,7 +300,7 @@ HASH_WALK_END} static void conn_mod_write_sendq(rb_fde_t *fd, void *data) { - conn_t *conn = data; + conn_t *conn = (conn_t *)data; const char *err; int retlen; if(IsDead(conn)) @@ -370,8 +370,8 @@ static void mod_cmd_write_queue(mod_ctl_t * ctl, const void *data, size_t len) { mod_ctl_buf_t *ctl_buf; - ctl_buf = rb_malloc(sizeof(mod_ctl_buf_t)); - ctl_buf->buf = rb_malloc(len); + ctl_buf = (mod_ctl_buf_t *)rb_malloc(sizeof(mod_ctl_buf_t)); + ctl_buf->buf = (uint8_t *)rb_malloc(len); ctl_buf->buflen = len; memcpy(ctl_buf->buf, data, len); ctl_buf->nfds = 0; @@ -386,7 +386,7 @@ common_zlib_deflate(conn_t * conn, void *buf, size_t len) char outbuf[READBUF_SIZE]; int ret, have; z_stream *outstream = &((zlib_stream_t *) conn->stream)->outstream; - outstream->next_in = buf; + outstream->next_in = (Bytef *)buf; outstream->avail_in = len; outstream->next_out = (Bytef *) outbuf; outstream->avail_out = sizeof(outbuf); @@ -419,7 +419,7 @@ common_zlib_inflate(conn_t * conn, void *buf, size_t len) { char outbuf[READBUF_SIZE]; int ret, have = 0; - ((zlib_stream_t *) conn->stream)->instream.next_in = buf; + ((zlib_stream_t *) conn->stream)->instream.next_in = (Bytef *)buf; ((zlib_stream_t *) conn->stream)->instream.avail_in = len; ((zlib_stream_t *) conn->stream)->instream.next_out = (Bytef *) outbuf; ((zlib_stream_t *) conn->stream)->instream.avail_out = sizeof(outbuf); @@ -429,7 +429,7 @@ common_zlib_inflate(conn_t * conn, void *buf, size_t len) ret = inflate(&((zlib_stream_t *) conn->stream)->instream, Z_NO_FLUSH); if(ret != Z_OK) { - if(!strncmp("ERROR ", buf, 6)) + if(!strncmp("ERROR ", (const char *)buf, 6)) { close_conn(conn, WAIT_PLAIN, "Received uncompressed ERROR"); return; @@ -475,7 +475,7 @@ static void conn_plain_read_cb(rb_fde_t *fd, void *data) { char inbuf[READBUF_SIZE]; - conn_t *conn = data; + conn_t *conn = (conn_t *)data; int length = 0; if(conn == NULL) return; @@ -524,7 +524,7 @@ static void conn_plain_read_shutdown_cb(rb_fde_t *fd, void *data) { char inbuf[READBUF_SIZE]; - conn_t *conn = data; + conn_t *conn = (conn_t *)data; int length = 0; if(conn == NULL) @@ -553,7 +553,7 @@ static void conn_mod_read_cb(rb_fde_t *fd, void *data) { char inbuf[READBUF_SIZE]; - conn_t *conn = data; + conn_t *conn = (conn_t *)data; const char *err = remote_closed; int length; if(conn == NULL) @@ -617,7 +617,7 @@ conn_mod_read_cb(rb_fde_t *fd, void *data) static void conn_plain_write_sendq(rb_fde_t *fd, void *data) { - conn_t *conn = data; + conn_t *conn = (conn_t *)data; int retlen; if(IsDead(conn)) @@ -629,7 +629,7 @@ conn_plain_write_sendq(rb_fde_t *fd, void *data) } if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno))) { - close_conn(data, NO_WAIT, NULL); + close_conn(conn, NO_WAIT, NULL); return; } @@ -708,7 +708,7 @@ ssl_send_open(conn_t *conn) static void ssl_process_accept_cb(rb_fde_t *F, int status, struct sockaddr *addr, rb_socklen_t len, void *data) { - conn_t *conn = data; + conn_t *conn = (conn_t *)data; if(status == RB_OK) { @@ -727,7 +727,7 @@ ssl_process_accept_cb(rb_fde_t *F, int status, struct sockaddr *addr, rb_socklen static void ssl_process_connect_cb(rb_fde_t *F, int status, void *data) { - conn_t *conn = data; + conn_t *conn = (conn_t *)data; if(status == RB_OK) { @@ -976,7 +976,7 @@ mod_process_cmd_recv(mod_ctl_t * ctl) RB_DLINK_FOREACH_SAFE(ptr, next, ctl->readq.head) { - ctl_buf = ptr->data; + ctl_buf = (mod_ctl_buf_t *)ptr->data; switch (*ctl_buf->buf) { @@ -1075,14 +1075,14 @@ static void mod_read_ctl(rb_fde_t *F, void *data) { mod_ctl_buf_t *ctl_buf; - mod_ctl_t *ctl = data; + mod_ctl_t *ctl = (mod_ctl_t *)data; int retlen; int i; do { - ctl_buf = rb_malloc(sizeof(mod_ctl_buf_t)); - ctl_buf->buf = rb_malloc(READBUF_SIZE); + ctl_buf = (mod_ctl_buf_t *)rb_malloc(sizeof(mod_ctl_buf_t)); + ctl_buf->buf = (uint8_t *)rb_malloc(READBUF_SIZE); ctl_buf->buflen = READBUF_SIZE; retlen = rb_recv_fd_buf(ctl->F, ctl_buf->buf, ctl_buf->buflen, ctl_buf->F, MAXPASSFD); @@ -1112,14 +1112,14 @@ mod_read_ctl(rb_fde_t *F, void *data) static void mod_write_ctl(rb_fde_t *F, void *data) { - mod_ctl_t *ctl = data; + mod_ctl_t *ctl = (mod_ctl_t *)data; mod_ctl_buf_t *ctl_buf; rb_dlink_node *ptr, *next; int retlen, x; RB_DLINK_FOREACH_SAFE(ptr, next, ctl->writeq.head) { - ctl_buf = ptr->data; + ctl_buf = (mod_ctl_buf_t *)ptr->data; retlen = rb_send_fd_buf(ctl->F, ctl_buf->F, ctl_buf->nfds, ctl_buf->buf, ctl_buf->buflen, ppid); if(retlen > 0) @@ -1204,7 +1204,7 @@ main(int argc, char **argv) rb_init_rawbuffers(1024); rb_init_prng(NULL, RB_PRNG_DEFAULT); ssld_ssl_ok = rb_supports_ssl(); - mod_ctl = rb_malloc(sizeof(mod_ctl_t)); + mod_ctl = (mod_ctl_t *)rb_malloc(sizeof(mod_ctl_t)); mod_ctl->F = rb_open(ctlfd, RB_FD_SOCKET, "ircd control socket"); mod_ctl->F_pipe = rb_open(pipefd, RB_FD_PIPE, "ircd pipe"); rb_set_nb(mod_ctl->F); diff --git a/tools/Makefile.am b/tools/Makefile.am index b93debdab..ce38c78fb 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,13 +1,18 @@ +AM_CPPFLAGS = $(WARNFLAGS) +AM_CPPFLAGS += @LTDLINCL@ +AM_CPPFLAGS += -I$(top_srcdir)/include +AM_CPPFLAGS += -isystem $(top_srcdir)/boost/include + +AM_LDFLAGS = -L$(top_srcdir)/rb +AM_LDFLAGS += -L$(top_srcdir)/boost/lib + bin_PROGRAMS = charybdis-mkpasswd charybdis-mkfingerprint -AM_CFLAGS=$(WARNFLAGS) -AM_CPPFLAGS = $(DEFAULT_INCLUDES) -I$(top_srcdir)/include -charybdis_mkpasswd_SOURCES = mkpasswd.c -charybdis_mkpasswd_LDADD = $(top_srcdir)/rb/librb.la - -charybdis_mkfingerprint_SOURCES = mkfingerprint.c -charybdis_mkfingerprint_LDADD = $(top_srcdir)/rb/librb.la +charybdis_mkpasswd_SOURCES = mkpasswd.cc +charybdis_mkpasswd_LDADD = -lrb -lboost_system +charybdis_mkfingerprint_SOURCES = mkfingerprint.cc +charybdis_mkfingerprint_LDADD = -lrb -lboost_system mrproper-local: rm -f genssl diff --git a/tools/mkfingerprint.c b/tools/mkfingerprint.cc similarity index 99% rename from tools/mkfingerprint.c rename to tools/mkfingerprint.cc index aaacc0445..b8ab9f41f 100644 --- a/tools/mkfingerprint.c +++ b/tools/mkfingerprint.cc @@ -18,6 +18,7 @@ * USA */ #include +#include #include int main(int argc, char *argv[]) diff --git a/tools/mkpasswd.c b/tools/mkpasswd.cc similarity index 99% rename from tools/mkpasswd.c rename to tools/mkpasswd.cc index 41456f5f8..76d67ce1a 100644 --- a/tools/mkpasswd.c +++ b/tools/mkpasswd.cc @@ -10,6 +10,7 @@ * Aaron Sethman */ #include +#include #ifndef __MINGW32__ #include #endif @@ -374,7 +375,7 @@ generate_random_salt(char *salt, int length) { return (generate_poor_salt(salt, length)); } - buf = calloc(1, length); + buf = (char *)calloc(1, length); if(read(fd, buf, length) != length) { free(buf); diff --git a/wsockd/Makefile.am b/wsockd/Makefile.am index 159d2d221..9a11fe9de 100644 --- a/wsockd/Makefile.am +++ b/wsockd/Makefile.am @@ -1,7 +1,11 @@ bin_PROGRAMS = wsockd -AM_CFLAGS=$(WARNFLAGS) -AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CPPFLAGS = $(WARNFLAGS) +AM_CPPFLAGS += -isystem $(top_srcdir)/boost/include +AM_CPPFLAGS += -I$(top_srcdir)/include -wsockd_SOURCES = wsockd.c sha1.c -wsockd_LDADD = $(top_srcdir)/rb/librb.la +AM_LDFLAGS = -L$(top_srcdir)/rb +AM_LDFLAGS += -L$(top_srcdir)/boost/lib + +wsockd_SOURCES = wsockd.cc sha1.c +wsockd_LDADD = -lrb -lboost_system diff --git a/wsockd/wsockd.c b/wsockd/wsockd.cc similarity index 95% rename from wsockd/wsockd.c rename to wsockd/wsockd.cc index 2582cb57a..44147f173 100644 --- a/wsockd/wsockd.c +++ b/wsockd/wsockd.cc @@ -21,7 +21,11 @@ */ #include + +extern "C" +{ #include "sha1.h" +} #define MAXPASSFD 4 #ifndef READBUF_SIZE @@ -251,7 +255,7 @@ clean_dead_conns(void *unused) RB_DLINK_FOREACH_SAFE(ptr, next, dead_list.head) { - conn = ptr->data; + conn = (conn_t *)ptr->data; free_conn(conn); } @@ -261,7 +265,7 @@ clean_dead_conns(void *unused) static void conn_plain_write_sendq(rb_fde_t *fd, void *data) { - conn_t *conn = data; + conn_t *conn = (conn_t *)data; int retlen; if(IsDead(conn)) @@ -272,7 +276,7 @@ conn_plain_write_sendq(rb_fde_t *fd, void *data) if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno))) { - close_conn(data, NO_WAIT, NULL); + close_conn(conn, NO_WAIT, NULL); return; } @@ -285,7 +289,7 @@ conn_plain_write_sendq(rb_fde_t *fd, void *data) static void conn_mod_write_sendq(rb_fde_t *fd, void *data) { - conn_t *conn = data; + conn_t *conn = (conn_t *)data; const char *err; int retlen; @@ -335,7 +339,7 @@ conn_mod_write_short_frame(conn_t * conn, void *data, int len) conn_mod_write(conn, &hdr, sizeof(hdr)); conn_mod_write(conn, data, len); - conn_mod_write(conn, "\r\n", 2); + conn_mod_write(conn, (void *)"\r\n", 2); } static void @@ -350,7 +354,7 @@ conn_mod_write_long_frame(conn_t * conn, void *data, int len) conn_mod_write(conn, &hdr, sizeof(hdr)); conn_mod_write(conn, data, len); - conn_mod_write(conn, "\r\n", 2); + conn_mod_write(conn, (void *)"\r\n", 2); } static void @@ -371,14 +375,14 @@ conn_mod_write_frame(conn_t *conn, void *data, int len) static void mod_write_ctl(rb_fde_t *F, void *data) { - mod_ctl_t *ctl = data; + mod_ctl_t *ctl = (mod_ctl_t *)data; mod_ctl_buf_t *ctl_buf; rb_dlink_node *ptr, *next; int retlen, x; RB_DLINK_FOREACH_SAFE(ptr, next, ctl->writeq.head) { - ctl_buf = ptr->data; + ctl_buf = (mod_ctl_buf_t *)ptr->data; retlen = rb_send_fd_buf(ctl->F, ctl_buf->F, ctl_buf->nfds, ctl_buf->buf, ctl_buf->buflen, ppid); if(retlen > 0) @@ -402,8 +406,8 @@ static void mod_cmd_write_queue(mod_ctl_t * ctl, const void *data, size_t len) { mod_ctl_buf_t *ctl_buf; - ctl_buf = rb_malloc(sizeof(mod_ctl_buf_t)); - ctl_buf->buf = rb_malloc(len); + ctl_buf = (mod_ctl_buf_t *)rb_malloc(sizeof(mod_ctl_buf_t)); + ctl_buf->buf = (uint8_t *)rb_malloc(len); ctl_buf->buflen = len; memcpy(ctl_buf->buf, data, len); ctl_buf->nfds = 0; @@ -455,7 +459,7 @@ close_conn(conn_t * conn, int wait_plain, const char *fmt, ...) static conn_t * make_conn(mod_ctl_t * ctl, rb_fde_t *mod_fd, rb_fde_t *plain_fd) { - conn_t *conn = rb_malloc(sizeof(conn_t)); + conn_t *conn = (conn_t *)rb_malloc(sizeof(conn_t)); conn->ctl = ctl; conn->mod_fd = mod_fd; conn->plain_fd = plain_fd; @@ -656,9 +660,9 @@ conn_mod_handshake_process(conn_t *conn) resp = (char *) rb_base64_encode(digest, SHA1_DIGEST_LENGTH); - conn_mod_write(conn, WEBSOCKET_ANSWER_STRING_1, strlen(WEBSOCKET_ANSWER_STRING_1)); + conn_mod_write(conn, (void *)WEBSOCKET_ANSWER_STRING_1, strlen(WEBSOCKET_ANSWER_STRING_1)); conn_mod_write(conn, resp, strlen(resp)); - conn_mod_write(conn, WEBSOCKET_ANSWER_STRING_2, strlen(WEBSOCKET_ANSWER_STRING_2)); + conn_mod_write(conn, (void *)WEBSOCKET_ANSWER_STRING_2, strlen(WEBSOCKET_ANSWER_STRING_2)); rb_free(resp); } @@ -673,7 +677,7 @@ conn_mod_read_cb(rb_fde_t *fd, void *data) memset(inbuf, 0, sizeof inbuf); - conn_t *conn = data; + conn_t *conn = (conn_t *)data; int length = 0; if (conn == NULL) return; @@ -765,7 +769,7 @@ conn_plain_read_cb(rb_fde_t *fd, void *data) memset(inbuf, 0, sizeof inbuf); - conn_t *conn = data; + conn_t *conn = (conn_t *)data; int length = 0; if(conn == NULL) return; @@ -811,7 +815,7 @@ static void conn_plain_read_shutdown_cb(rb_fde_t *fd, void *data) { char inbuf[READBUF_SIZE]; - conn_t *conn = data; + conn_t *conn = (conn_t *)data; int length = 0; if(conn == NULL) @@ -866,7 +870,7 @@ mod_process_cmd_recv(mod_ctl_t * ctl) RB_DLINK_FOREACH_SAFE(ptr, next, ctl->readq.head) { - ctl_buf = ptr->data; + ctl_buf = (mod_ctl_buf_t *)ptr->data; switch (*ctl_buf->buf) { @@ -895,14 +899,14 @@ static void mod_read_ctl(rb_fde_t *F, void *data) { mod_ctl_buf_t *ctl_buf; - mod_ctl_t *ctl = data; + mod_ctl_t *ctl = (mod_ctl_t *)data; int retlen; int i; do { - ctl_buf = rb_malloc(sizeof(mod_ctl_buf_t)); - ctl_buf->buf = rb_malloc(READBUF_SIZE); + ctl_buf = (mod_ctl_buf_t *)rb_malloc(sizeof(mod_ctl_buf_t)); + ctl_buf->buf = (uint8_t *)rb_malloc(READBUF_SIZE); ctl_buf->buflen = READBUF_SIZE; retlen = rb_recv_fd_buf(ctl->F, ctl_buf->buf, ctl_buf->buflen, ctl_buf->F, MAXPASSFD); @@ -992,7 +996,7 @@ main(int argc, char **argv) rb_linebuf_init(4096); rb_init_rawbuffers(4096); - mod_ctl = rb_malloc(sizeof(mod_ctl_t)); + mod_ctl = (mod_ctl_t *)rb_malloc(sizeof(mod_ctl_t)); mod_ctl->F = rb_open(ctlfd, RB_FD_SOCKET, "ircd control socket"); mod_ctl->F_pipe = rb_open(pipefd, RB_FD_PIPE, "ircd pipe"); rb_set_nb(mod_ctl->F);