AcessNative/nativefs - Fixed memory leak due to Close() not being bound
[tpg/acess2.git] / Usermode / Libraries / libaxwin2.so_src / main.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  * main.c - Library Initialisation
8  */
9 #include "common.h"
10 #include <string.h>
11
12 // === GLOBALS ===
13  int    giAxWin_Mode = 0;
14  int    giAxWin_PID = 9;        // HACK!
15 tAxWin_MessageCallback  *gAxWin_DefaultCallback;
16
17 // === CODE ===
18 int SoMain()
19 {
20         return 0;
21 }
22
23 tAxWin_Message *AxWin_int_SendAndWait(int RetID, tAxWin_Message *Message)
24 {
25         tAxWin_Message  *msg;
26         tAxWin_RetMsg   *rmsg;
27
28         AxWin_SendMessage(Message);
29         
30         for(;;)
31         {
32                 msg = AxWin_WaitForMessage();
33                 
34                 rmsg = (void*)msg->Data;
35                 if(msg->ID == MSG_SRSP_RETURN && rmsg->ReqID == Message->ID )
36                         break;
37                 
38                 AxWin_HandleMessage(msg);
39                 free(msg);
40         }
41         
42         return msg;
43 }
44
45 int AxWin_Register(const char *Name, tAxWin_MessageCallback *DefaultCallback)
46 {
47         tAxWin_Message  req;
48         tAxWin_Message  *msg;
49          int    ret;
50          int    len = strlen(Name);
51         
52         req.ID = MSG_SREQ_REGISTER;
53         req.Size = 1 + (len+1)/4;
54         strcpy(req.Data, Name);
55         
56         msg = AxWin_int_SendAndWait(MSG_SRSP_RETURN, &req);
57         ret = ((tAxWin_RetMsg*)msg->Data)->Value;
58         free(msg);
59
60         gAxWin_DefaultCallback = DefaultCallback;
61         
62         return !!ret;
63 }
64
65 tAxWin_Element *AxWin_CreateWindow(const char *Title)
66 {
67         tAxWin_Message  req;
68         tAxWin_Message  *msg;
69         tAxWin_Element  *ret;
70          int    len = strlen(Title);
71         
72         req.ID = MSG_SREQ_ADDWIN;
73         req.Size = 1 + (len+1)/4;
74         strcpy(req.Data, Title);
75         
76         msg = AxWin_int_SendAndWait(MSG_SRSP_RETURN, &req);
77         ret = (tAxWin_Element*) ((tAxWin_RetMsg*)msg->Data)->Value;
78         free(msg);
79         
80         return ret;
81 }
82
83 tAxWin_Element *AxWin_AddMenuItem(tAxWin_Element *Parent, const char *Label, int Message)
84 {
85         return NULL;
86 }

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