From 3199c6fb39f02b36a07ef65bf4b07d6ec340944d Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Wed, 12 Aug 2009 14:18:25 -0700 Subject: Convert extension decoding to function pointer tables Each extension now registers it's own request, reply, event & error decoding functions as needed in the central table, instead of a cascading block of if/else statements to modify for each new extension added. Signed-off-by: Alan Coopersmith --- decode_lbx.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'decode_lbx.c') diff --git a/decode_lbx.c b/decode_lbx.c index dd74657..90b9fd1 100644 --- a/decode_lbx.c +++ b/decode_lbx.c @@ -32,9 +32,10 @@ #include "lbxscope.h" #include "extensions.h" -unsigned char LBXRequest, LBXEvent, LBXError; +static unsigned char LBXRequest, LBXError; +unsigned char LBXEvent; /* exported for DecodeEvent in decode11.c */ -void +static void lbx_decode_req ( FD fd, const unsigned char *buf) @@ -70,7 +71,7 @@ lbx_decode_req ( } } -void +static void lbx_decode_reply ( FD fd, const unsigned char *buf, @@ -85,7 +86,7 @@ lbx_decode_reply ( } } -void +static void lbx_decode_error ( FD fd, const unsigned char *buf) @@ -100,7 +101,7 @@ lbx_decode_error ( } } -void +static void lbx_decode_event ( FD fd, const unsigned char *buf) @@ -149,4 +150,8 @@ InitializeLBX ( p = DefineType(LBXEVENT, ENUMERATED, "LBXEVENT", (PrintProcType) PrintENUMERATED); DefineEValue (p, 0L, "SwitchEvent"); DefineEValue (p, 1L, "CloseEvent"); + + InitializeExtensionDecoder(LBXRequest, lbx_decode_req, lbx_decode_reply); + InitializeExtensionErrorDecoder(LBXError, lbx_decode_error); + InitializeExtensionEventDecoder(LBXEvent, lbx_decode_event); } -- cgit v1.2.1