/* vi:set ts=8 sts=4 sw=4:
*
* VIM - Vi IMproved by Bram Moolenaar
* X command server 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.
*
* if_xcmdsrv.c: Functions for passing commands through an X11 display.
*
*/
#include "vim.h"
#include "version.h"
#if defined(FEAT_CLIENTSERVER) || defined(PROTO)
# ifdef FEAT_X11
# include <X11/Intrinsic.h>
# include <X11/Xatom.h>
# endif
# if defined(HAVE_SYS_SELECT_H) && \
(!defined(HAVE_SYS_TIME_H) || defined(SYS_SELECT_WITH_SYS_TIME))
# include <sys/select.h>
# endif
# ifndef HAVE_SELECT
# ifdef HAVE_SYS_POLL_H
# include <sys/poll.h>
# else
# ifdef HAVE_POLL_H
# include <poll.h>
# endif
# endif
# endif
/*
* This file provides procedures that implement the command server functionality
* of Vim when in contact with an X11 server.
*
* Adapted from TCL/TK's send command in tkSend.c of the tk 3.6 distribution.
* Adapted for use in Vim by Flemming Madsen. Protocol changed to that of tk 4
*/
/*
* Copyright (c) 1989-1993 The Regents of the University of California.
* All rights reserved.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
/*
* When a result is being awaited from a sent command, one of
* the following structures is present on a list of all outstanding
* sent commands. The information in the structure is used to
* process the result when it arrives. You're probably wondering