diff options
-rw-r--r-- | extensions.c | 28 | ||||
-rw-r--r-- | extensions.h | 2 | ||||
-rw-r--r-- | print11.c | 17 | ||||
-rw-r--r-- | proto.h | 1 | ||||
-rw-r--r-- | server.c | 25 | ||||
-rw-r--r-- | table11.c | 3 | ||||
-rw-r--r-- | x11.h | 5 |
7 files changed, 80 insertions, 1 deletions
diff --git a/extensions.c b/extensions.c index bacc47e..b374b67 100644 --- a/extensions.c +++ b/extensions.c @@ -85,6 +85,9 @@ DefineExtNameValue(int type, unsigned char value, const char *extname) case ERROR: typename = "-Error"; break; + case EXTENSION: + typename = ""; + break; default: panic("Impossible argument to DefineExtNameValue"); } @@ -142,6 +145,8 @@ ProcessQueryExtensionReply(long seq, const unsigned char *buf) ext_by_request[qe->request - EXTENSION_MIN_REQ] = qe; + DefineExtNameValue(EXTENSION, qe->request, qe->name); + for (i = 0; decodable_extensions[i].name != NULL ; i++) { if (strcmp(qe->name, decodable_extensions[i].name) == 0) { decodable_extensions[i].init_func(buf); @@ -171,6 +176,7 @@ static extension_decode_req_ptr ExtensionRequestDecoder[NUM_EXTENSIONS]; static extension_decode_reply_ptr ExtensionReplyDecoder[NUM_EXTENSIONS]; static extension_decode_error_ptr ExtensionErrorDecoder[NUM_EXTENSIONS]; static extension_decode_event_ptr ExtensionEventDecoder[NUM_EXT_EVENTS]; +static extension_decode_event_ptr GenericEventDecoder[NUM_EXTENSIONS]; void InitializeExtensionDecoder (int Request, extension_decode_req_ptr reqd, @@ -216,6 +222,21 @@ InitializeExtensionEventDecoder(int Event, extension_decode_event_ptr evd) ExtensionEventDecoder[Event - EXTENSION_MIN_EV] = evd; } + +void +InitializeGenericEventDecoder(int Request, extension_decode_event_ptr evd) +{ + if ((Request > EXTENSION_MAX_REQ) || (Request < EXTENSION_MIN_REQ)) { + char errmsg[128]; + + snprintf(errmsg, sizeof(errmsg), "Failed to register decoder" + " for invalid generic extension event code %d.", Request); + warn(errmsg); + return; + } + GenericEventDecoder[Request - EXTENSION_MIN_REQ] = evd; +} + void ExtensionRequest (FD fd, const unsigned char *buf, short Request) { @@ -273,10 +294,17 @@ ExtensionEvent (FD fd, const unsigned char *buf, short Event) if ((Event <= EXTENSION_MAX_EV) && (Event >= EXTENSION_MIN_EV)) { decode_event = ExtensionEventDecoder[Event - EXTENSION_MIN_EV]; + } else if (Event == Event_Type_Generic) { + int Request = IByte (&buf[1]); + if ((Request <= EXTENSION_MAX_REQ) && (Request >= EXTENSION_MIN_REQ)) { + decode_event = GenericEventDecoder[Request - EXTENSION_MIN_REQ]; + } } if (decode_event != NULL) { decode_event(fd, buf); + } else if (Event == Event_Type_Generic) { + UnknownGenericEvent(buf); } else { UnknownEvent(buf); } diff --git a/extensions.h b/extensions.h index d93e013..8529b65 100644 --- a/extensions.h +++ b/extensions.h @@ -75,5 +75,7 @@ extern void InitializeExtensionErrorDecoder(int Error, extension_decode_error_ptr errd); extern void InitializeExtensionEventDecoder(int Event, extension_decode_event_ptr evd); +extern void InitializeGenericEventDecoder (int Request, + extension_decode_event_ptr evd); #endif /* XSCOPE_EXTENSIONS_H */ @@ -954,6 +954,23 @@ MappingNotifyEvent ( } void +UnknownGenericEvent ( + const unsigned char *buf) +{ + long n; + + PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* GenericEvent */; + if (Verbose < 1) + return; + PrintField(buf, 1, 1, EXTENSION, "extension"); + printfield (buf, 2, 2, CARD16, "sequence number"); + printfield (buf, 4, 4, DVALUE4(n), "event length"); + PrintField(buf, 2, 8, CARD16, "event type"); + n = ILong (&buf[4]) + 5; + (void) PrintList (&buf[12], n, CARD32, "data"); +} + +void UnknownEvent ( const unsigned char *buf) { @@ -78,6 +78,7 @@ extern void SelectionNotifyEvent (const unsigned char *buf); extern void ColormapNotifyEvent (const unsigned char *buf); extern void ClientMessageEvent (const unsigned char *buf); extern void MappingNotifyEvent (const unsigned char *buf); +extern void UnknownGenericEvent (const unsigned char *buf); extern void UnknownEvent (const unsigned char *buf); extern void ExtendedRequest (int fd, const unsigned char *buf); @@ -683,20 +683,43 @@ ErrorPacket ( return(n); } +/* FinishEvent/EventPacket: since GenericEvents may be longer than 32 bytes + now, mirror the FinishReply/ReplyPacket model for getting the required + data length to handle them. */ static long -EventPacket ( +FinishEvent ( FD fd, const unsigned char *buf, long n) { CS[fd].ByteProcessing = ServerPacket; CS[fd].NumberofBytesNeeded = 32; + enterprocedure("FinishEvent"); if (ScopeEnabled) DecodeEvent(fd, buf, n); return(n); } +static long +EventPacket ( + FD fd, + const unsigned char *buf, + long n) +{ + short Event = IByte (&buf[0]); + long eventlength = 0; + + CS[fd].ByteProcessing = FinishEvent; + CS[fd].NumberofBytesNeeded = 32; + if (Event == Event_Type_Generic) { + eventlength = ILong(&buf[4]); + CS[fd].NumberofBytesNeeded += (4 * eventlength); + } + debug(8,(stderr, "need %ld bytes to finish reply\n", (4 * eventlength))); + return(0); +} + static long ReplyPacket ( @@ -604,6 +604,7 @@ InitEnumeratedTypes (void) DefineEValue(p, 32L, "ColormapNotify"); DefineEValue(p, 33L, "ClientMessage"); DefineEValue(p, 34L, "MappingNotify"); + DefineEValue(p, 35L, "GenericEvent"); p = DefineType(BITGRAVITY, ENUMERATED, "BITGRAVITY", (PrintProcType) PrintENUMERATED); @@ -876,6 +877,8 @@ InitEnumeratedTypes (void) DefineEValue(p, 3L, "PseudoColor"); DefineEValue(p, 4L, "TrueColor"); DefineEValue(p, 5L, "DirectColor"); + + p = DefineType(EXTENSION, ENUMERATED, "EXTENSION", (PrintProcType) PrintENUMERATED); } /* ************************************************************ */ @@ -258,6 +258,8 @@ #define BIGREQREQUEST 157 #define BIGREQREPLY 158 +#define EXTENSION 159 + #define MaxTypes 256 extern char ScopeEnabled; @@ -589,4 +591,7 @@ extern const char REQUESTHEADER[], EVENTHEADER[], ERRORHEADER[], REPLYHEADER[]; } \ } while (0) +/* Constant defined in Generic Event Protocol 1.0 for event type */ +#define Event_Type_Generic 35 + #endif /* XSCOPE_X11_H */ |