summaryrefslogtreecommitdiffabout
path: root/src/sysvinit.c
Side-by-side diff
Diffstat (limited to 'src/sysvinit.c') (more/less context) (show whitespace changes)
-rw-r--r--src/sysvinit.c62
1 files changed, 56 insertions, 6 deletions
diff --git a/src/sysvinit.c b/src/sysvinit.c
index 3ba986b..c5d25da 100644
--- a/src/sysvinit.c
+++ b/src/sysvinit.c
@@ -55,13 +55,13 @@ static int boot_trans_tab[max_boot_state][sizeof(valid_runlevels)-1] = {
};
enum boot_state boot_state;
-int runlevel = 0;
-int prevlevel = 'N';
+static int runlevel = 0;
+static int prevlevel = 'N';
-int initdefault; /* Default runlevel */
-int dfl_level;
-char *emergency_shell = EMERGENCY_SHELL;
-int emergency;
+int initdefault;
+static int dfl_level;
+static char *emergency_shell = EMERGENCY_SHELL;
+static int emergency;
static int inittrans (void);
@@ -1283,3 +1283,53 @@ sysvinit_parse_argv (int argc, char **argv)
dfl_level = c;
}
}
+
+int
+cb_initdefault (enum grecs_callback_command cmd,
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
+{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
+
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
+ return 1;
+ if (strlen (value->v.string) != 1)
+ {
+ grecs_error (locus, 0, _("argument must be a single character"));
+ return 1;
+ }
+ if (!is_valid_runlevel (value->v.string[0]))
+ {
+ grecs_error (locus, 0, _("not a valid runlevel"));
+ return 1;
+ }
+ initdefault = toupper (value->v.string[0]);
+ return 0;
+}
+
+int
+cb_runlevels (enum grecs_callback_command cmd,
+ grecs_node_t *node,
+ void *varptr, void *cb_data)
+{
+ grecs_locus_t *locus = &node->locus;
+ grecs_value_t *value = node->v.value;
+ char **sptr = varptr, *p;
+
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
+ return 1;
+ for (p = value->v.string; *p; p++)
+ {
+ if (!is_valid_runlevel (*p))
+ {
+ grecs_error (locus, 0, _("not a valid runlevel: %c"), *p);
+ return 1;
+ }
+ }
+ *sptr = grecs_strdup (value->v.string);
+ for (p = *sptr; *p; p++)
+ *p = toupper (*p);
+ return 0;
+}
+

Return to:

Send suggestions and report system problems to the System administrator.