From 2c93550a5394c632ae6b820e38ca75ab5df5aae7 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 9 Jan 2013 14:34:55 +0900 Subject: a bit more fleshing out on the server side --- vxi11_server.c | 74 +++++++++++++++++++++++++--------------------------------- 1 file changed, 32 insertions(+), 42 deletions(-) (limited to 'vxi11_server.c') diff --git a/vxi11_server.c b/vxi11_server.c index 950a31d..ec2eb95 100644 --- a/vxi11_server.c +++ b/vxi11_server.c @@ -32,8 +32,8 @@ static bool haveLock(int lid) { return globals.VxiLocks.locked_network_server == lid; } -static void waitForLock(long timeout) { - +static bool waitForLock(long timeout) { + return false; } static void lock(int lid) { @@ -67,33 +67,33 @@ create_link_1_svc(Create_LinkParms *argp, struct svc_req *rqstp) { Device_WriteResp * device_write_1_svc(Device_WriteParms *argp, struct svc_req *rqstp) { - printf("device_write_1_svc()\n"); static Device_WriteResp result; - printf("%s\n", argp->data.data_val); - - /* - * insert server code here - */ + printf("device_write_1_svc()\n"); - //result.size = argp->data.data_len; - result.size = 1; - result.error = 0; + if (isLocked(argp->lid) && !haveLock(argp->lid)) + result.error = ERR_DEVICELOCKEDBYANOTHERLINK; + else { + printf("%s\n", argp->data.data_val); + //result.size = argp->data.data_len; + result.size = 1; + result.error = 0; + } return &result; } Device_ReadResp * device_read_1_svc(Device_ReadParms *argp, struct svc_req *rqstp) { - printf("device_read_1_svc()\n"); static Device_ReadResp result; + printf("device_read_1_svc()\n"); - /* - * insert server code here - */ - - result.data.data_val = "HELLO!"; - result.data.data_len = 7; - result.error = 0; - result.reason = 0x4; + if (isLocked(argp->lid) && !haveLock(argp->lid)) + result.error = ERR_DEVICELOCKEDBYANOTHERLINK; + else { + result.data.data_val = "HELLO!"; + result.data.data_len = 7; + result.error = 0; + result.reason = 0x4; + } return &result; } @@ -111,10 +111,6 @@ device_trigger_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) { printf("device_trigger_1_svc()\n"); static Device_Error result; - /* - * insert server code here - */ - result.error = 0; return &result; } @@ -124,44 +120,39 @@ device_clear_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) { printf("device_clear_1_svc()\n"); static Device_Error result; - /* - * insert server code here - */ - result.error = 0; return &result; } Device_Error * device_remote_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) { - printf("device_remote_1_svc()\n"); static Device_Error result; + printf("device_remote_1_svc()\n"); - /* - * insert server code here - */ - - result.error = 0; + if (isLocked() && !haveLock(argp->lid)) + result.error = ERR_DEVICELOCKEDBYANOTHERLINK; + else + result.error = 0; return &result; } Device_Error * device_local_1_svc(Device_GenericParms *argp, struct svc_req *rqstp) { - printf("device_local_1_svc()\n"); static Device_Error result; + printf("device_local_1_svc()\n"); - /* - * insert server code here - */ - result.error = 0; + if (isLocked() && !haveLock(argp->lid)) + result.error = ERR_DEVICELOCKEDBYANOTHERLINK; + else + result.error = 0; return &result; } Device_Error * device_lock_1_svc(Device_LockParms *argp, struct svc_req *rqstp) { static Device_Error result; - printf("device_lock_1_svc()\n"); + if (isLocked(argp->lid)) { result.error = ERR_DEVICELOCKEDBYANOTHERLINK; if (haveLock(argp->lid)) { @@ -172,7 +163,6 @@ device_lock_1_svc(Device_LockParms *argp, struct svc_req *rqstp) { lock(argp->lid); result.error = 0; } - return &result; } @@ -192,8 +182,8 @@ device_unlock_1_svc(Device_Link *argp, struct svc_req *rqstp) { Device_Error * device_enable_srq_1_svc(Device_EnableSrqParms *argp, struct svc_req *rqstp) { - printf("device_enable_srq_1_svc()\n"); static Device_Error result; + printf("device_enable_srq_1_svc()\n"); return &result; } -- cgit