/*
* csopendi.c -- open connection to CSDPS agent
*
* (c) Copyright 1990-1994 Adobe Systems Incorporated.
* All rights reserved.
*
* Permission to use, copy, modify, distribute, and sublicense this software
* and its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notices appear in all copies and that
* both those copyright notices and this permission notice appear in
* supporting documentation and that the name of Adobe Systems Incorporated
* not be used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. No trademark license
* to use the Adobe trademarks is hereby granted. If the Adobe trademark
* "Display PostScript"(tm) is used to describe this software, its
* functionality or for any other purpose, such use shall be limited to a
* statement that this software works in conjunction with the Display
* PostScript system. Proper trademark attribution to reflect Adobe's
* ownership of the trademark shall be given whenever any such reference to
* the Display PostScript system is made.
*
* ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
* ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
* ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE
* TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT
* PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
*
* Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
* Incorporated which may be registered in certain jurisdictions
*
* Portions Copyright Massachusetts Institute of Technology 1985, 1986
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* Author: Adobe Systems Incorporated and MIT X Consortium
*/
/* $XFree86$ */
#include <stdlib.h>
#include <stdio.h>
#define NEED_EVENTS
#include "cslibint.h"
#ifdef XXX
extern int _Xdebug;
extern Display *_XHeadOfDisplayList;
#ifndef lint
#endif
#endif /* XXX */
#include "DPSCAPClient.h"
#include <DPS/dpsXclient.h>
#include <DPS/dpsNXargs.h>
#include "dpsassert.h"
#include "dpsNXprops.h"
#include "csfindNX.h"
#include "csstartNX.h"
#ifdef DPSLNKL
#include "dpslnkl.inc"
#endif /* DPSLNKL */
/* +++ Someday make this common with XDPS.c version */
0, 0, 0
};
static void OutOfMemory (Display *);
#ifdef XXX
/*
* First, a routine for setting authorization data
*/
static int xauth_namelen = 0;
static int xauth_datalen = 0;
{
xauth_namelen = xauth_datalen = 0;
if (namelen > 0) { /* try to allocate space */
if (!tmpname) return;
} else {
}
if (datalen > 0) {
if (!tmpdata) {
return;
}
} else {
}
return;
}
#endif /* XXX */
/*
* Connects to a server, creates a Display object and returns a pointer to
* the newly created Display back to the caller.
*/
XExtData *
{
register int i;
int idisplay;
int server_addrlen = 0;
int conn_family;
/*
* Find an agent to talk to.
*/
#ifdef DPSLNKL
extern unsigned ANXPFunc();
#ifdef PSUSEPN
ANXVENDOR, /* From dpslnkl.inc */
ANXPFunc());
#else /* PSUSEPN */
ANXVENDOR); /* From dpslnkl.inc */
#endif /* PSUSEPN */
#else /* DPSLNKL */
#endif /* DPSLNKL */
case findnx_not_found: {
/* try to start-up an NX? */
if (autoLaunch == True) {
int requestedTrans;
int requestedPort = 0;
if (requestedTrans == XDPSNX_USE_BEST) {
(void *)XDPSNX_TRANS_UNIX);
}
/* cons-up an arg. to pass to Agent we are forking */
additionalArgs[0] = transportArg;
if (requestedPort == XDPSNX_USE_BEST) {
if (requestedPort < 0) {
return(NULL);
}
}
"dec" : "tcp"),
/* ASSERT: first argument in additionalArgs must be
anywhere */
if (i > 256-1-4)
else
break;
}
}
return(NULL);
} else {
"::" : ":"),
}
} else { /* autoLaunch != True */
return(NULL);
}
}
break;
case findnx_found: { /* XDPSNXFindNX() == Success */
(transport == XDPSNX_TRANS_UNIX ?
"unix" : agentHost),
port);
/* Free agentHost later */
}
break;
case findnx_error:
return(NULL);
break;
default:
break;
}
/*
* Attempt to allocate a display structure. Return NULL if allocation fails.
*/
return(NULL);
}
/*
* Call the Connect routine to get the network socket. If -1 is returned, the
* connection failed. The connect routine will set fullname to point to the
* expanded name.
*/
&server_addrlen, &server_addr)) < 0) {
return(NULL);
}
#ifdef XXX
/*
* Look up the authorization protocol name and data if necessary.
*/
if (xauth_name && xauth_data) {
} else {
(unsigned short) server_addrlen,
(unsigned short) xauth_namelen,
if (authptr) {
} else {
conn_auth_namelen = 0;
conn_auth_datalen = 0;
}
}
#ifdef HASDES
/*
* build XDM-AUTHORIZATION-1 data
*/
if (conn_auth_namelen == 19 &&
{
int i, j;
int addrlen;
long now;
j = 0;
for (i = 0; i < 8; i++)
{
encrypted_data[j] = conn_auth_data[i];
j++;
}
{
}
else
{
encrypted_data[j] = 0xff; j++;
encrypted_data[j] = 0xff; j++;
encrypted_data[j] = 0xff; j++;
encrypted_data[j] = 0xff; j++;
i = getpid ();
encrypted_data[j] = (i) & 0xff; j++;
}
for (i = 3; i >= 0; i--)
{
j++;
}
}
#endif /* HASDES */
#endif /* XXX */
/*
* We succeeded at authorization, so let us move the data into
* the display structure.
*/
#ifdef XXX
/* this field is not present in post X11R5 */
#endif
for (i = KeyPress; i < 128; i++) {
}
/* Salt away the host:display string for later use.
Storage owned by agent, Xmalloc'd by connection
call above */
/* Set up the output buffers. */
OutOfMemory (dpy);
return(NULL);
}
/* Create extension data */
{
return(NULL);
}
/* Parse names to get true display name */
{
register char *s, *p;
char *dxname;
/* Agent is not on the same host as client, so fix
up the stupid abbreviations used for the display,
and whoever came up with the syntax should be shot. */
if (*s == ':')
break;
else
*p++ = *s;
*p = '\0';
if (nametmp[0] == '\0'
{
if (*s)
strcat(trueDisplayName, s);
else
}
else
}
else
if (agentHost)
return(ext);
}
/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL
after this returns. */
{
}
#ifdef NEEDFORNX
/* XFreeDisplayStructure frees all the storage associated with a
* Display. It is used by XOpenDisplay if it runs out of memory,
* and also by XCloseDisplay. It needs to check whether all pointers
* are non-NULL before dereferencing them, since it may be called
* by XOpenDisplay before the Display structure is fully formed.
* XOpenDisplay must be sure to initialize all the pointers to NULL
* before the first possible call on this.
*/
static void
{
register int i;
register int j;
register int k;
}
}
}
}
}
if (dpy->pixmap_format) {
register int i;
}
if (dpy->display_name)
if (dpy->modifiermap)
if (dpy->key_bindings)
}
}
#endif /* NEEDFORNX */
void
{
if (!agent) return;
if (agent->display_name)
}