]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/cache.c
Add topic TS and channel TS constraints for /LIST.
[irc/rqf/shadowircd.git] / src / cache.c
index c72b33378d5569099430045134ca7660426f3b9f..04766b7448d04711719a21e1cf9253cb7b418c2c 100644 (file)
@@ -29,7 +29,6 @@
  * 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"
@@ -136,13 +135,20 @@ cache_file(const char *filename, const char *shortname, int flags)
                if(!EmptyString(line))
                {
                        lineptr = rb_malloc(sizeof(struct cacheline));
-                       rb_strlcpy(lineptr->data, line, sizeof(lineptr->data));
+                       untabify(lineptr->data, line, sizeof(lineptr->data));
                        rb_dlinkAddTail(lineptr, &lineptr->linenode, &cacheptr->contents);
                }
                else
                        rb_dlinkAddTailAlloc(emptyline, &cacheptr->contents);
        }
 
+       if (0 == rb_dlink_list_length(&cacheptr->contents))
+       {
+               /* No contents. Don't cache it after all. */
+               rb_free(cacheptr);
+               cacheptr = NULL;
+       }
+
        fclose(in);
        return cacheptr;
 }
@@ -224,6 +230,10 @@ load_help(void)
        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);
@@ -242,6 +252,8 @@ load_help(void)
 
        while((ldirent = readdir(helpfile_dir)) != NULL)
        {
+               if(ldirent->d_name[0] == '.')
+                       continue;
                rb_snprintf(filename, sizeof(filename), "%s/%s", HPATH, ldirent->d_name);
                cacheptr = cache_file(filename, ldirent->d_name, HELP_OPER);
                irc_dictionary_add(help_dict_oper, cacheptr->name, cacheptr);
@@ -255,8 +267,29 @@ load_help(void)
 
        while((ldirent = readdir(helpfile_dir)) != NULL)
        {
+               if(ldirent->d_name[0] == '.')
+                       continue;
                rb_snprintf(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 = irc_dictionary_retrieve(help_dict_oper, ldirent->d_name);
+
+                       if(cacheptr != NULL)
+                       {
+                               cacheptr->flags |= HELP_USER;
+                               continue;
+                       }
+               }
+#endif
+
                cacheptr = cache_file(filename, ldirent->d_name, HELP_USER);
                irc_dictionary_add(help_dict_user, cacheptr->name, cacheptr);
        }