#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_oper = NULL;
+struct Dictionary *help_dict_user = NULL;
+
/* init_cache()
*
* inputs -
user_motd = cache_file(MPATH, "ircd.motd", 0);
oper_motd = cache_file(OPATH, "opers.motd", 0);
+
+ help_dict_oper = irc_dictionary_create(strcasecmp);
+ help_dict_user = irc_dictionary_create(strcasecmp);
}
/* cache_file()
local_tm = localtime(&sb.st_mtime);
if(local_tm != NULL)
- ircsnprintf(user_motd_changed, sizeof(user_motd_changed),
+ rb_snprintf(user_motd_changed, sizeof(user_motd_changed),
"%d/%d/%d %d:%d",
local_tm->tm_mday, local_tm->tm_mon + 1,
1900 + local_tm->tm_year, local_tm->tm_hour,
*
* inputs -
* outputs -
- * side effects - contents of help directories are loaded.
+ * side effects - old help cache deleted
+ * - contents of help directories are loaded.
*/
void
load_help(void)
struct dirent *ldirent= NULL;
char filename[MAXPATHLEN];
struct cachefile *cacheptr;
+ struct DictionaryIter iter;
-#if defined(S_ISLNK) && defined(HAVE_LSTAT)
- struct stat sb;
-#endif
+ DICTIONARY_FOREACH(cacheptr, &iter, help_dict_oper)
+ {
+ irc_dictionary_delete(help_dict_oper, cacheptr->name);
+ free_cachefile(cacheptr);
+ }
+ DICTIONARY_FOREACH(cacheptr, &iter, help_dict_user)
+ {
+ irc_dictionary_delete(help_dict_user, cacheptr->name);
+ free_cachefile(cacheptr);
+ }
- /* opers must be done first */
helpfile_dir = opendir(HPATH);
if(helpfile_dir == NULL)
while((ldirent = readdir(helpfile_dir)) != NULL)
{
- ircsnprintf(filename, sizeof(filename), "%s/%s", HPATH, ldirent->d_name);
+ rb_snprintf(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_oper, cacheptr->name, cacheptr);
}
closedir(helpfile_dir);
while((ldirent = readdir(helpfile_dir)) != NULL)
{
- ircsnprintf(filename, sizeof(filename), "%s/%s", UHPATH, ldirent->d_name);
-
-#if defined(S_ISLNK) && defined(HAVE_LSTAT)
- if(lstat(filename, &sb) < 0)
- continue;
-
- /* ok, if its a symlink, we work on the presumption if an
- * oper help exists of that name, its a symlink to that --fl
- */
- if(S_ISLNK(sb.st_mode))
- {
- cacheptr = hash_find_help(ldirent->d_name, HELP_OPER);
-
- if(cacheptr != NULL)
- {
- cacheptr->flags |= HELP_USER;
- continue;
- }
- }
-#endif
+ rb_snprintf(filename, sizeof(filename), "%s/%s", UHPATH, ldirent->d_name);
cacheptr = cache_file(filename, ldirent->d_name, HELP_USER);
- add_to_help_hash(cacheptr->name, cacheptr);
+ irc_dictionary_add(help_dict_user, cacheptr->name, cacheptr);
}
closedir(helpfile_dir);