0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

Change struct Dictionary(*) to rb_dictionary(_\1).

This cleans things up a slightly and puts the dictionary stuff in its
own namespace.
This commit is contained in:
Elizabeth Myers 2016-03-23 08:09:58 -05:00
parent 2ac4ba969b
commit 4177311e6e
15 changed files with 129 additions and 121 deletions

View file

@ -1,6 +1,8 @@
#ifndef INCLUDED_CACHE_H #ifndef INCLUDED_CACHE_H
#define INCLUDED_CACHE_H #define INCLUDED_CACHE_H
#include "rb_dictionary.h"
#define HELP_MAX 100 #define HELP_MAX 100
#define CACHEFILELEN 30 #define CACHEFILELEN 30
@ -43,8 +45,7 @@ void send_user_motd(struct Client *);
void send_oper_motd(struct Client *); void send_oper_motd(struct Client *);
void cache_user_motd(void); void cache_user_motd(void);
struct Dictionary; extern rb_dictionary *help_dict_oper;
extern struct Dictionary *help_dict_oper; extern rb_dictionary *help_dict_user;
extern struct Dictionary *help_dict_user;
#endif #endif

View file

@ -21,9 +21,12 @@
#ifndef __CAPABILITY_H__ #ifndef __CAPABILITY_H__
#define __CAPABILITY_H__ #define __CAPABILITY_H__
#include "stdinc.h"
#include "rb_dictionary.h"
struct CapabilityIndex { struct CapabilityIndex {
const char *name; const char *name;
struct Dictionary *cap_dict; rb_dictionary *cap_dict;
unsigned int highest_bit; unsigned int highest_bit;
rb_dlink_node node; rb_dlink_node node;
}; };

View file

@ -25,10 +25,10 @@
#ifndef INCLUDED_hash_h #ifndef INCLUDED_hash_h
#define INCLUDED_hash_h #define INCLUDED_hash_h
struct Dictionary; #include "rb_dictionary.h"
struct rb_radixtree; #include "rb_radixtree.h"
extern struct Dictionary *nd_dict; extern rb_dictionary *nd_dict;
extern struct rb_radixtree *resv_tree; extern struct rb_radixtree *resv_tree;
extern struct rb_radixtree *channel_tree; extern struct rb_radixtree *channel_tree;

View file

@ -39,7 +39,7 @@ extern void mod_add_cmd(struct Message *msg);
extern void mod_del_cmd(struct Message *msg); extern void mod_del_cmd(struct Message *msg);
extern char *reconstruct_parv(int parc, const char *parv[]); extern char *reconstruct_parv(int parc, const char *parv[]);
extern struct Dictionary *alias_dict; extern rb_dictionary *alias_dict;
extern struct Dictionary *cmd_dict; extern rb_dictionary *cmd_dict;
#endif /* INCLUDED_parse_h_h */ #endif /* INCLUDED_parse_h_h */

View file

