util.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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* General utility routines.
*/
#include <syslog.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <strings.h>
#include <time.h>
#include <errno.h>
#include <libintl.h>
#include <unistd.h>
#include "inetd_impl.h"
/* location of inetd's debug log file */
#define DEBUG_LOG_FILE "/var/tmp/inetd.log"
/* size of buffer used in msg() to expand printf() like messages into */
#define MSG_BUF_SIZE 1024
#define TIME_BUF_SIZE 50
/* number of pollfd we grow the pollfd array by at a time in set_pollfd() */
#define POLLFDS_GROWTH_SIZE 16
/* enumeration of message types supported by msg() */
typedef enum {
/*
* Collection of information for each method type.
* NOTE: This table is indexed into using the instance_method_t
* enumeration, so the ordering needs to be kept in synch.
*/
method_type_info_t methods[] = {
};
void
msg_init(void)
{
/* Try once at startup to open the log file. */
}
void
msg_fini(void)
{
}
closelog();
}
/*
* Outputs a msg. If 'type' is set tp MT_ERROR or MT_WARN the message goes
* to syslog with severitys LOG_ERROR and LOG_WARN respectively. For all
* values of 'type' the message is written to the debug log file, if it
* was openable when inetd started.
*/
static void
{
/*
* Use a stack buffer so we stand more chance of reporting a
* memory shortage failure.
*/
char buf[MSG_BUF_SIZE];
char timebuf[TIME_BUF_SIZE];
if (!logging_enabled)
return;
/*
* Log error and warning messages to syslog with appropriate severity.
*/
}
/*
* We managed to open the log file at startup. Log all
* message types there - in addition to syslog.
*/
}
}
}
/*
* Output a warning message. Unlike error_msg(), syslog doesn't get told
* to log to the console if syslogd isn't around.
*/
void
{
closelog();
closelog();
}
void
{
}
void
{
}
void
poll_fini(void)
{
}
}
struct pollfd *
find_pollfd(int fd)
{
nfds_t n;
for (n = 0; n < num_pollfds; n++) {
return (&(poll_fds[n]));
}
return (NULL);
}
int
{
struct pollfd *p;
int i;
debug_msg("Entering set_pollfd, fd: %d, num_pollfds: %d, fds: %x,"
p = find_pollfd(fd);
((num_pollfds + POLLFDS_GROWTH_SIZE) *
return (-1);
}
poll_fds = p;
for (i = 1; i < POLLFDS_GROWTH_SIZE; i++)
p = &poll_fds[num_pollfds];
}
p->revents = 0;
return (0);
}
void
clear_pollfd(int fd)
{
struct pollfd *p;
p->fd = -1;
p->events = 0;
p->revents = 0;
}
}
isset_pollfd(int fd)
{
}
/*
* An extension of read() that keeps retrying until either the full request has
* completed, the other end of the connection/pipe is closed, no data is
* Returns 0 if the data is successfully read, 1 if the other end of the pipe/
* else -1 if an unexpected error occurs.
*/
int
{
int ret;
if (sz == 0)
return (0);
do {
return (1);
case -1:
return (1);
return (-1);
}
break;
default:
}
return (0);
}
/*
* Return B_TRUE if instance 'inst' has exceeded its configured maximum
* concurrent copies limit, else B_FALSE.
*/
{
/* any value <=0 means that copies limits are disabled */
}
/*
*/
void
{
}
/*
* Cancel the bind retry timer associated with the instance.
*/
void
{
}
void
enable_blocking(int fd)
{
}
void
disable_blocking(int fd)
{
}