extern void send_user_motd(struct Client *);
extern void send_oper_motd(struct Client *);
+struct Dictionary;
+extern struct Dictionary *help_dict;
+
#endif
#include "modules.h"
#include "hash.h"
#include "cache.h"
+#include "irc_dictionary.h"
static int m_help(struct Client *, struct Client *, int, const char **);
static int mo_help(struct Client *, struct Client *, int, const char **);
static int
m_help(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
- static time_t last_used = 0;
-
- /* HELP is always local */
- if((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
- {
- /* safe enough to give this on a local connect only */
- sendto_one(source_p, form_str(RPL_LOAD2HI),
- me.name, source_p->name, "HELP");
- sendto_one(source_p, form_str(RPL_ENDOFHELP),
- me.name, source_p->name,
- (parc > 1 && !EmptyString(parv[1])) ? parv[1] : "index");
- return 0;
- }
- else
- {
- last_used = CurrentTime;
- }
-
dohelp(source_p, HELP_USER, parc > 1 ? parv[1] : NULL);
return 0;
if(EmptyString(topic))
topic = ntopic;
- hptr = hash_find_help(topic, flags);
+ hptr = irc_dictionary_retrieve(help_dict, topic);
- if(hptr == NULL)
+ if(hptr == NULL || !(hptr->flags & flags))
{
sendto_one(source_p, form_str(ERR_HELPNOTFOUND),
me.name, source_p->name, topic);
#include "hash.h"
#include "cache.h"
#include "sprintf_irc.h"
+#include "irc_dictionary.h"
static BlockHeap *cachefile_heap = NULL;
static BlockHeap *cacheline_heap = NULL;
struct cachefile *oper_motd = NULL;
char user_motd_changed[MAX_DATE_STRING];
+struct Dictionary *help_dict = NULL;
+
/* init_cache()
*
* inputs -
user_motd = cache_file(MPATH, "ircd.motd", 0);
oper_motd = cache_file(OPATH, "opers.motd", 0);
+
+ help_dict = irc_dictionary_create(strcasecmp);
}
/* cache_file()
{
ircsnprintf(filename, sizeof(filename), "%s/%s", HPATH, ldirent->d_name);
cacheptr = cache_file(filename, ldirent->d_name, HELP_OPER);
- add_to_help_hash(cacheptr->name, cacheptr);
+ irc_dictionary_add(help_dict, cacheptr->name, cacheptr);
}
closedir(helpfile_dir);
*/
if(S_ISLNK(sb.st_mode))
{
- cacheptr = hash_find_help(ldirent->d_name, HELP_OPER);
+ cacheptr = irc_dictionary_retrieve(help_dict, ldirent->d_name);
- if(cacheptr != NULL)
+ if(cacheptr != NULL && cacheptr->flags & HELP_OPER) /* is this really needed? --nenolod */
{
cacheptr->flags |= HELP_USER;
continue;
#endif
cacheptr = cache_file(filename, ldirent->d_name, HELP_USER);
- add_to_help_hash(cacheptr->name, cacheptr);
+ irc_dictionary_add(help_dict, cacheptr->name, cacheptr);
}
closedir(helpfile_dir);
dlink_list *idTable;
dlink_list *resvTable;
dlink_list *hostTable;
-dlink_list *helpTable;
/*
* look in whowas.c for the missing ...[WW_MAX]; entry
channelTable = MyMalloc(sizeof(dlink_list) * CH_MAX);
hostTable = MyMalloc(sizeof(dlink_list) * HOST_MAX);
resvTable = MyMalloc(sizeof(dlink_list) * R_MAX);
- helpTable = MyMalloc(sizeof(dlink_list) * HELP_MAX);
}
#ifndef RICER_HASHING
return fnv_hash_upper_len((const unsigned char *) name, R_MAX_BITS, 30);
}
-static unsigned int
-hash_help(const char *name)
-{
- unsigned int h = 0;
-
- while(*name)
- {
- h += (unsigned int) (ToLower(*name++) & 0xDF);
- }
-
- return (h % HELP_MAX);
-}
-
/* add_to_id_hash()
*
* adds an entry to the id hash table
dlinkAddAlloc(aconf, &resvTable[hashv]);
}
-void
-add_to_help_hash(const char *name, struct cachefile *hptr)
-{
- unsigned int hashv;
-
- if(EmptyString(name) || hptr == NULL)
- return;
-
- hashv = hash_help(name);
- dlinkAddAlloc(hptr, &helpTable[hashv]);
-}
-
/* del_from_id_hash()
*
* removes an id from the id hash table
dlinkFindDestroy(aconf, &resvTable[hashv]);
}
-void
-clear_help_hash(void)
-{
- dlink_node *ptr;
- dlink_node *next_ptr;
- int i;
-
- HASH_WALK_SAFE(i, HELP_MAX, ptr, next_ptr, helpTable)
- {
- free_cachefile(ptr->data);
- dlinkDestroy(ptr, &helpTable[i]);
- }
- HASH_WALK_END
-}
-
/* find_id()
*
* finds a client entry from the id hash table
return NULL;
}
-struct cachefile *
-hash_find_help(const char *name, int flags)
-{
- struct cachefile *hptr;
- dlink_node *ptr;
- unsigned int hashv;
-
- if(EmptyString(name))
- return NULL;
-
- hashv = hash_help(name);
-
- DLINK_FOREACH(ptr, helpTable[hashv].head)
- {
- hptr = ptr->data;
-
- if((irccmp(name, hptr->name) == 0) &&
- (hptr->flags & flags))
- return hptr;
- }
-
- return NULL;
-}
-
void
clear_resv_hash(void)
{