@ -47,8 +47,8 @@ struct cacheline *emptyline = NULL;
rb_dlink_list links_cache_list; rb_dlink_list links_cache_list;
char user_motd_changed[MAX_DATE_STRING]; char user_motd_changed[MAX_DATE_STRING];
struct Dictionary *help_dict_oper = NULL; rb_dictionary *help_dict_oper = NULL;
struct Dictionary *help_dict_user = NULL; rb_dictionary *help_dict_user = NULL;
/* init_cache() /* init_cache()
* *
@ -237,7 +237,7 @@ load_help(void)
struct dirent *ldirent= NULL; struct dirent *ldirent= NULL;
char filename[PATH_MAX]; char filename[PATH_MAX];
struct cachefile *cacheptr; struct cachefile *cacheptr;
struct DictionaryIter iter; rb_dictionary_iter iter;
#if defined(S_ISLNK) && defined(HAVE_LSTAT) #if defined(S_ISLNK) && defined(HAVE_LSTAT)
struct stat sb; struct stat sb;

View file

@ -129,7 +129,7 @@ capability_require(struct CapabilityIndex *idx, const char *cap)
} }
static void static void
capability_destroy(struct DictionaryElement *delem, void *privdata) capability_destroy(rb_dictionary_element *delem, void *privdata)
{ {
s_assert(delem != NULL); s_assert(delem != NULL);
@ -165,7 +165,7 @@ capability_index_destroy(struct CapabilityIndex *idx)
const char * const char *
capability_index_list(struct CapabilityIndex *idx, unsigned int cap_mask) capability_index_list(struct CapabilityIndex *idx, unsigned int cap_mask)
{ {
struct DictionaryIter iter; rb_dictionary_iter iter;
struct CapabilityEntry *entry; struct CapabilityEntry *entry;
static char buf[BUFSIZE]; static char buf[BUFSIZE];
char *t = buf; char *t = buf;
@ -193,7 +193,7 @@ capability_index_list(struct CapabilityIndex *idx, unsigned int cap_mask)
unsigned int unsigned int
capability_index_mask(struct CapabilityIndex *idx) capability_index_mask(struct CapabilityIndex *idx)
{ {
struct DictionaryIter iter; rb_dictionary_iter iter;
struct CapabilityEntry *entry; struct CapabilityEntry *entry;
unsigned int mask = 0; unsigned int mask = 0;
@ -211,7 +211,7 @@ capability_index_mask(struct CapabilityIndex *idx)
unsigned int unsigned int
capability_index_get_required(struct CapabilityIndex *idx) capability_index_get_required(struct CapabilityIndex *idx)
{ {
struct DictionaryIter iter; rb_dictionary_iter iter;
struct CapabilityEntry *entry; struct CapabilityEntry *entry;
unsigned int mask = 0; unsigned int mask = 0;
@ -235,7 +235,7 @@ capability_index_stats(void (*cb)(const char *line, void *privdata), void *privd
RB_DLINK_FOREACH(node, capability_indexes.head) RB_DLINK_FOREACH(node, capability_indexes.head)
{ {
struct CapabilityIndex *idx = node->data; struct CapabilityIndex *idx = node->data;
struct DictionaryIter iter; rb_dictionary_iter iter;
struct CapabilityEntry *entry; struct CapabilityEntry *entry;
snprintf(buf, sizeof buf, "'%s': allocated bits - %d", idx->name, (idx->highest_bit - 1)); snprintf(buf, sizeof buf, "'%s': allocated bits - %d", idx->name, (idx->highest_bit - 1));

View file

@ -79,7 +79,7 @@ static rb_bh *away_heap = NULL;
static char current_uid[IDLEN]; static char current_uid[IDLEN];
static int32_t current_connid = 0; static int32_t current_connid = 0;
struct Dictionary *nd_dict = NULL; rb_dictionary *nd_dict = NULL;
enum enum
{ {

View file

@ -58,8 +58,8 @@ struct dnsstatreq
}; };
/* These serve as a form of sparse array */ /* These serve as a form of sparse array */
static struct Dictionary *query_dict; static rb_dictionary *query_dict;
static struct Dictionary *stat_dict; static rb_dictionary *stat_dict;
rb_dlink_list nameservers; rb_dlink_list nameservers;

View file

@ -40,8 +40,8 @@
#include "rb_dictionary.h" #include "rb_dictionary.h"
#include "rb_radixtree.h" #include "rb_radixtree.h"
struct Dictionary *client_connid_tree = NULL; rb_dictionary *client_connid_tree = NULL;
struct Dictionary *client_zconnid_tree = NULL; rb_dictionary *client_zconnid_tree = NULL;
struct rb_radixtree *client_id_tree = NULL; struct rb_radixtree *client_id_tree = NULL;
struct rb_radixtree *client_name_tree = NULL; struct rb_radixtree *client_name_tree = NULL;

View file

@ -42,8 +42,8 @@
#include "packet.h" #include "packet.h"
#include "s_assert.h" #include "s_assert.h"
struct Dictionary *cmd_dict = NULL; rb_dictionary *cmd_dict = NULL;
struct Dictionary *alias_dict = NULL; rb_dictionary *alias_dict = NULL;
static void cancel_clients(struct Client *, struct Client *); static void cancel_clients(struct Client *, struct Client *);
static void remove_unknown(struct Client *, const char *, char *); static void remove_unknown(struct Client *, const char *, char *);

View file

