diff options
author | daniel <danieruru@gmail.com> | 2013-01-11 13:58:36 +0900 |
---|---|---|
committer | daniel <danieruru@gmail.com> | 2013-01-11 13:58:36 +0900 |
commit | 2287a7ca37de5dadf9eda790e3afa96262cb9e76 (patch) | |
tree | 3b39e28804e9193adad45d30fbe6be7e60fe2124 /libvxi11client/libvxi11client.c | |
parent | cacd8ba78d2c17286507d0bae498c136dba19c9c (diff) |
add callback for interrupt
Diffstat (limited to 'libvxi11client/libvxi11client.c')
-rw-r--r-- | libvxi11client/libvxi11client.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c index b212487..e33cb24 100644 --- a/libvxi11client/libvxi11client.c +++ b/libvxi11client/libvxi11client.c @@ -28,6 +28,7 @@ static CLIENT* abortclnt = NULL; static Device_Link link; static GThread* interruptthread; static bool interruptchannelopen = false; +static void (*interruptcallback)(void) = NULL; static void killinterruptthreadandwait() { #ifdef DEBUG @@ -43,6 +44,11 @@ device_intr_srq_1_svc(Device_SrqParms *argp, struct svc_req *rqstp) { #ifdef DEBUG printf("device_intr_srq_1_svc()\n"); #endif + + if (interruptcallback != NULL) { + interruptcallback(); + } + static char * result; return (void *) &result; } @@ -474,7 +480,7 @@ int vxi11_destroy_intr_chan() { * enable interrupts */ -int vxi11_enable_srq(bool enable, char* handle) { +int vxi11_enable_srq(bool enable, char* handle, void (*callback)(void)) { if (!interruptchannelopen) return 0; else if (clnt == NULL) @@ -483,9 +489,16 @@ int vxi11_enable_srq(bool enable, char* handle) { return 0; Device_EnableSrqParms params = { .lid = link, .enable = enable }; - if (handle != NULL) { - params.handle.handle_val = handle; - params.handle.handle_len = strlen(handle); + if (enable) { + if (handle != NULL) { + params.handle.handle_val = handle; + params.handle.handle_len = strlen(handle); + } + interruptcallback = callback; + } + else { + params.handle.handle_val = NULL; + params.handle.handle_len = 0; } Device_Error* error = device_enable_srq_1(¶ms, clnt); if (error != NULL && error->error == 0) { |