tcp_misc.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) 1996-2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <libintl.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
#include <strings.h>
#include <syslog.h>
#include <unistd.h>
#include <fcntl.h>
#include <netdb.h>
#include "netpr.h"
#include "netdebug.h"
{
return (NULL);
return (tcpjob);
}
int
{
struct sockaddr_in6 serv_addr;
int s,
err,
unsigned timo = 1;
int retry;
int rtnerr;
/*
* Get the host address and port number to connect to.
*/
return (-1);
}
gettext("Netpr: System call getipnodebyname fails\n"));
"getipnodebyname() returned %d", error_num);
return (-1);
}
do {
retry = 0;
rtnerr = 0;
/*
* Try connecting to the printer.
*/
if (s < 0) {
gettext("Netpr: System call socket fails\n"));
rtnerr = -1;
} else {
sizeof (serv_addr)) < 0) {
(void) alarm(0);
timo *= 2;
retry++;
} else {
gettext("Netpr: Cannot connect to printer\n"));
rtnerr = -1;
}
/* The connect on this socket failed; close it */
(void) close(s);
} else
(void) alarm(0);
}
} while (retry);
}
int
{
char c;
int xfer;
int nr = 0;
int ctr = 0;
int msg_given = 0;
int nlps = 0;
return (xfer);
}
gettext("Netpr: System error: possible loss of data\n"));
"shutdown error; possible loss of data");
return (E_SYSTEM_ERROR);
}
/* read in single character ack or msg from printer */
(void) alarm(2);
errno = 0;
(void) alarm(0);
if (msg_given == 0) {
gettext("Printer not responding;" \
"Either warming up or needs attention\n"));
msg_given++;
}
/* if no ACK received, do not loop forever */
break;
}
} else {
break;
}
}
if (ctr > 1)
buf);
}
return (E_SUCCESS);
}