Cleanup Commit
[tpg/acess2.git] / Usermode / Libraries / libaxwin2.so_src / messages.c
1 /*
2  * AxWin Window Manager Interface Library
3  * By John Hodge (thePowersGang)
4  * This file is published under the terms of the Acess Licence. See the
5  * file COPYING for details.
6  * 
7  * messages.c - Message Handling
8  */
9 #include "common.h"
10
11 // === PROTOTYPES ===
12  int    AxWin_MessageLoop();
13 tAxWin_Message  *AxWin_WaitForMessage();
14  int    AxWin_HandleMessage(tAxWin_Message *Message);
15
16 // === CODE ===
17 /**
18  * \brief Loop forever, checking and waiting for messages
19  */
20 int AxWin_MessageLoop()
21 {
22         tAxWin_Message  *msg;
23          int    ret;
24         for(;;)
25         {
26                 msg = AxWin_WaitForMessage();
27                 ret = AxWin_HandleMessage(msg);
28                 
29                 if(ret < 0)     return 0;
30         }
31         return 0;
32 }
33
34 /**
35  * \brief Wait for a message
36  */
37 tAxWin_Message *AxWin_WaitForMessage()
38 {
39          int    length;
40         pid_t   src;
41         tAxWin_Message  *ret;
42         
43         switch( giAxWin_Mode )
44         {
45         case AXWIN_MODE_IPC:
46                 while( (length = SysGetMessage(&src, NULL)) == 0 )      sleep();
47                 ret = malloc(length);
48                 SysGetMessage(NULL, ret);
49                 break;
50         default:
51                 break;
52         }
53         return 0;
54 }
55
56 /**
57  * \brief Handles a recieved message
58  */
59 int AxWin_HandleMessage(tAxWin_Message *Message)
60 {
61         switch(Message->ID)
62         {
63         default:        return 0;
64         }
65 }

UCC git Repository :: git.ucc.asn.au