mirror of
https://github.com/matrix-construct/construct
synced 2024-09-08 01:35:39 +02:00
Merge branch 'master' into authd-framework-2
This commit is contained in:
commit
064e88556d
38 changed files with 333 additions and 328 deletions
6
NEWS.md
6
NEWS.md
|
@ -42,6 +42,12 @@ See LICENSE for licensing details (GPL v2).
|
|||
stuff has been renamed and shuffled around to be more consistent.
|
||||
|
||||
### code
|
||||
- irc_dictionary and irc_radixtree stuff is now in librb, prefixed accordingly.
|
||||
Typedefs have been added for consistency reasons. For example, now you would
|
||||
write `rb_dictionary *foo` and `RB_DICTIONARY_FOREACH`.
|
||||
- C99 bools have been added. Don't use ints as simple true/false flags anymore.
|
||||
Don't use `YES`/`NO` or `TRUE`/`FALSE` macros (`TRUE`/`FALSE` has been removed
|
||||
and `YES`/`NO` is awaiting the same fate). Use just `true` and `false`.
|
||||
- libratbox has been renamed to librb, as we have diverged from upstream long
|
||||
ago.
|
||||
- Almost all 2.8-style hashtable structures have been moved to dictionaries or
|
||||
|
|
|
@ -93,16 +93,16 @@ struct counter
|
|||
/* flags set by command line options */
|
||||
struct flags
|
||||
{
|
||||
int none;
|
||||
int export;
|
||||
int import;
|
||||
int verify;
|
||||
int vacuum;
|
||||
int pretend;
|
||||
int verbose;
|
||||
int wipe;
|
||||
int dupes_ok;
|
||||
} flag = {YES, NO, NO, NO, NO, NO, NO, NO, NO};
|
||||
bool none;
|
||||
bool export;
|
||||
bool import;
|
||||
bool verify;
|
||||
bool vacuum;
|
||||
bool pretend;
|
||||
bool verbose;
|
||||
bool wipe;
|
||||
bool dupes_ok;
|
||||
} flag = {true, false, false, false, false, false, false, false, false};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
static int table_has_rows(const char *table);
|
||||
|
@ -145,32 +145,32 @@ main(int argc, char *argv[])
|
|||
print_help(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'i':
|
||||
flag.none = NO;
|
||||
flag.import = YES;
|
||||
flag.none = false;
|
||||
flag.import = true;
|
||||
break;
|
||||
case 'e':
|
||||
flag.none = NO;
|
||||
flag.export = YES;
|
||||
flag.none = false;
|
||||
flag.export = true;
|
||||
break;
|
||||
case 'u':
|
||||
flag.none = NO;
|
||||
flag.verify = YES;
|
||||
flag.none = false;
|
||||
flag.verify = true;
|
||||
break;
|
||||
case 's':
|
||||
flag.none = NO;
|
||||
flag.vacuum = YES;
|
||||
flag.none = false;
|
||||
flag.vacuum = true;
|
||||
break;
|
||||
case 'p':
|
||||
flag.pretend = YES;
|
||||
flag.pretend = true;
|
||||
break;
|
||||
case 'v':
|
||||
flag.verbose = YES;
|
||||
flag.verbose = true;
|
||||
break;
|
||||
case 'w':
|
||||
flag.wipe = YES;
|
||||
flag.wipe = true;
|
||||
break;
|
||||
case 'd':
|
||||
flag.dupes_ok = YES;
|
||||
flag.dupes_ok = true;
|
||||
break;
|
||||
default: /* '?' */
|
||||
print_help(EXIT_FAILURE);
|
||||
|
@ -200,7 +200,7 @@ main(int argc, char *argv[])
|
|||
fprintf(stdout,
|
||||
"* charybdis bantool v.%s\n", BT_VERSION);
|
||||
|
||||
if(flag.pretend == NO)
|
||||
if(flag.pretend == false)
|
||||
{
|
||||
if(rsdb_init(db_error_cb) == -1)
|
||||
{
|
||||
|
@ -214,7 +214,7 @@ main(int argc, char *argv[])
|
|||
|
||||
if(flag.import && flag.wipe)
|
||||
{
|
||||
flag.dupes_ok = YES; /* dont check for dupes if we are wiping the db clean */
|
||||
flag.dupes_ok = true; /* dont check for dupes if we are wiping the db clean */
|
||||
for(i = 0; i < 3; i++)
|
||||
fprintf(stdout,
|
||||
"* WARNING: YOU ARE ABOUT TO WIPE YOUR DATABASE!\n");
|
||||
|
@ -226,7 +226,7 @@ main(int argc, char *argv[])
|
|||
wipe_schema();
|
||||
}
|
||||
}
|
||||
if(flag.verbose && flag.dupes_ok == YES)
|
||||
if(flag.verbose && flag.dupes_ok == true)
|
||||
fprintf(stdout, "* Allowing duplicate bans...\n");
|
||||
|
||||
/* checking for our files to import or export */
|
||||
|
@ -235,7 +235,7 @@ main(int argc, char *argv[])
|
|||
snprintf(conf, sizeof(conf), "%s/%s.conf%s",
|
||||
etc, bandb_table[i], bandb_suffix[i]);
|
||||
|
||||
if(flag.import && flag.pretend == NO)
|
||||
if(flag.import && flag.pretend == false)
|
||||
rsdb_transaction(RSDB_TRANS_START);
|
||||
|
||||
if(flag.import)
|
||||
|
@ -244,7 +244,7 @@ main(int argc, char *argv[])
|
|||
if(flag.export)
|
||||
export_config(conf, i);
|
||||
|
||||
if(flag.import && flag.pretend == NO)
|
||||
if(flag.import && flag.pretend == false)
|
||||
rsdb_transaction(RSDB_TRANS_END);
|
||||
}
|
||||
|
||||
|
@ -497,9 +497,9 @@ import_config(const char *conf, int id)
|
|||
else
|
||||
snprintf(newreason, sizeof(newreason), "%s", f_reason);
|
||||
|
||||
if(flag.pretend == NO)
|
||||
if(flag.pretend == false)
|
||||
{
|
||||
if(flag.dupes_ok == NO)
|
||||
if(flag.dupes_ok == false)
|
||||
drop_dupes(f_mask1, f_mask2, bandb_table[id]);
|
||||
|
||||
rsdb_exec(NULL,
|
||||
|
|
|
@ -20,18 +20,16 @@ DECLARE_MODULE_AV2(echotags, NULL, NULL, echotags_clist, NULL, NULL, NULL, NULL,
|
|||
static void
|
||||
m_echotags(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
sendto_one_notice(source_p, ":*** You sent %zu tags.", msgbuf_p->n_tags);
|
||||
|
||||
for (i = 0; i < msgbuf_p->n_tags; i++)
|
||||
for (size_t i = 0; i < msgbuf_p->n_tags; i++)
|
||||
{
|
||||
struct MsgTag *tag = &msgbuf_p->tags[i];
|
||||
|
||||
if (tag->value)
|
||||
sendto_one_notice(source_p, ":*** %d: %s => %s", i, tag->key, tag->value);
|
||||
sendto_one_notice(source_p, ":*** %zu: %s => %s", i, tag->key, tag->value);
|
||||
else
|
||||
sendto_one_notice(source_p, ":*** %d: %s", i, tag->key);
|
||||
sendto_one_notice(source_p, ":*** %zu: %s", i, tag->key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef INCLUDED_CACHE_H
|
||||
#define INCLUDED_CACHE_H
|
||||
|
||||
#include "rb_dictionary.h"
|
||||
|
||||
#define HELP_MAX 100
|
||||
|
||||
#define CACHEFILELEN 30
|
||||
|
@ -43,8 +45,7 @@ void send_user_motd(struct Client *);
|
|||
void send_oper_motd(struct Client *);
|
||||
void cache_user_motd(void);
|
||||
|
||||
struct Dictionary;
|
||||
extern struct Dictionary *help_dict_oper;
|
||||
extern struct Dictionary *help_dict_user;
|
||||
extern rb_dictionary *help_dict_oper;
|
||||
extern rb_dictionary *help_dict_user;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -21,9 +21,12 @@
|
|||
#ifndef __CAPABILITY_H__
|
||||
#define __CAPABILITY_H__
|
||||
|
||||
#include "stdinc.h"
|
||||
#include "rb_dictionary.h"
|
||||
|
||||
struct CapabilityIndex {
|
||||
const char *name;
|
||||
struct Dictionary *cap_dict;
|
||||
rb_dictionary *cap_dict;
|
||||
unsigned int highest_bit;
|
||||
rb_dlink_node node;
|
||||
};
|
||||
|
|
|
@ -73,7 +73,7 @@ struct Channel
|
|||
unsigned int join_count; /* joins within delta */
|
||||
unsigned int join_delta; /* last ts of join */
|
||||
|
||||
unsigned long bants;
|
||||
time_t bants;
|
||||
time_t channelts;
|
||||
char *chname;
|
||||
|
||||
|
@ -93,7 +93,7 @@ struct membership
|
|||
struct Client *client_p;
|
||||
unsigned int flags;
|
||||
|
||||
unsigned long bants;
|
||||
time_t bants;
|
||||
};
|
||||
|
||||
#define BANLEN 195
|
||||
|
|
|
@ -31,19 +31,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
/* Blah. I use these a lot. -Dianora */
|
||||
#ifdef YES
|
||||
#undef YES
|
||||
#endif
|
||||
|
||||
#define YES 1
|
||||
|
||||
#ifdef NO
|
||||
#undef NO
|
||||
#endif
|
||||
|
||||
#define NO 0
|
||||
|
||||
/* Just blindly define our own MIN/MAX macro */
|
||||
|
||||
#define IRCD_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
|
|
|
@ -25,12 +25,12 @@
|
|||
#ifndef INCLUDED_hash_h
|
||||
#define INCLUDED_hash_h
|
||||
|
||||
struct Dictionary;
|
||||
struct rb_radixtree;
|
||||
#include "rb_dictionary.h"
|
||||
#include "rb_radixtree.h"
|
||||
|
||||
extern struct Dictionary *nd_dict;
|
||||
extern struct rb_radixtree *resv_tree;
|
||||
extern struct rb_radixtree *channel_tree;
|
||||
extern rb_dictionary *nd_dict;
|
||||
extern rb_radixtree *resv_tree;
|
||||
extern rb_radixtree *channel_tree;
|
||||
|
||||
/* Magic value for FNV hash functions */
|
||||
#define FNV1_32_INIT 0x811c9dc5UL
|
||||
|
|
|
@ -54,7 +54,7 @@ typedef void (*MessageHandler) (struct MsgBuf *, struct Client *, struct Client
|
|||
struct MessageEntry
|
||||
{
|
||||
MessageHandler handler;
|
||||
int min_para;
|
||||
size_t min_para;
|
||||
};
|
||||
|
||||
/* Message table structure */
|
||||
|
|
|
@ -39,7 +39,7 @@ extern void mod_add_cmd(struct Message *msg);
|
|||
extern void mod_del_cmd(struct Message *msg);
|
||||
extern char *reconstruct_parv(int parc, const char *parv[]);
|
||||
|
||||
extern struct Dictionary *alias_dict;
|
||||
extern struct Dictionary *cmd_dict;
|
||||
extern rb_dictionary *alias_dict;
|
||||
extern rb_dictionary *cmd_dict;
|
||||
|
||||
#endif /* INCLUDED_parse_h_h */
|
||||
|
|
|
@ -373,8 +373,8 @@ extern void add_temp_dline(struct ConfItem *);
|
|||
extern void report_temp_klines(struct Client *);
|
||||
extern void show_temp_klines(struct Client *, rb_dlink_list *);
|
||||
|
||||
extern int rehash(int);
|
||||
extern void rehash_bans(int);
|
||||
extern bool rehash(bool);
|
||||
extern void rehash_bans(void);
|
||||
|
||||
extern int conf_add_server(struct ConfItem *, int);
|
||||
extern void conf_add_class_to_conf(struct ConfItem *);
|
||||
|
|
|
@ -131,7 +131,7 @@ struct oper_conf
|
|||
extern struct remote_conf *make_remote_conf(void);
|
||||
extern void free_remote_conf(struct remote_conf *);
|
||||
|
||||
extern int find_shared_conf(const char *username, const char *host,
|
||||
extern bool find_shared_conf(const char *username, const char *host,
|
||||
const char *server, int flags);
|
||||
extern void propagate_generic(struct Client *source_p, const char *command,
|
||||
const char *target, int cap, const char *format, ...);
|
||||
|
|
10
ircd/cache.c
10
ircd/cache.c
|
@ -47,8 +47,8 @@ struct cacheline *emptyline = NULL;
|
|||
rb_dlink_list links_cache_list;
|
||||
char user_motd_changed[MAX_DATE_STRING];
|
||||
|
||||
struct Dictionary *help_dict_oper = NULL;
|
||||
struct Dictionary *help_dict_user = NULL;
|
||||
rb_dictionary *help_dict_oper = NULL;
|
||||
rb_dictionary *help_dict_user = NULL;
|
||||
|
||||
/* init_cache()
|
||||
*
|
||||
|
@ -237,18 +237,18 @@ load_help(void)
|
|||
struct dirent *ldirent= NULL;
|
||||
char filename[PATH_MAX];
|
||||
struct cachefile *cacheptr;
|
||||
struct DictionaryIter iter;
|
||||
rb_dictionary_iter iter;
|
||||
|
||||
#if defined(S_ISLNK) && defined(HAVE_LSTAT)
|
||||
struct stat sb;
|
||||
#endif
|
||||
|
||||
DICTIONARY_FOREACH(cacheptr, &iter, help_dict_oper)
|
||||
RB_DICTIONARY_FOREACH(cacheptr, &iter, help_dict_oper)
|
||||
{
|
||||
rb_dictionary_delete(help_dict_oper, cacheptr->name);
|
||||
free_cachefile(cacheptr);
|
||||
}
|
||||
DICTIONARY_FOREACH(cacheptr, &iter, help_dict_user)
|
||||
RB_DICTIONARY_FOREACH(cacheptr, &iter, help_dict_user)
|
||||
{
|
||||
rb_dictionary_delete(help_dict_user, cacheptr->name);
|
||||
free_cachefile(cacheptr);
|
||||
|
|
|
@ -129,7 +129,7 @@ capability_require(struct CapabilityIndex *idx, const char *cap)
|
|||
}
|
||||
|
||||
static void
|
||||
capability_destroy(struct DictionaryElement *delem, void *privdata)
|
||||
capability_destroy(rb_dictionary_element *delem, void *privdata)
|
||||
{
|
||||
s_assert(delem != NULL);
|
||||
|
||||
|
@ -165,7 +165,7 @@ capability_index_destroy(struct CapabilityIndex *idx)
|
|||
const char *
|
||||
capability_index_list(struct CapabilityIndex *idx, unsigned int cap_mask)
|
||||
{
|
||||
struct DictionaryIter iter;
|
||||
rb_dictionary_iter iter;
|
||||
struct CapabilityEntry *entry;
|
||||
static char buf[BUFSIZE];
|
||||
char *t = buf;
|
||||
|
@ -175,7 +175,7 @@ capability_index_list(struct CapabilityIndex *idx, unsigned int cap_mask)
|
|||
|
||||
*t = '\0';
|
||||
|
||||
DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
|
||||
RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
|
||||
{
|
||||
if ((1 << entry->value) & cap_mask)
|
||||
{
|
||||
|
@ -193,13 +193,13 @@ capability_index_list(struct CapabilityIndex *idx, unsigned int cap_mask)
|
|||
unsigned int
|
||||
capability_index_mask(struct CapabilityIndex *idx)
|
||||
{
|
||||
struct DictionaryIter iter;
|
||||
rb_dictionary_iter iter;
|
||||
struct CapabilityEntry *entry;
|
||||
unsigned int mask = 0;
|
||||
|
||||
s_assert(idx != NULL);
|
||||
|
||||
DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
|
||||
RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
|
||||
{
|
||||
if (!(entry->flags & CAP_ORPHANED))
|
||||
mask |= (1 << entry->value);
|
||||
|
@ -211,13 +211,13 @@ capability_index_mask(struct CapabilityIndex *idx)
|
|||
unsigned int
|
||||
capability_index_get_required(struct CapabilityIndex *idx)
|
||||
{
|
||||
struct DictionaryIter iter;
|
||||
rb_dictionary_iter iter;
|
||||
struct CapabilityEntry *entry;
|
||||
unsigned int mask = 0;
|
||||
|
||||
s_assert(idx != NULL);
|
||||
|
||||
DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
|
||||
RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
|
||||
{
|
||||
if (!(entry->flags & CAP_ORPHANED) && (entry->flags & CAP_REQUIRED))
|
||||
mask |= (1 << entry->value);
|
||||
|
@ -235,13 +235,13 @@ 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 DictionaryIter iter;
|
||||
rb_dictionary_iter iter;
|
||||
struct CapabilityEntry *entry;
|
||||
|
||||
snprintf(buf, sizeof buf, "'%s': allocated bits - %d", idx->name, (idx->highest_bit - 1));
|
||||
cb(buf, privdata);
|
||||
|
||||
DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
|
||||
RB_DICTIONARY_FOREACH(entry, &iter, idx->cap_dict)
|
||||
{
|
||||
snprintf(buf, sizeof buf, "bit %d: '%s'", entry->value, entry->cap);
|
||||
cb(buf, privdata);
|
||||
|
|
|
@ -79,7 +79,7 @@ static rb_bh *away_heap = NULL;
|
|||
static char current_uid[IDLEN];
|
||||
static int32_t current_connid = 0;
|
||||
|
||||
struct Dictionary *nd_dict = NULL;
|
||||
rb_dictionary *nd_dict = NULL;
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -58,8 +58,8 @@ struct dnsstatreq
|
|||
};
|
||||
|
||||
/* These serve as a form of sparse array */
|
||||
static struct Dictionary *query_dict;
|
||||
static struct Dictionary *stat_dict;
|
||||
static rb_dictionary *query_dict;
|
||||
static rb_dictionary *stat_dict;
|
||||
|
||||
rb_dlink_list nameservers;
|
||||
|
||||
|
|
16
ircd/hash.c
16
ircd/hash.c
|
@ -40,14 +40,14 @@
|
|||
#include "rb_dictionary.h"
|
||||
#include "rb_radixtree.h"
|
||||
|
||||
struct Dictionary *client_connid_tree = NULL;
|
||||
struct Dictionary *client_zconnid_tree = NULL;
|
||||
struct rb_radixtree *client_id_tree = NULL;
|
||||
struct rb_radixtree *client_name_tree = NULL;
|
||||
rb_dictionary *client_connid_tree = NULL;
|
||||
rb_dictionary *client_zconnid_tree = NULL;
|
||||
rb_radixtree *client_id_tree = NULL;
|
||||
rb_radixtree *client_name_tree = NULL;
|
||||
|
||||
struct rb_radixtree *channel_tree = NULL;
|
||||
struct rb_radixtree *resv_tree = NULL;
|
||||
struct rb_radixtree *hostname_tree = NULL;
|
||||
rb_radixtree *channel_tree = NULL;
|
||||
rb_radixtree *resv_tree = NULL;
|
||||
rb_radixtree *hostname_tree = NULL;
|
||||
|
||||
/*
|
||||
* look in whowas.c for the missing ...[WW_MAX]; entry
|
||||
|
@ -480,7 +480,7 @@ void
|
|||
clear_resv_hash(void)
|
||||
{
|
||||
struct ConfItem *aconf;
|
||||
struct rb_radixtree_iteration_state iter;
|
||||
rb_radixtree_iteration_state iter;
|
||||
|
||||
RB_RADIXTREE_FOREACH(aconf, &iter, resv_tree)
|
||||
{
|
||||
|
|
14
ircd/ircd.c
14
ircd/ircd.c
|
@ -178,7 +178,13 @@ print_startup(int pid)
|
|||
* -- jilles */
|
||||
if (!server_state_foreground)
|
||||
{
|
||||
(void) write(0, ".", 1);
|
||||
/* GCC complains on Linux if we don't check the value of write pedantically.
|
||||
* Technically you're supposed to check the value, yes, but it probably can't fail.
|
||||
* No, casting to void is of no use to shut the warning up. You HAVE to use the value.
|
||||
* --Elizfaox
|
||||
*/
|
||||
if(write(0, ".", 1) < 1)
|
||||
abort();
|
||||
}
|
||||
if (dup2(1, 0) == -1)
|
||||
abort();
|
||||
|
@ -284,13 +290,13 @@ check_rehash(void *unused)
|
|||
*/
|
||||
if(dorehash)
|
||||
{
|
||||
rehash(1);
|
||||
rehash(true);
|
||||
dorehash = false;
|
||||
}
|
||||
|
||||
if(dorehashbans)
|
||||
{
|
||||
rehash_bans(1);
|
||||
rehash_bans();
|
||||
dorehashbans = false;
|
||||
}
|
||||
|
||||
|
@ -690,7 +696,7 @@ charybdis_main(int argc, char *argv[])
|
|||
init_bandb();
|
||||
init_ssld();
|
||||
|
||||
rehash_bans(0);
|
||||
rehash_bans();
|
||||
|
||||
initialize_server_capabs(); /* Set up default_server_capabs */
|
||||
initialize_global_set_options();
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "send.h"
|
||||
#include "rb_radixtree.h"
|
||||
|
||||
static struct rb_radixtree *monitor_tree;
|
||||
static rb_radixtree *monitor_tree;
|
||||
|
||||
void
|
||||
init_monitor(void)
|
||||
|
|
|
@ -35,7 +35,6 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line)
|
|||
char *ch;
|
||||
char *parv[MAXPARA];
|
||||
size_t n_para;
|
||||
int i;
|
||||
|
||||
/* skip any leading spaces */
|
||||
for (ch = line; *ch && *ch == ' '; ch++)
|
||||
|
@ -108,7 +107,7 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line)
|
|||
return 1;
|
||||
|
||||
msgbuf->cmd = parv[0];
|
||||
for (i = 0; i < n_para; i++)
|
||||
for (size_t i = 0; i < n_para; i++)
|
||||
msgbuf_append_para(msgbuf, parv[i]);
|
||||
|
||||
return 0;
|
||||
|
@ -117,9 +116,7 @@ msgbuf_parse(struct MsgBuf *msgbuf, char *line)
|
|||
static int
|
||||
msgbuf_has_matching_tags(struct MsgBuf *msgbuf, unsigned int capmask)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < msgbuf->n_tags; i++)
|
||||
for (size_t i = 0; i < msgbuf->n_tags; i++)
|
||||
{
|
||||
if ((msgbuf->tags[i].capmask & capmask) != 0)
|
||||
return 1;
|
||||
|
@ -131,14 +128,12 @@ msgbuf_has_matching_tags(struct MsgBuf *msgbuf, unsigned int capmask)
|
|||
static void
|
||||
msgbuf_unparse_tags(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!msgbuf_has_matching_tags(msgbuf, capmask))
|
||||
return;
|
||||
|
||||
*buf = '@';
|
||||
|
||||
for (i = 0; i < msgbuf->n_tags; i++)
|
||||
for (size_t i = 0; i < msgbuf->n_tags; i++)
|
||||
{
|
||||
if ((msgbuf->tags[i].capmask & capmask) == 0)
|
||||
continue;
|
||||
|
@ -185,11 +180,9 @@ msgbuf_unparse_prefix(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned
|
|||
int
|
||||
msgbuf_unparse(char *buf, size_t buflen, struct MsgBuf *msgbuf, unsigned int capmask)
|
||||
{
|
||||
int i;
|
||||
|
||||
msgbuf_unparse_prefix(buf, buflen, msgbuf, capmask);
|
||||
|
||||
for (i = msgbuf->cmd != NULL ? 0 : 1; i < msgbuf->n_para; i++)
|
||||
for (size_t i = msgbuf->cmd != NULL ? 0 : 1; i < msgbuf->n_para; i++)
|
||||
{
|
||||
if (i == (msgbuf->n_para - 1))
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "operhash.h"
|
||||
#include "rb_radixtree.h"
|
||||
|
||||
static struct rb_radixtree *operhash_tree = NULL;
|
||||
static rb_radixtree *operhash_tree = NULL;
|
||||
|
||||
struct operhash_entry
|
||||
{
|
||||
|
|
12
ircd/parse.c
12
ircd/parse.c
|
@ -42,8 +42,8 @@
|
|||
#include "packet.h"
|
||||
#include "s_assert.h"
|
||||
|
||||
struct Dictionary *cmd_dict = NULL;
|
||||
struct Dictionary *alias_dict = NULL;
|
||||
rb_dictionary *cmd_dict = NULL;
|
||||
rb_dictionary *alias_dict = NULL;
|
||||
|
||||
static void cancel_clients(struct Client *, struct Client *);
|
||||
static void remove_unknown(struct Client *, const char *, char *);
|
||||
|
@ -246,13 +246,13 @@ handle_command(struct Message *mptr, struct MsgBuf *msgbuf_p, struct Client *cli
|
|||
|
||||
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
||||
"Dropping server %s due to (invalid) command '%s'"
|
||||
" with only %zu arguments (expecting %d).",
|
||||
" with only %zu arguments (expecting %zu).",
|
||||
client_p->name, mptr->cmd, msgbuf_p->n_para, ehandler.min_para);
|
||||
ilog(L_SERVER,
|
||||
"Insufficient parameters (%zu < %d) for command '%s' from %s.",
|
||||
"Insufficient parameters (%zu < %zu) for command '%s' from %s.",
|
||||
msgbuf_p->n_para, ehandler.min_para, mptr->cmd, client_p->name);
|
||||
snprintf(squitreason, sizeof squitreason,
|
||||
"Insufficient parameters (%zu < %d) for command '%s'",
|
||||
"Insufficient parameters (%zu < %zu) for command '%s'",
|
||||
msgbuf_p->n_para, ehandler.min_para, mptr->cmd);
|
||||
exit_client(client_p, client_p, client_p, squitreason);
|
||||
return (-1);
|
||||
|
@ -278,7 +278,7 @@ handle_encap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so
|
|||
ehandler = mptr->handlers[ENCAP_HANDLER];
|
||||
handler = ehandler.handler;
|
||||
|
||||
if(parc < ehandler.min_para ||
|
||||
if((size_t)parc < ehandler.min_para ||
|
||||
(ehandler.min_para && EmptyString(parv[ehandler.min_para - 1])))
|
||||
return;
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@ extern char **myargv;
|
|||
void
|
||||
restart(const char *mesg)
|
||||
{
|
||||
static int was_here = NO; /* redundant due to restarting flag below */
|
||||
static bool was_here = false; /* redundant due to restarting flag below */
|
||||
|
||||
if(was_here)
|
||||
abort();
|
||||
was_here = YES;
|
||||
was_here = true;
|
||||
|
||||
ilog(L_MAIN, "Restarting Server because: %s", mesg);
|
||||
|
||||
|
|
|
@ -636,10 +636,10 @@ attach_conf(struct Client *client_p, struct ConfItem *aconf)
|
|||
* as a result of an operator issuing this command, else assume it has been
|
||||
* called as a result of the server receiving a HUP signal.
|
||||
*/
|
||||
int
|
||||
rehash(int sig)
|
||||
bool
|
||||
rehash(bool sig)
|
||||
{
|
||||
if(sig != 0)
|
||||
if(sig)
|
||||
{
|
||||
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
||||
"Got signal SIGHUP, reloading ircd conf. file");
|
||||
|
@ -647,7 +647,7 @@ rehash(int sig)
|
|||
|
||||
rehash_authd();
|
||||
/* don't close listeners until we know we can go ahead with the rehash */
|
||||
read_conf_files(NO);
|
||||
read_conf_files(false);
|
||||
|
||||
if(ServerInfo.description != NULL)
|
||||
rb_strlcpy(me.info, ServerInfo.description, sizeof(me.info));
|
||||
|
@ -655,11 +655,11 @@ rehash(int sig)
|
|||
rb_strlcpy(me.info, "unknown", sizeof(me.info));
|
||||
|
||||
open_logfiles();
|
||||
return (0);
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
rehash_bans(int sig)
|
||||
rehash_bans(void)
|
||||
{
|
||||
bandb_rehash_bans();
|
||||
}
|
||||
|
@ -1417,7 +1417,7 @@ read_conf_files(bool cold)
|
|||
* free an alias{} entry.
|
||||
*/
|
||||
static void
|
||||
free_alias_cb(struct DictionaryElement *ptr, void *unused)
|
||||
free_alias_cb(rb_dictionary_element *ptr, void *unused)
|
||||
{
|
||||
struct alias_entry *aptr = ptr->data;
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ free_remote_conf(struct remote_conf *remote_p)
|
|||
rb_free(remote_p);
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
find_shared_conf(const char *username, const char *host,
|
||||
const char *server, int flags)
|
||||
{
|
||||
|
@ -190,13 +190,13 @@ find_shared_conf(const char *username, const char *host,
|
|||
match(shared_p->server, server))
|
||||
{
|
||||
if(shared_p->flags & flags)
|
||||
return YES;
|
||||
return true;
|
||||
else
|
||||
return NO;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -685,7 +685,7 @@ expire_temp_rxlines(void *unused)
|
|||
struct ConfItem *aconf;
|
||||
rb_dlink_node *ptr;
|
||||
rb_dlink_node *next_ptr;
|
||||
struct rb_radixtree_iteration_state state;
|
||||
rb_radixtree_iteration_state state;
|
||||
|
||||
RB_RADIXTREE_FOREACH(aconf, &state, resv_tree)
|
||||
{
|
||||
|
|
|
@ -62,7 +62,7 @@ struct scache_entry
|
|||
time_t last_split;
|
||||
};
|
||||
|
||||
static struct rb_radixtree *scache_tree = NULL;
|
||||
static rb_radixtree *scache_tree = NULL;
|
||||
|
||||
void
|
||||
clear_scache_hash_table(void)
|
||||
|
@ -134,7 +134,7 @@ void
|
|||
scache_send_flattened_links(struct Client *source_p)
|
||||
{
|
||||
struct scache_entry *scache_ptr;
|
||||
struct rb_radixtree_iteration_state iter;
|
||||
rb_radixtree_iteration_state iter;
|
||||
int show;
|
||||
|
||||
RB_RADIXTREE_FOREACH(scache_ptr, &iter, scache_tree)
|
||||
|
@ -170,7 +170,7 @@ void
|
|||
scache_send_missing(struct Client *source_p)
|
||||
{
|
||||
struct scache_entry *scache_ptr;
|
||||
struct rb_radixtree_iteration_state iter;
|
||||
rb_radixtree_iteration_state iter;
|
||||
|
||||
RB_RADIXTREE_FOREACH(scache_ptr, &iter, scache_tree)
|
||||
{
|
||||
|
@ -191,7 +191,7 @@ void
|
|||
count_scache(size_t * number_servers_cached, size_t * mem_servers_cached)
|
||||
{
|
||||
struct scache_entry *scache_ptr;
|
||||
struct rb_radixtree_iteration_state iter;
|
||||
rb_radixtree_iteration_state iter;
|
||||
|
||||
*number_servers_cached = 0;
|
||||
*mem_servers_cached = 0;
|
||||
|
|
|
@ -223,7 +223,7 @@ linebuf_put_msgvbuf(struct MsgBuf *msgbuf, buf_head_t *linebuf, unsigned int cap
|
|||
rb_linebuf_newbuf(linebuf);
|
||||
msgbuf_unparse_prefix(buf, sizeof buf, msgbuf, capmask);
|
||||
rb_linebuf_putprefix(linebuf, pattern, va, buf);
|
||||
}
|
||||
}
|
||||
|
||||
/* linebuf_put_msgbuf
|
||||
*
|
||||
|
@ -505,7 +505,7 @@ sendto_channel_flags(struct Client *one, int type, struct Client *source_p,
|
|||
struct membership *msptr;
|
||||
rb_dlink_node *ptr;
|
||||
rb_dlink_node *next_ptr;
|
||||
unsigned int current_capmask = 0;
|
||||
int current_capmask = 0;
|
||||
struct MsgBuf msgbuf;
|
||||
|
||||
rb_linebuf_newbuf(&rb_linebuf_local);
|
||||
|
|
|
@ -452,7 +452,6 @@ ssl_process_certfp(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
|
|||
uint32_t len;
|
||||
uint8_t *certfp;
|
||||
char *certfp_string;
|
||||
int i;
|
||||
|
||||
if(ctl_buf->buflen > 5 + RB_SSL_CERTFP_LEN)
|
||||
return; /* bogus message..drop it.. XXX should warn here */
|
||||
|
@ -465,7 +464,7 @@ ssl_process_certfp(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
|
|||
return;
|
||||
rb_free(client_p->certfp);
|
||||
certfp_string = rb_malloc(len * 2 + 1);
|
||||
for(i = 0; i < len; i++)
|
||||
for(uint32_t i = 0; i < len; i++)
|
||||
snprintf(certfp_string + 2 * i, 3, "%02x",
|
||||
certfp[i]);
|
||||
client_p->certfp = certfp_string;
|
||||
|
@ -478,7 +477,7 @@ ssl_process_cmd_recv(ssl_ctl_t * ctl)
|
|||
static const char *no_ssl_or_zlib = "ssld has neither SSL/TLS or zlib support killing all sslds";
|
||||
rb_dlink_node *ptr, *next;
|
||||
ssl_ctl_buf_t *ctl_buf;
|
||||
int len;
|
||||
unsigned long len;
|
||||
|
||||
if(ctl->dead)
|
||||
return;
|
||||
|
|
|
@ -46,7 +46,7 @@ struct whowas_top
|
|||
rb_dlink_list wwlist;
|
||||
};
|
||||
|
||||
static struct rb_radixtree *whowas_tree = NULL;
|
||||
static rb_radixtree *whowas_tree = NULL;
|
||||
static rb_dlink_list whowas_list = {NULL, NULL, 0};
|
||||
static unsigned int whowas_list_length = NICKNAMEHISTORYLENGTH;
|
||||
static void whowas_trim(void *unused);
|
||||
|
|
|
@ -27,59 +27,63 @@
|
|||
|
||||
#include "librb-config.h"
|
||||
|
||||
struct Dictionary; /* defined in src/dictionary.c */
|
||||
typedef struct rb_dictionary rb_dictionary;
|
||||
typedef struct rb_dictionary_element rb_dictionary_element;
|
||||
typedef struct rb_dictionary_iter rb_dictionary_iter;
|
||||
|
||||
struct rb_dictionary;
|
||||
|
||||
typedef int (*DCF)(/* const void *a, const void *b */);
|
||||
|
||||
struct DictionaryElement
|
||||
struct rb_dictionary_element
|
||||
{
|
||||
struct DictionaryElement *left, *right, *prev, *next;
|
||||
rb_dictionary_element *left, *right, *prev, *next;
|
||||
void *data;
|
||||
const void *key;
|
||||
int position;
|
||||
};
|
||||
|
||||
struct DictionaryIter
|
||||
struct rb_dictionary_iter
|
||||
{
|
||||
struct DictionaryElement *cur, *next;
|
||||
rb_dictionary_element *cur, *next;
|
||||
};
|
||||
|
||||
/*
|
||||
* this is a convenience macro for inlining iteration of dictionaries.
|
||||
*/
|
||||
#define DICTIONARY_FOREACH(element, state, dict) for (rb_dictionary_foreach_start((dict), (state)); (element = rb_dictionary_foreach_cur((dict), (state))); rb_dictionary_foreach_next((dict), (state)))
|
||||
#define RB_DICTIONARY_FOREACH(element, state, dict) for (rb_dictionary_foreach_start((dict), (state)); (element = rb_dictionary_foreach_cur((dict), (state))); rb_dictionary_foreach_next((dict), (state)))
|
||||
|
||||
/*
|
||||
* rb_dictionary_create_named() creates a new dictionary tree which has a name.
|
||||
* name is the name, compare_cb is the comparator.
|
||||
*/
|
||||
extern struct Dictionary *rb_dictionary_create(const char *name, DCF compare_cb);
|
||||
extern rb_dictionary *rb_dictionary_create(const char *name, DCF compare_cb);
|
||||
|
||||
/*
|
||||
* rb_dictionary_set_comparator_func() resets the comparator used for lookups and
|
||||
* insertions in the DTree structure.
|
||||
*/
|
||||
extern void rb_dictionary_set_comparator_func(struct Dictionary *dict,
|
||||
extern void rb_dictionary_set_comparator_func(rb_dictionary *dict,
|
||||
DCF compare_cb);
|
||||
|
||||
/*
|
||||
* rb_dictionary_get_comparator_func() returns the comparator used for lookups and
|
||||
* insertions in the DTree structure.
|
||||
*/
|
||||
extern DCF rb_dictionary_get_comparator_func(struct Dictionary *dict);
|
||||
extern DCF rb_dictionary_get_comparator_func(rb_dictionary *dict);
|
||||
|
||||
/*
|
||||
* rb_dictionary_get_linear_index() returns the linear index of an object in the
|
||||
* DTree structure.
|
||||
*/
|
||||
extern int rb_dictionary_get_linear_index(struct Dictionary *dict, const void *key);
|
||||
extern int rb_dictionary_get_linear_index(rb_dictionary *dict, const void *key);
|
||||
|
||||
/*
|
||||
* rb_dictionary_destroy() destroys all entries in a dtree, and also optionally calls
|
||||
* a defined callback function to destroy any data attached to it.
|
||||
*/
|
||||
extern void rb_dictionary_destroy(struct Dictionary *dtree,
|
||||
void (*destroy_cb)(struct DictionaryElement *delem, void *privdata),
|
||||
extern void rb_dictionary_destroy(rb_dictionary *dtree,
|
||||
void (*destroy_cb)(rb_dictionary_element *delem, void *privdata),
|
||||
void *privdata);
|
||||
|
||||
/*
|
||||
|
@ -88,8 +92,8 @@ extern void rb_dictionary_destroy(struct Dictionary *dtree,
|
|||
*
|
||||
* To shortcircuit iteration, return non-zero from the callback function.
|
||||
*/
|
||||
extern void rb_dictionary_foreach(struct Dictionary *dtree,
|
||||
int (*foreach_cb)(struct DictionaryElement *delem, void *privdata),
|
||||
extern void rb_dictionary_foreach(rb_dictionary *dtree,
|
||||
int (*foreach_cb)(rb_dictionary_element *delem, void *privdata),
|
||||
void *privdata);
|
||||
|
||||
/*
|
||||
|
@ -99,8 +103,8 @@ extern void rb_dictionary_foreach(struct Dictionary *dtree,
|
|||
* When the object is found, a non-NULL is returned from the callback, which results
|
||||
* in that object being returned to the user.
|
||||
*/
|
||||
extern void *rb_dictionary_search(struct Dictionary *dtree,
|
||||
void *(*foreach_cb)(struct DictionaryElement *delem, void *privdata),
|
||||
extern void *rb_dictionary_search(rb_dictionary *dtree,
|
||||
void *(*foreach_cb)(rb_dictionary_element *delem, void *privdata),
|
||||
void *privdata);
|
||||
|
||||
/*
|
||||
|
@ -109,48 +113,48 @@ extern void *rb_dictionary_search(struct Dictionary *dtree,
|
|||
* in progress at a time, it is permitted to remove the current element
|
||||
* of the iteration (but not any other element).
|
||||
*/
|
||||
extern void rb_dictionary_foreach_start(struct Dictionary *dtree,
|
||||
struct DictionaryIter *state);
|
||||
extern void rb_dictionary_foreach_start(rb_dictionary *dtree,
|
||||
rb_dictionary_iter *state);
|
||||
|
||||
/*
|
||||
* rb_dictionary_foreach_cur() returns the current element of the iteration,
|
||||
* or NULL if there are no more elements.
|
||||
*/
|
||||
extern void *rb_dictionary_foreach_cur(struct Dictionary *dtree,
|
||||
struct DictionaryIter *state);
|
||||
extern void *rb_dictionary_foreach_cur(rb_dictionary *dtree,
|
||||
rb_dictionary_iter *state);
|
||||
|
||||
/*
|
||||
* rb_dictionary_foreach_next() moves to the next element.
|
||||
*/
|
||||
extern void rb_dictionary_foreach_next(struct Dictionary *dtree,
|
||||
struct DictionaryIter *state);
|
||||
extern void rb_dictionary_foreach_next(rb_dictionary *dtree,
|
||||
rb_dictionary_iter *state);
|
||||
|
||||
/*
|
||||
* rb_dictionary_add() adds a key->value entry to the dictionary tree.
|
||||
*/
|
||||
extern struct DictionaryElement *rb_dictionary_add(struct Dictionary *dtree, const void *key, void *data);
|
||||
extern rb_dictionary_element *rb_dictionary_add(rb_dictionary *dtree, const void *key, void *data);
|
||||
|
||||
/*
|
||||
* rb_dictionary_find() returns a struct DictionaryElement container from a dtree for key 'key'.
|
||||
* rb_dictionary_find() returns a rb_dictionary_element container from a dtree for key 'key'.
|
||||
*/
|
||||
extern struct DictionaryElement *rb_dictionary_find(struct Dictionary *dtree, const void *key);
|
||||
extern rb_dictionary_element *rb_dictionary_find(rb_dictionary *dtree, const void *key);
|
||||
|
||||
/*
|
||||
* rb_dictionary_find() returns data from a dtree for key 'key'.
|
||||
*/
|
||||
extern void *rb_dictionary_retrieve(struct Dictionary *dtree, const void *key);
|
||||
extern void *rb_dictionary_retrieve(rb_dictionary *dtree, const void *key);
|
||||
|
||||
/*
|
||||
* rb_dictionary_delete() deletes a key->value entry from the dictionary tree.
|
||||
*/
|
||||
extern void *rb_dictionary_delete(struct Dictionary *dtree, const void *key);
|
||||
extern void *rb_dictionary_delete(rb_dictionary *dtree, const void *key);
|
||||
|
||||
/*
|
||||
* rb_dictionary_size() returns the number of elements in a dictionary tree.
|
||||
*/
|
||||
extern unsigned int rb_dictionary_size(struct Dictionary *dtree);
|
||||
extern unsigned int rb_dictionary_size(rb_dictionary *dtree);
|
||||
|
||||
void rb_dictionary_stats(struct Dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata);
|
||||
void rb_dictionary_stats(rb_dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata);
|
||||
void rb_dictionary_stats_walk(void (*cb)(const char *line, void *privdata), void *privdata);
|
||||
|
||||
#ifndef _WIN32
|
||||
|
|
|
@ -39,12 +39,16 @@ struct rb_radixtree; /* defined in src/rb_radixtree.c */
|
|||
|
||||
struct rb_radixtree_leaf; /* defined in src/rb_radixtree.c */
|
||||
|
||||
typedef struct rb_radixtree rb_radixtree;
|
||||
typedef struct rb_radixtree_leaf rb_radixtree_leaf;
|
||||
typedef struct rb_radixtree_iteration_state rb_radixtree_iteration_state;
|
||||
|
||||
/*
|
||||
* struct rb_radixtree_iteration_state, private.
|
||||
*/
|
||||
struct rb_radixtree_iteration_state
|
||||
{
|
||||
struct rb_radixtree_leaf *cur, *next;
|
||||
rb_radixtree_leaf *cur, *next;
|
||||
void *pspare[4];
|
||||
int ispare[4];
|
||||
};
|
||||
|
@ -63,7 +67,7 @@ struct rb_radixtree_iteration_state
|
|||
* compare_cb is the canonizing function.
|
||||
*/
|
||||
|
||||
extern struct rb_radixtree *rb_radixtree_create(const char *name, void (*canonize_cb)(char *key));
|
||||
extern rb_radixtree *rb_radixtree_create(const char *name, void (*canonize_cb)(char *key));
|
||||
|
||||
/*
|
||||
* rb_radixtree_shutdown() deallocates all heaps used in patricia trees. This is
|
||||
|
@ -76,7 +80,7 @@ extern void rb_radixtree_shutdown(void);
|
|||
* rb_radixtree_destroy() destroys all entries in a dtree, and also optionally calls
|
||||
* a defined callback function to destroy any data attached to it.
|
||||
*/
|
||||
extern void rb_radixtree_destroy(struct rb_radixtree *dtree, void (*destroy_cb)(const char *key, void *data, void *privdata), void *privdata);
|
||||
extern void rb_radixtree_destroy(rb_radixtree *dtree, void (*destroy_cb)(const char *key, void *data, void *privdata), void *privdata);
|
||||
|
||||
/*
|
||||
* rb_radixtree_foreach() iterates all entries in a dtree, and also optionally calls
|
||||
|
@ -84,7 +88,7 @@ extern void rb_radixtree_destroy(struct rb_radixtree *dtree, void (*destroy_cb)(
|
|||
*
|
||||
* To shortcircuit iteration, return non-zero from the callback function.
|
||||
*/
|
||||
extern void rb_radixtree_foreach(struct rb_radixtree *dtree, int (*foreach_cb)(const char *key, void *data, void *privdata), void *privdata);
|
||||
extern void rb_radixtree_foreach(rb_radixtree *dtree, int (*foreach_cb)(const char *key, void *data, void *privdata), void *privdata);
|
||||
|
||||
/*
|
||||
* rb_radixtree_search() iterates all entries in a dtree, and also optionally calls
|
||||
|
@ -93,7 +97,7 @@ extern void rb_radixtree_foreach(struct rb_radixtree *dtree, int (*foreach_cb)(c
|
|||
* When the object is found, a non-NULL is returned from the callback, which results
|
||||
* in that object being returned to the user.
|
||||
*/
|
||||
extern void *rb_radixtree_search(struct rb_radixtree *dtree, void *(*foreach_cb)(const char *key, void *data, void *privdata), void *privdata);
|
||||
extern void *rb_radixtree_search(rb_radixtree *dtree, void *(*foreach_cb)(const char *key, void *data, void *privdata), void *privdata);
|
||||
|
||||
/*
|
||||
* rb_radixtree_foreach_start() begins an iteration over all items
|
||||
|
@ -101,7 +105,7 @@ extern void *rb_radixtree_search(struct rb_radixtree *dtree, void *(*foreach_cb)
|
|||
* in progress at a time, it is permitted to remove the current element
|
||||
* of the iteration (but not any other element).
|
||||
*/
|
||||
extern void rb_radixtree_foreach_start(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state);
|
||||
extern void rb_radixtree_foreach_start(rb_radixtree *dtree, rb_radixtree_iteration_state *state);
|
||||
|
||||
/*
|
||||
* rb_radixtree_foreach_start_from() begins an iteration over all items,
|
||||
|
@ -110,44 +114,44 @@ extern void rb_radixtree_foreach_start(struct rb_radixtree *dtree, struct rb_rad
|
|||
* of the iteration (but not any other element).
|
||||
* Use NULL as a key to have it start at the beginning.
|
||||
*/
|
||||
extern void rb_radixtree_foreach_start_from(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state, const char *key);
|
||||
extern void rb_radixtree_foreach_start_from(rb_radixtree *dtree, rb_radixtree_iteration_state *state, const char *key);
|
||||
|
||||
/*
|
||||
* rb_radixtree_foreach_cur() returns the current element of the iteration,
|
||||
* or NULL if there are no more elements.
|
||||
*/
|
||||
extern void *rb_radixtree_foreach_cur(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state);
|
||||
extern void *rb_radixtree_foreach_cur(rb_radixtree *dtree, rb_radixtree_iteration_state *state);
|
||||
|
||||
/*
|
||||
* rb_radixtree_foreach_next() moves to the next element.
|
||||
*/
|
||||
extern void rb_radixtree_foreach_next(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state);
|
||||
extern void rb_radixtree_foreach_next(rb_radixtree *dtree, rb_radixtree_iteration_state *state);
|
||||
|
||||
/*
|
||||
* rb_radixtree_add() adds a key->value entry to the patricia tree.
|
||||
*/
|
||||
extern int rb_radixtree_add(struct rb_radixtree *dtree, const char *key, void *data);
|
||||
extern int rb_radixtree_add(rb_radixtree *dtree, const char *key, void *data);
|
||||
|
||||
/*
|
||||
* rb_radixtree_find() returns data from a dtree for key 'key'.
|
||||
*/
|
||||
extern void *rb_radixtree_retrieve(struct rb_radixtree *dtree, const char *key);
|
||||
extern void *rb_radixtree_retrieve(rb_radixtree *dtree, const char *key);
|
||||
|
||||
/*
|
||||
* rb_radixtree_delete() deletes a key->value entry from the patricia tree.
|
||||
*/
|
||||
extern void *rb_radixtree_delete(struct rb_radixtree *dtree, const char *key);
|
||||
extern void *rb_radixtree_delete(rb_radixtree *dtree, const char *key);
|
||||
|
||||
/* Low-level functions */
|
||||
struct rb_radixtree_leaf *rb_radixtree_elem_add(struct rb_radixtree *dtree, const char *key, void *data);
|
||||
struct rb_radixtree_leaf *rb_radixtree_elem_find(struct rb_radixtree *dtree, const char *key, int fuzzy);
|
||||
void rb_radixtree_elem_delete(struct rb_radixtree *dtree, struct rb_radixtree_leaf *elem);
|
||||
const char *rb_radixtree_elem_get_key(struct rb_radixtree_leaf *elem);
|
||||
void rb_radixtree_elem_set_data(struct rb_radixtree_leaf *elem, void *data);
|
||||
void *rb_radixtree_elem_get_data(struct rb_radixtree_leaf *elem);
|
||||
rb_radixtree_leaf *rb_radixtree_elem_add(rb_radixtree *dtree, const char *key, void *data);
|
||||
rb_radixtree_leaf *rb_radixtree_elem_find(rb_radixtree *dtree, const char *key, int fuzzy);
|
||||
void rb_radixtree_elem_delete(rb_radixtree *dtree, rb_radixtree_leaf *elem);
|
||||
const char *rb_radixtree_elem_get_key(rb_radixtree_leaf *elem);
|
||||
void rb_radixtree_elem_set_data(rb_radixtree_leaf *elem, void *data);
|
||||
void *rb_radixtree_elem_get_data(rb_radixtree_leaf *elem);
|
||||
|
||||
unsigned int rb_radixtree_size(struct rb_radixtree *dict);
|
||||
void rb_radixtree_stats(struct rb_radixtree *dict, void (*cb)(const char *line, void *privdata), void *privdata);
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
#include <rb_lib.h>
|
||||
#include <rb_dictionary.h>
|
||||
|
||||
struct Dictionary
|
||||
struct rb_dictionary
|
||||
{
|
||||
DCF compare_cb;
|
||||
struct DictionaryElement *root, *head, *tail;
|
||||
rb_dictionary_element *root, *head, *tail;
|
||||
unsigned int count;
|
||||
char *id;
|
||||
unsigned int dirty:1;
|
||||
|
@ -55,10 +55,10 @@ static rb_dlink_list dictionary_list = {NULL, NULL, 0};
|
|||
* - if services runs out of memory and cannot allocate the object,
|
||||
* the program will abort.
|
||||
*/
|
||||
struct Dictionary *rb_dictionary_create(const char *name,
|
||||
rb_dictionary *rb_dictionary_create(const char *name,
|
||||
DCF compare_cb)
|
||||
{
|
||||
struct Dictionary *dtree = (struct Dictionary *) rb_malloc(sizeof(struct Dictionary));
|
||||
rb_dictionary *dtree = (rb_dictionary *) rb_malloc(sizeof(rb_dictionary));
|
||||
|
||||
dtree->compare_cb = compare_cb;
|
||||
dtree->id = rb_strdup(name);
|
||||
|
@ -69,7 +69,7 @@ struct Dictionary *rb_dictionary_create(const char *name,
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_set_comparator_func(struct Dictionary *dict,
|
||||
* rb_dictionary_set_comparator_func(rb_dictionary *dict,
|
||||
* DCF compare_cb)
|
||||
*
|
||||
* Resets the comparator function used by the dictionary code for
|
||||
|
@ -85,7 +85,7 @@ struct Dictionary *rb_dictionary_create(const char *name,
|
|||
* Side Effects:
|
||||
* - the dictionary comparator function is reset.
|
||||
*/
|
||||
void rb_dictionary_set_comparator_func(struct Dictionary *dict,
|
||||
void rb_dictionary_set_comparator_func(rb_dictionary *dict,
|
||||
DCF compare_cb)
|
||||
{
|
||||
lrb_assert(dict != NULL);
|
||||
|
@ -95,7 +95,7 @@ void rb_dictionary_set_comparator_func(struct Dictionary *dict,
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_get_comparator_func(struct Dictionary *dict)
|
||||
* rb_dictionary_get_comparator_func(rb_dictionary *dict)
|
||||
*
|
||||
* Returns the current comparator function used by the dictionary.
|
||||
*
|
||||
|
@ -109,7 +109,7 @@ void rb_dictionary_set_comparator_func(struct Dictionary *dict,
|
|||
* - none
|
||||
*/
|
||||
DCF
|
||||
rb_dictionary_get_comparator_func(struct Dictionary *dict)
|
||||
rb_dictionary_get_comparator_func(rb_dictionary *dict)
|
||||
{
|
||||
lrb_assert(dict != NULL);
|
||||
|
||||
|
@ -117,7 +117,7 @@ rb_dictionary_get_comparator_func(struct Dictionary *dict)
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_get_linear_index(struct Dictionary *dict,
|
||||
* rb_dictionary_get_linear_index(rb_dictionary *dict,
|
||||
* const void *key)
|
||||
*
|
||||
* Gets a linear index number for key.
|
||||
|
@ -133,9 +133,9 @@ rb_dictionary_get_comparator_func(struct Dictionary *dict)
|
|||
* - rebuilds the linear index if the tree is marked as dirty.
|
||||
*/
|
||||
int
|
||||
rb_dictionary_get_linear_index(struct Dictionary *dict, const void *key)
|
||||
rb_dictionary_get_linear_index(rb_dictionary *dict, const void *key)
|
||||
{
|
||||
struct DictionaryElement *elem;
|
||||
rb_dictionary_element *elem;
|
||||
|
||||
lrb_assert(dict != NULL);
|
||||
lrb_assert(key != NULL);
|
||||
|
@ -148,7 +148,7 @@ rb_dictionary_get_linear_index(struct Dictionary *dict, const void *key)
|
|||
return elem->position;
|
||||
else
|
||||
{
|
||||
struct DictionaryElement *delem;
|
||||
rb_dictionary_element *delem;
|
||||
int i;
|
||||
|
||||
for (delem = dict->head, i = 0; delem != NULL; delem = delem->next, i++)
|
||||
|
@ -161,7 +161,7 @@ rb_dictionary_get_linear_index(struct Dictionary *dict, const void *key)
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_retune(struct Dictionary *dict, const void *key)
|
||||
* rb_dictionary_retune(rb_dictionary *dict, const void *key)
|
||||
*
|
||||
* Retunes the tree, self-optimizing for the element which belongs to key.
|
||||
*
|
||||
|
@ -175,9 +175,9 @@ rb_dictionary_get_linear_index(struct Dictionary *dict, const void *key)
|
|||
* - a new root node is nominated.
|
||||
*/
|
||||
static void
|
||||
rb_dictionary_retune(struct Dictionary *dict, const void *key)
|
||||
rb_dictionary_retune(rb_dictionary *dict, const void *key)
|
||||
{
|
||||
struct DictionaryElement n, *tn, *left, *right, *node;
|
||||
rb_dictionary_element n, *tn, *left, *right, *node;
|
||||
int ret;
|
||||
|
||||
lrb_assert(dict != NULL);
|
||||
|
@ -253,8 +253,8 @@ rb_dictionary_retune(struct Dictionary *dict, const void *key)
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_link(struct Dictionary *dict,
|
||||
* struct DictionaryElement *delem)
|
||||
* rb_dictionary_link(rb_dictionary *dict,
|
||||
* rb_dictionary_element *delem)
|
||||
*
|
||||
* Links a dictionary tree element to the dictionary.
|
||||
*
|
||||
|
@ -274,8 +274,8 @@ rb_dictionary_retune(struct Dictionary *dict, const void *key)
|
|||
* - a node is linked to the dictionary tree
|
||||
*/
|
||||
static void
|
||||
rb_dictionary_link(struct Dictionary *dict,
|
||||
struct DictionaryElement *delem)
|
||||
rb_dictionary_link(rb_dictionary *dict,
|
||||
rb_dictionary_element *delem)
|
||||
{
|
||||
lrb_assert(dict != NULL);
|
||||
lrb_assert(delem != NULL);
|
||||
|
@ -340,7 +340,7 @@ rb_dictionary_link(struct Dictionary *dict,
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_unlink_root(struct Dictionary *dict)
|
||||
* rb_dictionary_unlink_root(rb_dictionary *dict)
|
||||
*
|
||||
* Unlinks the root dictionary tree element from the dictionary.
|
||||
*
|
||||
|
@ -354,9 +354,9 @@ rb_dictionary_link(struct Dictionary *dict,
|
|||
* - the root node is unlinked from the dictionary tree
|
||||
*/
|
||||
static void
|
||||
rb_dictionary_unlink_root(struct Dictionary *dict)
|
||||
rb_dictionary_unlink_root(rb_dictionary *dict)
|
||||
{
|
||||
struct DictionaryElement *delem, *nextnode, *parentofnext;
|
||||
rb_dictionary_element *delem, *nextnode, *parentofnext;
|
||||
|
||||
dict->dirty = TRUE;
|
||||
|
||||
|
@ -409,7 +409,7 @@ rb_dictionary_unlink_root(struct Dictionary *dict)
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_destroy(struct Dictionary *dtree,
|
||||
* rb_dictionary_destroy(rb_dictionary *dtree,
|
||||
* void (*destroy_cb)(dictionary_elem_t *delem, void *privdata),
|
||||
* void *privdata);
|
||||
*
|
||||
|
@ -430,11 +430,11 @@ rb_dictionary_unlink_root(struct Dictionary *dict)
|
|||
* - if this is called without a callback, the objects bound to the
|
||||
* DTree will not be destroyed.
|
||||
*/
|
||||
void rb_dictionary_destroy(struct Dictionary *dtree,
|
||||
void (*destroy_cb)(struct DictionaryElement *delem, void *privdata),
|
||||
void rb_dictionary_destroy(rb_dictionary *dtree,
|
||||
void (*destroy_cb)(rb_dictionary_element *delem, void *privdata),
|
||||
void *privdata)
|
||||
{
|
||||
struct DictionaryElement *n, *tn;
|
||||
rb_dictionary_element *n, *tn;
|
||||
|
||||
lrb_assert(dtree != NULL);
|
||||
|
||||
|
@ -452,7 +452,7 @@ void rb_dictionary_destroy(struct Dictionary *dtree,
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_foreach(struct Dictionary *dtree,
|
||||
* rb_dictionary_foreach(rb_dictionary *dtree,
|
||||
* void (*destroy_cb)(dictionary_elem_t *delem, void *privdata),
|
||||
* void *privdata);
|
||||
*
|
||||
|
@ -469,18 +469,18 @@ void rb_dictionary_destroy(struct Dictionary *dtree,
|
|||
* Side Effects:
|
||||
* - on success, a dtree is iterated
|
||||
*/
|
||||
void rb_dictionary_foreach(struct Dictionary *dtree,
|
||||
int (*foreach_cb)(struct DictionaryElement *delem, void *privdata),
|
||||
void rb_dictionary_foreach(rb_dictionary *dtree,
|
||||
int (*foreach_cb)(rb_dictionary_element *delem, void *privdata),
|
||||
void *privdata)
|
||||
{
|
||||
struct DictionaryElement *n, *tn;
|
||||
rb_dictionary_element *n, *tn;
|
||||
|
||||
lrb_assert(dtree != NULL);
|
||||
|
||||
RB_DLINK_FOREACH_SAFE(n, tn, dtree->head)
|
||||
{
|
||||
/* delem_t is a subclass of node_t. */
|
||||
struct DictionaryElement *delem = (struct DictionaryElement *) n;
|
||||
rb_dictionary_element *delem = (rb_dictionary_element *) n;
|
||||
|
||||
if (foreach_cb != NULL)
|
||||
(*foreach_cb)(delem, privdata);
|
||||
|
@ -488,8 +488,8 @@ void rb_dictionary_foreach(struct Dictionary *dtree,
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_search(struct Dictionary *dtree,
|
||||
* void (*destroy_cb)(struct DictionaryElement *delem, void *privdata),
|
||||
* rb_dictionary_search(rb_dictionary *dtree,
|
||||
* void (*destroy_cb)(rb_dictionary_element *delem, void *privdata),
|
||||
* void *privdata);
|
||||
*
|
||||
* Searches all entries in a DTree using a custom callback.
|
||||
|
@ -506,11 +506,11 @@ void rb_dictionary_foreach(struct Dictionary *dtree,
|
|||
* Side Effects:
|
||||
* - a dtree is iterated until the requested conditions are met
|
||||
*/
|
||||
void *rb_dictionary_search(struct Dictionary *dtree,
|
||||
void *(*foreach_cb)(struct DictionaryElement *delem, void *privdata),
|
||||
void *rb_dictionary_search(rb_dictionary *dtree,
|
||||
void *(*foreach_cb)(rb_dictionary_element *delem, void *privdata),
|
||||
void *privdata)
|
||||
{
|
||||
struct DictionaryElement *n, *tn;
|
||||
rb_dictionary_element *n, *tn;
|
||||
void *ret = NULL;
|
||||
|
||||
lrb_assert(dtree != NULL);
|
||||
|
@ -518,7 +518,7 @@ void *rb_dictionary_search(struct Dictionary *dtree,
|
|||
RB_DLINK_FOREACH_SAFE(n, tn, dtree->head)
|
||||
{
|
||||
/* delem_t is a subclass of node_t. */
|
||||
struct DictionaryElement *delem = (struct DictionaryElement *) n;
|
||||
rb_dictionary_element *delem = (rb_dictionary_element *) n;
|
||||
|
||||
if (foreach_cb != NULL)
|
||||
ret = (*foreach_cb)(delem, privdata);
|
||||
|
@ -531,8 +531,8 @@ void *rb_dictionary_search(struct Dictionary *dtree,
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_foreach_start(struct Dictionary *dtree,
|
||||
* struct DictionaryIter *state);
|
||||
* rb_dictionary_foreach_start(rb_dictionary *dtree,
|
||||
* rb_dictionary_iter *state);
|
||||
*
|
||||
* Initializes a static DTree iterator.
|
||||
*
|
||||
|
@ -546,8 +546,8 @@ void *rb_dictionary_search(struct Dictionary *dtree,
|
|||
* Side Effects:
|
||||
* - the static iterator, &state, is initialized.
|
||||
*/
|
||||
void rb_dictionary_foreach_start(struct Dictionary *dtree,
|
||||
struct DictionaryIter *state)
|
||||
void rb_dictionary_foreach_start(rb_dictionary *dtree,
|
||||
rb_dictionary_iter *state)
|
||||
{
|
||||
lrb_assert(dtree != NULL);
|
||||
lrb_assert(state != NULL);
|
||||
|
@ -568,8 +568,8 @@ void rb_dictionary_foreach_start(struct Dictionary *dtree,
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_foreach_cur(struct Dictionary *dtree,
|
||||
* struct DictionaryIter *state);
|
||||
* rb_dictionary_foreach_cur(rb_dictionary *dtree,
|
||||
* rb_dictionary_iter *state);
|
||||
*
|
||||
* Returns the data from the current node being iterated by the
|
||||
* static iterator.
|
||||
|
@ -584,8 +584,8 @@ void rb_dictionary_foreach_start(struct Dictionary *dtree,
|
|||
* Side Effects:
|
||||
* - none
|
||||
*/
|
||||
void *rb_dictionary_foreach_cur(struct Dictionary *dtree,
|
||||
struct DictionaryIter *state)
|
||||
void *rb_dictionary_foreach_cur(rb_dictionary *dtree,
|
||||
rb_dictionary_iter *state)
|
||||
{
|
||||
lrb_assert(dtree != NULL);
|
||||
lrb_assert(state != NULL);
|
||||
|
@ -594,8 +594,8 @@ void *rb_dictionary_foreach_cur(struct Dictionary *dtree,
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_foreach_next(struct Dictionary *dtree,
|
||||
* struct DictionaryIter *state);
|
||||
* rb_dictionary_foreach_next(rb_dictionary *dtree,
|
||||
* rb_dictionary_iter *state);
|
||||
*
|
||||
* Advances a static DTree iterator.
|
||||
*
|
||||
|
@ -609,8 +609,8 @@ void *rb_dictionary_foreach_cur(struct Dictionary *dtree,
|
|||
* Side Effects:
|
||||
* - the static iterator, &state, is advanced to a new DTree node.
|
||||
*/
|
||||
void rb_dictionary_foreach_next(struct Dictionary *dtree,
|
||||
struct DictionaryIter *state)
|
||||
void rb_dictionary_foreach_next(rb_dictionary *dtree,
|
||||
rb_dictionary_iter *state)
|
||||
{
|
||||
lrb_assert(dtree != NULL);
|
||||
lrb_assert(state != NULL);
|
||||
|
@ -630,7 +630,7 @@ void rb_dictionary_foreach_next(struct Dictionary *dtree,
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_find(struct Dictionary *dtree, const void *key)
|
||||
* rb_dictionary_find(rb_dictionary *dtree, const void *key)
|
||||
*
|
||||
* Looks up a DTree node by name.
|
||||
*
|
||||
|
@ -645,7 +645,7 @@ void rb_dictionary_foreach_next(struct Dictionary *dtree,
|
|||
* Side Effects:
|
||||
* - none
|
||||
*/
|
||||
struct DictionaryElement *rb_dictionary_find(struct Dictionary *dict, const void *key)
|
||||
rb_dictionary_element *rb_dictionary_find(rb_dictionary *dict, const void *key)
|
||||
{
|
||||
lrb_assert(dict != NULL);
|
||||
lrb_assert(key != NULL);
|
||||
|
@ -660,7 +660,7 @@ struct DictionaryElement *rb_dictionary_find(struct Dictionary *dict, const void
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_add(struct Dictionary *dtree, const void *key, void *data)
|
||||
* rb_dictionary_add(rb_dictionary *dtree, const void *key, void *data)
|
||||
*
|
||||
* Creates a new DTree node and binds data to it.
|
||||
*
|
||||
|
@ -676,9 +676,9 @@ struct DictionaryElement *rb_dictionary_find(struct Dictionary *dict, const void
|
|||
* Side Effects:
|
||||
* - data is inserted into the DTree.
|
||||
*/
|
||||
struct DictionaryElement *rb_dictionary_add(struct Dictionary *dict, const void *key, void *data)
|
||||
rb_dictionary_element *rb_dictionary_add(rb_dictionary *dict, const void *key, void *data)
|
||||
{
|
||||
struct DictionaryElement *delem;
|
||||
rb_dictionary_element *delem;
|
||||
|
||||
lrb_assert(dict != NULL);
|
||||
lrb_assert(key != NULL);
|
||||
|
@ -695,7 +695,7 @@ struct DictionaryElement *rb_dictionary_add(struct Dictionary *dict, const void
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_delete(struct Dictionary *dtree, const void *key)
|
||||
* rb_dictionary_delete(rb_dictionary *dtree, const void *key)
|
||||
*
|
||||
* Deletes data from a dictionary tree.
|
||||
*
|
||||
|
@ -713,9 +713,9 @@ struct DictionaryElement *rb_dictionary_add(struct Dictionary *dict, const void
|
|||
* Notes:
|
||||
* - the returned data needs to be mowgli_freed/released manually!
|
||||
*/
|
||||
void *rb_dictionary_delete(struct Dictionary *dtree, const void *key)
|
||||
void *rb_dictionary_delete(rb_dictionary *dtree, const void *key)
|
||||
{
|
||||
struct DictionaryElement *delem = rb_dictionary_find(dtree, key);
|
||||
rb_dictionary_element *delem = rb_dictionary_find(dtree, key);
|
||||
void *data;
|
||||
|
||||
if (delem == NULL)
|
||||
|
@ -730,7 +730,7 @@ void *rb_dictionary_delete(struct Dictionary *dtree, const void *key)
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_retrieve(struct Dictionary *dtree, const void *key)
|
||||
* rb_dictionary_retrieve(rb_dictionary *dtree, const void *key)
|
||||
*
|
||||
* Retrieves data from a dictionary.
|
||||
*
|
||||
|
@ -745,9 +745,9 @@ void *rb_dictionary_delete(struct Dictionary *dtree, const void *key)
|
|||
* Side Effects:
|
||||
* - none
|
||||
*/
|
||||
void *rb_dictionary_retrieve(struct Dictionary *dtree, const void *key)
|
||||
void *rb_dictionary_retrieve(rb_dictionary *dtree, const void *key)
|
||||
{
|
||||
struct DictionaryElement *delem = rb_dictionary_find(dtree, key);
|
||||
rb_dictionary_element *delem = rb_dictionary_find(dtree, key);
|
||||
|
||||
if (delem != NULL)
|
||||
return delem->data;
|
||||
|
@ -756,7 +756,7 @@ void *rb_dictionary_retrieve(struct Dictionary *dtree, const void *key)
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_size(struct Dictionary *dict)
|
||||
* rb_dictionary_size(rb_dictionary *dict)
|
||||
*
|
||||
* Returns the size of a dictionary.
|
||||
*
|
||||
|
@ -769,7 +769,7 @@ void *rb_dictionary_retrieve(struct Dictionary *dtree, const void *key)
|
|||
* Side Effects:
|
||||
* - none
|
||||
*/
|
||||
unsigned int rb_dictionary_size(struct Dictionary *dict)
|
||||
unsigned int rb_dictionary_size(rb_dictionary *dict)
|
||||
{
|
||||
lrb_assert(dict != NULL);
|
||||
|
||||
|
@ -778,7 +778,7 @@ unsigned int rb_dictionary_size(struct Dictionary *dict)
|
|||
|
||||
/* returns the sum of the depths of the subtree rooted in delem at depth depth */
|
||||
static int
|
||||
stats_recurse(struct DictionaryElement *delem, int depth, int *pmaxdepth)
|
||||
stats_recurse(rb_dictionary_element *delem, int depth, int *pmaxdepth)
|
||||
{
|
||||
int result;
|
||||
|
||||
|
@ -793,7 +793,7 @@ stats_recurse(struct DictionaryElement *delem, int depth, int *pmaxdepth)
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_dictionary_stats(struct Dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata)
|
||||
* rb_dictionary_stats(rb_dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata)
|
||||
*
|
||||
* Returns the size of a dictionary.
|
||||
*
|
||||
|
@ -808,7 +808,7 @@ stats_recurse(struct DictionaryElement *delem, int depth, int *pmaxdepth)
|
|||
* Side Effects:
|
||||
* - callback called with stats text
|
||||
*/
|
||||
void rb_dictionary_stats(struct Dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata)
|
||||
void rb_dictionary_stats(rb_dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata)
|
||||
{
|
||||
char str[256];
|
||||
int sum, maxdepth;
|
||||
|
|
|
@ -53,11 +53,15 @@ rb_dlink_list radixtree_list = {NULL, NULL, 0};
|
|||
*/
|
||||
|
||||
union rb_radixtree_elem;
|
||||
typedef union rb_radixtree_elem rb_radixtree_elem;
|
||||
|
||||
/* Other typedefs are in rb_radixtree.h */
|
||||
typedef struct rb_radixtree_node rb_radixtree_node;
|
||||
|
||||
struct rb_radixtree
|
||||
{
|
||||
void (*canonize_cb)(char *key);
|
||||
union rb_radixtree_elem *root;
|
||||
rb_radixtree_elem *root;
|
||||
|
||||
unsigned int count;
|
||||
char *id;
|
||||
|
@ -74,8 +78,8 @@ struct rb_radixtree_node
|
|||
int nibnum;
|
||||
|
||||
/* branches of the tree */
|
||||
union rb_radixtree_elem *down[POINTERS_PER_NODE];
|
||||
union rb_radixtree_elem *parent;
|
||||
rb_radixtree_elem *down[POINTERS_PER_NODE];
|
||||
rb_radixtree_elem *parent;
|
||||
|
||||
char parent_val;
|
||||
};
|
||||
|
@ -90,7 +94,7 @@ struct rb_radixtree_leaf
|
|||
|
||||
/* key (canonized copy) */
|
||||
char *key;
|
||||
union rb_radixtree_elem *parent;
|
||||
rb_radixtree_elem *parent;
|
||||
|
||||
char parent_val;
|
||||
};
|
||||
|
@ -98,9 +102,9 @@ struct rb_radixtree_leaf
|
|||
union rb_radixtree_elem
|
||||
{
|
||||
int nibnum;
|
||||
struct rb_radixtree_node node;
|
||||
rb_radixtree_node node;
|
||||
|
||||
struct rb_radixtree_leaf leaf;
|
||||
rb_radixtree_leaf leaf;
|
||||
};
|
||||
|
||||
#define IS_LEAF(elem) ((elem)->nibnum == -1)
|
||||
|
@ -123,8 +127,8 @@ union rb_radixtree_elem
|
|||
* Side Effects:
|
||||
* - none
|
||||
*/
|
||||
static union rb_radixtree_elem *
|
||||
first_leaf(union rb_radixtree_elem *delem)
|
||||
static rb_radixtree_elem *
|
||||
first_leaf(rb_radixtree_elem *delem)
|
||||
{
|
||||
int val;
|
||||
|
||||
|
@ -160,10 +164,10 @@ first_leaf(union rb_radixtree_elem *delem)
|
|||
* - if services runs out of memory and cannot allocate the object,
|
||||
* the program will abort.
|
||||
*/
|
||||
struct rb_radixtree *
|
||||
rb_radixtree *
|
||||
rb_radixtree_create(const char *name, void (*canonize_cb)(char *key))
|
||||
{
|
||||
struct rb_radixtree *dtree = (struct rb_radixtree *) rb_malloc(sizeof(struct rb_radixtree));
|
||||
rb_radixtree *dtree = (rb_radixtree *) rb_malloc(sizeof(rb_radixtree));
|
||||
|
||||
dtree->canonize_cb = canonize_cb;
|
||||
dtree->id = rb_strdup(name);
|
||||
|
@ -175,7 +179,7 @@ rb_radixtree_create(const char *name, void (*canonize_cb)(char *key))
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_radixtree_destroy(struct rb_radixtree *dtree,
|
||||
* rb_radixtree_destroy(rb_radixtree *dtree,
|
||||
* void (*destroy_cb)(const char *key, void *data, void *privdata),
|
||||
* void *privdata);
|
||||
*
|
||||
|
@ -197,10 +201,10 @@ rb_radixtree_create(const char *name, void (*canonize_cb)(char *key))
|
|||
* DTree will not be destroyed.
|
||||
*/
|
||||
void
|
||||
rb_radixtree_destroy(struct rb_radixtree *dtree, void (*destroy_cb)(const char *key, void *data, void *privdata), void *privdata)
|
||||
rb_radixtree_destroy(rb_radixtree *dtree, void (*destroy_cb)(const char *key, void *data, void *privdata), void *privdata)
|
||||
{
|
||||
struct rb_radixtree_iteration_state state;
|
||||
union rb_radixtree_elem *delem;
|
||||
rb_radixtree_iteration_state state;
|
||||
rb_radixtree_elem *delem;
|
||||
|
||||
void *entry;
|
||||
|
||||
|
@ -223,7 +227,7 @@ rb_radixtree_destroy(struct rb_radixtree *dtree, void (*destroy_cb)(const char *
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_radixtree_foreach(struct rb_radixtree *dtree,
|
||||
* rb_radixtree_foreach(rb_radixtree *dtree,
|
||||
* int (*foreach_cb)(const char *key, void *data, void *privdata),
|
||||
* void *privdata);
|
||||
*
|
||||
|
@ -241,9 +245,9 @@ rb_radixtree_destroy(struct rb_radixtree *dtree, void (*destroy_cb)(const char *
|
|||
* - on success, a dtree is iterated
|
||||
*/
|
||||
void
|
||||
rb_radixtree_foreach(struct rb_radixtree *dtree, int (*foreach_cb)(const char *key, void *data, void *privdata), void *privdata)
|
||||
rb_radixtree_foreach(rb_radixtree *dtree, int (*foreach_cb)(const char *key, void *data, void *privdata), void *privdata)
|
||||
{
|
||||
union rb_radixtree_elem *delem, *next;
|
||||
rb_radixtree_elem *delem, *next;
|
||||
|
||||
int val;
|
||||
|
||||
|
@ -299,7 +303,7 @@ rb_radixtree_foreach(struct rb_radixtree *dtree, int (*foreach_cb)(const char *k
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_radixtree_search(struct rb_radixtree *dtree,
|
||||
* rb_radixtree_search(rb_radixtree *dtree,
|
||||
* void *(*foreach_cb)(const char *key, void *data, void *privdata),
|
||||
* void *privdata);
|
||||
*
|
||||
|
@ -318,9 +322,9 @@ rb_radixtree_foreach(struct rb_radixtree *dtree, int (*foreach_cb)(const char *k
|
|||
* - a dtree is iterated until the requested conditions are met
|
||||
*/
|
||||
void *
|
||||
rb_radixtree_search(struct rb_radixtree *dtree, void *(*foreach_cb)(const char *key, void *data, void *privdata), void *privdata)
|
||||
rb_radixtree_search(rb_radixtree *dtree, void *(*foreach_cb)(const char *key, void *data, void *privdata), void *privdata)
|
||||
{
|
||||
union rb_radixtree_elem *delem, *next;
|
||||
rb_radixtree_elem *delem, *next;
|
||||
|
||||
int val;
|
||||
void *ret = NULL;
|
||||
|
@ -382,8 +386,8 @@ rb_radixtree_search(struct rb_radixtree *dtree, void *(*foreach_cb)(const char *
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_radixtree_foreach_start(struct rb_radixtree *dtree,
|
||||
* struct rb_radixtree_iteration_state *state);
|
||||
* rb_radixtree_foreach_start(rb_radixtree *dtree,
|
||||
* rb_radixtree_iteration_state *state);
|
||||
*
|
||||
* Initializes a static DTree iterator.
|
||||
*
|
||||
|
@ -398,7 +402,7 @@ rb_radixtree_search(struct rb_radixtree *dtree, void *(*foreach_cb)(const char *
|
|||
* - the static iterator, &state, is initialized.
|
||||
*/
|
||||
void
|
||||
rb_radixtree_foreach_start(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state)
|
||||
rb_radixtree_foreach_start(rb_radixtree *dtree, rb_radixtree_iteration_state *state)
|
||||
{
|
||||
if (dtree == NULL)
|
||||
return;
|
||||
|
@ -421,8 +425,8 @@ rb_radixtree_foreach_start(struct rb_radixtree *dtree, struct rb_radixtree_itera
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_radixtree_foreach_cur(struct rb_radixtree *dtree,
|
||||
* struct rb_radixtree_iteration_state *state);
|
||||
* rb_radixtree_foreach_cur(rb_radixtree *dtree,
|
||||
* rb_radixtree_iteration_state *state);
|
||||
*
|
||||
* Returns the data from the current node being iterated by the
|
||||
* static iterator.
|
||||
|
@ -438,7 +442,7 @@ rb_radixtree_foreach_start(struct rb_radixtree *dtree, struct rb_radixtree_itera
|
|||
* - none
|
||||
*/
|
||||
void *
|
||||
rb_radixtree_foreach_cur(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state)
|
||||
rb_radixtree_foreach_cur(rb_radixtree *dtree, rb_radixtree_iteration_state *state)
|
||||
{
|
||||
if (dtree == NULL)
|
||||
return NULL;
|
||||
|
@ -446,12 +450,12 @@ rb_radixtree_foreach_cur(struct rb_radixtree *dtree, struct rb_radixtree_iterati
|
|||
lrb_assert(state != NULL);
|
||||
|
||||
return STATE_CUR(state) != NULL ?
|
||||
((struct rb_radixtree_leaf *) STATE_CUR(state))->data : NULL;
|
||||
((rb_radixtree_leaf *) STATE_CUR(state))->data : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* rb_radixtree_foreach_next(struct rb_radixtree *dtree,
|
||||
* struct rb_radixtree_iteration_state *state);
|
||||
* rb_radixtree_foreach_next(rb_radixtree *dtree,
|
||||
* rb_radixtree_iteration_state *state);
|
||||
*
|
||||
* Advances a static DTree iterator.
|
||||
*
|
||||
|
@ -466,11 +470,11 @@ rb_radixtree_foreach_cur(struct rb_radixtree *dtree, struct rb_radixtree_iterati
|
|||
* - the static iterator, &state, is advanced to a new DTree node.
|
||||
*/
|
||||
void
|
||||
rb_radixtree_foreach_next(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state)
|
||||
rb_radixtree_foreach_next(rb_radixtree *dtree, rb_radixtree_iteration_state *state)
|
||||
{
|
||||
struct rb_radixtree_leaf *leaf;
|
||||
rb_radixtree_leaf *leaf;
|
||||
|
||||
union rb_radixtree_elem *delem, *next;
|
||||
rb_radixtree_elem *delem, *next;
|
||||
|
||||
int val;
|
||||
|
||||
|
@ -537,7 +541,7 @@ rb_radixtree_foreach_next(struct rb_radixtree *dtree, struct rb_radixtree_iterat
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_radixtree_elem_find(struct rb_radixtree *dtree, const char *key)
|
||||
* rb_radixtree_elem_find(rb_radixtree *dtree, const char *key)
|
||||
*
|
||||
* Looks up a DTree node by name.
|
||||
*
|
||||
|
@ -553,14 +557,14 @@ rb_radixtree_foreach_next(struct rb_radixtree *dtree, struct rb_radixtree_iterat
|
|||
* Side Effects:
|
||||
* - none
|
||||
*/
|
||||
struct rb_radixtree_leaf *
|
||||
rb_radixtree_elem_find(struct rb_radixtree *dict, const char *key, int fuzzy)
|
||||
rb_radixtree_leaf *
|
||||
rb_radixtree_elem_find(rb_radixtree *dict, const char *key, int fuzzy)
|
||||
{
|
||||
char ckey_store[256];
|
||||
|
||||
char *ckey_buf = NULL;
|
||||
const char *ckey;
|
||||
union rb_radixtree_elem *delem;
|
||||
rb_radixtree_elem *delem;
|
||||
|
||||
int val, keylen;
|
||||
|
||||
|
@ -612,7 +616,7 @@ rb_radixtree_elem_find(struct rb_radixtree *dict, const char *key, int fuzzy)
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_radixtree_foreach_start_from(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state, const char *key)
|
||||
* rb_radixtree_foreach_start_from(rb_radixtree *dtree, rb_radixtree_iteration_state *state, const char *key)
|
||||
*
|
||||
* Starts iteration from a specified key, by wrapping rb_radixtree_elem_find().
|
||||
*
|
||||
|
@ -628,7 +632,7 @@ rb_radixtree_elem_find(struct rb_radixtree *dict, const char *key, int fuzzy)
|
|||
* - the iterator's state is initialized at a specific point
|
||||
*/
|
||||
void
|
||||
rb_radixtree_foreach_start_from(struct rb_radixtree *dtree, struct rb_radixtree_iteration_state *state, const char *key)
|
||||
rb_radixtree_foreach_start_from(rb_radixtree *dtree, rb_radixtree_iteration_state *state, const char *key)
|
||||
{
|
||||
lrb_assert(dtree != NULL);
|
||||
lrb_assert(state != NULL);
|
||||
|
@ -647,7 +651,7 @@ rb_radixtree_foreach_start_from(struct rb_radixtree *dtree, struct rb_radixtree_
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_radixtree_add(struct rb_radixtree *dtree, const char *key, void *data)
|
||||
* rb_radixtree_add(rb_radixtree *dtree, const char *key, void *data)
|
||||
*
|
||||
* Creates a new DTree node and binds data to it.
|
||||
*
|
||||
|
@ -663,14 +667,14 @@ rb_radixtree_foreach_start_from(struct rb_radixtree *dtree, struct rb_radixtree_
|
|||
* Side Effects:
|
||||
* - data is inserted into the DTree.
|
||||
*/
|
||||
struct rb_radixtree_leaf *
|
||||
rb_radixtree_elem_add(struct rb_radixtree *dict, const char *key, void *data)
|
||||
rb_radixtree_leaf *
|
||||
rb_radixtree_elem_add(rb_radixtree *dict, const char *key, void *data)
|
||||
{
|
||||
char *ckey;
|
||||
|
||||
union rb_radixtree_elem *delem, *prev, *newnode;
|
||||
rb_radixtree_elem *delem, *prev, *newnode;
|
||||
|
||||
union rb_radixtree_elem **place1;
|
||||
rb_radixtree_elem **place1;
|
||||
|
||||
int val, keylen;
|
||||
int i, j;
|
||||
|
@ -720,7 +724,7 @@ rb_radixtree_elem_add(struct rb_radixtree *dict, const char *key, void *data)
|
|||
lrb_assert(prev == NULL);
|
||||
lrb_assert(dict->count == 0);
|
||||
place1 = &dict->root;
|
||||
*place1 = rb_malloc(sizeof(struct rb_radixtree_leaf));
|
||||
*place1 = rb_malloc(sizeof(rb_radixtree_leaf));
|
||||
lrb_assert(*place1 != NULL);
|
||||
(*place1)->nibnum = -1;
|
||||
(*place1)->leaf.data = data;
|
||||
|
@ -745,7 +749,7 @@ rb_radixtree_elem_add(struct rb_radixtree *dict, const char *key, void *data)
|
|||
if ((prev == NULL) || (prev->nibnum < i))
|
||||
{
|
||||
/* Insert new node below prev */
|
||||
newnode = rb_malloc(sizeof(struct rb_radixtree_node));
|
||||
newnode = rb_malloc(sizeof(rb_radixtree_node));
|
||||
lrb_assert(newnode != NULL);
|
||||
newnode->nibnum = i;
|
||||
newnode->node.parent = prev;
|
||||
|
@ -800,7 +804,7 @@ rb_radixtree_elem_add(struct rb_radixtree *dict, const char *key, void *data)
|
|||
val = NIBBLE_VAL(ckey, i);
|
||||
place1 = &newnode->node.down[val];
|
||||
lrb_assert(*place1 == NULL);
|
||||
*place1 = rb_malloc(sizeof(struct rb_radixtree_leaf));
|
||||
*place1 = rb_malloc(sizeof(rb_radixtree_leaf));
|
||||
lrb_assert(*place1 != NULL);
|
||||
(*place1)->nibnum = -1;
|
||||
(*place1)->leaf.data = data;
|
||||
|
@ -812,13 +816,13 @@ rb_radixtree_elem_add(struct rb_radixtree *dict, const char *key, void *data)
|
|||
}
|
||||
|
||||
int
|
||||
rb_radixtree_add(struct rb_radixtree *dict, const char *key, void *data)
|
||||
rb_radixtree_add(rb_radixtree *dict, const char *key, void *data)
|
||||
{
|
||||
return (rb_radixtree_elem_add(dict, key, data) != NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* rb_radixtree_delete(struct rb_radixtree *dtree, const char *key)
|
||||
* rb_radixtree_delete(rb_radixtree *dtree, const char *key)
|
||||
*
|
||||
* Deletes data from a patricia tree.
|
||||
*
|
||||
|
@ -837,10 +841,10 @@ rb_radixtree_add(struct rb_radixtree *dict, const char *key, void *data)
|
|||
* - the returned data needs to be rb_freed/released manually!
|
||||
*/
|
||||
void *
|
||||
rb_radixtree_delete(struct rb_radixtree *dict, const char *key)
|
||||
rb_radixtree_delete(rb_radixtree *dict, const char *key)
|
||||
{
|
||||
void *data;
|
||||
struct rb_radixtree_leaf *leaf;
|
||||
rb_radixtree_leaf *leaf;
|
||||
|
||||
leaf = rb_radixtree_elem_find(dict, key, 0);
|
||||
|
||||
|
@ -853,16 +857,16 @@ rb_radixtree_delete(struct rb_radixtree *dict, const char *key)
|
|||
}
|
||||
|
||||
void
|
||||
rb_radixtree_elem_delete(struct rb_radixtree *dict, struct rb_radixtree_leaf *leaf)
|
||||
rb_radixtree_elem_delete(rb_radixtree *dict, rb_radixtree_leaf *leaf)
|
||||
{
|
||||
union rb_radixtree_elem *delem, *prev, *next;
|
||||
rb_radixtree_elem *delem, *prev, *next;
|
||||
|
||||
int val, i, used;
|
||||
|
||||
lrb_assert(dict != NULL);
|
||||
lrb_assert(leaf != NULL);
|
||||
|
||||
delem = (union rb_radixtree_elem *) leaf;
|
||||
delem = (rb_radixtree_elem *) leaf;
|
||||
|
||||
val = delem->leaf.parent_val;
|
||||
prev = delem->leaf.parent;
|
||||
|
@ -924,7 +928,7 @@ rb_radixtree_elem_delete(struct rb_radixtree *dict, struct rb_radixtree_leaf *le
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_radixtree_retrieve(struct rb_radixtree *dtree, const char *key)
|
||||
* rb_radixtree_retrieve(rb_radixtree *dtree, const char *key)
|
||||
*
|
||||
* Retrieves data from a patricia.
|
||||
*
|
||||
|
@ -940,9 +944,9 @@ rb_radixtree_elem_delete(struct rb_radixtree *dict, struct rb_radixtree_leaf *le
|
|||
* - none
|
||||
*/
|
||||
void *
|
||||
rb_radixtree_retrieve(struct rb_radixtree *dtree, const char *key)
|
||||
rb_radixtree_retrieve(rb_radixtree *dtree, const char *key)
|
||||
{
|
||||
struct rb_radixtree_leaf *delem = rb_radixtree_elem_find(dtree, key, 0);
|
||||
rb_radixtree_leaf *delem = rb_radixtree_elem_find(dtree, key, 0);
|
||||
|
||||
if (delem != NULL)
|
||||
return delem->data;
|
||||
|
@ -951,7 +955,7 @@ rb_radixtree_retrieve(struct rb_radixtree *dtree, const char *key)
|
|||
}
|
||||
|
||||
const char *
|
||||
rb_radixtree_elem_get_key(struct rb_radixtree_leaf *leaf)
|
||||
rb_radixtree_elem_get_key(rb_radixtree_leaf *leaf)
|
||||
{
|
||||
lrb_assert(leaf != NULL);
|
||||
|
||||
|
@ -959,7 +963,7 @@ rb_radixtree_elem_get_key(struct rb_radixtree_leaf *leaf)
|
|||
}
|
||||
|
||||
void
|
||||
rb_radixtree_elem_set_data(struct rb_radixtree_leaf *leaf, void *data)
|
||||
rb_radixtree_elem_set_data(rb_radixtree_leaf *leaf, void *data)
|
||||
{
|
||||
lrb_assert(leaf != NULL);
|
||||
|
||||
|
@ -967,7 +971,7 @@ rb_radixtree_elem_set_data(struct rb_radixtree_leaf *leaf, void *data)
|
|||
}
|
||||
|
||||
void *
|
||||
rb_radixtree_elem_get_data(struct rb_radixtree_leaf *leaf)
|
||||
rb_radixtree_elem_get_data(rb_radixtree_leaf *leaf)
|
||||
{
|
||||
lrb_assert(leaf != NULL);
|
||||
|
||||
|
@ -975,7 +979,7 @@ rb_radixtree_elem_get_data(struct rb_radixtree_leaf *leaf)
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_radixtree_size(struct rb_radixtree *dict)
|
||||
* rb_radixtree_size(rb_radixtree *dict)
|
||||
*
|
||||
* Returns the size of a patricia.
|
||||
*
|
||||
|
@ -989,7 +993,7 @@ rb_radixtree_elem_get_data(struct rb_radixtree_leaf *leaf)
|
|||
* - none
|
||||
*/
|
||||
unsigned int
|
||||
rb_radixtree_size(struct rb_radixtree *dict)
|
||||
rb_radixtree_size(rb_radixtree *dict)
|
||||
{
|
||||
lrb_assert(dict != NULL);
|
||||
|
||||
|
@ -999,11 +1003,11 @@ rb_radixtree_size(struct rb_radixtree *dict)
|
|||
/* returns the sum of the depths of the subtree rooted in delem at depth depth */
|
||||
/* there is no need for this to be recursive, but it is easier... */
|
||||
static int
|
||||
stats_recurse(union rb_radixtree_elem *delem, int depth, int *pmaxdepth)
|
||||
stats_recurse(rb_radixtree_elem *delem, int depth, int *pmaxdepth)
|
||||
{
|
||||
int result = 0;
|
||||
int val;
|
||||
union rb_radixtree_elem *next;
|
||||
rb_radixtree_elem *next;
|
||||
|
||||
if (depth > *pmaxdepth)
|
||||
*pmaxdepth = depth;
|
||||
|
@ -1046,7 +1050,7 @@ stats_recurse(union rb_radixtree_elem *delem, int depth, int *pmaxdepth)
|
|||
}
|
||||
|
||||
/*
|
||||
* rb_radixtree_stats(struct rb_radixtree *dict, void (*cb)(const char *line, void *privdata), void *privdata)
|
||||
* rb_radixtree_stats(rb_radixtree *dict, void (*cb)(const char *line, void *privdata), void *privdata)
|
||||
*
|
||||
* Returns the size of a patricia.
|
||||
*
|
||||
|
@ -1062,7 +1066,7 @@ stats_recurse(union rb_radixtree_elem *delem, int depth, int *pmaxdepth)
|
|||
* - callback called with stats text
|
||||
*/
|
||||
void
|
||||
rb_radixtree_stats(struct rb_radixtree *dict, void (*cb)(const char *line, void *privdata), void *privdata)
|
||||
rb_radixtree_stats(rb_radixtree *dict, void (*cb)(const char *line, void *privdata), void *privdata)
|
||||
{
|
||||
char str[256];
|
||||
int sum, maxdepth;
|
||||
|
|
|
@ -157,7 +157,7 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags)
|
|||
int buflen = 0;
|
||||
int mlen;
|
||||
struct CapabilityEntry *entry;
|
||||
struct DictionaryIter iter;
|
||||
rb_dictionary_iter iter;
|
||||
|
||||
mlen = snprintf(buf, sizeof buf, ":%s CAP %s %s",
|
||||
me.name,
|
||||
|
@ -171,7 +171,7 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags)
|
|||
return;
|
||||
}
|
||||
|
||||
DICTIONARY_FOREACH(entry, &iter, cli_capindex->cap_dict)
|
||||
RB_DICTIONARY_FOREACH(entry, &iter, cli_capindex->cap_dict)
|
||||
{
|
||||
size_t caplen = 0;
|
||||
struct ClientCapability *clicap = entry->ownerdata;
|
||||
|
|
|
@ -471,7 +471,7 @@ static void safelist_one_channel(struct Client *source_p, struct Channel *chptr,
|
|||
static void safelist_iterate_client(struct Client *source_p)
|
||||
{
|
||||
struct Channel *chptr;
|
||||
struct rb_radixtree_iteration_state iter;
|
||||
rb_radixtree_iteration_state iter;
|
||||
|
||||
RB_RADIXTREE_FOREACH_FROM(chptr, &iter, channel_tree, source_p->localClient->safelist_data->chname)
|
||||
{
|
||||
|
|
|
@ -157,7 +157,7 @@ flattened_map(struct Client *client_p)
|
|||
rb_dlink_node *ptr;
|
||||
struct Client *target_p;
|
||||
int i, len;
|
||||
int cnt = 0;
|
||||
unsigned long cnt = 0;
|
||||
|
||||
/* First display me as the root */
|
||||
rb_strlcpy(buf, me.name, BUFSIZE);
|
||||
|
|
|
@ -73,7 +73,7 @@ rehash_bans_loc(struct Client *source_p)
|
|||
if (!MyConnect(source_p))
|
||||
remote_rehash_oper_p = source_p;
|
||||
|
||||
rehash_bans(0);
|
||||
rehash_bans();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -197,7 +197,7 @@ static void
|
|||
rehash_tresvs(struct Client *source_p)
|
||||
{
|
||||
struct ConfItem *aconf;
|
||||
struct rb_radixtree_iteration_state iter;
|
||||
rb_radixtree_iteration_state iter;
|
||||
rb_dlink_node *ptr;
|
||||
rb_dlink_node *next_ptr;
|
||||
|
||||
|
|
|
@ -285,9 +285,9 @@ static void
|
|||
stats_delay(struct Client *source_p)
|
||||
{
|
||||
struct nd_entry *nd;
|
||||
struct DictionaryIter iter;
|
||||
rb_dictionary_iter iter;
|
||||
|
||||
DICTIONARY_FOREACH(nd, &iter, nd_dict)
|
||||
RB_DICTIONARY_FOREACH(nd, &iter, nd_dict)
|
||||
{
|
||||
sendto_one_notice(source_p, ":Delaying: %s for %ld",
|
||||
nd->name, (long) nd->expire);
|
||||
|
@ -734,11 +734,11 @@ stats_klines(struct Client *source_p)
|
|||
static void
|
||||
stats_messages(struct Client *source_p)
|
||||
{
|
||||
struct DictionaryIter iter;
|
||||
rb_dictionary_iter iter;
|
||||
struct Message *msg;
|
||||
struct alias_entry *amsg;
|
||||
|
||||
DICTIONARY_FOREACH(msg, &iter, cmd_dict)
|
||||
RB_DICTIONARY_FOREACH(msg, &iter, cmd_dict)
|
||||
{
|
||||
s_assert(msg->cmd != NULL);
|
||||
sendto_one_numeric(source_p, RPL_STATSCOMMANDS,
|
||||
|
@ -747,7 +747,7 @@ stats_messages(struct Client *source_p)
|
|||
msg->bytes, msg->rcount);
|
||||
}
|
||||
|
||||
DICTIONARY_FOREACH(amsg, &iter, alias_dict)
|
||||
RB_DICTIONARY_FOREACH(amsg, &iter, alias_dict)
|
||||
{
|
||||
s_assert(amsg->name != NULL);
|
||||
sendto_one_numeric(source_p, RPL_STATSCOMMANDS,
|
||||
|
@ -870,7 +870,7 @@ static void
|
|||
stats_tresv(struct Client *source_p)
|
||||
{
|
||||
struct ConfItem *aconf;
|
||||
struct rb_radixtree_iteration_state state;
|
||||
rb_radixtree_iteration_state state;
|
||||
rb_dlink_node *ptr;
|
||||
|
||||
RB_DLINK_FOREACH(ptr, resv_conf_list.head)
|
||||
|
@ -896,7 +896,7 @@ static void
|
|||
stats_resv(struct Client *source_p)
|
||||
{
|
||||
struct ConfItem *aconf;
|
||||
struct rb_radixtree_iteration_state state;
|
||||
rb_radixtree_iteration_state state;
|
||||
rb_dlink_node *ptr;
|
||||
|
||||
RB_DLINK_FOREACH(ptr, resv_conf_list.head)
|
||||
|
|
Loading…
Reference in a new issue