home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / Msgs / c / Drop next >
Encoding:
Text File  |  1992-04-09  |  1.9 KB  |  77 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Msgs.Drop.c
  12.     Author:  Copyright © 1992 Jason Williams
  13.     Version: 1.00 (08 Apr 1992)
  14.     Purpose: MessageTrans-like message handling functions.
  15.              (If you want MessageTrans, use the SWI interface, if you want
  16.              high-level message handling, use this code...)
  17. */
  18.  
  19.  
  20. #include <stdlib.h>
  21. #include "Msgs.h"
  22.  
  23. typedef struct msg_def *msgdefptr;
  24.  
  25. typedef struct msg_def
  26. {
  27.   msgdefptr   next;
  28.   union
  29.   {
  30.     char        *text;
  31.     msgdefptr   taglist;
  32.   } data;
  33.   char        tag[10];
  34. } msg_def;
  35.  
  36.  
  37. extern msgdefptr msgs_grouplist;
  38. extern BOOL Msgs__MatchToken(char *tag1, char *tag2, BOOL wcallowed);
  39.  
  40.  
  41. extern void Msgs_DropGroup(char *grouptag)
  42. {
  43.   msgdefptr ptr, next, last;
  44.  
  45.   ptr = msgs_grouplist;            /* Try to find group */
  46.   while (ptr != NULL)
  47.   {
  48.     if (Msgs__MatchToken(grouptag, ptr->tag, TRUE))
  49.       break;
  50.  
  51.     last = ptr;
  52.     ptr = ptr->next;
  53.   }
  54.  
  55.   if (ptr == NULL)                  /* group not found   */
  56.     return;
  57.  
  58.   if (ptr == msgs_grouplist)        /* unlink from list  */
  59.     msgs_grouplist = ptr->next;
  60.   else
  61.     last->next = ptr->next;
  62.  
  63.   next = ptr->data.taglist;         /* Kill group record */
  64.   free(ptr);
  65.   ptr = next;
  66.  
  67.   while (ptr != NULL)               /* Kill message list */
  68.   {
  69.     if (ptr->data.text != NULL)
  70.       free(ptr->data.text);
  71.  
  72.     next = ptr->next;
  73.     free(ptr);
  74.     ptr = next;
  75.   }
  76. }
  77.