]> jfr.im git - solanum.git/blobdiff - ircd/cache.c
Resolve shfit/reduce conflict in timespec production (#54)
[solanum.git] / ircd / cache.c
index 88dab60d6e4908f2068a59749b97e330e73859c1..c720e0abdd96c542ee24e398090be45bb2541891 100644 (file)
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
- *
- * $Id: cache.c 25119 2008-03-13 16:57:05Z androsyn $
  */
 
 #include "stdinc.h"
 #include "ircd_defs.h"
-#include "common.h"
 #include "s_conf.h"
 #include "client.h"
 #include "hash.h"
 #include "cache.h"
-#include "irc_dictionary.h"
+#include "rb_dictionary.h"
 #include "numeric.h"
 #include "send.h"
 
@@ -49,8 +46,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()
  *
@@ -67,12 +64,12 @@ init_cache(void)
 
        user_motd_changed[0] = '\0';
 
-       user_motd = cache_file(MPATH, "ircd.motd", 0);
-       oper_motd = cache_file(OPATH, "opers.motd", 0);
+       user_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_MOTD], "ircd.motd", 0);
+       oper_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_OMOTD], "opers.motd", 0);
        memset(&links_cache_list, 0, sizeof(links_cache_list));
 
-       help_dict_oper = irc_dictionary_create(strcasecmp);
-       help_dict_user = irc_dictionary_create(strcasecmp);
+       help_dict_oper = rb_dictionary_create("oper help", rb_strcasecmp);
+       help_dict_user = rb_dictionary_create("user help", rb_strcasecmp);
 }
 
 /*
@@ -188,7 +185,7 @@ cache_links(void *unused)
 
                /* if the below is ever modified, change LINKSLINELEN */
                links_line = rb_malloc(LINKSLINELEN);
-               rb_snprintf(links_line, LINKSLINELEN, "%s %s :1 %s",
+               snprintf(links_line, LINKSLINELEN, "%s %s :1 %s",
                           target_p->name, me.name,
                           target_p->info[0] ? target_p->info :
                            "(Unknown Location)");
@@ -220,6 +217,10 @@ free_cachefile(struct cachefile *cacheptr)
                        rb_free(line->data);
                        rb_free(line);
                }
+               else
+               {
+                       rb_free_rb_dlink_node(ptr);
+               }
        }
 
        rb_free(cacheptr);
@@ -239,24 +240,24 @@ 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)
        {
-               irc_dictionary_delete(help_dict_oper, cacheptr->name);
+               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)
        {
-               irc_dictionary_delete(help_dict_user, cacheptr->name);
+               rb_dictionary_delete(help_dict_user, cacheptr->name);
                free_cachefile(cacheptr);
        }
 
-       helpfile_dir = opendir(HPATH);
+       helpfile_dir = opendir(ircd_paths[IRCD_PATH_OPERHELP]);
 
        if(helpfile_dir == NULL)
                return;
@@ -265,13 +266,13 @@ load_help(void)
        {
                if(ldirent->d_name[0] == '.')
                        continue;
-               rb_snprintf(filename, sizeof(filename), "%s/%s", HPATH, ldirent->d_name);
+               snprintf(filename, sizeof(filename), "%s%c%s", ircd_paths[IRCD_PATH_OPERHELP], RB_PATH_SEPARATOR, ldirent->d_name);
                cacheptr = cache_file(filename, ldirent->d_name, HELP_OPER);
-               irc_dictionary_add(help_dict_oper, cacheptr->name, cacheptr);
+               rb_dictionary_add(help_dict_oper, cacheptr->name, cacheptr);
        }
 
        closedir(helpfile_dir);
-       helpfile_dir = opendir(UHPATH);
+       helpfile_dir = opendir(ircd_paths[IRCD_PATH_USERHELP]);
 
        if(helpfile_dir == NULL)
                return;
@@ -280,7 +281,7 @@ load_help(void)
        {
                if(ldirent->d_name[0] == '.')
                        continue;
-               rb_snprintf(filename, sizeof(filename), "%s/%s", UHPATH, ldirent->d_name);
+               snprintf(filename, sizeof(filename), "%s%c%s", ircd_paths[IRCD_PATH_USERHELP], RB_PATH_SEPARATOR, ldirent->d_name);
 
 #if defined(S_ISLNK) && defined(HAVE_LSTAT)
                if(lstat(filename, &sb) < 0)
@@ -291,7 +292,7 @@ load_help(void)
                 */
                if(S_ISLNK(sb.st_mode))
                {
-                       cacheptr = irc_dictionary_retrieve(help_dict_oper, ldirent->d_name);
+                       cacheptr = rb_dictionary_retrieve(help_dict_oper, ldirent->d_name);
 
                        if(cacheptr != NULL)
                        {
@@ -302,7 +303,7 @@ load_help(void)
 #endif
 
                cacheptr = cache_file(filename, ldirent->d_name, HELP_USER);
-               irc_dictionary_add(help_dict_user, cacheptr->name, cacheptr);
+               rb_dictionary_add(help_dict_user, cacheptr->name, cacheptr);
        }
 
        closedir(helpfile_dir);
@@ -344,13 +345,13 @@ cache_user_motd(void)
        struct stat sb;
        struct tm *local_tm;
 
-       if(stat(MPATH, &sb) == 0)
+       if(stat(ircd_paths[IRCD_PATH_IRCD_MOTD], &sb) == 0)
        {
                local_tm = localtime(&sb.st_mtime);
 
                if(local_tm != NULL)
                {
-                       rb_snprintf(user_motd_changed, sizeof(user_motd_changed),
+                       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,
@@ -358,7 +359,7 @@ cache_user_motd(void)
                }
        }
        free_cachefile(user_motd);
-       user_motd = cache_file(MPATH, "ircd.motd", 0);
+       user_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_MOTD], "ircd.motd", 0);
 }