diff options
Diffstat (limited to 'src/sysvinit.c')
-rw-r--r-- | src/sysvinit.c | 43 |
1 files changed, 11 insertions, 32 deletions
diff --git a/src/sysvinit.c b/src/sysvinit.c index 375a0d5..a4e0d63 100644 --- a/src/sysvinit.c +++ b/src/sysvinit.c @@ -1,8 +1,8 @@ /* This file is part of GNU Pies. - Copyright (C) 2013 Sergey Poznyakoff + Copyright (C) 2013-2016 Sergey Poznyakoff GNU Pies is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. @@ -276,13 +276,13 @@ runlevel_setup_prog (struct prog *prog, void *data) if (rc < 0) return 0; if (rc) prog->v.p.status = status_enabled; else prog->v.p.status = status_disabled; - debug (1, ("%s: %s", prog->tag, + debug (1, ("%s: %s", prog_tag (prog), prog->v.p.status == status_enabled ? "enabled" : "disabled")); } return 0; } @@ -873,22 +873,23 @@ inittab_parse (const char *file) debug_level = atoi (ws.ws_wordv[3]); } else if (strcmp (ws.ws_wordv[2], "next") == 0) { if (ws.ws_wordc >= 5) { - enum config_syntax synt; + struct config_syntax *synt = + str_to_config_syntax (ws.ws_wordv[3]); - if (str_to_config_syntax (ws.ws_wordv[3], &synt)) + if (!synt) logmsg (LOG_ERR, "%s:%u: %s", file, line_no, _("unknown syntax type")); else - add_config (synt, ws.ws_wordv[4]); + config_file_add (synt, ws.ws_wordv[4]); } else if (ws.ws_wordc == 4) - add_config (CONF_PIES, ws.ws_wordv[3]); + config_file_add_type (CONF_PIES, ws.ws_wordv[3]); } else if (strcmp (ws.ws_wordv[2], "stop") == 0) { wordsplit_free (&ws); break; } @@ -930,58 +931,36 @@ inittab_parse (const char *file) logmsg (LOG_ERR, "%s:%u: %s", file, line_no, _("unknown action")); err = 1; continue; } - comp = calloc (1, sizeof (*comp)); - if (!comp) - { - logmsg (LOG_ERR, "%s:%u: %s", file, line_no, - _("not enough memory")); - err = 1; - continue; - } - + comp = component_create (id); comp->mode = ap->mode; - comp->tag = strdup (id); - comp->runlevels = strdup (runlevels); - - if (!comp->tag || !comp->runlevels) - { - component_free (comp); - logmsg (LOG_ERR, "%s:%u: %s", file, line_no, - _("not enough memory")); - err = 1; - continue; - } + comp->runlevels = grecs_strdup (runlevels); if (wordsplit (process, &ws, WRDSF_DEFFLAGS)) { component_free (comp); logmsg (LOG_ERR, "%s:%u: wordsplit: %s", file, line_no, strerror (errno)); err = 1; continue; } - comp->argc = ws.ws_wordc; - comp->argv = ws.ws_wordv; - comp->program = strdup (ws.ws_wordv[0]); - ws.ws_wordc = 0; - ws.ws_wordv = NULL; + wordsplit_getwords (&ws, &comp->argc, &comp->argv); + comp->program = grecs_strdup (comp->argv[0]); wordsplit_free (&ws); comp->flags |= CF_SIGGROUP; if (ap->parser && ap->parser (comp, file, line_no)) { component_free (comp); err = 1; continue; } - register_prog (comp); } free (buf); fclose (fp); return err; } |