]> jfr.im git - solanum.git/blobdiff - src/cache.c
Merge links_cache into scache and rework scache.
[solanum.git] / src / cache.c
index d8ac748e9f162317ccd63b00b42a762bfb0fcf65..c55364a7a1321c52bf09d9599426790b862d4095 100644 (file)
@@ -29,7 +29,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $Id: cache.c 254 2005-09-21 23:35:12Z nenolod $
+ * $Id: cache.c 3436 2007-05-02 19:56:40Z jilles $
  */
 
 #include "stdinc.h"
@@ -50,8 +50,6 @@ static BlockHeap *cacheline_heap = NULL;
 
 struct cachefile *user_motd = NULL;
 struct cachefile *oper_motd = NULL;
-struct cacheline *emptyline = NULL;
-dlink_list links_cache_list;
 char user_motd_changed[MAX_DATE_STRING];
 
 /* init_cache()
@@ -66,15 +64,10 @@ init_cache(void)
        cachefile_heap = BlockHeapCreate(sizeof(struct cachefile), CACHEFILE_HEAP_SIZE);
        cacheline_heap = BlockHeapCreate(sizeof(struct cacheline), CACHELINE_HEAP_SIZE);
 
-       /* allocate the emptyline */
-       emptyline = BlockHeapAlloc(cacheline_heap);
-       emptyline->data[0] = ' ';
-       emptyline->data[1] = '\0';
        user_motd_changed[0] = '\0';
 
        user_motd = cache_file(MPATH, "ircd.motd", 0);
        oper_motd = cache_file(OPATH, "opers.motd", 0);
-       memset(&links_cache_list, 0, sizeof(links_cache_list));
 }
 
 /* cache_file()
@@ -124,57 +117,18 @@ cache_file(const char *filename, const char *shortname, int flags)
                if((p = strchr(line, '\n')) != NULL)
                        *p = '\0';
 
-               if(!EmptyString(line))
-               {
-                       lineptr = BlockHeapAlloc(cacheline_heap);
-                       strlcpy(lineptr->data, line, sizeof(lineptr->data));
-                       dlinkAddTail(lineptr, &lineptr->linenode, &cacheptr->contents);
-               }
+               lineptr = BlockHeapAlloc(cacheline_heap);
+               if(EmptyString(line))
+                       strlcpy(lineptr->data, " ", sizeof(lineptr->data));
                else
-                       dlinkAddTailAlloc(emptyline, &cacheptr->contents);
+                       strlcpy(lineptr->data, line, sizeof(lineptr->data));
+               dlinkAddTail(lineptr, &lineptr->linenode, &cacheptr->contents);
        }
 
        fclose(in);
        return cacheptr;
 }
 
-void
-cache_links(void *unused)
-{
-       struct Client *target_p;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
-       char *links_line;
-
-       DLINK_FOREACH_SAFE(ptr, next_ptr, links_cache_list.head)
-       {
-               MyFree(ptr->data);
-               free_dlink_node(ptr);
-       }
-
-       links_cache_list.head = links_cache_list.tail = NULL;
-       links_cache_list.length = 0;
-
-       DLINK_FOREACH(ptr, global_serv_list.head)
-       {
-               target_p = ptr->data;
-
-               /* skip ourselves (done in /links) and hidden servers */
-               if(IsMe(target_p) ||
-                  (IsHidden(target_p) && !ConfigServerHide.disable_hidden))
-                       continue;
-
-               /* if the below is ever modified, change LINKSLINELEN */
-               links_line = MyMalloc(LINKSLINELEN);
-               ircsnprintf(links_line, LINKSLINELEN, "%s %s :1 %s",
-                          target_p->name, me.name, 
-                          target_p->info[0] ? target_p->info : 
-                           "(Unknown Location)");
-
-               dlinkAddTailAlloc(links_line, &links_cache_list);
-       }
-}
-
 /* free_cachefile()
  *
  * inputs      - cachefile to free
@@ -192,8 +146,7 @@ free_cachefile(struct cachefile *cacheptr)
 
        DLINK_FOREACH_SAFE(ptr, next_ptr, cacheptr->contents.head)
        {
-               if(ptr->data != emptyline)
-                       BlockHeapFree(cacheline_heap, ptr->data);
+               BlockHeapFree(cacheline_heap, ptr->data);
        }
 
        BlockHeapFree(cachefile_heap, cacheptr);