home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / Event / c / MRelease < prev    next >
Encoding:
Text File  |  1992-03-31  |  2.3 KB  |  64 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:    Event.MRelease.c
  12.     Author:  Copyright © 1992 Jason Williams
  13.     Version: 1.00 (16 Mar 1992)
  14.     Purpose: Extension to Event.c to allow routing of specific message types
  15.              to different windows' message handlers.
  16. */
  17.  
  18. #include "EMsgDefs.h"
  19.  
  20. extern linklist_header eventmsg__claimanchor;
  21.  
  22.  
  23. extern int EventMsg_Release(message_action messagetype, window_handle window,
  24.                             event_handler handler)
  25. {
  26.   eventmsg_claimrecord *ptr, *nextmess;
  27.   eventmsg_windowrecord *wptr, *next;
  28.   int result = 0;
  29.  
  30.   ptr = (eventmsg_claimrecord *) eventmsg__claimanchor.next;
  31.  
  32.   while (ptr != NULL)                           /* Search all message claims */
  33.   {
  34.     if (ptr->messagetype == messagetype)
  35.     {
  36.       wptr = (eventmsg_windowrecord *) ptr->windowlist.next;
  37.       while (wptr != NULL)                      /* Search all window claims  */
  38.       {
  39.         next = (eventmsg_windowrecord *) wptr->header.next;
  40.         if (wptr->window == window && wptr->handler == handler)
  41.         {                            /* Found claim for window+handler combo */
  42.           LinkList_Unlink(&(ptr->windowlist), &(wptr->header));
  43.           free(wptr);
  44.           result += 1;                     /* Count of window claims removed */
  45.         }
  46.         wptr = next;
  47.       }
  48.  
  49.       nextmess = (eventmsg_claimrecord *) ptr->header.next;
  50.       if (ptr->windowlist.next == NULL)               /* m-list is now empty */
  51.       {
  52.         LinkList_Unlink(&eventmsg__claimanchor, &(ptr->header));
  53.                                                       /* remove message type */
  54.         free(ptr);                                    /* free memory up      */
  55.       }
  56.       ptr = nextmess;
  57.     }
  58.     else
  59.       ptr = (eventmsg_claimrecord *) ptr->header.next;
  60.   }
  61.  
  62.   return(result);
  63. }
  64.