X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin3_src%2Flibaxwin3.so_src%2Fmsg.c;h=2b501672ac50a87cfbce426887d0b9c63475809d;hb=6516331968f11dd9e5c495572f27cc69fa3d4c48;hp=3b6a3ba54316ab864c31ee5024d8036e9819e184;hpb=19dae42a211f5dff3471b7a53cf1de3b9518d330;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c b/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c index 3b6a3ba5..2b501672 100644 --- a/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c +++ b/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c @@ -11,10 +11,12 @@ #include #include // AxWin3 common #include "include/internal.h" +#include "include/ipc.h" // === CONSTANTS === enum eConnectionType { + CONNTYPE_NONE, CONNTYPE_SENDMESSAGE, CONNTYPE_UDP, CONNTYPE_TCP @@ -120,12 +122,16 @@ tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void) 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; - 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) { @@ -164,3 +170,15 @@ tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void) 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); + } +} +