1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-03 00:03:14 +02:00

Const const const

This commit is contained in:
Bram Matthys
2021-09-11 08:17:12 +02:00
parent ac84d4f207
commit 7cabd4b79e
21 changed files with 88 additions and 88 deletions
+2 -2
View File
@@ -34,7 +34,7 @@ ModuleHeader MOD_HEADER
/* Variables */
long CAP_ACCOUNT_TAG = 0L;
int account_tag_mtag_is_ok(Client *client, char *name, char *value);
int account_tag_mtag_is_ok(Client *client, const char *name, const char *value);
void mtag_add_account(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature);
MOD_INIT()
@@ -75,7 +75,7 @@ MOD_UNLOAD()
* syntax.
* We simply allow account-tag ONLY from servers and with any syntax.
*/
int account_tag_mtag_is_ok(Client *client, char *name, char *value)
int account_tag_mtag_is_ok(Client *client, const char *name, const char *value)
{
if (IsServer(client))
return 1;
+2 -2
View File
@@ -37,7 +37,7 @@ CMD_FUNC(cmd_batch);
/* Variables */
long CAP_BATCH = 0L;
int batch_mtag_is_ok(Client *client, char *name, char *value);
int batch_mtag_is_ok(Client *client, const char *name, const char *value);
MOD_INIT()
{
@@ -111,7 +111,7 @@ CMD_FUNC(cmd_batch)
* syntax.
* We simply allow batch ONLY from servers and with any syntax.
*/
int batch_mtag_is_ok(Client *client, char *name, char *value)
int batch_mtag_is_ok(Client *client, const char *name, const char *value)
{
if (IsServer(client))
return 1;
+2 -2
View File
@@ -36,7 +36,7 @@ ModuleHeader MOD_HEADER
"unrealircd-6",
};
int bottag_mtag_is_ok(Client *client, char *name, char *value);
int bottag_mtag_is_ok(Client *client, const char *name, const char *value);
void mtag_add_bottag(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature);
MOD_INIT()
@@ -68,7 +68,7 @@ MOD_UNLOAD()
/** This function verifies if the client sending the mtag is permitted to do so.
*/
int bottag_mtag_is_ok(Client *client, char *name, char *value)
int bottag_mtag_is_ok(Client *client, const char *name, const char *value)
{
if (IsServer(client) && (value == NULL))
return 1; /* OK */
+17 -17
View File
@@ -97,16 +97,16 @@ static void freecfg(struct cfgstruct *cfg);
static void hbm_init_hashes(ModuleInfo *m);
static void init_history_storage(ModuleInfo *modinfo);
int hbm_modechar_del(Channel *channel, int modechar);
int hbm_history_add(char *object, MessageTag *mtags, char *line);
int hbm_history_add(const char *object, MessageTag *mtags, const char *line);
int hbm_history_cleanup(HistoryLogObject *h);
HistoryResult *hbm_history_request(char *object, HistoryFilter *filter);
int hbm_history_destroy(char *object);
int hbm_history_set_limit(char *object, int max_lines, long max_time);
HistoryResult *hbm_history_request(const char *object, HistoryFilter *filter);
int hbm_history_destroy(const char *object);
int hbm_history_set_limit(const char *object, int max_lines, long max_time);
EVENT(history_mem_clean);
EVENT(history_mem_init);
static int hbm_read_masterdb(void);
static void hbm_read_dbs(void);
static int hbm_read_db(char *fname);
static int hbm_read_db(const char *fname);
static int hbm_write_masterdb(void);
static int hbm_write_db(HistoryLogObject *h);
static void hbm_delete_db(HistoryLogObject *h);
@@ -427,12 +427,12 @@ static void init_history_storage(ModuleInfo *modinfo)
ClientCapabilityAdd(modinfo->handle, &cap, NULL);
}
uint64_t hbm_hash(char *object)
uint64_t hbm_hash(const char *object)
{
return siphash_nocase(object, siphashkey_history_backend_mem) % HISTORY_BACKEND_MEM_HASH_TABLE_SIZE;
}
HistoryLogObject *hbm_find_object(char *object)
HistoryLogObject *hbm_find_object(const char *object)
{
int hashv = hbm_hash(object);
HistoryLogObject *h;
@@ -445,7 +445,7 @@ HistoryLogObject *hbm_find_object(char *object)
return NULL;
}
HistoryLogObject *hbm_find_or_add_object(char *object)
HistoryLogObject *hbm_find_or_add_object(const char *object)
{
int hashv = hbm_hash(object);
HistoryLogObject *h;
@@ -539,7 +539,7 @@ void hbm_duplicate_mtags(HistoryLogLine *l, MessageTag *m)
}
/** Add a line to a history object */
void hbm_history_add_line(HistoryLogObject *h, MessageTag *mtags, char *line)
void hbm_history_add_line(HistoryLogObject *h, MessageTag *mtags, const char *line)
{
HistoryLogLine *l = safe_alloc(sizeof(HistoryLogLine) + strlen(line));
strcpy(l->line, line); /* safe, see memory allocation above ^ */
@@ -590,7 +590,7 @@ void hbm_history_del_line(HistoryLogObject *h, HistoryLogLine *l)
}
/** Add history entry */
int hbm_history_add(char *object, MessageTag *mtags, char *line)
int hbm_history_add(const char *object, MessageTag *mtags, const char *line)
{
HistoryLogObject *h = hbm_find_or_add_object(object);
if (!h->max_lines)
@@ -958,7 +958,7 @@ static int hbm_return_between(HistoryResult *r, HistoryLogObject *h, HistoryFilt
return 0;
}
HistoryResult *hbm_history_request(char *object, HistoryFilter *filter)
HistoryResult *hbm_history_request(const char *object, HistoryFilter *filter)
{
HistoryResult *r;
HistoryLogObject *h = hbm_find_object(object);
@@ -1053,7 +1053,7 @@ int hbm_history_cleanup(HistoryLogObject *h)
return 1;
}
int hbm_history_destroy(char *object)
int hbm_history_destroy(const char *object)
{
HistoryLogObject *h = hbm_find_object(object);
HistoryLogLine *l, *l_next;
@@ -1078,7 +1078,7 @@ int hbm_history_destroy(char *object)
}
/** Set new limit on history object */
int hbm_history_set_limit(char *object, int max_lines, long max_time)
int hbm_history_set_limit(const char *object, int max_lines, long max_time)
{
HistoryLogObject *h = hbm_find_or_add_object(object);
h->max_lines = max_lines;
@@ -1286,7 +1286,7 @@ static void hbm_read_dbs(void)
/** Read a channel history db file */
static int hbm_read_db(char *fname)
static int hbm_read_db(const char *fname)
{
UnrealDB *db = NULL;
// header
@@ -1486,7 +1486,7 @@ EVENT(history_mem_clean)
} while(loopcnt++ < HISTORY_CLEAN_PER_LOOP);
}
char *hbm_history_filename(HistoryLogObject *h)
const char *hbm_history_filename(HistoryLogObject *h)
{
static char fname[512];
char oname[OBJECTLEN+1];
@@ -1527,7 +1527,7 @@ char *hbm_history_filename(HistoryLogObject *h)
static int hbm_write_db(HistoryLogObject *h)
{
UnrealDB *db;
char *realfname;
const char *realfname;
char tmpfname[512];
HistoryLogLine *l;
MessageTag *m;
@@ -1600,7 +1600,7 @@ static int hbm_write_db(HistoryLogObject *h)
static void hbm_delete_db(HistoryLogObject *h)
{
UnrealDB *db;
char *fname;
const char *fname;
if (!cfg.persist || !hbm_prehash || !hbm_posthash)
{
#ifdef DEBUGMODE
+8 -8
View File
@@ -20,10 +20,10 @@ ModuleHeader MOD_HEADER
};
/* Forward declarations */
int hbn_history_set_limit(char *object, int max_lines, long max_time);
int hbn_history_add(char *object, MessageTag *mtags, char *line);
HistoryResult *hbn_history_request(char *object, HistoryFilter *filter);
int hbn_history_destroy(char *object);
int hbn_history_set_limit(const char *object, int max_lines, long max_time);
int hbn_history_add(const char *object, MessageTag *mtags, const char *line);
HistoryResult *hbn_history_request(const char *object, HistoryFilter *filter);
int hbn_history_destroy(const char *object);
MOD_INIT()
{
@@ -53,22 +53,22 @@ MOD_UNLOAD()
return MOD_SUCCESS;
}
int hbn_history_add(char *object, MessageTag *mtags, char *line)
int hbn_history_add(const char *object, MessageTag *mtags, const char *line)
{
return 1;
}
HistoryResult *hbn_history_request(char *object, HistoryFilter *filter)
HistoryResult *hbn_history_request(const char *object, HistoryFilter *filter)
{
return NULL;
}
int hbn_history_set_limit(char *object, int max_lines, long max_time)
int hbn_history_set_limit(const char *object, int max_lines, long max_time)
{
return 1;
}
int hbn_history_destroy(char *object)
int hbn_history_destroy(const char *object)
{
return 1;
}
+2 -2
View File
@@ -35,7 +35,7 @@ ModuleHeader MOD_HEADER
long CAP_JSON_LOG = 0L;
/* Forward declarations */
int json_log_mtag_is_ok(Client *client, char *name, char *value);
int json_log_mtag_is_ok(Client *client, const char *name, const char *value);
int json_log_mtag_should_send_to_client(Client *target);
MOD_INIT()
@@ -73,7 +73,7 @@ MOD_UNLOAD()
/** This function verifies if the client sending
* We simply allow from servers without any syntax checking.
*/
int json_log_mtag_is_ok(Client *client, char *name, char *value)
int json_log_mtag_is_ok(Client *client, const char *name, const char *value)
{
if (IsServer(client) || IsMe(client))
return 1;
+2 -2
View File
@@ -61,7 +61,7 @@ static long CAP_LABELED_RESPONSE = 0L;
static char packet[8192];
int labeled_response_mtag_is_ok(Client *client, char *name, char *value);
int labeled_response_mtag_is_ok(Client *client, const char *name, const char *value);
MOD_TEST()
{
@@ -336,7 +336,7 @@ int lr_packet(Client *from, Client *to, Client *intended_to, char **msg, int *le
/** This function verifies if the client sending the
* tag is permitted to do so and uses a permitted syntax.
*/
int labeled_response_mtag_is_ok(Client *client, char *name, char *value)
int labeled_response_mtag_is_ok(Client *client, const char *name, const char *value)
{
if (BadPtr(value))
return 0;
+2 -2
View File
@@ -34,7 +34,7 @@ ModuleHeader MOD_HEADER
/* Variables */
long CAP_ACCOUNT_TAG = 0L;
int msgid_mtag_is_ok(Client *client, char *name, char *value);
int msgid_mtag_is_ok(Client *client, const char *name, const char *value);
void mtag_add_or_inherit_msgid(Client *sender, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature);
MOD_INIT()
@@ -69,7 +69,7 @@ MOD_UNLOAD()
* syntax.
* We simply allow msgid ONLY from servers and with any syntax.
*/
int msgid_mtag_is_ok(Client *client, char *name, char *value)
int msgid_mtag_is_ok(Client *client, const char *name, const char *value)
{
if (IsServer(client) && !BadPtr(value))
return 1;
+3 -3
View File
@@ -32,14 +32,14 @@ ModuleHeader MOD_HEADER
};
long CAP_MESSAGE_TAGS = 0L;
char *_mtags_to_string(MessageTag *m, Client *client);
const char *_mtags_to_string(MessageTag *m, Client *client);
void _parse_message_tags(Client *client, char **str, MessageTag **mtag_list);
MOD_TEST()
{
MARK_AS_OFFICIAL_MODULE(modinfo);
EfunctionAddString(modinfo->handle, EFUNC_MTAGS_TO_STRING, _mtags_to_string);
EfunctionAddConstString(modinfo->handle, EFUNC_MTAGS_TO_STRING, _mtags_to_string);
EfunctionAddVoid(modinfo->handle, EFUNC_PARSE_MESSAGE_TAGS, _parse_message_tags);
return 0;
@@ -263,7 +263,7 @@ int client_accepts_tag(const char *token, Client *client)
* Taking into account the restrictions that 'client' may have.
* @returns A string (static buffer) or NULL if no tags at all (!)
*/
char *_mtags_to_string(MessageTag *m, Client *client)
const char *_mtags_to_string(MessageTag *m, Client *client)
{
static char buf[4096], name[8192], value[8192];
static char tbuf[4094];
+3 -3
View File
@@ -33,7 +33,7 @@ ModuleHeader MOD_HEADER
"unrealircd-6",
};
int replytag_mtag_is_ok(Client *client, char *name, char *value);
int replytag_mtag_is_ok(Client *client, const char *name, const char *value);
void mtag_add_replytag(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature);
MOD_INIT()
@@ -73,9 +73,9 @@ MOD_UNLOAD()
/** This function verifies if the client sending the mtag is permitted to do so.
*/
int replytag_mtag_is_ok(Client *client, char *name, char *value)
int replytag_mtag_is_ok(Client *client, const char *name, const char *value)
{
char *p;
const char *p;
/* Require a non-empty parameter */
if (BadPtr(value))
+2 -2
View File
@@ -34,7 +34,7 @@ ModuleHeader MOD_HEADER
/* Variables */
long CAP_SERVER_TIME = 0L;
int server_time_mtag_is_ok(Client *client, char *name, char *value);
int server_time_mtag_is_ok(Client *client, const char *name, const char *value);
void mtag_add_or_inherit_time(Client *sender, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature);
MOD_INIT()
@@ -75,7 +75,7 @@ MOD_UNLOAD()
* syntax.
* We simply allow server-time ONLY from servers.
*/
int server_time_mtag_is_ok(Client *client, char *name, char *value)
int server_time_mtag_is_ok(Client *client, const char *name, const char *value)
{
if (IsServer(client) && !BadPtr(value))
return 1;
+2 -2
View File
@@ -31,7 +31,7 @@ ModuleHeader MOD_HEADER
"unrealircd-6",
};
int ti_mtag_is_ok(Client *client, char *name, char *value);
int ti_mtag_is_ok(Client *client, const char *name, const char *value);
void mtag_add_ti(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature);
MOD_INIT()
@@ -69,7 +69,7 @@ MOD_UNLOAD()
/** This function verifies if the client sending the mtag is permitted to do so.
*/
int ti_mtag_is_ok(Client *client, char *name, char *value)
int ti_mtag_is_ok(Client *client, const char *name, const char *value)
{
/* Require a non-empty parameter */
if (BadPtr(value))
+2 -2
View File
@@ -34,7 +34,7 @@ ModuleHeader MOD_HEADER
/* Variables */
long CAP_ACCOUNT_TAG = 0L;
int userhost_mtag_is_ok(Client *client, char *name, char *value);
int userhost_mtag_is_ok(Client *client, const char *name, const char *value);
int userhost_mtag_should_send_to_client(Client *target);
void mtag_add_userhost(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature);
@@ -71,7 +71,7 @@ MOD_UNLOAD()
* syntax.
* We simply allow userhost-tag ONLY from servers and with any syntax.
*/
int userhost_mtag_is_ok(Client *client, char *name, char *value)
int userhost_mtag_is_ok(Client *client, const char *name, const char *value)
{
if (IsServer(client))
return 1;
+2 -2
View File
@@ -34,7 +34,7 @@ ModuleHeader MOD_HEADER
/* Variables */
long CAP_ACCOUNT_TAG = 0L;
int userip_mtag_is_ok(Client *client, char *name, char *value);
int userip_mtag_is_ok(Client *client, const char *name, const char *value);
int userip_mtag_should_send_to_client(Client *target);
void mtag_add_userip(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature);
@@ -71,7 +71,7 @@ MOD_UNLOAD()
* syntax.
* We simply allow userip-tag ONLY from servers and with any syntax.
*/
int userip_mtag_is_ok(Client *client, char *name, char *value)
int userip_mtag_is_ok(Client *client, const char *name, const char *value)
{
if (IsServer(client))
return 1;