]> jfr.im git - irc/quakenet/newserv.git/blobdiff - helpmod2/hterm.c
CHANSERV: remove E type escapes
[irc/quakenet/newserv.git] / helpmod2 / hterm.c
index 1270c8415bdfa62f0f8969e22554a934163d055a..4e7abebc7d67e60773d0c25652e6f3a32f6c0341 100644 (file)
@@ -2,7 +2,6 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include "../lib/sstring.h"
 
 #include "hterm.h"
 
@@ -18,6 +17,8 @@ hterm *hterm_add(hterm** ptr, const char *name, const char *desc)
     if (name == NULL || desc == NULL || hterm_get(*ptr, name))
         return NULL;
 
+    for (;*ptr && strcmp(name, (*ptr)->name->content) > 0;ptr = &(*ptr)->next);
+
     htrm = (hterm*)malloc(sizeof(hterm));
     htrm->name = getsstring(name, strlen(name));
     htrm->description = getsstring(desc, strlen(desc));
@@ -61,15 +62,29 @@ hterm *hterm_get_and_find(hterm *source, const char *str)
     hterm *ptr;
     ptr = hterm_get(source, str);
     if (ptr != NULL)
+    {
+        ptr->usage++;
         return ptr;
+    }
     ptr = hterm_get(hterms, str);
     if (ptr != NULL)
+    {
+        ptr->usage++;
         return ptr;
+    }
     ptr = hterm_find(source, str);
     if (ptr != NULL)
+    {
+        ptr->usage++;
         return ptr;
+    }
     ptr = hterm_find(hterms, str);
-    return ptr;
+    if (ptr != NULL)
+    {
+        ptr->usage++;
+        return ptr;
+    }
+    return NULL;
 }
 
 hterm *hterm_del(hterm** start, hterm *htrm)