From 55f30b05ac6902ac17bad04f38fd4f381a8d75f7 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sat, 24 Mar 2007 22:42:29 +0000 Subject: inetd,ed,msh: data/bss reduction (in mss, more than 9k of it) --- networking/inetd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'networking') diff --git a/networking/inetd.c b/networking/inetd.c index 48e23db2e..83123463f 100644 --- a/networking/inetd.c +++ b/networking/inetd.c @@ -172,7 +172,6 @@ #include #endif -#define _PATH_INETDCONF "/etc/inetd.conf" #define _PATH_INETDPID "/var/run/inetd.pid" @@ -327,10 +326,9 @@ static int timingout; static struct servent *sp; static uid_t uid; -static const char *CONFIG = _PATH_INETDCONF; +static const char *config_filename = "/etc/inetd.conf"; static FILE *fconfig; -static char line[1024]; static char *defhost; /* xstrdup(NULL) returns NULL, but this one @@ -350,7 +348,7 @@ static int setconfig(void) fseek(fconfig, 0L, SEEK_SET); return 1; } - fconfig = fopen(CONFIG, "r"); + fconfig = fopen(config_filename, "r"); return (fconfig != NULL); } @@ -511,6 +509,8 @@ static void setup(servtab_t *sep) static char *nextline(void) { +#define line bb_common_bufsiz1 + char *cp; FILE *fd = fconfig; @@ -541,10 +541,12 @@ static char *skip(char **cpp) /* int report; */ int c; c = getc(fconfig); - (void) ungetc(c, fconfig); - if (c == ' ' || c == '\t') - if ((cp = nextline())) + ungetc(c, fconfig); + if (c == ' ' || c == '\t') { + cp = nextline(); + if (cp) goto again; + } *cpp = NULL; /* goto erp; */ return NULL; @@ -924,7 +926,7 @@ static void config(int sig ATTRIBUTE_UNUSED) char protoname[10]; if (!setconfig()) { - bb_perror_msg("%s", CONFIG); + bb_perror_msg("%s", config_filename); return; } for (sep = servtab; sep; sep = sep->se_next) @@ -1281,10 +1283,10 @@ int inetd_main(int argc, char *argv[]) uid = getuid(); if (uid != 0) - CONFIG = NULL; + config_filename = NULL; if (argc > 0) - CONFIG = argv[0]; - if (CONFIG == NULL) + config_filename = argv[0]; + if (config_filename == NULL) bb_error_msg_and_die("non-root must specify a config file"); #ifdef BB_NOMMU -- cgit v1.2.3