GIF89a=( �' 7IAXKgNgYvYx\%wh&h}t�h%�s%x�}9�R��&�0%� (�.��5�SD��&�a)�x5��;ͣ*ȡ&ղ)ׯ7׵<ѻ4�3�H֧KͯT��Y�aq��q��F� !� ' !� NETSCAPE2.0 , =( ��pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g���E�������R���E����B�� ��ȸ��D���"�Ů� �H��L��D٫D�B�����D���T���H �G��A R�ڐ |�� ٭&��E8�S�kG�A�px�a��� R2XB��E8I���6X�:vT)�~��q�賥��"F~%x� � 4#Z�0O|-4Bs�X:= Q� Sal��yXJ`GȦ|s h��K3l7�B|�$'7Jީܪ0!��D�n=�P� ����0`�R�lj����v>���5 �.69�ϸd�����nlv�9��f{���Pbx �l5}�p� ��� �3a���I�O����!ܾ���i��9��#��)p�a ޽ �{�)vm��%D~ 6f��s}Œ�D�W E�`!� �&L8x� �ܝ{)x`X/>�}m��R�*|`D�=�_ ^�5 !_&'a�O�7�c��`DCx`�¥�9�Y�F���`?��"� �n@`�} lď��@4>�d S �v�xN��"@~d��=�g�s~G��� ���ud &p8Q�)ƫlXD����A~H�ySun�j���k*D�LH�] ��C"J��Xb~ʪwSt}6K,��q�S:9ت:���l�@�`�� �.۬�t9�S�[:��=`9N����{¿�A !R�:���6��x�0�_ �;������^���#����!����U���;0L1�����p% A��U̬ݵ��%�S��!���~`�G���� ���=4�np�3���������u�u�ٮ|%2�I��r�#0��J``8�@S@5� ���^`8E�]�.�S���7 � �0�j S�D� z���i�S�����!���l��w9*�D�I�nEX��� &A�Go�Qf��F��;���}�J����F5��Q|���X��T��y���]� o ��C=��:���PB@ D׽S�(>�C�x}`��xJЬ�۠��p+eE0`�}`A �/NE�� �9@��� H�7�!%B0`�l*��!8 2�%� �:�1�0E��ux%nP1�!�C)�P81l�ɸF#Ƭ{����B0>�� �b�`��O3��()yRpb��E.ZD8�H@% �Rx+%���c� ���f��b�d�`F�"8�XH"��-�|1�6iI, 2�$+](A*j� QT�o0.�U�`�R�}`�SN����yae�����b��o~ S)�y�@��3 �tT�0�&�+~L�f"�-|�~��>!�v��~�\Q1)}@�}h#aP72�"�$ !� " , =( &7IAXG]KgNgYvYxR"k\%w]'}h}t�h%�g+�s%r.m3ax3�x�}9��&��+�!7�0%� (�.�SD��&��;�"&ײ)׻4��6�K� �@pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g �� E �� �������E �´��C���ǶR��D��"Ʒ�ʱH��M��GڬD�B����D��T����G���C�C� l&�~:'�tU�6ɹ#��)�'�.6�&��Ȼ K(8p0N�?!�2"��NIJX>R��OM '��2�*x�>#n� �@<[:�I�f ��T���Cdb��[�}E�5MBo��@�`@��tW-3 �x�B���jI�&E�9[T&$��ﯧ&"s��ȳ����dc�UUρ#���ldj?����`\}���u|3'�R]�6 �S#�!�FKL�*N E���`$�:e�YD�q�.�촁�s \-�jA 9�����-��M[�x(�s��x�|���p��}k�T�DpE@W� ��]k`1� ���Yb ��0l��*n0��"~zBd�~u�7�0Bl��0-�x~|U�U0 �h�*HS�|��e"#"?vp�i`e6^�+q��`m8 #V�� ��VS|`��"m"сSn|@:U���~`pb�G�ED����2F�I�? >�x� R� ��%~jx��<�a�9ij�2�D��&: Z`�]w���:�6��B�7eFJ|�ҧ�,���FǮcS�ʶ+B�,�ܺN���>PAD�HD��~���n��}�#�� Q��S���2�X�{�k�lQ�2�����w�|2� h9��G�,m���3��6-��E�L��I�³*K���q�`DwV�QXS��peS��� qܧTS����R�u �<�a�*At�lmE� � ��N[P1�ۦ��$��@`��Dpy�yXvCAy�B`}D� 0QwG#� �a[^�� $���Ǧ{L�"[��K�g�;�S~��GX.�goT.��ư��x���?1z��x~:�g�|�L� ��S`��0S]P�^p F<""�?!,�!N4&P� ����:T�@h�9%t��:�-~�I<`�9p I&.)^ 40D#p@�j4�ج:�01��rܼF2oW�#Z ;$Q q  �K��Nl#29 !F@�Bh�ᏬL!XF�LHKh�.�hE&J�G��<"WN!�����Y@� >R~19J"�2,/ &.GXB%�R�9B6�W]���W�I�$��9�RE8Y� ��"�A5�Q.axB�&ة�J�! �t)K%tS-�JF b�NMxL��)�R��"���6O!TH�H� 0 !� ) , =( &AXKgNgYvYxR"k\%wh&h}h%�g+�s%r.x3�x�}9��&��+�R,�!7�0%� (�.��5��&�a)��;�"&ף*Ȳ)ׯ7׻4�3��6�H֧KͻH�T��Y��q��h� ��pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g �� E$����� � ����$E$��"��D� � ������R��C��� E ��H�M��G�D� �B��ϾD��a��`1r��Ӑ�� �o~�zU!L�C'�yW�UGt����ll�0���uG�)A�s[��x� �xO%��X2�  P�n:R/��aHae+�Dm?# ǣ6�8�J�x�Di�M���j���5oQ7�- <! *�l��R2r/a!l)d� A"�E���� &� ;��c �%����b��pe~C"B���H�eF2��`8qb�t_`ur`e� w�u3��Pv�h""�`�Íx�LĹ��3� �~ֺ�:���MDfJ� �۵�W�%�S�X �؁)�@��:E��w�u�Sxb8y\m�zS��Zb�E�L��w!y(>�"w�=�|��s�d �C�W)H�cC$�L �7r.�\{)@�`@ �X�$PD `aaG:���O�72E�amn]�"Rc�x�R� &dR8`g��i�xLR!�P &d����T���i�|�_ � Qi�#�`g:��:noM� :V �)p����W&a=�e�k� j���1߲s�x�W�jal|0��B0�, \j۴:6���C ��W��|��9���zĸV {�;��n��V�m�I��.��PN� ����C��+��By�ѾHŸ:��� 7�Y�FTk�SaoaY$D�S���29R�kt� ��f� ��:��Sp�3�I��DZ� �9���g��u�*3)O��[_hv ,���Et x�BH� �[��64M@�S�M7d�l�ܶ5-��U܍��z�R3Ԭ3~ ��P��5�g: ���kN�&0�j4���#{��3S�2�K�'ợl���2K{� {۶?~m𸧠�I�nE�='����^���_�=��~�#O���'���o..�Y�n��CSO��a��K��o,���b�����{�C�� "�{�K ��w��Ozdը�:$ ���v�] A#� ���a�z)Rx׿ƥ�d``�w-�y�f�K!����|��P��=�`�(f��'Pa ��BJa%��f�%`�}F����6>��`G"�}�=�!o`�^FP�ةQ�C���`(�}\�ݮ ��$<��n@dĠE#��U�I�!� #l��9`k���'Rr��Z�NB�MF �[�+9���-�wj���8�r� ,V�h"�|�S=�G_��"E� 0i*%̲��da0mVk�):;&6p>�jK ��# �D�:�c?:R Ӭf��I-�"�<�="��7�3S��c2RW ,�8(T"P0F¡Jh�" ; 403WebShell
403Webshell
Server IP : 81.88.48.95  /  Your IP : 10.2.217.94, 216.73.216.227
Web Server : Apache
System : Linux opus07 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u3 x86_64
User : nobody ( 99)
PHP Version : 5.3.3-7+squeeze3
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/share/vim/vimcurrent/tools/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/vim/vimcurrent/tools/xcmdsrv_client.c
/* vi:set ts=8 sts=4 sw=4:
 *
 * VIM - Vi IMproved	by Bram Moolenaar
 * X-Windows communication by Flemming Madsen
 *
 * Do ":help uganda"  in Vim to read copying and usage conditions.
 * Do ":help credits" in Vim to see a list of people who contributed.
 * See README.txt for an overview of the Vim source code.
 *
 * Client for sending commands to an '+xcmdsrv' enabled vim.
 * This is mostly a de-Vimified version of if_xcmdsrv.c in vim.
 * See that file for a protocol specification.
 *
 * You can make a test program with a Makefile like:
 *  xcmdsrv_client: xcmdsrv_client.c
 *	cc -o $@ -g -DMAIN -I/usr/X11R6/include -L/usr/X11R6/lib $< -lX11
 *
 */

#include <stdio.h>
#include <string.h>
#ifdef HAVE_SELECT
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#else
#include <sys/poll.h>
#endif
#include <X11/Intrinsic.h>
#include <X11/Xatom.h>

#define __ARGS(x) x

/* Client API */
char * sendToVim __ARGS((Display *dpy, char *name, char *cmd, int asKeys, int *code));

#ifdef MAIN
/* A sample program */
main(int argc, char **argv)
{
    char    *res;
    int	    code;

    if (argc == 4)
    {
	if ((res = sendToVim(XOpenDisplay(NULL), argv[2], argv[3],
			     argv[1][0] != 'e', &code)) != NULL)
	{
	    if (code)
		printf("Error code returned: %d\n", code);
	    puts(res);
	}
	exit(0);
    }
    else
	fprintf(stderr, "Usage: %s {k|e} <server> <command>", argv[0]);

    exit(1);
}
#endif

/*
 * Maximum size property that can be read at one time by
 * this module:
 */

#define MAX_PROP_WORDS 100000

/*
 * Forward declarations for procedures defined later in this file:
 */

static int	x_error_check __ARGS((Display *dpy, XErrorEvent *error_event));
static int	AppendPropCarefully __ARGS((Display *display,
		    Window window, Atom property, char *value, int length));
static Window	LookupName __ARGS((Display *dpy, char *name,
		    int delete, char **loose));
static int	SendInit __ARGS((Display *dpy));
static char	*SendEventProc __ARGS((Display *dpy, XEvent *eventPtr,
				      int expect, int *code));
static int	IsSerialName __ARGS((char *name));

/* Private variables */
static Atom	registryProperty = None;
static Atom	commProperty = None;
static Window	commWindow = None;
static int	got_x_error = FALSE;


/*
 * sendToVim --
 *	Send to an instance of Vim via the X display.
 *
 * Results:
 *	A string with the result or NULL. Caller must free if non-NULL
 */

    char *
sendToVim(dpy, name, cmd, asKeys, code)
    Display	*dpy;			/* Where to send. */
    char	*name;			/* Where to send. */
    char	*cmd;			/* What to send. */
    int		asKeys;			/* Interpret as keystrokes or expr ? */
    int		*code;			/* Return code. 0 => OK */
{
    Window	    w;
    Atom	    *plist;
    XErrorHandler   old_handler;
#define STATIC_SPACE 500
    char	    *property, staticSpace[STATIC_SPACE];
    int		    length;
    int		    res;
    static int	    serial = 0;	/* Running count of sent commands.
				 * Used to give each command a
				 * different serial number. */
    XEvent	    event;
    XPropertyEvent  *e = (XPropertyEvent *)&event;
    time_t	    start;
    char	    *result;
    char	    *loosename = NULL;

    if (commProperty == None && dpy != NULL)
    {
	if (SendInit(dpy) < 0)
	    return NULL;
    }

    /*
     * Bind the server name to a communication window.
     *
     * Find any survivor with a serialno attached to the name if the
     * original registrant of the wanted name is no longer present.
     *
     * Delete any lingering names from dead editors.
     */

    old_handler = XSetErrorHandler(x_error_check);
    while (TRUE)
    {
	got_x_error = FALSE;
	w = LookupName(dpy, name, 0, &loosename);
	/* Check that the window is hot */
	if (w != None)
	{
	    plist = XListProperties(dpy, w, &res);
	    XSync(dpy, False);
	    if (plist != NULL)
		XFree(plist);
	    if (got_x_error)
	    {
		LookupName(dpy, loosename ? loosename : name,
			   /*DELETE=*/TRUE, NULL);
		continue;
	    }
	}
	break;
    }
    if (w == None)
    {
	fprintf(stderr, "no registered server named %s\n", name);
	return NULL;
    }
    else if (loosename != NULL)
	name = loosename;

    /*
     * Send the command to target interpreter by appending it to the
     * comm window in the communication window.
     */

    length = strlen(name) + strlen(cmd) + 10;
    if (length <= STATIC_SPACE)
	property = staticSpace;
    else
	property = (char *) malloc((unsigned) length);

    serial++;
    sprintf(property, "%c%c%c-n %s%c-s %s",
		      0, asKeys ? 'k' : 'c', 0, name, 0, cmd);
    if (name == loosename)
	free(loosename);
    if (!asKeys)
    {
	/* Add a back reference to our comm window */
	sprintf(property + length, "%c-r %x %d", 0, (uint) commWindow, serial);
	length += strlen(property + length + 1) + 1;
    }

    res = AppendPropCarefully(dpy, w, commProperty, property, length + 1);
    if (length > STATIC_SPACE)
	free(property);
    if (res < 0)
    {
	fprintf(stderr, "Failed to send command to the destination program\n");
	return NULL;
    }

    if (asKeys) /* There is no answer for this - Keys are sent async */
	return NULL;


    /*
     * Enter a loop processing X events & pooling chars until we see the result
     */

#define SEND_MSEC_POLL 50

    time(&start);
    while ((time((time_t *) 0) - start) < 60)
    {
	/* Look out for the answer */
#ifndef HAVE_SELECT
	struct pollfd   fds;

	fds.fd = ConnectionNumber(dpy);
	fds.events = POLLIN;
	if (poll(&fds, 1, SEND_MSEC_POLL) < 0)
	    break;
#else
	fd_set	    fds;
	struct timeval  tv;

	tv.tv_sec = 0;
	tv.tv_usec =  SEND_MSEC_POLL * 1000;
	FD_ZERO(&fds);
	FD_SET(ConnectionNumber(dpy), &fds);
	if (select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &tv) < 0)
	    break;
#endif
	while (XEventsQueued(dpy, QueuedAfterReading) > 0)
	{
	    XNextEvent(dpy, &event);
	    if (event.type == PropertyNotify && e->window == commWindow)
		if ((result = SendEventProc(dpy, &event, serial, code)) != NULL)
		    return result;
	}
    }
    return NULL;
}


/*
 * SendInit --
 *	This procedure is called to initialize the
 *	communication channels for sending commands and
 *	receiving results.
 */

    static int
SendInit(dpy)
    Display *dpy;
{
    XErrorHandler old_handler;

    /*
     * Create the window used for communication, and set up an
     * event handler for it.
     */
    old_handler = XSetErrorHandler(x_error_check);
    got_x_error = FALSE;

    commProperty = XInternAtom(dpy, "Comm", False);
    /* Change this back to "InterpRegistry" to talk to tk processes */
    registryProperty = XInternAtom(dpy, "VimRegistry", False);

    if (commWindow == None)
    {
	commWindow =
	    XCreateSimpleWindow(dpy, XDefaultRootWindow(dpy),
				getpid(), 0, 10, 10, 0,
				WhitePixel(dpy, DefaultScreen(dpy)),
				WhitePixel(dpy, DefaultScreen(dpy)));
	XSelectInput(dpy, commWindow, PropertyChangeMask);
    }

    XSync(dpy, False);
    (void) XSetErrorHandler(old_handler);

    return got_x_error ? -1 : 0;
}

/*
 * LookupName --
 *	Given an interpreter name, see if the name exists in
 *	the interpreter registry for a particular display.
 *
 * Results:
 *	If the given name is registered, return the ID of
 *	the window associated with the name.  If the name
 *	isn't registered, then return 0.
 */

    static Window
LookupName(dpy, name, delete, loose)
    Display *dpy;	/* Display whose registry to check. */
    char *name;		/* Name of an interpreter. */
    int delete;		/* If non-zero, delete info about name. */
    char **loose;	/* Do another search matching -999 if not found
			   Return result here if a match is found */
{
    unsigned char   *regProp, *entry;
    unsigned char   *p;
    int		    result, actualFormat;
    unsigned long   numItems, bytesAfter;
    Atom	    actualType;
    Window	    returnValue;

    /*
     * Read the registry property.
     */

    regProp = NULL;
    result = XGetWindowProperty(dpy, RootWindow(dpy, 0), registryProperty, 0,
				MAX_PROP_WORDS, False, XA_STRING, &actualType,
				&actualFormat, &numItems, &bytesAfter,
				&regProp);

    if (actualType == None)
	return 0;

    /*
     * If the property is improperly formed, then delete it.
     */

    if ((result != Success) || (actualFormat != 8) || (actualType != XA_STRING))
    {
	if (regProp != NULL)
	    XFree(regProp);
	XDeleteProperty(dpy, RootWindow(dpy, 0), registryProperty);
	return 0;
    }

    /*
     * Scan the property for the desired name.
     */

    returnValue = None;
    entry = NULL;	/* Not needed, but eliminates compiler warning. */
    for (p = regProp; (p - regProp) < numItems; )
    {
	entry = p;
	while ((*p != 0) && (!isspace(*p)))
	    p++;
	if ((*p != 0) && (strcasecmp(name, p + 1) == 0))
	{
	    sscanf(entry, "%x", (uint*) &returnValue);
	    break;
	}
	while (*p != 0)
	    p++;
	p++;
    }

    if (loose != NULL && returnValue == None && !IsSerialName(name))
    {
	for (p = regProp; (p - regProp) < numItems; )
	{
	    entry = p;
	    while ((*p != 0) && (!isspace(*p)))
		p++;
	    if ((*p != 0) && IsSerialName(p + 1)
		    && (strncmp(name, p + 1, strlen(name)) == 0))
	    {
		sscanf(entry, "%x", (uint*) &returnValue);
		*loose = strdup(p + 1);
		break;
	    }
	    while (*p != 0)
		p++;
	    p++;
	}
    }

    /*
     * Delete the property, if that is desired (copy down the
     * remainder of the registry property to overlay the deleted
     * info, then rewrite the property).
     */

    if ((delete) && (returnValue != None))
    {
	int count;

	while (*p != 0)
	    p++;
	p++;
	count = numItems - (p-regProp);
	if (count > 0)
	    memcpy(entry, p, count);
	XChangeProperty(dpy, RootWindow(dpy, 0), registryProperty, XA_STRING,
			8, PropModeReplace, regProp,
			(int) (numItems - (p-entry)));
	XSync(dpy, False);
    }

    XFree(regProp);
    return returnValue;
}

    static char *
SendEventProc(dpy, eventPtr, expected, code)
    Display	   *dpy;
    XEvent	    *eventPtr;		/* Information about event. */
    int		    expected;		/* The one were waiting for */
    int		    *code;		/* Return code. 0 => OK */
{
    unsigned char   *propInfo;
    unsigned char   *p;
    int		    result, actualFormat;
    int		    retCode;
    unsigned long   numItems, bytesAfter;
    Atom	    actualType;

    if ((eventPtr->xproperty.atom != commProperty)
	    || (eventPtr->xproperty.state != PropertyNewValue))
    {
	return;
    }

    /*
     * Read the comm property and delete it.
     */

    propInfo = NULL;
    result = XGetWindowProperty(dpy, commWindow, commProperty, 0,
				MAX_PROP_WORDS, True, XA_STRING, &actualType,
				&actualFormat, &numItems, &bytesAfter,
				&propInfo);

    /*
     * If the property doesn't exist or is improperly formed
     * then ignore it.
     */

    if ((result != Success) || (actualType != XA_STRING)
	    || (actualFormat != 8))
    {
	if (propInfo != NULL)
	{
	    XFree(propInfo);
	}
	return;
    }

    /*
     * Several commands and results could arrive in the property at
     * one time;  each iteration through the outer loop handles a
     * single command or result.
     */

    for (p = propInfo; (p - propInfo) < numItems; )
    {
	/*
	 * Ignore leading NULs; each command or result starts with a
	 * NUL so that no matter how badly formed a preceding command
	 * is, we'll be able to tell that a new command/result is
	 * starting.
	 */

	if (*p == 0)
	{
	    p++;
	    continue;
	}

	if ((*p == 'r') && (p[1] == 0))
	{
	    int	    serial, gotSerial;
	    char  *res;

	    /*
	     * This is a reply to some command that we sent out.  Iterate
	     * over all of its options.  Stop when we reach the end of the
	     * property or something that doesn't look like an option.
	     */

	    p += 2;
	    gotSerial = 0;
	    res = "";
	    retCode = 0;
	    while (((p-propInfo) < numItems) && (*p == '-'))
	    {
		switch (p[1])
		{
		    case 'r':
			if (p[2] == ' ')
			    res = p + 3;
			break;
		    case 's':
			if (sscanf(p + 2, " %d", &serial) == 1)
			    gotSerial = 1;
			break;
		    case 'c':
			if (sscanf(p + 2, " %d", &retCode) != 1)
			    retCode = 0;
			break;
		}
		while (*p != 0)
		    p++;
		p++;
	    }

	    if (!gotSerial)
		continue;

	    if (code != NULL)
		*code = retCode;
	    return serial == expected ? strdup(res) : NULL;
	}
	else
	{
	    /*
	     * Didn't recognize this thing.  Just skip through the next
	     * null character and try again.
	     * Also, throw away commands that we cant process anyway.
	     */

	    while (*p != 0)
		p++;
	    p++;
	}
    }
    XFree(propInfo);
}

/*
 * AppendPropCarefully --
 *
 *	Append a given property to a given window, but set up
 *	an X error handler so that if the append fails this
 *	procedure can return an error code rather than having
 *	Xlib panic.
 *
 *  Return:
 *	0 on OK - -1 on error
 *--------------------------------------------------------------
 */

    static int
AppendPropCarefully(dpy, window, property, value, length)
    Display *dpy;		/* Display on which to operate. */
    Window window;		/* Window whose property is to
				 * be modified. */
    Atom property;		/* Name of property. */
    char *value;		/* Characters  to append to property. */
    int  length;		/* How much to append */
{
    XErrorHandler old_handler;

    old_handler = XSetErrorHandler(x_error_check);
    got_x_error = FALSE;
    XChangeProperty(dpy, window, property, XA_STRING, 8,
		    PropModeAppend, value, length);
    XSync(dpy, False);
    (void) XSetErrorHandler(old_handler);
    return got_x_error ? -1 : 0;
}


/*
 * Another X Error handler, just used to check for errors.
 */
/* ARGSUSED */
    static int
x_error_check(dpy, error_event)
    Display *dpy;
    XErrorEvent	*error_event;
{
    got_x_error = TRUE;
    return 0;
}

/*
 * Check if "str" looks like it had a serial number appended.
 * Actually just checks if the name ends in a digit.
 */
    static int
IsSerialName(str)
    char   *str;
{
    int len = strlen(str);

    return (len > 1 && isdigit(str[len - 1]));
}

Youez - 2016 - github.com/yon3zu
LinuXploit