/*
* (c) Copyright 1992-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
*
* Author: Adobe Systems Incorporated
*/
/* $XFree86: xc/lib/dps/csstartNX.c,v 1.6 2001/10/28 03:32:43 tsi Exp $ */
#include <DPS/dpsNXargs.h>
#include <errno.h>
#include "DPSCAPproto.h"
#include "Xlibnet.h" /* New for R5, delete for R4 */
#include "dpsassert.h"
#include "csfindNX.h"
#include "csstartNX.h"
/* ---Defines--- */
#include <stddef.h>
#ifndef CSDPSMAXPORT
#endif
#ifndef SO_REUSEADDR
#endif
/* ---Globals--- */
/* ---Private Functions--- */
static int
TryTCP(void)
{
int request;
int okay;
#ifndef ultrix
/* Ultrix has a nasty bug in getservbyname(). If the name passed
to it doesn't exist in the services list it will seg. fault...
* sigh * */
(char *) 0)) != 0)
}
/* So, for Ultrix we just default to the default default port :-) */
#endif /* ultrix */
{
return -1;
}
#ifdef SO_REUSEADDR
/* Necesary to restart the server without a reboot */
{
}
/* What the hell is all this? I'll tell you. We don't know
a prioi what port is free, so we try to bind to each
in sequence and return the one that works. */
#if !defined(AIXV3)
{
sizeof(struct linger)) != 0)
"Couldn't set TCP SO_DONTLINGER while recommending port.");
}
#endif /* AIXV3 */
#endif /* SO_REUSEADDR */
okay = 0;
{
int result;
errno = 0;
if (result < 0)
{
if (errno != EADDRINUSE)
{
return -1;
}
continue;
}
else
{
/* We have a good port number */
okay = 1;
break;
}
}
}
/* ---Functions--- */
int
{
int ret;
switch (transport)
{
case XDPSNX_TRANS_UNIX:
/* If the TCP socket exists, we just assume the UNIX one
is there too. FALL THRU! */
case XDPSNX_TRANS_TCP: /* TCP */
break;
default: ret = -1;
}
return(ret);
}
int
{
int i = 0;
/* Create the argv list for the execl() call */
if (execArgs != 0)
if (additionalArgs != 0) /* add on the add-on args. */
if (args == 0)
return(!Success);
if (additionalArgs != 0)
if (execArgs != 0)
/* now try to start up the agent... */
if (childPid == 0) { /* Child process */
#ifndef __UNIXOS2__
if (setsid() < 0)
#endif
/* Try to start the agent */
}
/* SHOULD NEVER REACH HERE */
} else { /* Parent (NX Client) */
/* if decmips, pray that we hesitate long enough for the child... */
/* Check on child (NX Agent) */
/* Server terminated or stopped; don't care, result is same... */
} else { /* we think the agent started okay */
}
}
} else { /* Error in fork */
}
return(status);
}