From f55682cbaacae61bb886059783ca0c6e60ac7f82 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Wed, 11 Sep 2019 10:04:47 +0200 Subject: [PATCH] More (typedef) struct name changes. Mostly configuration but also aCommand to RealCommand. Although not sure if this latter makes things a lot more descriptive :D. Can revisit later. (more to follow) --- include/class.h | 1 - include/dynconf.h | 26 +++++++++++--------------- include/h.h | 14 +++++--------- include/modules.h | 4 ++-- include/struct.h | 11 +++++------ src/api-command.c | 6 +++--- src/bsd.c | 2 +- src/conf.c | 18 +++++++++--------- src/modules.c | 4 ++-- src/modules/stats.c | 2 +- src/packet.c | 22 +++++++++++----------- src/parse.c | 4 ++-- 12 files changed, 52 insertions(+), 62 deletions(-) diff --git a/include/class.h b/include/class.h index 5afbc94fd..bbadd3548 100644 --- a/include/class.h +++ b/include/class.h @@ -52,7 +52,6 @@ typedef struct Class { extern aClass *classes; extern aClass *find_class(int); -extern int get_conf_class(aConfItem *); extern int get_client_class(Client *); extern int get_client_ping(Client *); extern int get_con_freq(aClass *); diff --git a/include/dynconf.h b/include/dynconf.h index 1e40eb846..c510c50cd 100644 --- a/include/dynconf.h +++ b/include/dynconf.h @@ -21,12 +21,9 @@ #define DYNCONF_H -/* config level */ -#define DYNCONF_CONF_VERSION "1.5" -#define DYNCONF_NETWORK_VERSION "2.2" -typedef struct zNetwork aNetwork; -struct zNetwork { +typedef struct NetworkConfiguration NetworkConfiguration; +struct NetworkConfiguration { unsigned x_inah:1; char *x_ircnetwork; char *x_ircnet005; @@ -54,8 +51,9 @@ typedef struct OperStat { typedef enum BroadcastChannelMessagesOption { BROADCAST_CHANNEL_MESSAGES_AUTO=1, BROADCAST_CHANNEL_MESSAGES_ALWAYS=2, BROADCAST_CHANNEL_MESSAGES_NEVER=3 } BroadcastChannelMessagesOption; -typedef struct zConfiguration aConfiguration; -struct zConfiguration { +/** The set { } block configuration */ +typedef struct Configuration Configuration; +struct Configuration { unsigned som:1; unsigned hide_ulines:1; unsigned flat_map:1; @@ -143,7 +141,7 @@ struct zConfiguration { int maxbanlength; int watch_away_notification; int uhnames; - aNetwork network; + NetworkConfiguration network; unsigned short default_ipv6_clone_mask; int ping_cookie; int min_nick_length; @@ -169,11 +167,9 @@ struct zConfiguration { BroadcastChannelMessagesOption broadcast_channel_messages; }; -#ifndef DYNCONF_C -extern MODVAR aConfiguration iConf; -extern MODVAR aConfiguration tempiConf; +extern MODVAR Configuration iConf; +extern MODVAR Configuration tempiConf; extern MODVAR int ipv6_disabled; -#endif #define KLINE_ADDRESS iConf.kline_address #define GLINE_ADDRESS iConf.gline_address @@ -278,7 +274,9 @@ extern MODVAR int ipv6_disabled; #define UHNAMES_ENABLED iConf.uhnames -/* Used for "is present?" and duplicate checking */ +/** Used for testing the set { } block configuration. + * It tests if a setting is present and is also used for duplicate checking. + */ struct SetCheck { unsigned has_show_opermotd:1; unsigned has_hide_ulines:1; @@ -371,5 +369,3 @@ struct SetCheck { unsigned has_nick_length:1; unsigned has_hide_ban_reason:1; }; - - diff --git a/include/h.h b/include/h.h index 3c53c608b..3d6ca2ffb 100644 --- a/include/h.h +++ b/include/h.h @@ -164,8 +164,8 @@ extern MODVAR int R_do_dns, R_fin_dns, R_fin_dnsc, R_fail_dns, #endif extern MODVAR struct list_head client_list, lclient_list, server_list, oper_list, unknown_list, global_server_list; -extern aCommand *find_Command(char *cmd, short token, int flags); -extern aCommand *find_Command_simple(char *cmd); +extern RealCommand *find_Command(char *cmd, short token, int flags); +extern RealCommand *find_Command_simple(char *cmd); extern Channel *find_channel(char *, Channel *); extern Membership *find_membership_link(Membership *lp, Channel *ptr); extern Member *find_member_link(Member *, Client *); @@ -215,7 +215,6 @@ extern Client *find_server(char *, Client *); extern Client *find_service(char *, Client *); #define find_server_quick(x) find_server(x, NULL) extern char *find_or_add(char *); -extern int attach_conf(Client *, aConfItem *); extern void inittoken(); extern void reset_help(); @@ -236,10 +235,7 @@ extern MODVAR int OpenFiles; /* number of files currently open */ extern MODVAR int debuglevel, portnum, debugtty, maxusersperchannel; extern MODVAR int readcalls, udpfd, resfd; extern Client *add_connection(ConfigItem_listen *, int); -extern int add_listener(aConfItem *); extern void add_local_domain(char *, int); -extern int check_server(Client *, struct hostent *, aConfItem *, - aConfItem *, int); extern int check_server_init(Client *); extern void close_connection(Client *); extern void close_listeners(); @@ -452,9 +448,9 @@ extern int checkprotoflags(Client *, int, char *, int); extern char *inetntop(int af, const void *in, char *local_dummy, size_t the_size); /* Internal command stuff - not for modules */ -extern MODVAR aCommand *CommandHash[256]; +extern MODVAR RealCommand *CommandHash[256]; extern void init_CommandHash(void); -extern aCommand *add_Command_backend(char *cmd); +extern RealCommand *add_Command_backend(char *cmd); /* CRULE */ char *crule_parse(char *); @@ -493,7 +489,7 @@ extern int rehash(Client *cptr, Client *sptr, int sig); extern int match_simple(const char *mask, const char *name); extern int match_esc(const char *mask, const char *name); extern void outofmemory(void); -extern int add_listener2(ConfigItem_listen *conf); +extern int add_listener(ConfigItem_listen *conf); extern void link_cleanup(ConfigItem_link *link_ptr); extern void listen_cleanup(); extern int numeric_collides(long numeric); diff --git a/include/modules.h b/include/modules.h index bee6e4bee..7fa00312b 100644 --- a/include/modules.h +++ b/include/modules.h @@ -377,7 +377,7 @@ typedef struct { typedef struct Command Command; struct Command { Command *prev, *next; - aCommand *cmd; + RealCommand *cmd; }; typedef struct Versionflag Versionflag; @@ -786,7 +786,7 @@ extern Efunction *EfunctionDel(Efunction *cb); extern Command *CommandAdd(Module *module, char *cmd, CmdFunc func, unsigned char params, int flags); extern Command *AliasAdd(Module *module, char *cmd, AliasCmdFunc aliasfunc, unsigned char params, int flags); extern void CommandDel(Command *command); -extern void CommandDelX(Command *command, aCommand *cmd); +extern void CommandDelX(Command *command, RealCommand *cmd); extern int CommandExists(char *name); extern Cmdoverride *CmdoverrideAdd(Module *module, char *cmd, OverrideCmdFunc func); extern Cmdoverride *CmdoverrideAddEx(Module *module, char *name, int priority, OverrideCmdFunc func); diff --git a/include/struct.h b/include/struct.h index 3bb91e0a9..211d72367 100644 --- a/include/struct.h +++ b/include/struct.h @@ -62,7 +62,6 @@ #include "channel.h" typedef struct LoopStruct LoopStruct; -typedef struct ConfItem aConfItem; typedef struct aTKline aTKline; typedef struct Spamfilter Spamfilter; typedef struct ServerBan ServerBan; @@ -135,7 +134,7 @@ typedef struct MotdDownload aMotdDownload; /* used to coordinate download of a r #endif typedef struct trecord aTrecord; -typedef struct aCommand aCommand; +typedef struct RealCommand RealCommand; typedef struct Cmdoverride Cmdoverride; typedef struct Member Member; typedef struct Membership Membership; @@ -1840,8 +1839,8 @@ extern SSL_CTX *init_ctx(TLSOptions *tlsoptions, int server); #define TLS_PROTOCOL_ALL 0xffff -struct aCommand { - aCommand *prev, *next; +struct RealCommand { + RealCommand *prev, *next; char *cmd; CmdFunc func; AliasCmdFunc aliasfunc; @@ -1850,7 +1849,7 @@ struct aCommand { unsigned parameters : 5; unsigned long bytes; Module *owner; - aCommand *friend; /* cmd if token, token if cmd */ + RealCommand *friend; /* cmd if token, token if cmd */ Cmdoverride *overriders; Cmdoverride *overridetail; #ifdef DEBUGMODE @@ -1863,7 +1862,7 @@ struct Cmdoverride { Cmdoverride *prev, *next; int priority; Module *owner; - aCommand *command; + RealCommand *command; OverrideCmdFunc func; }; diff --git a/src/api-command.c b/src/api-command.c index 3dee573ff..7e56a95e5 100644 --- a/src/api-command.c +++ b/src/api-command.c @@ -21,7 +21,7 @@ int CommandExists(char *name) { - aCommand *p; + RealCommand *p; for (p = CommandHash[toupper(*name)]; p; p = p->next) { @@ -35,7 +35,7 @@ int CommandExists(char *name) Command *CommandAddInternal(Module *module, char *cmd, CmdFunc func, AliasCmdFunc aliasfunc, unsigned char params, int flags) { Command *command = NULL; - aCommand *c; + RealCommand *c; if (find_Command_simple(cmd)) { @@ -102,7 +102,7 @@ Command *AliasAdd(Module *module, char *cmd, AliasCmdFunc aliasfunc, unsigned ch return CommandAddInternal(module, cmd, NULL, aliasfunc, params, flags); } -void CommandDelX(Command *command, aCommand *cmd) +void CommandDelX(Command *command, RealCommand *cmd) { Cmdoverride *ovr, *ovrnext; diff --git a/src/bsd.c b/src/bsd.c index 0f2b0bbc2..f0ac9cff7 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -360,7 +360,7 @@ int inetport(ConfigItem_listen *listener, char *ip, int port, int ipv6) return 0; } -int add_listener2(ConfigItem_listen *conf) +int add_listener(ConfigItem_listen *conf) { if (inetport(conf, conf->ip, conf->port, conf->ipv6)) { diff --git a/src/conf.c b/src/conf.c index cd292575e..99c52885a 100644 --- a/src/conf.c +++ b/src/conf.c @@ -270,8 +270,8 @@ ConfigItem_blacklist_module *conf_blacklist_module = NULL; ConfigItem_help *conf_help = NULL; ConfigItem_offchans *conf_offchans = NULL; -MODVAR aConfiguration iConf; -MODVAR aConfiguration tempiConf; +MODVAR Configuration iConf; +MODVAR Configuration tempiConf; MODVAR ConfigFile *conf = NULL; extern NameValueList *config_defines; MODVAR int ipv6_disabled = 0; @@ -1439,7 +1439,7 @@ ConfigCommand *config_binary_search(char *cmd) { return NULL; } -void free_iConf(aConfiguration *i) +void free_iConf(Configuration *i) { safefree(i->kline_address); safefree(i->gline_address); @@ -1481,7 +1481,7 @@ void free_iConf(aConfiguration *i) int config_test(); -void config_setdefaultsettings(aConfiguration *i) +void config_setdefaultsettings(Configuration *i) { char tmp[512]; @@ -1703,7 +1703,7 @@ void postconf_fixes(void) */ static void do_weird_shun_stuff() { -aCommand *cmptr; +RealCommand *cmptr; if ((cmptr = find_Command_simple("PART"))) { @@ -2380,7 +2380,7 @@ void config_rehash() MyFree(log_ptr); } for (alias_ptr = conf_alias; alias_ptr; alias_ptr = (ConfigItem_alias *)next) { - aCommand *cmptr = find_Command(alias_ptr->alias, 0, 0); + RealCommand *cmptr = find_Command(alias_ptr->alias, 0, 0); ConfigItem_alias_format *fmt; next = (ListStruct *)alias_ptr->next; safefree(alias_ptr->nick); @@ -8855,7 +8855,7 @@ void start_listeners(void) /* Try to bind to any ports that are not yet bound and not marked as temporary */ if (!(listenptr->options & LISTENER_BOUND) && !listenptr->flag.temporary) { - if (add_listener2(listenptr) == -1) + if (add_listener(listenptr) == -1) { ircd_log(LOG_ERROR, "Failed to bind to %s:%i", listenptr->ip, listenptr->port); failed = 1; @@ -8880,7 +8880,7 @@ void start_listeners(void) } /* NOTE: do not merge this with code above (nor in an else block), - * as add_listener2() affects this flag. + * as add_listener() affects this flag. */ if (listenptr->options & LISTENER_BOUND) ports_bound++; @@ -9006,7 +9006,7 @@ int _conf_alias(ConfigFile *conf, ConfigEntry *ce) ConfigItem_alias *alias = NULL; ConfigItem_alias_format *format; ConfigEntry *cep, *cepp; - aCommand *cmptr; + RealCommand *cmptr; if ((cmptr = find_Command(ce->ce_vardata, 0, M_ALIAS))) CommandDelX(NULL, cmptr); diff --git a/src/modules.c b/src/modules.c index 6616041da..9e487b666 100644 --- a/src/modules.c +++ b/src/modules.c @@ -749,7 +749,7 @@ CMD_FUNC(m_module) Module *mi; int i; char tmp[1024], *p; - aCommand *mptr; + RealCommand *mptr; int all = 0; if ((parc > 1) && !strcmp(parv[1], "-all")) @@ -1127,7 +1127,7 @@ Callback *CallbackDel(Callback *cb) Cmdoverride *CmdoverrideAddEx(Module *module, char *name, int priority, OverrideCmdFunc function) { - aCommand *p; + RealCommand *p; Cmdoverride *ovr; if (!(p = find_Command_simple(name))) diff --git a/src/modules/stats.c b/src/modules/stats.c index 8147ea514..249d133b9 100644 --- a/src/modules/stats.c +++ b/src/modules/stats.c @@ -507,7 +507,7 @@ int stats_allow(Client *sptr, char *para) int stats_command(Client *sptr, char *para) { int i; - aCommand *mptr; + RealCommand *mptr; for (i = 0; i < 256; i++) for (mptr = CommandHash[i]; mptr; mptr = mptr->next) if (mptr->count) diff --git a/src/packet.c b/src/packet.c index 2c9b086fa..f3817edd0 100644 --- a/src/packet.c +++ b/src/packet.c @@ -21,7 +21,7 @@ #include "unrealircd.h" -aCommand *CommandHash[256]; /* one per letter */ +RealCommand *CommandHash[256]; /* one per letter */ /* ** dopacket @@ -61,7 +61,7 @@ int dopacket(Client *cptr, char *buffer, int length) void init_CommandHash(void) { #ifdef DEVELOP_DEBUG - aCommand *p; + RealCommand *p; int i; long chainlength; #endif @@ -94,9 +94,9 @@ void init_CommandHash(void) #endif } -aCommand *add_Command_backend(char *cmd) +RealCommand *add_Command_backend(char *cmd) { - aCommand *c = MyMallocEx(sizeof(aCommand)); + RealCommand *c = MyMallocEx(sizeof(RealCommand)); c->cmd = strdup(cmd); @@ -106,9 +106,9 @@ aCommand *add_Command_backend(char *cmd) return c; } -static inline aCommand *find_Cmd(char *cmd, int flags) +static inline RealCommand *find_Cmd(char *cmd, int flags) { - aCommand *p; + RealCommand *p; for (p = CommandHash[toupper(*cmd)]; p; p = p->next) { if ((flags & M_UNREGISTERED) && !(p->flags & M_UNREGISTERED)) continue; @@ -124,18 +124,18 @@ static inline aCommand *find_Cmd(char *cmd, int flags) return NULL; } -aCommand *find_Command(char *cmd, short token, int flags) +RealCommand *find_Command(char *cmd, short token, int flags) { - aCommand *p; + RealCommand *p; Debug((DEBUG_NOTICE, "FindCommand %s", cmd)); return find_Cmd(cmd, flags); } -aCommand *find_Command_simple(char *cmd) +RealCommand *find_Command_simple(char *cmd) { - aCommand *p; + RealCommand *p; for (p = CommandHash[toupper(*cmd)]; p; p = p->next) { if (!strcasecmp(p->cmd, cmd)) @@ -170,7 +170,7 @@ aCommand *find_Command_simple(char *cmd) */ int do_cmd(Client *cptr, Client *sptr, MessageTag *mtags, char *cmd, int parc, char *parv[]) { -aCommand *cmptr; +RealCommand *cmptr; cmptr = find_Command_simple(cmd); if (!cmptr) diff --git a/src/parse.c b/src/parse.c index f7bfd5947..0b22e02af 100644 --- a/src/parse.c +++ b/src/parse.c @@ -83,7 +83,7 @@ int parse(Client *cptr, char *buffer, int length) time_t then, ticks; int retval; #endif - aCommand *cmptr = NULL; + RealCommand *cmptr = NULL; MessageTag *mtags = NULL; for (h = Hooks[HOOKTYPE_PACKET]; h; h = h->next) @@ -148,7 +148,7 @@ int parse2(Client *cptr, Client **fromptr, MessageTag *mtags, char *ch) time_t then, ticks; int retval; #endif - aCommand *cmptr = NULL; + RealCommand *cmptr = NULL; int bytes; *fromptr = cptr; /* The default, unless a source is specified (and permitted) */