]> jfr.im git - irc/quakenet/newserv.git/blobdiff - helpmod2/hticket.c
Add documentation files.
[irc/quakenet/newserv.git] / helpmod2 / hticket.c
index 05fc6c496e8a347e884c3fbb3e9fcbf9df9c8714..1425995903eecdc22a1e4c3880d35e6a6f7c93c9 100644 (file)
@@ -23,7 +23,9 @@ hticket *hticket_del(hticket *htick, struct hchannel_struct *hchan)
     for (ptr = &hchan->htickets;*ptr;ptr = &(*ptr)->next)
         if (*ptr == htick)
         {
-            hticket *tmp = (*ptr)->next;
+           hticket *tmp = (*ptr)->next;
+           if ((*ptr)->message)
+                freesstring((*ptr)->message);
             free(*ptr);
             *ptr = tmp;
             return NULL;
@@ -32,9 +34,9 @@ hticket *hticket_del(hticket *htick, struct hchannel_struct *hchan)
     return htick;
 }
 
-hticket *hticket_add(const char *authname, time_t expiration, struct hchannel_struct *hchan)
+hticket *hticket_add(const char *authname, time_t expiration, struct hchannel_struct *hchan, const char *message)
 {
-    hticket *tmp = hticket_get(authname, hchan);
+    hticket *tmp = hticket_get(authname, hchan), **ptr;
 
     if (hchan == NULL)
         return NULL;
@@ -46,9 +48,17 @@ hticket *hticket_add(const char *authname, time_t expiration, struct hchannel_st
 
     strcpy(tmp->authname, authname);
     tmp->time_expiration = expiration;
-    tmp->next = hchan->htickets;
 
-    hchan->htickets = tmp;
+    if (message == NULL)
+       tmp->message = NULL;
+    else
+        tmp->message = getsstring(message, strlen(message));
+
+    /* find the correct position */
+    for (ptr = &hchan->htickets;*ptr && (*ptr)->time_expiration >= expiration;ptr = &(*ptr)->next);
+
+    tmp->next = *ptr;
+    *ptr = tmp;
 
     return tmp;
 }