⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xtest1di.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 2 页
字号:
/* $XConsortium: xtest1di.c,v 1.13 94/04/17 20:33:01 rws Exp $ *//* $XFree86: xc/programs/Xserver/Xext/xtest1di.c,v 3.0 1996/05/06 05:55:45 dawes Exp $ *//* *	File:  xtest1di.c * *	This file contains the device independent parts of the input *	synthesis extension. *//*Copyright (c) 1986, 1987, 1988   X ConsortiumPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THEX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER INAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR INCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.Except as contained in this notice, the name of the X Consortium shall not beused in advertising or otherwise to promote the sale, use or other dealingsin this Software without prior written authorization from the X Consortium.Copyright 1986, 1987, 1988 by Hewlett-Packard CorporationPermission to use, copy, modify, and distribute thissoftware and its documentation for any purpose and withoutfee is hereby granted, provided that the above copyrightnotice appear in all copies and that both that copyrightnotice and this permission notice appear in supportingdocumentation, and that the name of Hewlett-Packard not be used inadvertising or publicity pertaining to distribution of thesoftware without specific, written prior permission.Hewlett-Packard makes no representations about the suitability of this software for any purpose.  It is provided "as is" without express or implied warranty.This software is not subject to any license of the AmericanTelephone and Telegraph Company or of the Regents of theUniversity of California.*//***************************************************************************** * include files ****************************************************************************/#define	 NEED_EVENTS#define	 NEED_REPLIES#include <stdio.h>#include "X.h"#include "Xproto.h"#include "misc.h"#include "os.h"#include "gcstruct.h"   #include "extnsionst.h"#include "dixstruct.h"#include "opaque.h"#define  XTestSERVER_SIDE#include "xtestext1.h"#include "xtest1dd.h"/***************************************************************************** * defines ****************************************************************************//***************************************************************************** * externals ****************************************************************************//* * id of client using XTestGetInput * * defined in xtest1dd.c */extern ClientPtr	current_xtest_client;/* * id of client using XTestFakeInput * * defined in xtest1dd.c */extern ClientPtr	playback_client;/***************************************************************************** * variables ****************************************************************************//* * Holds the request type code for this extension.  The request type code * for this extension may vary depending on how many extensions are installed * already, so the initial value given below will be added to the base request * code that is aquired when this extension is installed. */static int 		XTestReqCode = 0;/* * Holds the two event type codes for this extension.  The event type codes * for this extension may vary depending on how many extensions are installed * already, so the initial values given below will be added to the base event * code that is aquired when this extension is installed. */int 			XTestInputActionType = 0;int 			XTestFakeAckType = 1;/* * true => monitor stealing input */int			on_steal_input = FALSE;/* * true => monitor alone getting input */int			exclusive_steal = FALSE;/* * holds the resource type assigned to this extension */static RESTYPE		XTestType;/* * holds the resource ID for the client currently using XTestGetInput */static XID		current_client_id;/***************************************************************************** * function declarations ****************************************************************************/static DISPATCH_PROC(ProcXTestDispatch);static DISPATCH_PROC(SProcXTestDispatch);static DISPATCH_PROC(ProcTestFakeInput);static DISPATCH_PROC(SProcTestFakeInput);static DISPATCH_PROC(ProcTestGetInput);static DISPATCH_PROC(SProcTestGetInput);static DISPATCH_PROC(ProcTestStopInput);static DISPATCH_PROC(SProcTestStopInput);static DISPATCH_PROC(ProcTestReset);static DISPATCH_PROC(SProcTestReset);static DISPATCH_PROC(ProcTestQueryInputSize);static DISPATCH_PROC(SProcTestQueryInputSize);static void	XTestResetProc(#if NeedFunctionPrototypes	ExtensionEntry *	/* unused */#endif	);static void	SReplyXTestDispatch(#if NeedFunctionPrototypes	ClientPtr		/* client_ptr */,	int			/* size */,	char *			/* reply_ptr */#endif	);static void	SEventXTestDispatch(#if NeedFunctionPrototypes	xEvent *		/* from */,	xEvent *		/* to */#endif	);static int	XTestCurrentClientGone(#if NeedFunctionPrototypes	pointer			/* value */,	XID			/* id */#endif	);/***************************************************************************** * *	XTestExtension1Init * *	Called from InitExtensions in main() or from QueryExtension() if the *	extension is dynamically loaded. * *	XTestExtension1Init has no events or errors *	(other than the core errors). */voidXTestExtension1Init(){	/*	 * holds the pointer to the extension entry structure	 */	ExtensionEntry	*extEntry;	extEntry = AddExtension(XTestEXTENSION_NAME,				XTestEVENT_COUNT,				0,				ProcXTestDispatch,				SProcXTestDispatch,				XTestResetProc,				StandardMinorOpcode);	if (extEntry)	{		/*		 * remember the request code assigned to this extension		 */		XTestReqCode = extEntry->base;		/*		 * make an atom saying that this extension is present		 */		(void) MakeAtom(XTestEXTENSION_NAME,				strlen(XTestEXTENSION_NAME),				TRUE);		/*		 * remember the event codes assigned to this extension		 */		XTestInputActionType += extEntry->eventBase;		XTestFakeAckType += extEntry->eventBase;		/*		 * install the routine to handle byte-swapping the replies		 * for this extension in the ReplySwapVector table		 */		ReplySwapVector[XTestReqCode] = (ReplySwapPtr) SReplyXTestDispatch;		/*		 * install the routine to handle byte-swapping the events		 * for this extension in the EventSwapVector table		 */		EventSwapVector[XTestInputActionType] = SEventXTestDispatch;		EventSwapVector[XTestFakeAckType] = SEventXTestDispatch;		/*		 * get the resource type for this extension		 */		XTestType = CreateNewResourceType(XTestCurrentClientGone);		if (XTestType == 0)		{			FatalError("XTestExtension1Init: CreateNewResourceType failed\n");		}	} 	else 	{		FatalError("XTestExtension1Init: AddExtensions failed\n");	}}/***************************************************************************** * *	ProcXTestDispatch * * */static intProcXTestDispatch(client)	register ClientPtr	client;{	REQUEST(xReq);	if (stuff->data == X_TestFakeInput)	{		return(ProcTestFakeInput(client));	}	else if (stuff->data == X_TestGetInput)	{		return(ProcTestGetInput(client));	}	else if (stuff->data == X_TestStopInput)	{		return(ProcTestStopInput(client));	}	else if (stuff->data == X_TestReset)	{		return(ProcTestReset(client));	}	else if (stuff->data == X_TestQueryInputSize)	{		return(ProcTestQueryInputSize(client));	}	else	{		SendErrorToClient(client,				  XTestReqCode,				  stuff->data,				  None,				  BadRequest);		return(BadRequest);	}}/***************************************************************************** * *	SProcXTestDispatch * * */static intSProcXTestDispatch(client)	register ClientPtr	client;{	REQUEST(xReq);	if (stuff->data == X_TestFakeInput)	{		return(SProcTestFakeInput(client));	}	else if (stuff->data == X_TestGetInput)	{		return(SProcTestGetInput(client));	}	else if (stuff->data == X_TestStopInput)	{		return(SProcTestStopInput(client));	}	else if (stuff->data == X_TestReset)	{		return(SProcTestReset(client));	}	else if (stuff->data == X_TestQueryInputSize)	{		return(SProcTestQueryInputSize(client));	}	else	{		SendErrorToClient(client,				  XTestReqCode,				  stuff->data,				  None,				  BadRequest);		return(BadRequest);	}}/***************************************************************************** * *	SProcTestFakeInput * * */static intSProcTestFakeInput(client)	register ClientPtr	client;{	/*	 * used in the swaps and swapl macros for temporary storage space	 */	register char	n;	/*	 * index counter	 */	int		i;	/*	 * pointer to the next input action in the request	 */	CARD8		*input_action_ptr;	/*	 * holds the type of the next input action in the request	 */	int		input_action_type;	REQUEST(xTestFakeInputReq);	/*	 * byte-swap the fields in the request	 */	swaps(&stuff->length, n);	swapl(&stuff->ack, n);	/*	 * have to parse and then byte-swap the input action list here	 */	for (i = 0; i < XTestMAX_ACTION_LIST_SIZE;)	{		/*		 * point to the next input action in the request		 */		input_action_ptr = &(((xTestFakeInputReq *) stuff)->action_list[i]);		/*		 * figure out what type of input action it is		 */		input_action_type = (*input_action_ptr) & XTestACTION_TYPE_MASK;		/*		 * byte-swap the input action according to it's type		 */		switch (input_action_type)		{		case XTestKEY_ACTION:			/*			 * byte-swap the delay_time field			 */			swaps(&(((XTestKeyInfo *) input_action_ptr)->delay_time), n);			/*			 * advance to the next input action			 */			i += sizeof(XTestKeyInfo);			break;		case XTestMOTION_ACTION:			/*			 * byte-swap the delay_time field			 */			swaps(&(((XTestMotionInfo *) input_action_ptr)->delay_time), n);			/*			 * advance to the next input action			 */			i += sizeof(XTestMotionInfo);			break;		case XTestJUMP_ACTION:			/*			 * byte-swap the jumpx field			 */			swaps(&(((XTestJumpInfo *) input_action_ptr)->jumpx), n);			/*			 * byte-swap the jumpy field			 */			swaps(&(((XTestJumpInfo *) input_action_ptr)->jumpy), n);			/*			 * byte-swap the delay_time field			 */			swaps(&(((XTestJumpInfo *) input_action_ptr)->delay_time), n);			/*			 * advance to the next input action			 */			i += sizeof(XTestJumpInfo);			break;		default:			/*			 * if this is a delay input action, then byte-swap it,			 * otherwise we have reached the end of the input			 * actions in this request			 */			if (XTestUnpackDeviceID(*input_action_ptr) ==			    XTestDELAY_DEVICE_ID)			{				/*				 * byte-swap the delay_time field				 */				swapl(&(((XTestDelayInfo *) input_action_ptr)->delay_time), n);				/*				 * advance to the next input action				 */				i += sizeof(XTestDelayInfo);			}			else			{				/*				 * if the input action header byte is 0 or				 * ill-formed, then there are no more input				 * actions in this request				 */				i = XTestMAX_ACTION_LIST_SIZE;			}			break;		}	}	return(ProcTestFakeInput(client));}/***************************************************************************** * *	SProcTestGetInput * * */static intSProcTestGetInput(client)	register ClientPtr	client;{	/*	 * used in the swaps and swapl macros for temporary storage space	 */	register char	n;	REQUEST(xTestGetInputReq);	/*	 * byte-swap the fields in the request	 */	swaps(&stuff->length, n);	swapl(&stuff->mode, n);	return(ProcTestGetInput(client));}/***************************************************************************** * *	SProcTestStopInput * * */static intSProcTestStopInput(client)	register ClientPtr	client;{	/*	 * used in the swaps and swapl macros for temporary storage space

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -