From e5936873a4789969c4897fe29283fd506a22200a Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 8 Jan 2015 14:32:11 +0000 Subject: [PATCH] - Const-correctness git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/trunk@5338 82007160-df01-0410-b94d-b575c5fd34c7 --- src/irc.c | 38 +++++++++++++++++++------------------- src/irc.h | 2 +- src/opercmd.c | 25 +++++++++++++------------ src/opercmd.h | 6 +++--- src/scan.c | 28 ++++++++++++++-------------- src/scan.h | 6 +++--- 6 files changed, 53 insertions(+), 52 deletions(-) diff --git a/src/irc.c b/src/irc.c index 21ced4a..1abbec0 100644 --- a/src/irc.c +++ b/src/irc.c @@ -65,15 +65,15 @@ static struct ChannelConf *get_channel(const char *); static struct UserInfo *userinfo_create(char *); static void userinfo_free(struct UserInfo *source); -static void m_ping(char *[], unsigned int, char *, struct UserInfo *); -static void m_invite(char *[], unsigned int, char *, struct UserInfo *); -static void m_privmsg(char *[], unsigned int, char *, struct UserInfo *); -static void m_ctcp(char *[], unsigned int, char *, struct UserInfo *); -static void m_notice(char *[], unsigned int, char *, struct UserInfo *); -static void m_perform(char *[], unsigned int, char *, struct UserInfo *); -static void m_userhost(char *[], unsigned int, char *, struct UserInfo *); -static void m_cannot_join(char *[], unsigned int, char *, struct UserInfo *); -static void m_kill(char *[], unsigned int, char *, struct UserInfo *); +static void m_ping(char *[], unsigned int, char *, const struct UserInfo *); +static void m_invite(char *[], unsigned int, char *, const struct UserInfo *); +static void m_privmsg(char *[], unsigned int, char *, const struct UserInfo *); +static void m_ctcp(char *[], unsigned int, char *, const struct UserInfo *); +static void m_notice(char *[], unsigned int, char *, const struct UserInfo *); +static void m_perform(char *[], unsigned int, char *, const struct UserInfo *); +static void m_userhost(char *[], unsigned int, char *, const struct UserInfo *); +static void m_cannot_join(char *[], unsigned int, char *, const struct UserInfo *); +static void m_kill(char *[], unsigned int, char *, const struct UserInfo *); /* @@ -685,7 +685,7 @@ userinfo_free(struct UserInfo *source_p) * the source (parv[0]) is a server. */ static void -m_perform(char *parv[], unsigned int parc, char *msg, struct UserInfo *notused) +m_perform(char *parv[], unsigned int parc, char *msg, const struct UserInfo *notused) { node_t *node; @@ -734,7 +734,7 @@ m_perform(char *parv[], unsigned int parc, char *msg, struct UserInfo *notused) * the source (parv[0]) is a server. */ static void -m_ping(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p) +m_ping(char *parv[], unsigned int parc, char *msg, const struct UserInfo *source_p) { if (parc < 3) return; @@ -756,7 +756,7 @@ m_ping(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p) * the source (parv[0]) is a server. */ static void -m_invite(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p) +m_invite(char *parv[], unsigned int parc, char *msg, const struct UserInfo *source_p) { struct ChannelConf *channel = NULL; @@ -782,7 +782,7 @@ m_invite(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p) * the source (parv[0]) is a server. */ static void -m_privmsg(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p) +m_privmsg(char *parv[], unsigned int parc, char *msg, const struct UserInfo *source_p) { struct ChannelConf *channel = NULL; size_t nick_len; @@ -831,7 +831,7 @@ m_privmsg(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p) * */ static void -m_ctcp(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p) +m_ctcp(char *parv[], unsigned int parc, char *msg, const struct UserInfo *source_p) { if (strncasecmp(parv[3], "\001VERSION\001", 9) == 0) irc_send("NOTICE %s :\001VERSION Hybrid Open Proxy Monitor %s\001", @@ -851,12 +851,12 @@ m_ctcp(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p) * */ static void -m_notice(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p) +m_notice(char *parv[], unsigned int parc, char *msg, const struct UserInfo *source_p) { static regex_t *preg = NULL; regmatch_t pmatch[5]; int errnum; - char *user[4]; + const char *user[4]; /* Not interested in notices from users */ if (source_p) @@ -939,7 +939,7 @@ m_notice(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p) * */ static void -m_userhost(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p) +m_userhost(char *parv[], unsigned int parc, char *msg, const struct UserInfo *source_p) { if (parc < 4) return; @@ -957,7 +957,7 @@ m_userhost(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p * */ static void -m_cannot_join(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p) +m_cannot_join(char *parv[], unsigned int parc, char *msg, const struct UserInfo *source_p) { const struct ChannelConf *channel = NULL; @@ -984,7 +984,7 @@ m_cannot_join(char *parv[], unsigned int parc, char *msg, struct UserInfo *sourc * */ static void -m_kill(char *parv[], unsigned int parc, char *msg, struct UserInfo *source_p) +m_kill(char *parv[], unsigned int parc, char *msg, const struct UserInfo *source_p) { /* Restart hopm to rehash */ main_restart(); diff --git a/src/irc.h b/src/irc.h index 03e78f6..7df5d4a 100644 --- a/src/irc.h +++ b/src/irc.h @@ -16,7 +16,7 @@ struct UserInfo struct CommandHash { const char *command; - void (*handler)(char *[], unsigned int, char *, struct UserInfo *); + void (*handler)(char *[], unsigned int, char *, const struct UserInfo *); }; extern void irc_send(const char *, ...); diff --git a/src/opercmd.c b/src/opercmd.c index a59d120..3874f05 100644 --- a/src/opercmd.c +++ b/src/opercmd.c @@ -44,14 +44,14 @@ along with this program; if not, write to the Free Software static list_t *COMMANDS = NULL; /* List of active commands */ -static struct Command *command_create(const struct OperCommandHash *, char *param, char *irc_nick, struct ChannelConf *target); +static struct Command *command_create(const struct OperCommandHash *, char *param, char *irc_nick, const struct ChannelConf *target); static void command_free(struct Command *); -static void cmd_check(char *, struct ChannelConf *); -static void cmd_stat(char *, struct ChannelConf *); -static void cmd_fdstat(char *, struct ChannelConf *); +static void cmd_check(char *, const struct ChannelConf *); +static void cmd_stat(char *, const struct ChannelConf *); +static void cmd_fdstat(char *, const struct ChannelConf *); -static struct OperCommandHash COMMAND_TABLE[] = +static const struct OperCommandHash COMMAND_TABLE[] = { { "CHECK", cmd_check }, { "SCAN", cmd_check }, @@ -132,8 +132,8 @@ command_timer(void) * */ void -command_parse(char *command, char *msg, struct ChannelConf *target, - struct UserInfo *source_p) +command_parse(char *command, char *msg, const struct ChannelConf *target, + const struct UserInfo *source_p) { char *param; /* Parsed parameters */ @@ -206,9 +206,10 @@ command_parse(char *command, char *msg, struct ChannelConf *target, * Pointer to new Command */ static struct Command * -command_create(const struct OperCommandHash *tab, char *param, char *irc_nick, struct ChannelConf *target) +command_create(const struct OperCommandHash *tab, char *param, char *irc_nick, + const struct ChannelConf *target) { - struct Command *ret = xcalloc(sizeof *ret); + struct Command *const ret = xcalloc(sizeof *ret); if (param) ret->param = xstrdup(param); @@ -305,7 +306,7 @@ command_userhost(const char *reply) * */ static void -cmd_check(char *param, struct ChannelConf *target) +cmd_check(char *param, const struct ChannelConf *target) { scan_manual(param, target); } @@ -319,7 +320,7 @@ cmd_check(char *param, struct ChannelConf *target) * target: channel command was sent to */ static void -cmd_stat(char *param, struct ChannelConf *target) +cmd_stat(char *param, const struct ChannelConf *target) { stats_output(target->name); } @@ -333,7 +334,7 @@ cmd_stat(char *param, struct ChannelConf *target) * target: channel command was sent to */ static void -cmd_fdstat(char *param, struct ChannelConf *target) +cmd_fdstat(char *param, const struct ChannelConf *target) { fdstats_output(target->name); } diff --git a/src/opercmd.h b/src/opercmd.h index bf67124..c65a48d 100644 --- a/src/opercmd.h +++ b/src/opercmd.h @@ -7,7 +7,7 @@ struct OperCommandHash { const char *command; - void (*handler)(char *, struct ChannelConf *); + void (*handler)(char *, const struct ChannelConf *); }; struct Command @@ -27,7 +27,7 @@ struct Command char *irc_nick; /* Where the reply is to be sent. */ - struct ChannelConf *target; + const struct ChannelConf *target; /* * When it was added, because we might need to remove it if it does @@ -39,5 +39,5 @@ struct Command extern void command_init(void); extern void command_userhost(const char *); extern void command_timer(void); -extern void command_parse(char *, char *, struct ChannelConf *, struct UserInfo *); +extern void command_parse(char *, char *, const struct ChannelConf *, const struct UserInfo *); #endif diff --git a/src/scan.c b/src/scan.c index dcef636..7cb8f4b 100644 --- a/src/scan.c +++ b/src/scan.c @@ -66,15 +66,15 @@ static list_t *MASKS = NULL; /* Associative list of masks->scanners */ /* Function declarations */ -static struct scan_struct *scan_create(char *[], char *); +static struct scan_struct *scan_create(const char *[], const char *); static void scan_free(struct scan_struct *); -static void scan_irckline(struct scan_struct *, const char *, const char *); -static void scan_negative(struct scan_struct *); +static void scan_irckline(const struct scan_struct *, const char *, const char *); +static void scan_negative(const struct scan_struct *); static void scan_log(OPM_REMOTE_T *); /** Callbacks for LIBOPM */ -void scan_open_proxy(OPM_T *, OPM_REMOTE_T *, int, void *); -void scan_negotiation_failed(OPM_T *, OPM_REMOTE_T *, int, void *); +static void scan_open_proxy(OPM_T *, OPM_REMOTE_T *, int, void *); +static void scan_negotiation_failed(OPM_T *, OPM_REMOTE_T *, int, void *); static void scan_timeout(OPM_T *, OPM_REMOTE_T *, int, void *); static void scan_end(OPM_T *, OPM_REMOTE_T *, int, void *); static void scan_handle_error(OPM_T *, OPM_REMOTE_T *, int, void *); @@ -147,7 +147,7 @@ const char * scan_gettype(int protocol) { static const char *undef = "undefined"; - static struct protocol_assoc protocols[] = + static const struct protocol_assoc protocols[] = { { OPM_TYPE_HTTP, "HTTP" }, { OPM_TYPE_HTTPPOST, "HTTPPOST" }, @@ -300,7 +300,7 @@ scan_init(void) * */ void -scan_connect(char *user[], char *msg) +scan_connect(const char *user[], const char *msg) { struct sockaddr_in ip; node_t *p, *p2; @@ -424,9 +424,9 @@ scan_connect(char *user[], char *msg) * */ static struct scan_struct * -scan_create(char *user[], char *msg) +scan_create(const char *user[], const char *msg) { - struct scan_struct *ss = xcalloc(sizeof *ss); + struct scan_struct *const ss = xcalloc(sizeof *ss); ss->irc_nick = xstrdup(user[0]); ss->irc_username = xstrdup(user[1]); @@ -541,7 +541,7 @@ scan_positive(struct scan_struct *ss, const char *kline, const char *type) * * Return: NONE */ -void +static void scan_open_proxy(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *data) { struct scan_struct *ss; @@ -592,7 +592,7 @@ scan_open_proxy(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *data) * Return: NONE * */ -void +static void scan_negotiation_failed(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *data) { //struct scan_struct *ss; @@ -750,7 +750,7 @@ scan_handle_error(OPM_T *scanner, OPM_REMOTE_T *remote, int err, void *data) * */ static void -scan_negative(struct scan_struct *ss) +scan_negative(const struct scan_struct *ss) { /* Insert IP in negcache */ if (OptionsItem->negcache > 0) @@ -777,7 +777,7 @@ scan_negative(struct scan_struct *ss) * */ static void -scan_irckline(struct scan_struct *ss, const char *format, const char *type) +scan_irckline(const struct scan_struct *ss, const char *format, const char *type) { char message[MSGLENMAX]; /* OUTPUT */ @@ -862,7 +862,7 @@ scan_irckline(struct scan_struct *ss, const char *format, const char *type) * scan_struct contains a manual_target pointer. */ void -scan_manual(char *param, struct ChannelConf *target) +scan_manual(char *param, const struct ChannelConf *target) { struct in_addr *addr; struct scan_struct *ss; diff --git a/src/scan.h b/src/scan.h index 8ba06da..54b3a7a 100644 --- a/src/scan.h +++ b/src/scan.h @@ -16,7 +16,7 @@ struct scan_struct unsigned int scans; unsigned int positive; - struct ChannelConf *manual_target; + const struct ChannelConf *manual_target; }; struct scanner_struct @@ -41,9 +41,9 @@ struct kline_format_assoc extern void scan_init(void); extern const char *scan_gettype(int); extern void scan_cycle(void); -extern void scan_connect(char *[], char *); +extern void scan_connect(const char *[], const char *); extern void scan_checkfinished(struct scan_struct *); -extern void scan_manual(char *, struct ChannelConf *); +extern void scan_manual(char *, const struct ChannelConf *); extern int scan_checkexempt(const char *, const char *); extern void scan_timer(void); extern void scan_positive(struct scan_struct *, const char *, const char *); -- 2.30.2