Refactor #ifndef INETD_DISABLED --> #ifdef INETD_ENABLED

This patch changes the confusing logic in all #ifndef INETD_DISABLED
statements to instead be #ifdef INETD_ENABLED, which is quite a bit
more readable.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2016-12-30 13:34:31 +01:00
parent d9de2717a2
commit f95cd38ddb
5 changed files with 20 additions and 20 deletions
+3 -3
View File
@@ -140,7 +140,7 @@ static int do_start (char *buf, size_t len) { return call(service_unblock, buf,
static int do_pause (char *buf, size_t len) { return call(service_block, buf, len); }
static int do_restart(char *buf, size_t len) { return call(service_restart, buf, len); }
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
static int do_query_inetd(char *buf, size_t len)
{
int id = 1;
@@ -164,7 +164,7 @@ static int do_query_inetd(char *buf, size_t len)
return inetd_filter_str(&svc->inetd, buf, len);
}
#endif /* !INETD_DISABLED */
#endif /* INETD_ENABLED */
typedef struct {
char *event;
@@ -305,7 +305,7 @@ static void cb(uev_t *w, void *UNUSED(arg), int UNUSED(events))
result = do_restart(rq.data, sizeof(rq.data));
break;
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
case INIT_CMD_QUERY_INETD:
result = do_query_inetd(rq.data, sizeof(rq.data));
break;
+1 -1
View File
@@ -360,7 +360,7 @@ static void parse_dynamic(char *line, time_t mtime)
/* Classic inetd service */
if (MATCH_CMD(line, "inetd ", x)) {
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
service_register(SVC_TYPE_INETD, x, mtime, NULL);
#else
_e("Finit built with inetd support disabled, cannot register service inetd %s!", x);
+3 -3
View File
@@ -141,9 +141,9 @@ AS_IF([test "x$enable_watchdog" = "xyes"], [
AC_DEFINE(BUILTIN_WATCHDOG, 1, [Enable built-in watchdog, kicks on /dev/watchdog])])
### Disable features ###########################################################################
AS_IF([test "x$enable_inetd" != "xno"],
enable_inetd="yes", [
AC_DEFINE(INETD_DISABLED, 1, [Disable built-in inetd])])
AS_IF([test "x$enable_inetd" != "xno"], [
enable_inetd="yes"
AC_DEFINE(INETD_ENABLED, 1, [Enable built-in inetd])])
AS_IF([test "x$enable_quiet" != "xno"], [
AC_DEFINE(QUIET_MODE, 1, [Silent, after initial boot, no stopping/starting messages. Default: 1])
+2 -2
View File
@@ -377,7 +377,7 @@ static int show_status(char *arg)
continue;
}
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
if (svc_is_inetd(svc)) {
char *info;
struct init_request rq = {
@@ -401,7 +401,7 @@ static int show_status(char *arg)
printf("%s %s\n", svc->cmd, info);
}
else
#endif /* !INETD_DISABLED */
#endif /* INETD_ENABLED */
{
int i;
+11 -11
View File
@@ -174,7 +174,7 @@ static int service_start(svc_t *svc)
print_desc("", svc->desc);
}
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
if (svc_is_inetd(svc)) {
result = inetd_start(&svc->inetd);
if (!silent)
@@ -221,7 +221,7 @@ static int service_start(svc_t *svc)
args[i] = NULL;
/* Redirect inetd socket to stdin for connection */
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
if (svc_is_inetd_conn(svc)) {
dup2(svc->stdin_fd, STDIN_FILENO);
close(svc->stdin_fd);
@@ -287,7 +287,7 @@ static int service_start(svc_t *svc)
else
status = execv(svc->cmd, args); /* XXX: Maybe use execve() to be able to launch scripts? */
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
if (svc_is_inetd_conn(svc)) {
if (svc->inetd.type == SOCK_STREAM) {
close(STDIN_FILENO);
@@ -315,7 +315,7 @@ static int service_start(svc_t *svc)
svc->pid = pid;
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
if (svc_is_inetd_conn(svc) && svc->inetd.type == SOCK_STREAM)
close(svc->stdin_fd);
#endif
@@ -370,7 +370,7 @@ static int service_stop(svc_t *svc)
if (!svc)
return 1;
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
if (svc_is_inetd(svc)) {
int do_print = runlevel != 1 && !silent && !svc_is_busy(svc);
@@ -542,7 +542,7 @@ int service_register(int type, char *line, time_t mtime, char *username)
{
int i = 0;
int id = 1; /* Default to ID:1 */
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
int forking = 0;
#endif
int log = 0;
@@ -581,7 +581,7 @@ int service_register(int type, char *line, time_t mtime, char *username)
cond = &cmd[1];
else if (cmd[0] == ':') /* :ID */
id = atoi(&cmd[1]);
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
else if (!strncasecmp(cmd, "nowait", 6))
forking = 1;
else if (!strncasecmp(cmd, "wait", 4))
@@ -612,7 +612,7 @@ int service_register(int type, char *line, time_t mtime, char *username)
*proto++ = 0;
}
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
/* Find plugin that provides a callback for this inetd service */
if (type == SVC_TYPE_INETD) {
if (!strncasecmp(cmd, "internal", 8)) {
@@ -651,7 +651,7 @@ recreate:
return errno = ENOMEM;
}
}
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
else {
if (svc_is_inetd(svc) && type != SVC_TYPE_INETD) {
_d("Service was previously inetd, deregistering ...");
@@ -692,7 +692,7 @@ recreate:
conf_parse_cond(svc, cond);
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
if (svc_is_inetd(svc)) {
char *iface, *name = service;
@@ -839,7 +839,7 @@ restart:
break;
case SVC_DONE_STATE:
#ifndef INETD_DISABLED
#ifdef INETD_ENABLED
if (svc_is_inetd_conn(svc)) {
if (svc_is_busy(svc->inetd.svc)) {
svc_unblock(svc->inetd.svc);