/* vi:set ts=8 sw=8:
*
* VIM - Vi IMproved by Bram Moolenaar
* Visual Workshop integration by Gordon Prieur
*
* 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.
*/
/*
* Integration with Sun Workshop.
*
* This file should not change much, it's also used by other editors that
* connect to Workshop. Consider changing workshop.c instead.
*/
/*
-> consider using MakeSelectionVisible instead of gotoLine hacks
to show the line properly
-> consider using glue instead of our own message wrapping functions
(but can only use glue if we don't have to distribute source)
*/
#include "vim.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef INET_SOCKETS
#include <netdb.h>
#include <netinet/in.h>
#else
#include <sys/un.h>
#endif
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#ifdef HAVE_LIBGEN_H
# include <libgen.h>
#endif
#include <unistd.h>
#include <string.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/AtomMgr.h>
#include <Xm/PushB.h>
#ifdef HAVE_X11_XPM_H
# include <X11/xpm.h>
#else
# ifdef HAVE_XM_XPMP_H
# include <Xm/XpmP.h>
# endif
#endif
#ifdef HAVE_UTIL_DEBUG_H
# include <util/debug.h>
#endif
#ifdef HAVE_UTIL_MSGI18N_H
# include <util/msgi18n.h>
#endif
#include "integration.h" /* <EditPlugin/integration.h> */
#ifdef HAVE_FRAME_H
# include <frame.h>
#endif
#ifndef MAX
# define MAX(a, b) (a) > (b) ? (a) : (b)
#endif
#ifndef NOCATGETS
# define NOCATGETS(x) x
#endif
/* Functions private to this file */
static void workshop_connection_closed(void);
static void messageFromEserve(XtPointer clientData, int *NOTUSED1, XtInputId *NOTUSED2);
static void workshop_disconnect(void);
static void workshop_sensitivity(int num, char *table);
static void adjust_sign_name(char *filename);
static void process_menuItem(char *);
static void process_toolbarButton(char *);
static void workshop_set_option_first(char *name, char *value);
#define CMDBUFSIZ 2048
#ifdef DEBUG
static FILE *dfd;
static void pldebug(char *, ...);
static void unrecognised_message(char *);
#define HANDLE_ERRORS(cmd) else unrecognised_message(cmd);
#else
#define HANDLE_ERRORS(cmd)
#endif
/*
* Version number of the protocol between an editor and eserve.
* This number should be incremented when the protocol
* is changed.
*/
#define PROTOCOL_VERSION "4.0.0"
static int sd = -1;
static XtInputId inputHandler; /* Cookie for input */
Boolean save_files = True; /* When true, save all files before build actions */
void
workshop_connection_closed(void)
{
/*
* socket closed on other end
*/
XtRemoveInput(inputHandler);
inputHandler = 0;
sd = -1;
}
static char *
getCommand(void)
{
int len; /* length of this command */
char lenbuf[7]; /* get the length string here */
char *newcb; /* used to realloc cmdbuf */
static char *cmdbuf;/* get the command string here */
static int cbsize;/* size of cmdbuf */
if ((len = read(sd, &lenbuf, 6)) == 6) {
lenbuf[6] = 0; /* Terminate buffer such that atoi() works right */
len = atoi(lenbuf);
if (cbsize < (len + 1)) {
newcb = (char *) realloc(cmdbuf,
MAX((len + 256), CMDBUFSIZ));
if (newcb != NULL) {
cmdbuf = newcb;
cbsize = MAX((len + 256