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

📄 dixutils.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 2 页
字号:
/***********************************************************Copyright (c) 1987  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 1987 by Digital Equipment Corporation, Maynard, Massachusetts.                        All Rights ReservedPermission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and thatboth that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not beused in advertising or publicity pertaining to distribution of thesoftware without specific, written prior permission.  DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THISSOFTWARE.******************************************************************//*(c)Copyright 1988,1991 Adobe Systems Incorporated. All rights reserved.Permission to use, copy, modify, distribute, and sublicense this software and itsdocumentation for any purpose and without fee is hereby granted, provided thatthe above copyright notices appear in all copies and that both those copyrightnotices and this permission notice appear in supporting documentation and thatthe name of Adobe Systems Incorporated not be used in advertising or publicitypertaining to distribution of the software without specific, written priorpermission.  No trademark license to use the Adobe trademarks is herebygranted.  If the Adobe trademark "Display PostScript"(tm) is used to describethis software, its functionality or for any other purpose, such use shall belimited to a statement that this software works in conjunction with the DisplayPostScript system.  Proper trademark attribution to reflect Adobe's ownershipof the trademark shall be given whenever any such reference to the DisplayPostScript system is made.ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR ANYPURPOSE.  IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.  ADOBEDISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIEDWARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY RIGHTS.  IN NO EVENT SHALL ADOBE BE LIABLE TO YOUOR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANYDAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,NEGLIGENCE, STRICTLIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE ORPERFORMANCE OF THIS SOFTWARE.  ADOBE WILL NOT PROVIDE ANY TRAINING OR OTHERSUPPORT FOR THE SOFTWARE.Adobe, PostScript, and Display PostScript are trademarks of Adobe SystemsIncorporated which may be registered in certain jurisdictions.Author:  Adobe Systems Incorporated*//* $TOG: dixutils.c /main/33 1997/05/22 10:02:20 kaleb $ *//* $XFree86: xc/programs/Xserver/dix/dixutils.c,v 3.1.2.1 1997/05/23 12:19:35 dawes Exp $ */#include "X.h"#include "Xmd.h"#include "misc.h"#include "windowstr.h"#include "dixstruct.h"#include "pixmapstr.h"#include "scrnintstr.h"#define  XK_LATIN1#include "keysymdef.h"#ifdef XCSECURITY#define _SECURITY_SERVER#include "extensions/security.h"#endif/* * CompareTimeStamps returns -1, 0, or +1 depending on if the first * argument is less than, equal to or greater than the second argument. */intCompareTimeStamps(a, b)    TimeStamp a, b;{    if (a.months < b.months)	return EARLIER;    if (a.months > b.months)	return LATER;    if (a.milliseconds < b.milliseconds)	return EARLIER;    if (a.milliseconds > b.milliseconds)	return LATER;    return SAMETIME;}/* * convert client times to server TimeStamps */#define HALFMONTH ((unsigned long) 1<<31)TimeStampClientTimeToServerTime(c)     CARD32 c;{    TimeStamp ts;    if (c == CurrentTime)	return currentTime;    ts.months = currentTime.months;    ts.milliseconds = c;    if (c > currentTime.milliseconds)    {	if (((unsigned long) c - currentTime.milliseconds) > HALFMONTH)	    ts.months -= 1;    }    else if (c < currentTime.milliseconds)    {	if (((unsigned long)currentTime.milliseconds - c) > HALFMONTH)	    ts.months += 1;    }    return ts;}/* * ISO Latin-1 case conversion routine * * this routine always null-terminates the result, so * beware of too-small buffers */voidCopyISOLatin1Lowered(dest, source, length)    register unsigned char *dest, *source;    int length;{    register int i;    for (i = 0; i < length; i++, source++, dest++)    {	if ((*source >= XK_A) && (*source <= XK_Z))	    *dest = *source + (XK_a - XK_A);	else if ((*source >= XK_Agrave) && (*source <= XK_Odiaeresis))	    *dest = *source + (XK_agrave - XK_Agrave);	else if ((*source >= XK_Ooblique) && (*source <= XK_Thorn))	    *dest = *source + (XK_oslash - XK_Ooblique);	else	    *dest = *source;    }    *dest = '\0';}#ifdef XCSECURITY/* SecurityLookupWindow and SecurityLookupDrawable: * Look up the window/drawable taking into account the client doing * the lookup and the type of access desired.  Return the window/drawable * if it exists and the client is allowed access, else return NULL. * Most Proc* functions should be calling these instead of * LookupWindow and LookupDrawable, which do no access checks. */WindowPtrSecurityLookupWindow(rid, client, access_mode)    XID rid;    ClientPtr client;    Mask access_mode;{    WindowPtr	pWin;    client->errorValue = rid;    if(rid == INVALID)	return NULL;    if (client->trustLevel != XSecurityClientTrusted)	return (WindowPtr)SecurityLookupIDByType(client, rid, RT_WINDOW, access_mode);    if (client->lastDrawableID == rid)    {        if (client->lastDrawable->type == DRAWABLE_WINDOW)            return ((WindowPtr) client->lastDrawable);        return (WindowPtr) NULL;    }    pWin = (WindowPtr)SecurityLookupIDByType(client, rid, RT_WINDOW, access_mode);    if (pWin && pWin->drawable.type == DRAWABLE_WINDOW) {	client->lastDrawable = (DrawablePtr) pWin;	client->lastDrawableID = rid;	client->lastGCID = INVALID;	client->lastGC = (GCPtr)NULL;    }    return pWin;}pointerSecurityLookupDrawable(rid, client, access_mode)    XID rid;    ClientPtr client;    Mask access_mode;{    register DrawablePtr pDraw;    if(rid == INVALID)	return (pointer) NULL;    if (client->trustLevel != XSecurityClientTrusted)	return (DrawablePtr)SecurityLookupIDByClass(client, rid, RC_DRAWABLE,						    access_mode);    if (client->lastDrawableID == rid)	return ((pointer) client->lastDrawable);    pDraw = (DrawablePtr)SecurityLookupIDByClass(client, rid, RC_DRAWABLE,						 access_mode);    if (pDraw && (pDraw->type != UNDRAWABLE_WINDOW))        return (pointer)pDraw;		    return (pointer)NULL;}/* We can't replace the LookupWindow and LookupDrawable functions with * macros because of compatibility with loadable servers. */WindowPtrLookupWindow(rid, client)    XID rid;    ClientPtr client;{    return SecurityLookupWindow(rid, client, SecurityUnknownAccess);}pointerLookupDrawable(rid, client)    XID rid;    ClientPtr client;{    return SecurityLookupDrawable(rid, client, SecurityUnknownAccess);}#else /* not XCSECURITY */WindowPtrLookupWindow(rid, client)    XID rid;    ClientPtr client;{    WindowPtr	pWin;    client->errorValue = rid;    if(rid == INVALID)	return NULL;    if (client->lastDrawableID == rid)    {        if (client->lastDrawable->type == DRAWABLE_WINDOW)            return ((WindowPtr) client->lastDrawable);        return (WindowPtr) NULL;    }    pWin = (WindowPtr)LookupIDByType(rid, RT_WINDOW);    if (pWin && pWin->drawable.type == DRAWABLE_WINDOW) {	client->lastDrawable = (DrawablePtr) pWin;	client->lastDrawableID = rid;	client->lastGCID = INVALID;	client->lastGC = (GCPtr)NULL;    }    return pWin;}pointerLookupDrawable(rid, client)    XID rid;    ClientPtr client;{    register DrawablePtr pDraw;    if(rid == INVALID)	return (pointer) NULL;    if (client->lastDrawableID == rid)	return ((pointer) client->lastDrawable);    pDraw = (DrawablePtr)LookupIDByClass(rid, RC_DRAWABLE);    if (pDraw && (pDraw->type != UNDRAWABLE_WINDOW))        return (pointer)pDraw;		    return (pointer)NULL;}#endif /* XCSECURITY */ClientPtrLookupClient(rid, client)    XID rid;    ClientPtr client;{    pointer pRes = (pointer)SecurityLookupIDByClass(client, rid, RC_ANY,						    SecurityReadAccess);    int clientIndex = CLIENT_ID(rid);    if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT))    {	return clients[clientIndex];    }    return (ClientPtr)NULL;}intAlterSaveSetForClient(client, pWin, mode)    ClientPtr client;    WindowPtr pWin;    unsigned mode;{    int numnow;    pointer *pTmp;    int j;    numnow = client->numSaved;    j = 0;    if (numnow)    {	pTmp = client->saveSet;	while ((j < numnow) && (pTmp[j] != (pointer)pWin))	    j++;    }    if (mode == SetModeInsert)    {	if (j < numnow)         /* duplicate */	   return(Success);	numnow++;	pTmp = (pointer *)xrealloc(client->saveSet, sizeof(pointer) * numnow);	if (!pTmp)	    return(BadAlloc);	client->saveSet = pTmp;       	client->numSaved = numnow;	client->saveSet[numnow - 1] = (pointer)pWin;	return(Success);    }    else if ((mode == SetModeDelete) && (j < numnow))    {	while (j < numnow-1)	{           pTmp[j] = pTmp[j+1];	   j++;	}	numnow--;        if (numnow)	{    	    pTmp = (pointer *)xrealloc(client->saveSet,				       sizeof(pointer) * numnow);	    if (pTmp)		client->saveSet = pTmp;	}        else        {            xfree(client->saveSet);	    client->saveSet = (pointer *)NULL;	}	client->numSaved = numnow;	return(Success);    }    return(Success);}voidDeleteWindowFromAnySaveSet(pWin)    WindowPtr pWin;{    register int i;    register ClientPtr client;        for (i = 0; i< currentMaxClients; i++)    {    	client = clients[i];	if (client && client->numSaved)	    (void)AlterSaveSetForClient(client, pWin, SetModeDelete);    }}/* No-op Don't Do Anything : sometimes we need to be able to call a procedure * that doesn't do anything.  For example, on screen with only static * colormaps, if someone calls install colormap, it's easier to have a dummy * procedure to call than to check if there's a procedure  */voidNoopDDA(#undef NeedVarargsPrototypes#if NeedVarargsPrototypes    void* f, ...#endif){}typedef struct _BlockHandler {    BlockHandlerProcPtr BlockHandler;    WakeupHandlerProcPtr WakeupHandler;    pointer blockData;    Bool    deleted;} BlockHandlerRec, *BlockHandlerPtr;static BlockHandlerPtr	handlers;static int		numHandlers;static int		sizeHandlers;static Bool		inHandler;static Bool		handlerDeleted;/* called from the OS layer */voidBlockHandler(pTimeout, pReadmask)pointer	pTimeout;	/* DIX doesn't want to know how OS represents time */pointer pReadmask;	/* nor how it represents the set of descriptors */{    register int i, j;        ++inHandler;    for (i = 0; i < screenInfo.numScreens; i++)	(* screenInfo.screens[i]->BlockHandler)(i, 				screenInfo.screens[i]->blockData,				pTimeout, pReadmask);    for (i = 0; i < numHandlers; i++)	(*handlers[i].BlockHandler) (handlers[i].blockData,				     pTimeout, pReadmask);    if (handlerDeleted)    {	for (i = 0; i < numHandlers;)	    if (handlers[i].deleted)	    {	    	for (j = i; j < numHandlers - 1; j++)		    handlers[j] = handlers[j+1];	    	numHandlers--;	    }	    else		i++;	handlerDeleted = FALSE;    }    --inHandler;}voidWakeupHandler(result, pReadmask)int	result;	/* 32 bits of undefined result from the wait */pointer pReadmask;	/* the resulting descriptor mask */{    register int i, j;    ++inHandler;    for (i = numHandlers - 1; i >= 0; i--)	(*handlers[i].WakeupHandler) (handlers[i].blockData,				      result, pReadmask);    for (i = 0; i < screenInfo.numScreens; i++)	(* screenInfo.screens[i]->WakeupHandler)(i, 				screenInfo.screens[i]->wakeupData,				result, pReadmask);    if (handlerDeleted)    {	for (i = 0; i < numHandlers;)	    if (handlers[i].deleted)	    {	    	for (j = i; j < numHandlers - 1; j++)		    handlers[j] = handlers[j+1];	    	numHandlers--;	    }	    else		i++;	handlerDeleted = FALSE;    }    --inHandler;}/* Reentrant with BlockHandler and WakeupHandler, except wakeup won't * get called until next time */BoolRegisterBlockAndWakeupHandlers (blockHandler, wakeupHandler, blockData)    BlockHandlerProcPtr blockHandler;    WakeupHandlerProcPtr wakeupHandler;    pointer blockData;{    BlockHandlerPtr new;    if (numHandlers >= sizeHandlers)    {    	new = (BlockHandlerPtr) xrealloc (handlers, (numHandlers + 1) *				      	  sizeof (BlockHandlerRec));    	if (!new)

⌨️ 快捷键说明

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