]>
jfr.im git - solanum.git/blob - ircd/operhash.c
2 * operhash.c - Hashes nick!user@host{oper}
4 * Copyright (C) 2005 Lee Hardy <lee -at- leeh.co.uk>
5 * Copyright (C) 2005-2016 ircd-ratbox development team
6 * Copyright (C) 2016 William Pitcock <nenolod@dereferenced.org>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
12 * 1.Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 * 2.Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3.The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
33 #include <ratbox_lib.h>
38 #include "irc_radixtree.h"
40 static struct irc_radixtree
*operhash_tree
= NULL
;
44 unsigned int refcount
;
51 operhash_tree
= irc_radixtree_create("operhash", NULL
);
55 operhash_add(const char *name
)
57 struct operhash_entry
*ohash
;
63 if((ohash
= (struct operhash_entry
*) irc_radixtree_retrieve(operhash_tree
, name
)) != NULL
)
69 len
= strlen(name
) + 1;
70 ohash
= rb_malloc(sizeof(struct operhash_entry
) + len
);
72 memcpy(ohash
->name
, name
, len
);
73 irc_radixtree_add(operhash_tree
, ohash
->name
, ohash
);
78 operhash_find(const char *name
)
80 return irc_radixtree_retrieve(operhash_tree
, name
);
84 operhash_delete(const char *name
)
86 struct operhash_entry
*ohash
= irc_radixtree_retrieve(operhash_tree
, name
);