mirror of
https://github.com/Interlisp/maiko.git
synced 2026-04-26 12:27:32 +00:00
Remove CLX support. (#90)
CLX is a Common Lisp implementation of the X client library. It has some code in C, which was present here as `src/socket.c` and `src/socdvr.c`, exposed via opcodes in `src/subr.c`. This code had been removed (with prejudice apparently) by commenting out the code in `src/subr.c` with `#if NEVER`. This code would've been used by the Medley system images, but that code doesn't appear to be present. (There may or may not be something related in `XMAS` in the Medley repository.)
This commit is contained in:
@@ -1,10 +1,5 @@
|
|||||||
# Options for SunOS4, SPARC and X-Window
|
# Options for SunOS4, SPARC and X-Window
|
||||||
|
|
||||||
CLXFLAGS = -DCLX -DTCP_NODELAY
|
|
||||||
|
|
||||||
CLXFILES = $(OBJECTDIR)socket.o \
|
|
||||||
$(OBJECTDIR)socdvr.o
|
|
||||||
|
|
||||||
XFILES = $(OBJECTDIR)XClose.o \
|
XFILES = $(OBJECTDIR)XClose.o \
|
||||||
$(OBJECTDIR)Cursor.o \
|
$(OBJECTDIR)Cursor.o \
|
||||||
$(OBJECTDIR)XWindow.o \
|
$(OBJECTDIR)XWindow.o \
|
||||||
@@ -28,11 +23,10 @@ XFILES = $(OBJECTDIR)XClose.o \
|
|||||||
$(OBJECTDIR)XMouse.o \
|
$(OBJECTDIR)XMouse.o \
|
||||||
$(OBJECTDIR)Xsubwin.o \
|
$(OBJECTDIR)Xsubwin.o \
|
||||||
$(OBJECTDIR)Xcolor.o \
|
$(OBJECTDIR)Xcolor.o \
|
||||||
$(OBJECTDIR)Xwinman.o \
|
$(OBJECTDIR)Xwinman.o
|
||||||
$(CLXFILES)
|
|
||||||
|
|
||||||
XVERSION = XV11R4
|
XVERSION = XV11R4
|
||||||
XFLAGS = -DXWINDOW -D$(XVERSION) $(CLXFLAGS)
|
XFLAGS = -DXWINDOW -D$(XVERSION)
|
||||||
|
|
||||||
# This is to make the %$#@! Apollo cc happy
|
# This is to make the %$#@! Apollo cc happy
|
||||||
OEXT = .o
|
OEXT = .o
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
# Options for SunOS4, SPARC and X-Window
|
# Options for SunOS4, SPARC and X-Window
|
||||||
|
|
||||||
# CLXFLAGS = -DTCP_NODELAY
|
|
||||||
|
|
||||||
#CLXFILES = $(OBJECTDIR)socket.o \
|
|
||||||
# $(OBJECTDIR)socdvr.o
|
|
||||||
|
|
||||||
|
|
||||||
XFILES = $(OBJECTDIR)xmkicon.o \
|
XFILES = $(OBJECTDIR)xmkicon.o \
|
||||||
$(OBJECTDIR)xbbt.o \
|
$(OBJECTDIR)xbbt.o \
|
||||||
$(OBJECTDIR)dspif.o \
|
$(OBJECTDIR)dspif.o \
|
||||||
@@ -19,7 +13,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
XVERSION = XV11R4
|
XVERSION = XV11R4
|
||||||
XFLAGS = -DXWINDOW -DNOPIXRECT -D$(XVERSION) # $(CLXFLAGS)
|
XFLAGS = -DXWINDOW -DNOPIXRECT -D$(XVERSION)
|
||||||
|
|
||||||
# This is to make the %$#@! Apollo cc happy
|
# This is to make the %$#@! Apollo cc happy
|
||||||
OEXT = .o
|
OEXT = .o
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
|
|||||||
$(OBJECTDIR)xwinman.o
|
$(OBJECTDIR)xwinman.o
|
||||||
|
|
||||||
XVERSION = XV11R4
|
XVERSION = XV11R4
|
||||||
XFLAGS = -DXWINDOW -DNOPIXRECT -D$(XVERSION) $(CLXFLAGS)
|
XFLAGS = -DXWINDOW -DNOPIXRECT -D$(XVERSION)
|
||||||
|
|
||||||
# This is to make the %$#@! Apollo cc happy
|
# This is to make the %$#@! Apollo cc happy
|
||||||
OEXT = .o
|
OEXT = .o
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
|
|||||||
$(OBJECTDIR)xwinman.o
|
$(OBJECTDIR)xwinman.o
|
||||||
|
|
||||||
XVERSION = XV11R4
|
XVERSION = XV11R4
|
||||||
XFLAGS = -DXWINDOW -D$(XVERSION) $(CLXFLAGS)
|
XFLAGS = -DXWINDOW -D$(XVERSION)
|
||||||
|
|
||||||
# This is to make the %$#@! Apollo cc happy
|
# This is to make the %$#@! Apollo cc happy
|
||||||
OEXT = .o
|
OEXT = .o
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
|
|||||||
$(OBJECTDIR)xwinman.o
|
$(OBJECTDIR)xwinman.o
|
||||||
|
|
||||||
XVERSION = XV11R4
|
XVERSION = XV11R4
|
||||||
XFLAGS = -DXWINDOW -D$(XVERSION) $(CLXFLAGS)
|
XFLAGS = -DXWINDOW -D$(XVERSION)
|
||||||
|
|
||||||
# This is to make the %$#@! Apollo cc happy
|
# This is to make the %$#@! Apollo cc happy
|
||||||
OEXT = .o
|
OEXT = .o
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ XFILES = $(OBJECTDIR)xmkicon.o \
|
|||||||
$(OBJECTDIR)xwinman.o
|
$(OBJECTDIR)xwinman.o
|
||||||
|
|
||||||
XVERSION = XV11R4
|
XVERSION = XV11R4
|
||||||
XFLAGS = -DXWINDOW -DNOPIXRECT -D$(XVERSION) $(CLXFLAGS)
|
XFLAGS = -DXWINDOW -DNOPIXRECT -D$(XVERSION)
|
||||||
|
|
||||||
# This is to make the %$#@! Apollo cc happy
|
# This is to make the %$#@! Apollo cc happy
|
||||||
OEXT = .o
|
OEXT = .o
|
||||||
|
|||||||
@@ -806,14 +806,6 @@ $(OBJECTDIR)array6.o : $(SRCDIR)array6.c $(REQUIRED-INCS) $(INCDIR)lispemul.h
|
|||||||
$(INCDIR)arith.h $(INCDIR)my.h
|
$(INCDIR)arith.h $(INCDIR)my.h
|
||||||
$(CC) $(RFLAGS) $(SRCDIR)array6.c $(INLINE) -o $(OBJECTDIR)array6$(OEXT)
|
$(CC) $(RFLAGS) $(SRCDIR)array6.c $(INLINE) -o $(OBJECTDIR)array6$(OEXT)
|
||||||
|
|
||||||
$(OBJECTDIR)socket.o : $(SRCDIR)socket.c $(REQUIRED-INCS)
|
|
||||||
$(CC) $(RFLAGS) $(SRCDIR)socket.c -o $(OBJECTDIR)socket$(OEXT)
|
|
||||||
|
|
||||||
$(OBJECTDIR)socdvr.o : $(SRCDIR)socdvr.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \
|
|
||||||
$(INCDIR)adr68k.h $(INCDIR)lsptypes.h $(INCDIR)lispmap.h \
|
|
||||||
$(INCDIR)arith.h
|
|
||||||
$(CC) $(RFLAGS) $(SRCDIR)socdvr.c -o $(OBJECTDIR)socdvr$(OEXT)
|
|
||||||
|
|
||||||
$(OBJECTDIR)sxhash.o : $(SRCDIR)sxhash.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \
|
$(OBJECTDIR)sxhash.o : $(SRCDIR)sxhash.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \
|
||||||
$(INCDIR)lspglob.h $(INCDIR)adr68k.h \
|
$(INCDIR)lspglob.h $(INCDIR)adr68k.h \
|
||||||
$(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \
|
$(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ s/miscstats/miscstat/g
|
|||||||
s/osmessage/osmsg/g
|
s/osmessage/osmsg/g
|
||||||
s/osmessage/osmsg/g
|
s/osmessage/osmsg/g
|
||||||
s/setsysout/setsout/g
|
s/setsysout/setsout/g
|
||||||
s/socketdvr/socdvr/g
|
|
||||||
s/usersubrs/usrsubr/g
|
s/usersubrs/usrsubr/g
|
||||||
s/InitXevent/Xinit/g
|
s/InitXevent/Xinit/g
|
||||||
s/LispWindow/Xlspwin/g
|
s/LispWindow/Xlspwin/g
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ s/miscstats\.h/miscstat\.h/g
|
|||||||
s/osmessage\.c/osmsg\.c/g
|
s/osmessage\.c/osmsg\.c/g
|
||||||
s/osmessage\.h/osmsg\.h/g
|
s/osmessage\.h/osmsg\.h/g
|
||||||
s/setsysout\.c/setsout\.c/g
|
s/setsysout\.c/setsout\.c/g
|
||||||
s/socketdvr\.c/socdvr\.c/g
|
|
||||||
s/usersubrs\.c/usrsubr\.c/g
|
s/usersubrs\.c/usrsubr\.c/g
|
||||||
s/InitXevent\.c/Xinit\.c/g
|
s/InitXevent\.c/Xinit\.c/g
|
||||||
s/LispWindow\.c/Xlspwin\.c/g
|
s/LispWindow\.c/Xlspwin\.c/g
|
||||||
|
|||||||
277
src/socdvr.c
277
src/socdvr.c
@@ -1,277 +0,0 @@
|
|||||||
/* $Id: socdvr.c,v 1.2 1999/01/03 02:07:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
|
|
||||||
*/
|
|
||||||
|
|
||||||
/************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* (C) Copyright 1989-95 Venue. All Rights Reserved. */
|
|
||||||
/* Manufactured in the United States of America. */
|
|
||||||
/* */
|
|
||||||
/************************************************************************/
|
|
||||||
|
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/file.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <X11/Xproto.h>
|
|
||||||
|
|
||||||
#include "lispemul.h"
|
|
||||||
#include "arith.h"
|
|
||||||
#include "adr68k.h"
|
|
||||||
#include "lsptypes.h"
|
|
||||||
#include "lispmap.h"
|
|
||||||
|
|
||||||
#define min(x, y) (((x) > (y)) ? (y) : (x))
|
|
||||||
|
|
||||||
/***********************************************************/
|
|
||||||
/* L S t r i n g T o C S t r i n g */
|
|
||||||
/* */
|
|
||||||
/* Convert a lisp string to a C string up to MaxLen long. */
|
|
||||||
/***********************************************************/
|
|
||||||
|
|
||||||
#define LStringToCString(Lisp, C, MaxLen, Len) \
|
|
||||||
{ \
|
|
||||||
OneDArray *arrayp; \
|
|
||||||
char *base; \
|
|
||||||
short *sbase; \
|
|
||||||
int i; \
|
|
||||||
\
|
|
||||||
arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \
|
|
||||||
Len = min(MaxLen, arrayp->fillpointer); \
|
|
||||||
\
|
|
||||||
switch (arrayp->typenumber) { \
|
|
||||||
case THIN_CHAR_TYPENUMBER: \
|
|
||||||
base = \
|
|
||||||
((char *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \
|
|
||||||
for (i = 0; i < Len; i++) C[i] = base[i]; \
|
|
||||||
C[Len] = '\0'; \
|
|
||||||
break; \
|
|
||||||
\
|
|
||||||
case FAT_CHAR_TYPENUMBER: \
|
|
||||||
sbase = \
|
|
||||||
((short *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \
|
|
||||||
base = (char *)sbase; \
|
|
||||||
for (i = 0; i < Len * 2; i++) C[i] = base[i]; \
|
|
||||||
C[Len * 2] = '\0'; \
|
|
||||||
break; \
|
|
||||||
\
|
|
||||||
default: error("LStringToCString can not handle\n"); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define FGetNum(ptr, place) \
|
|
||||||
{ \
|
|
||||||
if (((ptr)&SEGMASK) == S_POSITIVE) { \
|
|
||||||
(place) = ((ptr)&0xffff); \
|
|
||||||
} else if (((ptr)&SEGMASK) == S_NEGATIVE) { \
|
|
||||||
(place) = (int)((ptr) | 0xffff0000); \
|
|
||||||
} else { \
|
|
||||||
return (NIL); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MAX_NAME_LEN 256
|
|
||||||
static char XServer_Name[MAX_NAME_LEN]; /* Name of host with X server */
|
|
||||||
static int XPort_Number = 0; /* Display # to ask for on it */
|
|
||||||
|
|
||||||
int XServer_Fd = -1; /* The socket for the X server */
|
|
||||||
|
|
||||||
extern DLword *Lisp_world;
|
|
||||||
|
|
||||||
/************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* O p e n _ S o c k e t */
|
|
||||||
/* */
|
|
||||||
/* Open a connection to an X server, by calling the CLX routine */
|
|
||||||
/* "connect_to_server". Returns T if successful, and NIL if not. */
|
|
||||||
/* The socket's fd is left in XServer_Fd, a global, so only one */
|
|
||||||
/* server connection can be open at one time (FIX THIS). */
|
|
||||||
/* */
|
|
||||||
/* args[0] - The lisp string name of the host the server is on */
|
|
||||||
/* args[1] - The SMALLP server-number we're connecting to. */
|
|
||||||
/* */
|
|
||||||
/************************************************************************/
|
|
||||||
|
|
||||||
LispPTR Open_Socket(LispPTR *args)
|
|
||||||
{
|
|
||||||
#ifdef TRACE
|
|
||||||
printf("TRACE: Open_Socket()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int length;
|
|
||||||
|
|
||||||
LStringToCString(args[0], XServer_Name, MAX_NAME_LEN, length);
|
|
||||||
FGetNum(args[1], XPort_Number);
|
|
||||||
XPort_Number -= X_TCP_PORT;
|
|
||||||
|
|
||||||
if (XServer_Fd == -1) {
|
|
||||||
XServer_Fd = connect_to_server(XServer_Name, XPort_Number);
|
|
||||||
|
|
||||||
if (XServer_Fd < 0) /* error in connect. */
|
|
||||||
{
|
|
||||||
perror("connecting to X server");
|
|
||||||
return (NIL);
|
|
||||||
}
|
|
||||||
|
|
||||||
{ /* Make it non-blocking I/O */
|
|
||||||
int res;
|
|
||||||
res = fcntl(XServer_Fd, F_GETFL);
|
|
||||||
res |= FNDELAY;
|
|
||||||
res = fcntl(XServer_Fd, F_SETFL, res);
|
|
||||||
}
|
|
||||||
} /* end if(XServer_Fd) */
|
|
||||||
|
|
||||||
return (ATOM_T);
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* C l o s e _ S o c k e t */
|
|
||||||
/* */
|
|
||||||
/* Close the socket connection to the X server. */
|
|
||||||
/* */
|
|
||||||
/************************************************************************/
|
|
||||||
|
|
||||||
LispPTR Close_Socket() {
|
|
||||||
int stat;
|
|
||||||
|
|
||||||
#ifdef TRACE
|
|
||||||
printf("TRACE: Close_Socket()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((stat = close(XServer_Fd)) ==
|
|
||||||
-1) { /* close failed; return NIL, but squash the old fd anyhow */
|
|
||||||
XServer_Fd = -1;
|
|
||||||
perror("Close_socket");
|
|
||||||
return (NIL);
|
|
||||||
} else { /* close succeeded; return T. */
|
|
||||||
XServer_Fd = -1;
|
|
||||||
return (ATOM_T);
|
|
||||||
}
|
|
||||||
} /* end Close_Socket */
|
|
||||||
|
|
||||||
/************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* R e a d _ S o c k e t */
|
|
||||||
/* */
|
|
||||||
/* Read up to 1 packet's worth from the X-server socket. */
|
|
||||||
/* */
|
|
||||||
/************************************************************************/
|
|
||||||
|
|
||||||
typedef struct { /* Format for an X-server packet */
|
|
||||||
DLword nil[22]; /* Packet header */
|
|
||||||
DLword length; /* Request byte length */
|
|
||||||
char data[592]; /* Data body */
|
|
||||||
} PACKET;
|
|
||||||
|
|
||||||
#define PACKET_DEFOFFSET 46
|
|
||||||
#define PACKET_MAXSIZE 638
|
|
||||||
|
|
||||||
LispPTR Read_Socket(LispPTR *args)
|
|
||||||
{
|
|
||||||
PACKET *packet;
|
|
||||||
char *buffer;
|
|
||||||
int length, actlen;
|
|
||||||
|
|
||||||
#ifdef TRACE
|
|
||||||
printf("TRACE: Read_Socket()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (XServer_Fd >= 0) {
|
|
||||||
packet = (PACKET *)Addr68k_from_LADDR(args[0]);
|
|
||||||
|
|
||||||
if ((length = (int)(packet->length) - PACKET_DEFOFFSET) > 0) {
|
|
||||||
buffer = &(packet->data[0]);
|
|
||||||
|
|
||||||
if ((actlen = read(XServer_Fd, buffer, length)) > 0) {
|
|
||||||
packet->length = (DLword)(actlen + PACKET_DEFOFFSET);
|
|
||||||
return (ATOM_T);
|
|
||||||
} /* end if(actlen) */
|
|
||||||
if (actlen < 0) /* error !*/
|
|
||||||
{
|
|
||||||
if ((errno != EWOULDBLOCK) & (errno != EINTR)) perror("reading X connection");
|
|
||||||
return (NIL);
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* end if(length) */
|
|
||||||
|
|
||||||
} /* end if( fd ) */
|
|
||||||
|
|
||||||
return (NIL);
|
|
||||||
|
|
||||||
} /* end Read_Socket */
|
|
||||||
|
|
||||||
/************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* W r i t e _ S o c k e t */
|
|
||||||
/* */
|
|
||||||
/* Write a packet of information to the X server's socket. */
|
|
||||||
/* */
|
|
||||||
/************************************************************************/
|
|
||||||
|
|
||||||
LispPTR Write_Socket(LispPTR *args)
|
|
||||||
{
|
|
||||||
PACKET *packet;
|
|
||||||
char *buffer;
|
|
||||||
int length, actlen;
|
|
||||||
|
|
||||||
#ifdef TRACE
|
|
||||||
printf("TRACE: Write_Socket()\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (XServer_Fd >= 0) {
|
|
||||||
packet = (PACKET *)Addr68k_from_LADDR(args[0]);
|
|
||||||
|
|
||||||
if ((length = (int)(packet->length) - PACKET_DEFOFFSET) > 0) {
|
|
||||||
buffer = &(packet->data[0]);
|
|
||||||
|
|
||||||
if ((actlen = write(XServer_Fd, buffer, length)) > 0) {
|
|
||||||
packet->length = (DLword)(actlen + PACKET_DEFOFFSET);
|
|
||||||
return (ATOM_T);
|
|
||||||
|
|
||||||
} /* end if( actlen ) */
|
|
||||||
if (actlen < 0) /* error !*/
|
|
||||||
{
|
|
||||||
if (errno != EINTR) perror("writing X connection");
|
|
||||||
return (NIL);
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* end if(length) */
|
|
||||||
|
|
||||||
} /* end if( fd ) */
|
|
||||||
|
|
||||||
packet->length = 0;
|
|
||||||
return (NIL);
|
|
||||||
|
|
||||||
} /* end Write_Socket */
|
|
||||||
|
|
||||||
/************************************************************************/
|
|
||||||
/* */
|
|
||||||
/* K b d _ T r a n s i t i o n */
|
|
||||||
/* */
|
|
||||||
/* Stuff a key transition into the C-level buffer from Lisp. */
|
|
||||||
/* */
|
|
||||||
/* args[0] - the key number (in lisps terms? Not sure) */
|
|
||||||
/* args[1] - upflg -- is it an up or down-transition? */
|
|
||||||
/* */
|
|
||||||
/************************************************************************/
|
|
||||||
extern int KBDEventFlg;
|
|
||||||
|
|
||||||
void Kbd_Transition(LispPTR *args)
|
|
||||||
/* args[0] is key-number */
|
|
||||||
/* args[1] is up-flg */
|
|
||||||
{
|
|
||||||
DLword key_number;
|
|
||||||
|
|
||||||
key_number = (DLword)(args[0] & 0xffff);
|
|
||||||
if (args[1])
|
|
||||||
kb_trans(key_number, 1);
|
|
||||||
else
|
|
||||||
kb_trans(key_number, 0);
|
|
||||||
|
|
||||||
DoRing();
|
|
||||||
/* If there's something for lisp to do, ask for an interrupt: */
|
|
||||||
if ((KBDEventFlg += 1) > 0) Irq_Stk_End = Irq_Stk_Check = 0;
|
|
||||||
|
|
||||||
} /* end Kbd_Transition */
|
|
||||||
122
src/socket.c
122
src/socket.c
@@ -1,122 +0,0 @@
|
|||||||
/* $Id: socket.c,v 1.2 1999/01/03 02:07:34 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
|
|
||||||
*/
|
|
||||||
/* Copyright Massachusetts Institute of Technology 1988 */
|
|
||||||
/*
|
|
||||||
* THIS IS AN OS DEPENDENT FILE! It should work on 4.2BSD derived
|
|
||||||
* systems. VMS and System V should plan to have their own version.
|
|
||||||
*
|
|
||||||
* This code was cribbed from lib/X/XConnDis.c.
|
|
||||||
* Compile using
|
|
||||||
* % cc -c socket.c -DUNIXCONN
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "version.h"
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <X11/Xos.h>
|
|
||||||
#include <X11/Xproto.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/tcp.h>
|
|
||||||
|
|
||||||
#ifdef UNIXCONN
|
|
||||||
#include <sys/un.h>
|
|
||||||
#ifndef X_UNIX_PATH
|
|
||||||
#define X_UNIX_PATH "/tmp/.X11-unix/X"
|
|
||||||
#endif /* X_UNIX_PATH */
|
|
||||||
#endif /* UNIXCONN */
|
|
||||||
void bcopy();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Attempts to connect to server, given host and display. Returns file
|
|
||||||
* descriptor (network socket) or 0 if connection fails.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int connect_to_server(char *host, int display)
|
|
||||||
{
|
|
||||||
struct sockaddr_in inaddr; /* INET socket address. */
|
|
||||||
struct sockaddr *addr; /* address to connect to */
|
|
||||||
struct hostent *host_ptr;
|
|
||||||
int addrlen; /* length of address */
|
|
||||||
#ifdef UNIXCONN
|
|
||||||
struct sockaddr_un unaddr; /* UNIX socket address. */
|
|
||||||
#endif
|
|
||||||
extern char *getenv();
|
|
||||||
extern struct hostent *gethostbyname();
|
|
||||||
int fd; /* Network socket */
|
|
||||||
{
|
|
||||||
#ifdef UNIXCONN
|
|
||||||
if ((host[0] == '\0') || (strcmp("unix", host) == 0)) {
|
|
||||||
/* Connect locally using Unix domain. */
|
|
||||||
unaddr.sun_family = AF_UNIX;
|
|
||||||
(void)strcpy(unaddr.sun_path, X_UNIX_PATH);
|
|
||||||
sprintf(&unaddr.sun_path[strlen(unaddr.sun_path)], "%d", display);
|
|
||||||
addr = (struct sockaddr *)&unaddr;
|
|
||||||
addrlen = strlen(unaddr.sun_path) + 2;
|
|
||||||
/*
|
|
||||||
* Open the network connection.
|
|
||||||
*/
|
|
||||||
if ((fd = socket((int)addr->sa_family, SOCK_STREAM, 0)) < 0)
|
|
||||||
return (-1); /* errno set by system call. */
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
/* Get the statistics on the specified host. */
|
|
||||||
if ((inaddr.sin_addr.s_addr = inet_addr(host)) == -1) {
|
|
||||||
if ((host_ptr = gethostbyname(host)) == NULL) {
|
|
||||||
/* No such host! */
|
|
||||||
errno = EINVAL;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
/* Check the address type for an internet host. */
|
|
||||||
if (host_ptr->h_addrtype != AF_INET) {
|
|
||||||
/* Not an Internet host! */
|
|
||||||
errno = EPROTOTYPE;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
/* Set up the socket data. */
|
|
||||||
inaddr.sin_family = host_ptr->h_addrtype;
|
|
||||||
bcopy((char *)host_ptr->h_addr, (char *)&inaddr.sin_addr, sizeof(inaddr.sin_addr));
|
|
||||||
} else {
|
|
||||||
inaddr.sin_family = AF_INET;
|
|
||||||
}
|
|
||||||
addr = (struct sockaddr *)&inaddr;
|
|
||||||
addrlen = sizeof(struct sockaddr_in);
|
|
||||||
inaddr.sin_port = display + X_TCP_PORT;
|
|
||||||
inaddr.sin_port = htons(inaddr.sin_port);
|
|
||||||
/*
|
|
||||||
* Open the network connection.
|
|
||||||
*/
|
|
||||||
if ((fd = socket((int)addr->sa_family, SOCK_STREAM, 0)) < 0) {
|
|
||||||
return (-1); /* errno set by system call. */
|
|
||||||
}
|
|
||||||
/* make sure to turn off TCP coalescence */
|
|
||||||
#ifdef TCP_NODELAY
|
|
||||||
{
|
|
||||||
int mi = 1;
|
|
||||||
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof(int));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Changed 9/89 to retry connection if system call was interrupted. This
|
|
||||||
* is necessary for multiprocessing implementations that use timers,
|
|
||||||
* since the timer results in a SIGALRM. -- jdi
|
|
||||||
*/
|
|
||||||
while (connect(fd, addr, addrlen) == -1) {
|
|
||||||
if (errno != EINTR) {
|
|
||||||
(void)close(fd);
|
|
||||||
return (-1); /* errno set by system call. */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Return the id if the connection succeeded.
|
|
||||||
*/
|
|
||||||
return (fd);
|
|
||||||
}
|
|
||||||
30
src/subr.c
30
src/subr.c
@@ -704,36 +704,6 @@ void OP_subrcall(int subr_no, int argnum) {
|
|||||||
TopOfStack = ATOM_T;
|
TopOfStack = ATOM_T;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*******************/
|
|
||||||
/* CLX Support ops */
|
|
||||||
/*******************/
|
|
||||||
#ifdef NEVER /* CLX */
|
|
||||||
case sb_OPEN_SOCKET: {
|
|
||||||
POP_SUBR_ARGS;
|
|
||||||
TopOfStack = Open_Socket(args);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case sb_CLOSE_SOCKET: {
|
|
||||||
TopOfStack = Close_Socket();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case sb_READ_SOCKET: {
|
|
||||||
POP_SUBR_ARGS;
|
|
||||||
TopOfStack = Read_Socket(args);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case sb_WRITE_SOCKET: {
|
|
||||||
POP_SUBR_ARGS;
|
|
||||||
TopOfStack = Write_Socket(args);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 0244: /* KB_TRANSITION */
|
|
||||||
{
|
|
||||||
POP_SUBR_ARGS;
|
|
||||||
TopOfStack = Kbd_Transition(args);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif /* CLX */
|
|
||||||
|
|
||||||
#ifndef NOFORN
|
#ifndef NOFORN
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user