mconnect.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* LINTLIBRARY */
# include <unistd.h>
# include <fcntl.h>
# include <errno.h>
# include <stdlib.h>
#include "lp.h"
#include "msgs.h"
#if defined(__STDC__)
static MESG * connect3_2 ( void );
static int checklock ( void );
#else
static MESG * connect3_2();
static int checklock();
#endif
/*
** mconnect() - OPEN A MESSAGE PATH
*/
#if defined(__STDC__)
#else
char *path;
int id1;
int id2;
#endif
{
int fd;
int wronly = 0;
int count = 0;
/*
** invoked as mconnect(path, 0, 0)
**
** Open <path>, if isastream() is true for the returned file
** descriptor, then we're done. If not, proceed with the 3.2
** handshaking.
*/
if (path)
{
/*
** Verify that the spooler is running and that the
** <path> identifies a pipe.
** This prevents us from getting hung in the open
** and from thinking the <path> is a non-streams pipe.
*/
if (checklock() == -1)
return(NULL);
return(NULL);
if (count++ > 20)
return (NULL);
sleep(1);
goto Again;
}
return(NULL);
else
wronly = 1;
{
#if defined(NOCONNLD)
int fds[2];
return(NULL);
return(NULL);
#endif
{
return(NULL);
}
return(md);
}
return(connect3_2());
}
{
{
return(NULL);
}
return(md);
}
return(NULL);
}
#if defined(__STDC__)
static MESG * connect3_2 ( void )
#else
static MESG * connect3_2()
#endif
{
char *msgbuf = 0,
*fifo_name = "UUUUUUUUNNNNN";
int tmp_fd = -1,
size;
short status;
return(NULL);
{
return (NULL);
}
/*
** Combine the machine node-name with the process ID to
** get a name that will be unique across the network.
** The 99999 is just a safety precaution against over-running
** the buffer.
*/
{
goto Error;
}
goto Error;
goto Error;
{
goto Error;
}
if (
)
{
goto Error;
}
else
{
goto Error;
}
/*
* Prepare to use the fifo the Spooler created. This new FIFO can be
* read ONLY by who we said we are, so if we lied, tough luck for us!
*/
{
goto Error;
}
goto Error;
{
goto Error;
}
if (
)
{
goto Error;
}
else
{
goto Error;
}
return (md);
{
}
if (tmp_fd != -1)
return(NULL);
}
#if defined(__STDC__)
static int checklock ( void )
#else
static int checklock()
#endif
{
int fd;
return (-1);
/*
* Now, we try to read-lock the lock file. This can only succeed if
* the Spooler (lpsched) is down.
*/
{
return (-1);
}
/*
* We can get here only when fcntl() == -1 && errno == EAGAIN,
* i.e., spooler (lpsched) is running.
*/
return(0);
}