git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of github.com:thepowersgang/acess2
[tpg/acess2.git]
/
Usermode
/
Applications
/
axwin3_src
/
libaxwin3.so_src
/
msg.c
diff --git
a/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c
b/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c
index
76b38c2
..
2b50167
100644
(file)
--- a/
Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c
+++ b/
Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c
@@
-9,12
+9,14
@@
#include <acess/sys.h>
#include <string.h>
#include <stdlib.h>
#include <acess/sys.h>
#include <string.h>
#include <stdlib.h>
-#include
"include/ipc.h"
+#include
<ipcmessages.h> // AxWin3 common
#include "include/internal.h"
#include "include/internal.h"
+#include "include/ipc.h"
// === CONSTANTS ===
enum eConnectionType
{
// === CONSTANTS ===
enum eConnectionType
{
+ CONNTYPE_NONE,
CONNTYPE_SENDMESSAGE,
CONNTYPE_UDP,
CONNTYPE_TCP
CONNTYPE_SENDMESSAGE,
CONNTYPE_UDP,
CONNTYPE_TCP
@@
-69,6
+71,14
@@
tAxWin3_MessageCallback AxWin3_SetMessageCallback(tAxWin3_MessageCallback Callba
return old;
}
return old;
}
+uint32_t AxWin3_int_GetWindowID(tHWND Window)
+{
+ if(Window)
+ return Window->ServerID;
+ else
+ return -1;
+}
+
tAxWin_IPCMessage *AxWin3_int_AllocateIPCMessage(tHWND Window, int Message, int Flags, int ExtraBytes)
{
tAxWin_IPCMessage *ret;
tAxWin_IPCMessage *AxWin3_int_AllocateIPCMessage(tHWND Window, int Message, int Flags, int ExtraBytes)
{
tAxWin_IPCMessage *ret;
@@
-76,10
+86,7
@@
tAxWin_IPCMessage *AxWin3_int_AllocateIPCMessage(tHWND Window, int Message, int
ret = malloc( sizeof(tAxWin_IPCMessage) + ExtraBytes );
ret->Flags = Flags;
ret->ID = Message;
ret = malloc( sizeof(tAxWin_IPCMessage) + ExtraBytes );
ret->Flags = Flags;
ret->ID = Message;
- if(Window)
- ret->Window = Window->ServerID;
- else
- ret->Window = -1;
+ ret->Window = AxWin3_int_GetWindowID(Window);
ret->Size = ExtraBytes;
return ret;
}
ret->Size = ExtraBytes;
return ret;
}
@@
-115,15
+122,20
@@
tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void)
switch(giConnectionType)
{
case CONNTYPE_SENDMESSAGE:
switch(giConnectionType)
{
case CONNTYPE_SENDMESSAGE:
- // TODO: Less hack, I need a version of select for GetMessage etc
- if(SysGetMessage(NULL, NULL) == 0) sleep();
- while(SysGetMessage(NULL, NULL))
+ for( ;; )
{
pid_t tid;
{
pid_t tid;
- len = SysGetMessage(&tid, NULL);
+
+ // Wait for a message to arrive
+ while( !(len = SysGetMessage(&tid, NULL)) )
+ {
+ _SysWaitEvent(THREAD_EVENT_IPCMSG);
+ }
+
// Check if the message came from the server
if(tid != giConnectionNum)
{
// Check if the message came from the server
if(tid != giConnectionNum)
{
+ _SysDebug("%i byte message from %i", len, tid);
// If not, pass the buck (or ignore)
if( gAxWin3_MessageCallback )
gAxWin3_MessageCallback(tid, len);
// If not, pass the buck (or ignore)
if( gAxWin3_MessageCallback )
gAxWin3_MessageCallback(tid, len);
@@
-134,7
+146,11
@@
tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void)
// If it's from the server, allocate a buffer and return it
ret = malloc(len);
// If it's from the server, allocate a buffer and return it
ret = malloc(len);
- if(ret == NULL) return NULL;
+ if(ret == NULL) {
+ _SysDebug("malloc() failed, ignoring message");
+ SysGetMessage(NULL, GETMSG_IGNORE);
+ return NULL;
+ }
SysGetMessage(NULL, ret);
break;
}
SysGetMessage(NULL, ret);
break;
}
@@
-154,3
+170,15
@@
tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void)
return ret;
}
return ret;
}
+tAxWin_IPCMessage *AxWin3_int_WaitIPCMessage(int WantedID)
+{
+ tAxWin_IPCMessage *msg;
+ for(;;)
+ {
+ msg = AxWin3_int_GetIPCMessage();
+ if(msg->ID == WantedID) return msg;
+ AxWin3_int_HandleMessage( msg );
+ free(msg);
+ }
+}
+
UCC
git Repository :: git.ucc.asn.au