@ -1417,7 +1417,7 @@ read_conf_files(bool cold)
* free an alias{} entry. * free an alias{} entry.
*/ */
static void 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; struct alias_entry *aptr = ptr->data;

View file

@ -27,21 +27,25 @@
#include "librb-config.h" #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 */); 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; void *data;
const void *key; const void *key;
int position; int position;
}; };
struct DictionaryIter struct rb_dictionary_iter
{ {
struct DictionaryElement *cur, *next; rb_dictionary_element *cur, *next;
}; };
/* /*
@ -53,33 +57,33 @@ struct DictionaryIter
* rb_dictionary_create_named() creates a new dictionary tree which has a name. * rb_dictionary_create_named() creates a new dictionary tree which has a name.
* name is the name, compare_cb is the comparator. * 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 * rb_dictionary_set_comparator_func() resets the comparator used for lookups and
* insertions in the DTree structure. * 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); DCF compare_cb);
/* /*
* rb_dictionary_get_comparator_func() returns the comparator used for lookups and * rb_dictionary_get_comparator_func() returns the comparator used for lookups and
* insertions in the DTree structure. * 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 * rb_dictionary_get_linear_index() returns the linear index of an object in the
* DTree structure. * 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 * rb_dictionary_destroy() destroys all entries in a dtree, and also optionally calls
* a defined callback function to destroy any data attached to it. * a defined callback function to destroy any data attached to it.
*/ */
extern void rb_dictionary_destroy(struct Dictionary *dtree, extern void rb_dictionary_destroy(rb_dictionary *dtree,
void (*destroy_cb)(struct DictionaryElement *delem, void *privdata), void (*destroy_cb)(rb_dictionary_element *delem, void *privdata),
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. * To shortcircuit iteration, return non-zero from the callback function.
*/ */
extern void rb_dictionary_foreach(struct Dictionary *dtree, extern void rb_dictionary_foreach(rb_dictionary *dtree,
int (*foreach_cb)(struct DictionaryElement *delem, void *privdata), int (*foreach_cb)(rb_dictionary_element *delem, void *privdata),
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 * When the object is found, a non-NULL is returned from the callback, which results
* in that object being returned to the user. * in that object being returned to the user.
*/ */
extern void *rb_dictionary_search(struct Dictionary *dtree, extern void *rb_dictionary_search(rb_dictionary *dtree,
void *(*foreach_cb)(struct DictionaryElement *delem, void *privdata), void *(*foreach_cb)(rb_dictionary_element *delem, void *privdata),
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 * in progress at a time, it is permitted to remove the current element
* of the iteration (but not any other element). * of the iteration (but not any other element).
*/ */
extern void rb_dictionary_foreach_start(struct Dictionary *dtree, extern void rb_dictionary_foreach_start(rb_dictionary *dtree,
struct DictionaryIter *state); rb_dictionary_iter *state);
/* /*
* rb_dictionary_foreach_cur() returns the current element of the iteration, * rb_dictionary_foreach_cur() returns the current element of the iteration,
* or NULL if there are no more elements. * or NULL if there are no more elements.
*/ */
extern void *rb_dictionary_foreach_cur(struct Dictionary *dtree, extern void *rb_dictionary_foreach_cur(rb_dictionary *dtree,
struct DictionaryIter *state); rb_dictionary_iter *state);
/* /*
* rb_dictionary_foreach_next() moves to the next element. * rb_dictionary_foreach_next() moves to the next element.
*/ */
extern void rb_dictionary_foreach_next(struct Dictionary *dtree, extern void rb_dictionary_foreach_next(rb_dictionary *dtree,
struct DictionaryIter *state); rb_dictionary_iter *state);
/* /*
* rb_dictionary_add() adds a key->value entry to the dictionary tree. * 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'. * 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. * 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. * 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); void rb_dictionary_stats_walk(void (*cb)(const char *line, void *privdata), void *privdata);
#ifndef _WIN32 #ifndef _WIN32

View file

@ -26,10 +26,10 @@
#include <rb_lib.h> #include <rb_lib.h>
#include <rb_dictionary.h> #include <rb_dictionary.h>
struct Dictionary struct rb_dictionary
{ {
DCF compare_cb; DCF compare_cb;
struct DictionaryElement *root, *head, *tail; rb_dictionary_element *root, *head, *tail;
unsigned int count; unsigned int count;
char *id; char *id;
unsigned int dirty:1; 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, * - if services runs out of memory and cannot allocate the object,
* the program will abort. * the program will abort.
*/ */
struct Dictionary *rb_dictionary_create(const char *name, rb_dictionary *rb_dictionary_create(const char *name,
DCF compare_cb) 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->compare_cb = compare_cb;
dtree->id = rb_strdup(name); 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) * DCF compare_cb)
* *
* Resets the comparator function used by the dictionary code for * Resets the comparator function used by the dictionary code for
@ -85,7 +85,7 @@ struct Dictionary *rb_dictionary_create(const char *name,
* Side Effects: * Side Effects:
* - the dictionary comparator function is reset. * - 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) DCF compare_cb)
{ {
lrb_assert(dict != NULL); 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. * Returns the current comparator function used by the dictionary.
* *
@ -109,7 +109,7 @@ void rb_dictionary_set_comparator_func(struct Dictionary *dict,
* - none * - none
*/ */
DCF DCF
rb_dictionary_get_comparator_func(struct Dictionary *dict) rb_dictionary_get_comparator_func(rb_dictionary *dict)
{ {
lrb_assert(dict != NULL); 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) * const void *key)
* *
* Gets a linear index number for 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. * - rebuilds the linear index if the tree is marked as dirty.
*/ */
int 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(dict != NULL);
lrb_assert(key != NULL); lrb_assert(key != NULL);
@ -148,7 +148,7 @@ rb_dictionary_get_linear_index(struct Dictionary *dict, const void *key)
return elem->position; return elem->position;
else else
{ {
struct DictionaryElement *delem; rb_dictionary_element *delem;
int i; int i;
for (delem = dict->head, i = 0; delem != NULL; delem = delem->next, 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. * 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. * - a new root node is nominated.
*/ */
static void 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; int ret;
lrb_assert(dict != NULL); lrb_assert(dict != NULL);
@ -253,8 +253,8 @@ rb_dictionary_retune(struct Dictionary *dict, const void *key)
} }
/* /*
* rb_dictionary_link(struct Dictionary *dict, * rb_dictionary_link(rb_dictionary *dict,
* struct DictionaryElement *delem) * rb_dictionary_element *delem)
* *
* Links a dictionary tree element to the dictionary. * 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 * - a node is linked to the dictionary tree
*/ */
static void static void
rb_dictionary_link(struct Dictionary *dict, rb_dictionary_link(rb_dictionary *dict,
struct DictionaryElement *delem) rb_dictionary_element *delem)
{ {
lrb_assert(dict != NULL); lrb_assert(dict != NULL);
lrb_assert(delem != 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. * 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 * - the root node is unlinked from the dictionary tree
*/ */
static void 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; 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 (*destroy_cb)(dictionary_elem_t *delem, void *privdata),
* 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 * - if this is called without a callback, the objects bound to the
* DTree will not be destroyed. * DTree will not be destroyed.
*/ */
void rb_dictionary_destroy(struct Dictionary *dtree, void rb_dictionary_destroy(rb_dictionary *dtree,
void (*destroy_cb)(struct DictionaryElement *delem, void *privdata), void (*destroy_cb)(rb_dictionary_element *delem, void *privdata),
void *privdata) void *privdata)
{ {
struct DictionaryElement *n, *tn; rb_dictionary_element *n, *tn;
lrb_assert(dtree != NULL); 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 (*destroy_cb)(dictionary_elem_t *delem, void *privdata),
* void *privdata); * void *privdata);
* *
@ -469,18 +469,18 @@ void rb_dictionary_destroy(struct Dictionary *dtree,
* Side Effects: * Side Effects:
* - on success, a dtree is iterated * - on success, a dtree is iterated
*/ */
void rb_dictionary_foreach(struct Dictionary *dtree, void rb_dictionary_foreach(rb_dictionary *dtree,
int (*foreach_cb)(struct DictionaryElement *delem, void *privdata), int (*foreach_cb)(rb_dictionary_element *delem, void *privdata),
void *privdata) void *privdata)
{ {
struct DictionaryElement *n, *tn; rb_dictionary_element *n, *tn;
lrb_assert(dtree != NULL); lrb_assert(dtree != NULL);
RB_DLINK_FOREACH_SAFE(n, tn, dtree->head) RB_DLINK_FOREACH_SAFE(n, tn, dtree->head)
{ {
/* delem_t is a subclass of node_t. */ /* 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) if (foreach_cb != NULL)
(*foreach_cb)(delem, privdata); (*foreach_cb)(delem, privdata);
@ -488,8 +488,8 @@ void rb_dictionary_foreach(struct Dictionary *dtree,
} }
/* /*
* rb_dictionary_search(struct Dictionary *dtree, * rb_dictionary_search(rb_dictionary *dtree,
* void (*destroy_cb)(struct DictionaryElement *delem, void *privdata), * void (*destroy_cb)(rb_dictionary_element *delem, void *privdata),
* void *privdata); * void *privdata);
* *
* Searches all entries in a DTree using a custom callback. * Searches all entries in a DTree using a custom callback.
@ -506,11 +506,11 @@ void rb_dictionary_foreach(struct Dictionary *dtree,
* Side Effects: * Side Effects:
* - a dtree is iterated until the requested conditions are met * - a dtree is iterated until the requested conditions are met
*/ */
void *rb_dictionary_search(struct Dictionary *dtree, void *rb_dictionary_search(rb_dictionary *dtree,
void *(*foreach_cb)(struct DictionaryElement *delem, void *privdata), void *(*foreach_cb)(rb_dictionary_element *delem, void *privdata),
void *privdata) void *privdata)
{ {
struct DictionaryElement *n, *tn; rb_dictionary_element *n, *tn;
void *ret = NULL; void *ret = NULL;
lrb_assert(dtree != NULL); lrb_assert(dtree != NULL);
@ -518,7 +518,7 @@ void *rb_dictionary_search(struct Dictionary *dtree,
RB_DLINK_FOREACH_SAFE(n, tn, dtree->head) RB_DLINK_FOREACH_SAFE(n, tn, dtree->head)
{ {
/* delem_t is a subclass of node_t. */ /* 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) if (foreach_cb != NULL)
ret = (*foreach_cb)(delem, privdata); ret = (*foreach_cb)(delem, privdata);
@ -531,8 +531,8 @@ void *rb_dictionary_search(struct Dictionary *dtree,
} }
/* /*
* rb_dictionary_foreach_start(struct Dictionary *dtree, * rb_dictionary_foreach_start(rb_dictionary *dtree,
* struct DictionaryIter *state); * rb_dictionary_iter *state);
* *
* Initializes a static DTree iterator. * Initializes a static DTree iterator.
* *
@ -546,8 +546,8 @@ void *rb_dictionary_search(struct Dictionary *dtree,
* Side Effects: * Side Effects:
* - the static iterator, &state, is initialized. * - the static iterator, &state, is initialized.
*/ */
void rb_dictionary_foreach_start(struct Dictionary *dtree, void rb_dictionary_foreach_start(rb_dictionary *dtree,
struct DictionaryIter *state) rb_dictionary_iter *state)
{ {
lrb_assert(dtree != NULL); lrb_assert(dtree != NULL);
lrb_assert(state != NULL); lrb_assert(state != NULL);
@ -568,8 +568,8 @@ void rb_dictionary_foreach_start(struct Dictionary *dtree,
} }
/* /*
* rb_dictionary_foreach_cur(struct Dictionary *dtree, * rb_dictionary_foreach_cur(rb_dictionary *dtree,
* struct DictionaryIter *state); * rb_dictionary_iter *state);
* *
* Returns the data from the current node being iterated by the * Returns the data from the current node being iterated by the
* static iterator. * static iterator.
@ -584,8 +584,8 @@ void rb_dictionary_foreach_start(struct Dictionary *dtree,
* Side Effects: * Side Effects:
* - none * - none
*/ */
void *rb_dictionary_foreach_cur(struct Dictionary *dtree, void *rb_dictionary_foreach_cur(rb_dictionary *dtree,
struct DictionaryIter *state) rb_dictionary_iter *state)
{ {
lrb_assert(dtree != NULL); lrb_assert(dtree != NULL);
lrb_assert(state != NULL); lrb_assert(state != NULL);
@ -594,8 +594,8 @@ void *rb_dictionary_foreach_cur(struct Dictionary *dtree,
} }
/* /*
* rb_dictionary_foreach_next(struct Dictionary *dtree, * rb_dictionary_foreach_next(rb_dictionary *dtree,
* struct DictionaryIter *state); * rb_dictionary_iter *state);
* *
* Advances a static DTree iterator. * Advances a static DTree iterator.
* *
@ -609,8 +609,8 @@ void *rb_dictionary_foreach_cur(struct Dictionary *dtree,
* Side Effects: * Side Effects:
* - the static iterator, &state, is advanced to a new DTree node. * - the static iterator, &state, is advanced to a new DTree node.
*/ */
void rb_dictionary_foreach_next(struct Dictionary *dtree, void rb_dictionary_foreach_next(rb_dictionary *dtree,
struct DictionaryIter *state) rb_dictionary_iter *state)
{ {
lrb_assert(dtree != NULL); lrb_assert(dtree != NULL);
lrb_assert(state != 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. * Looks up a DTree node by name.
* *
@ -645,7 +645,7 @@ void rb_dictionary_foreach_next(struct Dictionary *dtree,
* Side Effects: * Side Effects:
* - none * - 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(dict != NULL);
lrb_assert(key != 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. * 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: * Side Effects:
* - data is inserted into the DTree. * - 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(dict != NULL);
lrb_assert(key != 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. * Deletes data from a dictionary tree.
* *
@ -713,9 +713,9 @@ struct DictionaryElement *rb_dictionary_add(struct Dictionary *dict, const void
* Notes: * Notes:
* - the returned data needs to be mowgli_freed/released manually! * - 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; void *data;
if (delem == NULL) 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. * Retrieves data from a dictionary.
* *
@ -745,9 +745,9 @@ void *rb_dictionary_delete(struct Dictionary *dtree, const void *key)
* Side Effects: * Side Effects:
* - none * - 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) if (delem != NULL)
return delem->data; 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. * Returns the size of a dictionary.
* *
@ -769,7 +769,7 @@ void *rb_dictionary_retrieve(struct Dictionary *dtree, const void *key)
* Side Effects: * Side Effects:
* - none * - none
*/ */
unsigned int rb_dictionary_size(struct Dictionary *dict) unsigned int rb_dictionary_size(rb_dictionary *dict)
{ {
lrb_assert(dict != NULL); 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 */ /* returns the sum of the depths of the subtree rooted in delem at depth depth */
static int static int
stats_recurse(struct DictionaryElement *delem, int depth, int *pmaxdepth) stats_recurse(rb_dictionary_element *delem, int depth, int *pmaxdepth)
{ {
int result; 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. * Returns the size of a dictionary.
* *
@ -808,7 +808,7 @@ stats_recurse(struct DictionaryElement *delem, int depth, int *pmaxdepth)
* Side Effects: * Side Effects:
* - callback called with stats text * - 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]; char str[256];
int sum, maxdepth; int sum, maxdepth;

View file

@ -157,7 +157,7 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags)
int buflen = 0; int buflen = 0;
int mlen; int mlen;
struct CapabilityEntry *entry; struct CapabilityEntry *entry;
struct DictionaryIter iter; rb_dictionary_iter iter;
mlen = snprintf(buf, sizeof buf, ":%s CAP %s %s", mlen = snprintf(buf, sizeof buf, ":%s CAP %s %s",
me.name, me.name,

View file

@ -285,7 +285,7 @@ static void
stats_delay(struct Client *source_p) stats_delay(struct Client *source_p)
{ {
struct nd_entry *nd; struct nd_entry *nd;
struct DictionaryIter iter; rb_dictionary_iter iter;
RB_DICTIONARY_FOREACH(nd, &iter, nd_dict) RB_DICTIONARY_FOREACH(nd, &iter, nd_dict)
{ {
@ -734,7 +734,7 @@ stats_klines(struct Client *source_p)
static void static void
stats_messages(struct Client *source_p) stats_messages(struct Client *source_p)
{ {
struct DictionaryIter iter; rb_dictionary_iter iter;
struct Message *msg; struct Message *msg;
struct alias_entry *amsg; struct alias_entry *amsg;