diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2004-01-17 02:47:45 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2004-01-17 02:47:45 +0000 |
commit | ff6ec8a2ae2d45fbd70159b35695e4f3f1736c4d (patch) | |
tree | 2c1a16ae869889943e6aef5a619efa574ce2f672 | |
parent | 3e77b4e954538af865c2b54e5713d7bc2e6791ba (diff) | |
download | busybox-w32-ff6ec8a2ae2d45fbd70159b35695e4f3f1736c4d.tar.gz busybox-w32-ff6ec8a2ae2d45fbd70159b35695e4f3f1736c4d.tar.bz2 busybox-w32-ff6ec8a2ae2d45fbd70159b35695e4f3f1736c4d.zip |
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.
-rw-r--r-- | networking/inetd.c | 200 |
1 files changed, 84 insertions, 116 deletions
diff --git a/networking/inetd.c b/networking/inetd.c index 8491fc38c..db0ee814b 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -131,25 +131,24 @@ | |||
131 | #include <stdarg.h> | 131 | #include <stdarg.h> |
132 | #include <time.h> | 132 | #include <time.h> |
133 | 133 | ||
134 | #ifndef OPEN_MAX | ||
135 | #define OPEN_MAX 64 | ||
136 | #endif | ||
137 | |||
134 | #define _PATH_INETDCONF "/etc/inetd.conf" | 138 | #define _PATH_INETDCONF "/etc/inetd.conf" |
135 | #define _PATH_INETDPID "/var/run/inetd.pid" | 139 | #define _PATH_INETDPID "/var/run/inetd.pid" |
136 | 140 | ||
137 | #define TOOMANY 40 /* don't start more than TOOMANY */ | 141 | #define TOOMANY 40 /* don't start more than TOOMANY */ |
138 | #define CNT_INTVL 60 /* servers in CNT_INTVL sec. */ | 142 | #define CNT_INTVL 60 /* servers in CNT_INTVL sec. */ |
139 | #define RETRYTIME (60*10) /* retry after bind or server fail */ | 143 | #define RETRYTIME (60*10) /* retry after bind or server fail */ |
140 | 144 | #define MAXARGV 20 | |
141 | #ifndef OPEN_MAX | ||
142 | #define OPEN_MAX 64 | ||
143 | #endif | ||
144 | 145 | ||
146 | #define se_ctrladdr se_un.se_un_ctrladdr | ||
147 | #define se_ctrladdr_in se_un.se_un_ctrladdr_in | ||
148 | #define se_ctrladdr_un se_un.se_un_ctrladdr_un | ||
145 | 149 | ||
146 | /* Reserve some descriptors, 3 stdio + at least: 1 log, 1 conf. file */ | 150 | /* Reserve some descriptors, 3 stdio + at least: 1 log, 1 conf. file */ |
147 | #define FD_MARGIN (8) | 151 | #define FD_MARGIN (8) |
148 | static int rlim_ofile_cur = OPEN_MAX; | ||
149 | |||
150 | #ifdef RLIMIT_NOFILE | ||
151 | static struct rlimit rlim_ofile; | ||
152 | #endif | ||
153 | 152 | ||
154 | /* Check unsupporting builtin */ | 153 | /* Check unsupporting builtin */ |
155 | #if defined CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO || \ | 154 | #if defined CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO || \ |
@@ -173,7 +172,6 @@ static struct servtab { | |||
173 | const struct biltin *se_bi; /* if built-in, description */ | 172 | const struct biltin *se_bi; /* if built-in, description */ |
174 | #endif | 173 | #endif |
175 | char *se_server; /* server program */ | 174 | char *se_server; /* server program */ |
176 | #define MAXARGV 20 | ||
177 | char *se_argv[MAXARGV+1]; /* program arguments */ | 175 | char *se_argv[MAXARGV+1]; /* program arguments */ |
178 | int se_fd; /* open descriptor */ | 176 | int se_fd; /* open descriptor */ |
179 | union { | 177 | union { |
@@ -181,9 +179,6 @@ static struct servtab { | |||
181 | struct sockaddr_in se_un_ctrladdr_in; | 179 | struct sockaddr_in se_un_ctrladdr_in; |
182 | struct sockaddr_un se_un_ctrladdr_un; | 180 | struct sockaddr_un se_un_ctrladdr_un; |
183 | } se_un; /* bound address */ | 181 | } se_un; /* bound address */ |
184 | #define se_ctrladdr se_un.se_un_ctrladdr | ||
185 | #define se_ctrladdr_in se_un.se_un_ctrladdr_in | ||
186 | #define se_ctrladdr_un se_un.se_un_ctrladdr_un | ||
187 | int se_ctrladdr_size; | 182 | int se_ctrladdr_size; |
188 | int se_max; /* max # of instances of this service */ | 183 | int se_max; /* max # of instances of this service */ |
189 | int se_count; /* number started since se_time */ | 184 | int se_count; /* number started since se_time */ |
@@ -191,21 +186,21 @@ static struct servtab { | |||
191 | struct servtab *se_next; | 186 | struct servtab *se_next; |
192 | } *servtab; | 187 | } *servtab; |
193 | 188 | ||
194 | /* Length of socket listen queue. Should be per-service probably. */ | 189 | #ifdef INETD_FEATURE_ENABLED |
195 | static int global_queuelen = 128; | 190 | struct biltin { |
196 | 191 | const char *bi_service; /* internally provided service name */ | |
197 | static int nsock, maxsock; | 192 | int bi_socktype; /* type of socket supported */ |
198 | static fd_set allsock; | 193 | short bi_fork; /* 1 if should fork before call */ |
199 | static int timingout; | 194 | short bi_wait; /* 1 if should wait for child */ |
200 | static sigset_t blockmask, emptymask; | 195 | void (*bi_fn)(int, struct servtab *); /* fn which performs it */ |
201 | 196 | }; | |
202 | 197 | ||
203 | /* Echo received data */ | 198 | /* Echo received data */ |
204 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO | 199 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO |
205 | static void echo_stream(int, struct servtab *); | 200 | static void echo_stream(int, struct servtab *); |
206 | static void echo_dg(int, struct servtab *); | 201 | static void echo_dg(int, struct servtab *); |
207 | #endif | 202 | #endif |
208 | /* Internet /dev/null */ | 203 | /* Internet /dev/null */ |
209 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD | 204 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD |
210 | static void discard_stream(int, struct servtab *); | 205 | static void discard_stream(int, struct servtab *); |
211 | static void discard_dg(int, struct servtab *); | 206 | static void discard_dg(int, struct servtab *); |
@@ -226,16 +221,6 @@ static void chargen_stream(int, struct servtab *); | |||
226 | static void chargen_dg(int, struct servtab *); | 221 | static void chargen_dg(int, struct servtab *); |
227 | #endif | 222 | #endif |
228 | 223 | ||
229 | |||
230 | #ifdef INETD_FEATURE_ENABLED | ||
231 | struct biltin { | ||
232 | const char *bi_service; /* internally provided service name */ | ||
233 | int bi_socktype; /* type of socket supported */ | ||
234 | short bi_fork; /* 1 if should fork before call */ | ||
235 | short bi_wait; /* 1 if should wait for child */ | ||
236 | void (*bi_fn)(int, struct servtab *); /* fn which performs it */ | ||
237 | }; | ||
238 | |||
239 | static const struct biltin biltins[] = { | 224 | static const struct biltin biltins[] = { |
240 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO | 225 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO |
241 | /* Echo received data */ | 226 | /* Echo received data */ |
@@ -266,7 +251,23 @@ static const struct biltin biltins[] = { | |||
266 | }; | 251 | }; |
267 | #endif /* INETD_FEATURE_ENABLED */ | 252 | #endif /* INETD_FEATURE_ENABLED */ |
268 | 253 | ||
254 | #ifdef RLIMIT_NOFILE | ||
255 | static struct rlimit rlim_ofile; | ||
256 | #endif | ||
257 | |||
258 | /* Length of socket listen queue. Should be per-service probably. */ | ||
259 | static int global_queuelen = 128; | ||
260 | |||
261 | static FILE *fconfig; | ||
262 | static sigset_t blockmask; | ||
263 | static sigset_t emptymask; | ||
264 | static fd_set allsock; | ||
265 | static int nsock; | ||
266 | static int maxsock; | ||
267 | static int timingout; | ||
268 | static int rlim_ofile_cur = OPEN_MAX; | ||
269 | static const char *CONFIG = _PATH_INETDCONF; | 269 | static const char *CONFIG = _PATH_INETDCONF; |
270 | static FILE *fconfig; | ||
270 | 271 | ||
271 | static void | 272 | static void |
272 | syslog_err_and_discard_dg(int se_socktype, const char *msg, ...) | 273 | 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, ...) | |||
285 | _exit(1); | 286 | _exit(1); |
286 | } | 287 | } |
287 | 288 | ||
288 | static FILE *fconfig; | 289 | static FILE *setconfig(void) |
289 | |||
290 | static FILE * | ||
291 | setconfig(void) | ||
292 | { | 290 | { |
293 | FILE *f = fconfig; | 291 | FILE *f = fconfig; |
294 | 292 | ||
@@ -302,8 +300,7 @@ setconfig(void) | |||
302 | return f; | 300 | return f; |
303 | } | 301 | } |
304 | 302 | ||
305 | static char * | 303 | static char *skip(char **cpp) |
306 | skip(char **cpp) | ||
307 | { | 304 | { |
308 | char *cp = *cpp; | 305 | char *cp = *cpp; |
309 | char *start; | 306 | char *start; |
@@ -335,8 +332,7 @@ again: | |||
335 | return (start); | 332 | return (start); |
336 | } | 333 | } |
337 | 334 | ||
338 | static char * | 335 | static char *newstr(char *cp) |
339 | newstr(char *cp) | ||
340 | { | 336 | { |
341 | cp = strdup(cp ? cp : ""); | 337 | cp = strdup(cp ? cp : ""); |
342 | if (cp) | 338 | if (cp) |
@@ -346,8 +342,7 @@ newstr(char *cp) | |||
346 | } | 342 | } |
347 | 343 | ||
348 | 344 | ||
349 | static struct servtab * | 345 | static struct servtab *getconfigent(void) |
350 | getconfigent(void) | ||
351 | { | 346 | { |
352 | static struct servtab serv; | 347 | static struct servtab serv; |
353 | struct servtab *sep = &serv; | 348 | struct servtab *sep = &serv; |
@@ -441,8 +436,7 @@ more: | |||
441 | return (sep); | 436 | return (sep); |
442 | } | 437 | } |
443 | 438 | ||
444 | static void | 439 | static void freeconfig(struct servtab *cp) |
445 | freeconfig(struct servtab *cp) | ||
446 | { | 440 | { |
447 | int i; | 441 | int i; |
448 | 442 | ||
@@ -459,8 +453,7 @@ freeconfig(struct servtab *cp) | |||
459 | static char **Argv; | 453 | static char **Argv; |
460 | static char *LastArg; | 454 | static char *LastArg; |
461 | 455 | ||
462 | static void | 456 | static void setproctitle(char *a, int s) |
463 | setproctitle(char *a, int s) | ||
464 | { | 457 | { |
465 | size_t size; | 458 | size_t size; |
466 | char *cp; | 459 | char *cp; |
@@ -480,8 +473,7 @@ setproctitle(char *a, int s) | |||
480 | } | 473 | } |
481 | #endif /* INETD_FEATURE_ENABLED */ | 474 | #endif /* INETD_FEATURE_ENABLED */ |
482 | 475 | ||
483 | static struct servtab * | 476 | static struct servtab *enter(struct servtab *cp) |
484 | enter(struct servtab *cp) | ||
485 | { | 477 | { |
486 | struct servtab *sep; | 478 | struct servtab *sep; |
487 | sigset_t oldmask; | 479 | sigset_t oldmask; |
@@ -499,8 +491,7 @@ enter(struct servtab *cp) | |||
499 | return (sep); | 491 | return (sep); |
500 | } | 492 | } |
501 | 493 | ||
502 | static int | 494 | static int bump_nofile(void) |
503 | bump_nofile(void) | ||
504 | { | 495 | { |
505 | #ifdef RLIMIT_NOFILE | 496 | #ifdef RLIMIT_NOFILE |
506 | 497 | ||
@@ -539,8 +530,7 @@ bump_nofile(void) | |||
539 | } | 530 | } |
540 | 531 | ||
541 | 532 | ||
542 | static void | 533 | static void setup(struct servtab *sep) |
543 | setup(struct servtab *sep) | ||
544 | { | 534 | { |
545 | int on = 1; | 535 | int on = 1; |
546 | 536 | ||
@@ -575,8 +565,7 @@ setup(struct servtab *sep) | |||
575 | } | 565 | } |
576 | } | 566 | } |
577 | 567 | ||
578 | static void | 568 | static void config(int signum) |
579 | config(int signum) | ||
580 | { | 569 | { |
581 | struct servtab *sep, *cp, **sepp; | 570 | struct servtab *sep, *cp, **sepp; |
582 | sigset_t oldmask; | 571 | sigset_t oldmask; |
@@ -705,8 +694,7 @@ config(int signum) | |||
705 | 694 | ||
706 | 695 | ||
707 | 696 | ||
708 | static void | 697 | static void reapchild(int signum) |
709 | reapchild(int signum) | ||
710 | { | 698 | { |
711 | int status; | 699 | int status; |
712 | int pid; | 700 | int pid; |
@@ -734,8 +722,7 @@ reapchild(int signum) | |||
734 | } | 722 | } |
735 | } | 723 | } |
736 | 724 | ||
737 | static void | 725 | static void retry(int signum) |
738 | retry(int signum) | ||
739 | { | 726 | { |
740 | struct servtab *sep; | 727 | struct servtab *sep; |
741 | 728 | ||
@@ -753,8 +740,7 @@ retry(int signum) | |||
753 | } | 740 | } |
754 | } | 741 | } |
755 | 742 | ||
756 | static void | 743 | static void goaway(int signum) |
757 | goaway(int signum) | ||
758 | { | 744 | { |
759 | struct servtab *sep; | 745 | struct servtab *sep; |
760 | 746 | ||
@@ -768,11 +754,9 @@ goaway(int signum) | |||
768 | 754 | ||
769 | 755 | ||
770 | 756 | ||
771 | extern int | 757 | extern int inetd_main(int argc, char *argv[]) |
772 | inetd_main(int argc, char *argv[]) | ||
773 | { | 758 | { |
774 | struct servtab *sep; | 759 | struct servtab *sep; |
775 | struct passwd *pwd; | ||
776 | struct group *grp = NULL; | 760 | struct group *grp = NULL; |
777 | struct sigaction sa; | 761 | struct sigaction sa; |
778 | int pid; | 762 | int pid; |
@@ -781,10 +765,7 @@ inetd_main(int argc, char *argv[]) | |||
781 | gid_t gid; | 765 | gid_t gid; |
782 | 766 | ||
783 | #ifdef INETD_FEATURE_ENABLED | 767 | #ifdef INETD_FEATURE_ENABLED |
784 | int dofork; | ||
785 | extern char **environ; | 768 | extern char **environ; |
786 | #else | ||
787 | # define dofork 1 | ||
788 | #endif | 769 | #endif |
789 | 770 | ||
790 | gid = getgid(); | 771 | gid = getgid(); |
@@ -914,12 +895,11 @@ inetd_main(int argc, char *argv[]) | |||
914 | sigprocmask(SIG_BLOCK, &blockmask, NULL); | 895 | sigprocmask(SIG_BLOCK, &blockmask, NULL); |
915 | pid = 0; | 896 | pid = 0; |
916 | #ifdef INETD_FEATURE_ENABLED | 897 | #ifdef INETD_FEATURE_ENABLED |
917 | dofork = (sep->se_bi == 0 || sep->se_bi->bi_fork); | 898 | if (sep->se_bi == 0 || sep->se_bi->bi_fork) |
918 | #endif | 899 | #endif |
919 | if (dofork) { | 900 | { |
920 | if (sep->se_count++ == 0) | 901 | if (sep->se_count++ == 0) |
921 | (void)gettimeofday(&sep->se_time, | 902 | (void)gettimeofday(&sep->se_time, (struct timezone *)0); |
922 | (struct timezone *)0); | ||
923 | else if (sep->se_count >= sep->se_max) { | 903 | else if (sep->se_count >= sep->se_max) { |
924 | struct timeval now; | 904 | struct timeval now; |
925 | 905 | ||
@@ -947,19 +927,19 @@ inetd_main(int argc, char *argv[]) | |||
947 | } | 927 | } |
948 | } | 928 | } |
949 | pid = fork(); | 929 | pid = fork(); |
950 | } | 930 | if (pid < 0) { |
951 | if (pid < 0) { | 931 | syslog(LOG_ERR, "fork: %m"); |
952 | syslog(LOG_ERR, "fork: %m"); | 932 | if (sep->se_socktype == SOCK_STREAM) |
953 | if (sep->se_socktype == SOCK_STREAM) | 933 | close(ctrl); |
954 | close(ctrl); | 934 | sigprocmask(SIG_SETMASK, &emptymask, NULL); |
955 | sigprocmask(SIG_SETMASK, &emptymask, NULL); | 935 | sleep(1); |
956 | sleep(1); | 936 | continue; |
957 | continue; | 937 | } |
958 | } | 938 | if (pid && sep->se_wait) { |
959 | if (pid && sep->se_wait) { | 939 | sep->se_wait = pid; |
960 | sep->se_wait = pid; | 940 | FD_CLR(sep->se_fd, &allsock); |
961 | FD_CLR(sep->se_fd, &allsock); | 941 | nsock--; |
962 | nsock--; | 942 | } |
963 | } | 943 | } |
964 | sigprocmask(SIG_SETMASK, &emptymask, NULL); | 944 | sigprocmask(SIG_SETMASK, &emptymask, NULL); |
965 | if (pid == 0) { | 945 | if (pid == 0) { |
@@ -968,8 +948,9 @@ inetd_main(int argc, char *argv[]) | |||
968 | (*sep->se_bi->bi_fn)(ctrl, sep); | 948 | (*sep->se_bi->bi_fn)(ctrl, sep); |
969 | else | 949 | else |
970 | #endif | 950 | #endif |
971 | { | 951 | { |
972 | if ((pwd = getpwnam(sep->se_user)) == NULL) { | 952 | struct passwd *pwd = getpwnam(sep->se_user); |
953 | if (pwd == NULL) { | ||
973 | syslog_err_and_discard_dg( | 954 | syslog_err_and_discard_dg( |
974 | sep->se_socktype, | 955 | sep->se_socktype, |
975 | "getpwnam: %s: No such user", | 956 | "getpwnam: %s: No such user", |
@@ -1041,8 +1022,7 @@ inetd_main(int argc, char *argv[]) | |||
1041 | 1022 | ||
1042 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO | 1023 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_ECHO |
1043 | /* Echo service -- echo data back */ | 1024 | /* Echo service -- echo data back */ |
1044 | static void | 1025 | static void echo_stream(int s, struct servtab *sep) |
1045 | echo_stream(int s, struct servtab *sep) | ||
1046 | { | 1026 | { |
1047 | char buffer[BUFSIZE]; | 1027 | char buffer[BUFSIZE]; |
1048 | int i; | 1028 | int i; |
@@ -1055,8 +1035,7 @@ echo_stream(int s, struct servtab *sep) | |||
1055 | } | 1035 | } |
1056 | 1036 | ||
1057 | /* Echo service -- echo data back */ | 1037 | /* Echo service -- echo data back */ |
1058 | static void | 1038 | static void echo_dg(int s, struct servtab *sep) |
1059 | echo_dg(int s, struct servtab *sep) | ||
1060 | { | 1039 | { |
1061 | char buffer[BUFSIZE]; | 1040 | char buffer[BUFSIZE]; |
1062 | int i; | 1041 | int i; |
@@ -1075,8 +1054,7 @@ echo_dg(int s, struct servtab *sep) | |||
1075 | 1054 | ||
1076 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD | 1055 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DISCARD |
1077 | /* Discard service -- ignore data */ | 1056 | /* Discard service -- ignore data */ |
1078 | static void | 1057 | static void discard_stream(int s, struct servtab *sep) |
1079 | discard_stream(int s, struct servtab *sep) | ||
1080 | { | 1058 | { |
1081 | char buffer[BUFSIZE]; | 1059 | char buffer[BUFSIZE]; |
1082 | 1060 | ||
@@ -1088,8 +1066,7 @@ discard_stream(int s, struct servtab *sep) | |||
1088 | } | 1066 | } |
1089 | 1067 | ||
1090 | /* Discard service -- ignore data */ | 1068 | /* Discard service -- ignore data */ |
1091 | static void | 1069 | static void discard_dg(int s, struct servtab *sep) |
1092 | discard_dg(int s, struct servtab *sep) | ||
1093 | { | 1070 | { |
1094 | char buffer[BUFSIZE]; | 1071 | char buffer[BUFSIZE]; |
1095 | (void)sep; | 1072 | (void)sep; |
@@ -1104,8 +1081,7 @@ discard_dg(int s, struct servtab *sep) | |||
1104 | static char ring[128]; | 1081 | static char ring[128]; |
1105 | static char *endring; | 1082 | static char *endring; |
1106 | 1083 | ||
1107 | static void | 1084 | static void initring(void) |
1108 | initring(void) | ||
1109 | { | 1085 | { |
1110 | int i; | 1086 | int i; |
1111 | 1087 | ||
@@ -1117,8 +1093,7 @@ initring(void) | |||
1117 | } | 1093 | } |
1118 | 1094 | ||
1119 | /* Character generator */ | 1095 | /* Character generator */ |
1120 | static void | 1096 | static void chargen_stream(int s, struct servtab *sep) |
1121 | chargen_stream(int s, struct servtab *sep) | ||
1122 | { | 1097 | { |
1123 | char *rs; | 1098 | char *rs; |
1124 | int len; | 1099 | int len; |
@@ -1149,8 +1124,7 @@ chargen_stream(int s, struct servtab *sep) | |||
1149 | } | 1124 | } |
1150 | 1125 | ||
1151 | /* Character generator */ | 1126 | /* Character generator */ |
1152 | static void | 1127 | static void chargen_dg(int s, struct servtab *sep) |
1153 | chargen_dg(int s, struct servtab *sep) | ||
1154 | { | 1128 | { |
1155 | struct sockaddr sa; | 1129 | struct sockaddr sa; |
1156 | static char *rs; | 1130 | static char *rs; |
@@ -1192,8 +1166,7 @@ chargen_dg(int s, struct servtab *sep) | |||
1192 | * some seventy years Bell Labs was asleep. | 1166 | * some seventy years Bell Labs was asleep. |
1193 | */ | 1167 | */ |
1194 | 1168 | ||
1195 | static long | 1169 | static long machtime(void) |
1196 | machtime(void) | ||
1197 | { | 1170 | { |
1198 | struct timeval tv; | 1171 | struct timeval tv; |
1199 | 1172 | ||
@@ -1204,8 +1177,7 @@ machtime(void) | |||
1204 | return (htonl((long)tv.tv_sec + 2208988800UL)); | 1177 | return (htonl((long)tv.tv_sec + 2208988800UL)); |
1205 | } | 1178 | } |
1206 | 1179 | ||
1207 | static void | 1180 | static void machtime_stream(int s, struct servtab *sep) |
1208 | machtime_stream(int s, struct servtab *sep) | ||
1209 | { | 1181 | { |
1210 | long result; | 1182 | long result; |
1211 | (void)sep; | 1183 | (void)sep; |
@@ -1214,8 +1186,7 @@ machtime_stream(int s, struct servtab *sep) | |||
1214 | write(s, (char *) &result, sizeof(result)); | 1186 | write(s, (char *) &result, sizeof(result)); |
1215 | } | 1187 | } |
1216 | 1188 | ||
1217 | static void | 1189 | static void machtime_dg(int s, struct servtab *sep) |
1218 | machtime_dg(int s, struct servtab *sep) | ||
1219 | { | 1190 | { |
1220 | long result; | 1191 | long result; |
1221 | struct sockaddr sa; | 1192 | struct sockaddr sa; |
@@ -1233,16 +1204,14 @@ machtime_dg(int s, struct servtab *sep) | |||
1233 | 1204 | ||
1234 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DAYTIME | 1205 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BILTIN_DAYTIME |
1235 | /* Return human-readable time of day */ | 1206 | /* Return human-readable time of day */ |
1236 | static int | 1207 | static int human_readable_time_sprintf(char *buffer) |
1237 | human_readable_time_sprintf(char *buffer) | ||
1238 | { | 1208 | { |
1239 | time_t clocc = time(NULL); | 1209 | time_t clocc = time(NULL); |
1240 | 1210 | ||
1241 | return sprintf(buffer, "%.24s\r\n", ctime(&clocc)); | 1211 | return sprintf(buffer, "%.24s\r\n", ctime(&clocc)); |
1242 | } | 1212 | } |
1243 | 1213 | ||
1244 | static void | 1214 | static void daytime_stream(int s, struct servtab *sep) |
1245 | daytime_stream(int s, struct servtab *sep) | ||
1246 | { | 1215 | { |
1247 | char buffer[256]; | 1216 | char buffer[256]; |
1248 | size_t st = human_readable_time_sprintf(buffer); | 1217 | size_t st = human_readable_time_sprintf(buffer); |
@@ -1253,8 +1222,7 @@ daytime_stream(int s, struct servtab *sep) | |||
1253 | } | 1222 | } |
1254 | 1223 | ||
1255 | /* Return human-readable time of day */ | 1224 | /* Return human-readable time of day */ |
1256 | static void | 1225 | static void daytime_dg(int s, struct servtab *sep) |
1257 | daytime_dg(int s, struct servtab *sep) | ||
1258 | { | 1226 | { |
1259 | char buffer[256]; | 1227 | char buffer[256]; |
1260 | struct sockaddr sa; | 1228 | struct sockaddr sa; |