Use 1 line for function name and return value,
remove dofork define/variable, dont check pid value is < or > than 0 if we know it is 0.
This commit is contained in:
parent
3e77b4e954
commit
ff6ec8a2ae
@ -131,25 +131,24 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#ifndef OPEN_MAX
|
||||||
|
#define OPEN_MAX 64
|
||||||
|
#endif
|
||||||
|
|
||||||
#define _PATH_INETDCONF "/etc/inetd.conf"
|
#define _PATH_INETDCONF "/etc/inetd.conf"
|
||||||
#define _PATH_INETDPID "/var/run/inetd.pid"
|
#define _PATH_INETDPID "/var/run/inetd.pid"
|
||||||
|
|
||||||
#define TOOMANY 40 /* don't start more than TOOMANY */
|
#define TOOMANY 40 /* don't start more than TOOMANY */
|
||||||
#define CNT_INTVL 60 /* servers in CNT_INTVL sec. */
|
#define CNT_INTVL 60 /* servers in CNT_INTVL sec. */
|
||||||
#define RETRYTIME (60*10) /* retry after bind or server fail */
|
#define RETRYTIME (60*10) /* retry after bind or server fail */
|
||||||
|
#define MAXARGV 20
|
||||||
#ifndef OPEN_MAX
|
|
||||||
#define OPEN_MAX 64
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#define se_ctrladdr se_un.se_un_ctrladdr
|
||||||
|
#define se_ctrladdr_in se_un.se_un_ctrladdr_in
|
||||||
|
#define se_ctrladdr_un se_un.se_un_ctrladdr_un
|
||||||
|
|
||||||
/* Reserve some descriptors, 3 stdio + at least: 1 log, 1 conf. file */
|
/* Reserve some descriptors, 3 stdio + at least: 1 log, 1 conf. file */
|
||||||
#define FD_MARGIN (8)
|
#define FD_MARGIN (8)
|
||||||
static int rlim_ofile_cur = OPEN_MAX;
|
|
||||||
|
|
||||||
#ifdef RLIMIT_NOFILE
|
|
||||||
static struct rlimit rlim_ofile;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Check unsupporting builtin */
|
/* Check unsupporting builtin */
|
||||||
#if defined CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO || \
|
#if defined CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO || \
|
||||||
@ -173,7 +172,6 @@ static struct servtab {
|
|||||||
const struct biltin *se_bi; /* if built-in, description */
|
const struct biltin *se_bi; /* if built-in, description */
|
||||||
#endif
|
#endif
|
||||||
char *se_server; /* server program */
|
char *se_server; /* server program */
|
||||||
#define MAXARGV 20
|
|
||||||
char *se_argv[MAXARGV+1]; /* program arguments */
|
char *se_argv[MAXARGV+1]; /* program arguments */
|
||||||
int se_fd; /* open descriptor */
|
int se_fd; /* open descriptor */
|
||||||
union {
|
union {
|
||||||
@ -181,9 +179,6 @@ static struct servtab {
|
|||||||
struct sockaddr_in se_un_ctrladdr_in;
|
struct sockaddr_in se_un_ctrladdr_in;
|
||||||
struct sockaddr_un se_un_ctrladdr_un;
|
struct sockaddr_un se_un_ctrladdr_un;
|
||||||
} se_un; /* bound address */
|
} se_un; /* bound address */
|
||||||
#define se_ctrladdr se_un.se_un_ctrladdr
|
|
||||||
#define se_ctrladdr_in se_un.se_un_ctrladdr_in
|
|
||||||
#define se_ctrladdr_un se_un.se_un_ctrladdr_un
|
|
||||||
int se_ctrladdr_size;
|
int se_ctrladdr_size;
|
||||||
int se_max; /* max # of instances of this service */
|
int se_max; /* max # of instances of this service */
|
||||||
int se_count; /* number started since se_time */
|
int se_count; /* number started since se_time */
|
||||||
@ -191,21 +186,21 @@ static struct servtab {
|
|||||||
struct servtab *se_next;
|
struct servtab *se_next;
|
||||||
} *servtab;
|
} *servtab;
|
||||||
|
|
||||||
/* Length of socket listen queue. Should be per-service probably. */
|
#ifdef INETD_FEATURE_ENABLED
|
||||||
static int global_queuelen = 128;
|
struct biltin {
|
||||||
|
const char *bi_service; /* internally provided service name */
|
||||||
|
int bi_socktype; /* type of socket supported */
|
||||||
|
short bi_fork; /* 1 if should fork before call */
|
||||||
|
short bi_wait; /* 1 if should wait for child */
|
||||||
|
void (*bi_fn)(int, struct servtab *); /* fn which performs it */
|
||||||
|
};
|
||||||
|
|
||||||
static int nsock, maxsock;
|
/* Echo received data */
|
||||||
static fd_set allsock;
|
|
||||||
static int timingout;
|
|
||||||
static sigset_t blockmask, emptymask;
|
|
||||||
|
|
||||||
|
|
||||||
/* Echo received data */
|
|
||||||
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO
|
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO
|
||||||
static void echo_stream(int, struct servtab *);
|
static void echo_stream(int, struct servtab *);
|
||||||
static void echo_dg(int, struct servtab *);
|
static void echo_dg(int, struct servtab *);
|
||||||
#endif
|
#endif
|
||||||
/* Internet /dev/null */
|
/* Internet /dev/null */
|
||||||
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD
|
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD
|
||||||
static void discard_stream(int, struct servtab *);
|
static void discard_stream(int, struct servtab *);
|
||||||
static void discard_dg(int, struct servtab *);
|
static void discard_dg(int, struct servtab *);
|
||||||
@ -226,16 +221,6 @@ static void chargen_stream(int, struct servtab *);
|
|||||||
static void chargen_dg(int, struct servtab *);
|
static void chargen_dg(int, struct servtab *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef INETD_FEATURE_ENABLED
|
|
||||||
struct biltin {
|
|
||||||
const char *bi_service; /* internally provided service name */
|
|
||||||
int bi_socktype; /* type of socket supported */
|
|
||||||
short bi_fork; /* 1 if should fork before call */
|
|
||||||
short bi_wait; /* 1 if should wait for child */
|
|
||||||
void (*bi_fn)(int, struct servtab *); /* fn which performs it */
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct biltin biltins[] = {
|
static const struct biltin biltins[] = {
|
||||||
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO
|
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO
|
||||||
/* Echo received data */
|
/* Echo received data */
|
||||||
@ -266,7 +251,23 @@ static const struct biltin biltins[] = {
|
|||||||
};
|
};
|
||||||
#endif /* INETD_FEATURE_ENABLED */
|
#endif /* INETD_FEATURE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef RLIMIT_NOFILE
|
||||||
|
static struct rlimit rlim_ofile;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Length of socket listen queue. Should be per-service probably. */
|
||||||
|
static int global_queuelen = 128;
|
||||||
|
|
||||||
|
static FILE *fconfig;
|
||||||
|
static sigset_t blockmask;
|
||||||
|
static sigset_t emptymask;
|
||||||
|
static fd_set allsock;
|
||||||
|
static int nsock;
|
||||||
|
static int maxsock;
|
||||||
|
static int timingout;
|
||||||
|
static int rlim_ofile_cur = OPEN_MAX;
|
||||||
static const char *CONFIG = _PATH_INETDCONF;
|
static const char *CONFIG = _PATH_INETDCONF;
|
||||||
|
static FILE *fconfig;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
syslog_err_and_discard_dg(int se_socktype, const char *msg, ...)
|
syslog_err_and_discard_dg(int se_socktype, const char *msg, ...)
|
||||||
@ -285,10 +286,7 @@ syslog_err_and_discard_dg(int se_socktype, const char *msg, ...)
|
|||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FILE *fconfig;
|
static FILE *setconfig(void)
|
||||||
|
|
||||||
static FILE *
|
|
||||||
setconfig(void)
|
|
||||||
{
|
{
|
||||||
FILE *f = fconfig;
|
FILE *f = fconfig;
|
||||||
|
|
||||||
@ -302,8 +300,7 @@ setconfig(void)
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *skip(char **cpp)
|
||||||
skip(char **cpp)
|
|
||||||
{
|
{
|
||||||
char *cp = *cpp;
|
char *cp = *cpp;
|
||||||
char *start;
|
char *start;
|
||||||
@ -335,8 +332,7 @@ again:
|
|||||||
return (start);
|
return (start);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *newstr(char *cp)
|
||||||
newstr(char *cp)
|
|
||||||
{
|
{
|
||||||
cp = strdup(cp ? cp : "");
|
cp = strdup(cp ? cp : "");
|
||||||
if (cp)
|
if (cp)
|
||||||
@ -346,8 +342,7 @@ newstr(char *cp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct servtab *
|
static struct servtab *getconfigent(void)
|
||||||
getconfigent(void)
|
|
||||||
{
|
{
|
||||||
static struct servtab serv;
|
static struct servtab serv;
|
||||||
struct servtab *sep = &serv;
|
struct servtab *sep = &serv;
|
||||||
@ -441,8 +436,7 @@ more:
|
|||||||
return (sep);
|
return (sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void freeconfig(struct servtab *cp)
|
||||||
freeconfig(struct servtab *cp)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -459,8 +453,7 @@ freeconfig(struct servtab *cp)
|
|||||||
static char **Argv;
|
static char **Argv;
|
||||||
static char *LastArg;
|
static char *LastArg;
|
||||||
|
|
||||||
static void
|
static void setproctitle(char *a, int s)
|
||||||
setproctitle(char *a, int s)
|
|
||||||
{
|
{
|
||||||
size_t size;
|
size_t size;
|
||||||
char *cp;
|
char *cp;
|
||||||
@ -480,8 +473,7 @@ setproctitle(char *a, int s)
|
|||||||
}
|
}
|
||||||
#endif /* INETD_FEATURE_ENABLED */
|
#endif /* INETD_FEATURE_ENABLED */
|
||||||
|
|
||||||
static struct servtab *
|
static struct servtab *enter(struct servtab *cp)
|
||||||
enter(struct servtab *cp)
|
|
||||||
{
|
{
|
||||||
struct servtab *sep;
|
struct servtab *sep;
|
||||||
sigset_t oldmask;
|
sigset_t oldmask;
|
||||||
@ -499,8 +491,7 @@ enter(struct servtab *cp)
|
|||||||
return (sep);
|
return (sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int bump_nofile(void)
|
||||||
bump_nofile(void)
|
|
||||||
{
|
{
|
||||||
#ifdef RLIMIT_NOFILE
|
#ifdef RLIMIT_NOFILE
|
||||||
|
|
||||||
@ -539,8 +530,7 @@ bump_nofile(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void setup(struct servtab *sep)
|
||||||
setup(struct servtab *sep)
|
|
||||||
{
|
{
|
||||||
int on = 1;
|
int on = 1;
|
||||||
|
|
||||||
@ -575,8 +565,7 @@ setup(struct servtab *sep)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void config(int signum)
|
||||||
config(int signum)
|
|
||||||
{
|
{
|
||||||
struct servtab *sep, *cp, **sepp;
|
struct servtab *sep, *cp, **sepp;
|
||||||
sigset_t oldmask;
|
sigset_t oldmask;
|
||||||
@ -705,8 +694,7 @@ config(int signum)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void reapchild(int signum)
|
||||||
reapchild(int signum)
|
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
int pid;
|
int pid;
|
||||||
@ -734,8 +722,7 @@ reapchild(int signum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void retry(int signum)
|
||||||
retry(int signum)
|
|
||||||
{
|
{
|
||||||
struct servtab *sep;
|
struct servtab *sep;
|
||||||
|
|
||||||
@ -753,8 +740,7 @@ retry(int signum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void goaway(int signum)
|
||||||
goaway(int signum)
|
|
||||||
{
|
{
|
||||||
struct servtab *sep;
|
struct servtab *sep;
|
||||||
|
|
||||||
@ -768,11 +754,9 @@ goaway(int signum)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern int
|
extern int inetd_main(int argc, char *argv[])
|
||||||
inetd_main(int argc, char *argv[])
|
|
||||||
{
|
{
|
||||||
struct servtab *sep;
|
struct servtab *sep;
|
||||||
struct passwd *pwd;
|
|
||||||
struct group *grp = NULL;
|
struct group *grp = NULL;
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
int pid;
|
int pid;
|
||||||
@ -781,10 +765,7 @@ inetd_main(int argc, char *argv[])
|
|||||||
gid_t gid;
|
gid_t gid;
|
||||||
|
|
||||||
#ifdef INETD_FEATURE_ENABLED
|
#ifdef INETD_FEATURE_ENABLED
|
||||||
int dofork;
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
#else
|
|
||||||
# define dofork 1
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gid = getgid();
|
gid = getgid();
|
||||||
@ -914,12 +895,11 @@ inetd_main(int argc, char *argv[])
|
|||||||
sigprocmask(SIG_BLOCK, &blockmask, NULL);
|
sigprocmask(SIG_BLOCK, &blockmask, NULL);
|
||||||
pid = 0;
|
pid = 0;
|
||||||
#ifdef INETD_FEATURE_ENABLED
|
#ifdef INETD_FEATURE_ENABLED
|
||||||
dofork = (sep->se_bi == 0 || sep->se_bi->bi_fork);
|
if (sep->se_bi == 0 || sep->se_bi->bi_fork)
|
||||||
#endif
|
#endif
|
||||||
if (dofork) {
|
{
|
||||||
if (sep->se_count++ == 0)
|
if (sep->se_count++ == 0)
|
||||||
(void)gettimeofday(&sep->se_time,
|
(void)gettimeofday(&sep->se_time, (struct timezone *)0);
|
||||||
(struct timezone *)0);
|
|
||||||
else if (sep->se_count >= sep->se_max) {
|
else if (sep->se_count >= sep->se_max) {
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
|
|
||||||
@ -947,19 +927,19 @@ inetd_main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pid = fork();
|
pid = fork();
|
||||||
}
|
if (pid < 0) {
|
||||||
if (pid < 0) {
|
syslog(LOG_ERR, "fork: %m");
|
||||||
syslog(LOG_ERR, "fork: %m");
|
if (sep->se_socktype == SOCK_STREAM)
|
||||||
if (sep->se_socktype == SOCK_STREAM)
|
close(ctrl);
|
||||||
close(ctrl);
|
sigprocmask(SIG_SETMASK, &emptymask, NULL);
|
||||||
sigprocmask(SIG_SETMASK, &emptymask, NULL);
|
sleep(1);
|
||||||
sleep(1);
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if (pid && sep->se_wait) {
|
||||||
if (pid && sep->se_wait) {
|
sep->se_wait = pid;
|
||||||
sep->se_wait = pid;
|
FD_CLR(sep->se_fd, &allsock);
|
||||||
FD_CLR(sep->se_fd, &allsock);
|
nsock--;
|
||||||
nsock--;
|
}
|
||||||
}
|
}
|
||||||
sigprocmask(SIG_SETMASK, &emptymask, NULL);
|
sigprocmask(SIG_SETMASK, &emptymask, NULL);
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
@ -968,8 +948,9 @@ inetd_main(int argc, char *argv[])
|
|||||||
(*sep->se_bi->bi_fn)(ctrl, sep);
|
(*sep->se_bi->bi_fn)(ctrl, sep);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if ((pwd = getpwnam(sep->se_user)) == NULL) {
|
struct passwd *pwd = getpwnam(sep->se_user);
|
||||||
|
if (pwd == NULL) {
|
||||||
syslog_err_and_discard_dg(
|
syslog_err_and_discard_dg(
|
||||||
sep->se_socktype,
|
sep->se_socktype,
|
||||||
"getpwnam: %s: No such user",
|
"getpwnam: %s: No such user",
|
||||||
@ -1041,8 +1022,7 @@ inetd_main(int argc, char *argv[])
|
|||||||
|
|
||||||
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO
|
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO
|
||||||
/* Echo service -- echo data back */
|
/* Echo service -- echo data back */
|
||||||
static void
|
static void echo_stream(int s, struct servtab *sep)
|
||||||
echo_stream(int s, struct servtab *sep)
|
|
||||||
{
|
{
|
||||||
char buffer[BUFSIZE];
|
char buffer[BUFSIZE];
|
||||||
int i;
|
int i;
|
||||||
@ -1055,8 +1035,7 @@ echo_stream(int s, struct servtab *sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Echo service -- echo data back */
|
/* Echo service -- echo data back */
|
||||||
static void
|
static void echo_dg(int s, struct servtab *sep)
|
||||||
echo_dg(int s, struct servtab *sep)
|
|
||||||
{
|
{
|
||||||
char buffer[BUFSIZE];
|
char buffer[BUFSIZE];
|
||||||
int i;
|
int i;
|
||||||
@ -1075,8 +1054,7 @@ echo_dg(int s, struct servtab *sep)
|
|||||||
|
|
||||||
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD
|
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD
|
||||||
/* Discard service -- ignore data */
|
/* Discard service -- ignore data */
|
||||||
static void
|
static void discard_stream(int s, struct servtab *sep)
|
||||||
discard_stream(int s, struct servtab *sep)
|
|
||||||
{
|
{
|
||||||
char buffer[BUFSIZE];
|
char buffer[BUFSIZE];
|
||||||
|
|
||||||
@ -1088,8 +1066,7 @@ discard_stream(int s, struct servtab *sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Discard service -- ignore data */
|
/* Discard service -- ignore data */
|
||||||
static void
|
static void discard_dg(int s, struct servtab *sep)
|
||||||
discard_dg(int s, struct servtab *sep)
|
|
||||||
{
|
{
|
||||||
char buffer[BUFSIZE];
|
char buffer[BUFSIZE];
|
||||||
(void)sep;
|
(void)sep;
|
||||||
@ -1104,8 +1081,7 @@ discard_dg(int s, struct servtab *sep)
|
|||||||
static char ring[128];
|
static char ring[128];
|
||||||
static char *endring;
|
static char *endring;
|
||||||
|
|
||||||
static void
|
static void initring(void)
|
||||||
initring(void)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1117,8 +1093,7 @@ initring(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Character generator */
|
/* Character generator */
|
||||||
static void
|
static void chargen_stream(int s, struct servtab *sep)
|
||||||
chargen_stream(int s, struct servtab *sep)
|
|
||||||
{
|
{
|
||||||
char *rs;
|
char *rs;
|
||||||
int len;
|
int len;
|
||||||
@ -1149,8 +1124,7 @@ chargen_stream(int s, struct servtab *sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Character generator */
|
/* Character generator */
|
||||||
static void
|
static void chargen_dg(int s, struct servtab *sep)
|
||||||
chargen_dg(int s, struct servtab *sep)
|
|
||||||
{
|
{
|
||||||
struct sockaddr sa;
|
struct sockaddr sa;
|
||||||
static char *rs;
|
static char *rs;
|
||||||
@ -1192,8 +1166,7 @@ chargen_dg(int s, struct servtab *sep)
|
|||||||
* some seventy years Bell Labs was asleep.
|
* some seventy years Bell Labs was asleep.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static long
|
static long machtime(void)
|
||||||
machtime(void)
|
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
@ -1204,8 +1177,7 @@ machtime(void)
|
|||||||
return (htonl((long)tv.tv_sec + 2208988800UL));
|
return (htonl((long)tv.tv_sec + 2208988800UL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void machtime_stream(int s, struct servtab *sep)
|
||||||
machtime_stream(int s, struct servtab *sep)
|
|
||||||
{
|
{
|
||||||
long result;
|
long result;
|
||||||
(void)sep;
|
(void)sep;
|
||||||
@ -1214,8 +1186,7 @@ machtime_stream(int s, struct servtab *sep)
|
|||||||
write(s, (char *) &result, sizeof(result));
|
write(s, (char *) &result, sizeof(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void machtime_dg(int s, struct servtab *sep)
|
||||||
machtime_dg(int s, struct servtab *sep)
|
|
||||||
{
|
{
|
||||||
long result;
|
long result;
|
||||||
struct sockaddr sa;
|
struct sockaddr sa;
|
||||||
@ -1233,16 +1204,14 @@ machtime_dg(int s, struct servtab *sep)
|
|||||||
|
|
||||||
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DAYTIME
|
#ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DAYTIME
|
||||||
/* Return human-readable time of day */
|
/* Return human-readable time of day */
|
||||||
static int
|
static int human_readable_time_sprintf(char *buffer)
|
||||||
human_readable_time_sprintf(char *buffer)
|
|
||||||
{
|
{
|
||||||
time_t clocc = time(NULL);
|
time_t clocc = time(NULL);
|
||||||
|
|
||||||
return sprintf(buffer, "%.24s\r\n", ctime(&clocc));
|
return sprintf(buffer, "%.24s\r\n", ctime(&clocc));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void daytime_stream(int s, struct servtab *sep)
|
||||||
daytime_stream(int s, struct servtab *sep)
|
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
size_t st = human_readable_time_sprintf(buffer);
|
size_t st = human_readable_time_sprintf(buffer);
|
||||||
@ -1253,8 +1222,7 @@ daytime_stream(int s, struct servtab *sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return human-readable time of day */
|
/* Return human-readable time of day */
|
||||||
static void
|
static void daytime_dg(int s, struct servtab *sep)
|
||||||
daytime_dg(int s, struct servtab *sep)
|
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
struct sockaddr sa;
|
struct sockaddr sa;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user