aboutsummaryrefslogtreecommitdiff
path: root/src/splash.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-04-10 10:33:44 +0000
committerRoy Marples <roy@marples.name>2007-04-10 10:33:44 +0000
commit0c98067d57606c59866e9ff35f2a6aedaaedaf76 (patch)
tree6cb5a27b2e26d8c669770b3ff3b2516ff2e3db98 /src/splash.c
parentc5ddc6ef74460f72ea56350c6ff002c9630f6552 (diff)
Misc network fixes so we work on my stable server. Splash plugin removed as splashtuils-1.4 now ships with its own.
Diffstat (limited to 'src/splash.c')
-rw-r--r--src/splash.c130
1 files changed, 0 insertions, 130 deletions
diff --git a/src/splash.c b/src/splash.c
deleted file mode 100644
index dbea79a2..00000000
--- a/src/splash.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- splash.c
-
- Splash plugin for the Gentoo RC sytsem.
- splashutils needs to be re-written to support our new system.
- Until then, we provide this compatible module which calls the
- legacy bash scripts which is nasty. And slow.
-
- For any themes that use scripts, such as the live-cd theme,
- they will have to source /sbin/splash-functions.sh themselves like so
-
- if ! type splash >/dev/null 2>/dev/null ; then
- . /sbin/splash-functions.sh
- fi
-
- */
-
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <rc.h>
-
-#ifndef LIB
-# define LIB "lib"
-#endif
-
-#define SPLASH_CACHEDIR "/" LIB "/splash/cache"
-
-#define SPLASH_CMD "bash -c 'export SOFTLEVEL='%s'; export BOOTLEVEL=${RC_BOOTLEVEL}; export DEFAULTLEVEL=${RC_DEFAULTLEVEL}; export svcdir=${RC_SVCDIR}; add_suffix() { echo \"$@\"; }; . /etc/init.d/functions.sh; . /sbin/splash-functions.sh; splash %s %s %s'"
-
-int _splash_hook (rc_hook_t hook, const char *name);
-
-static int _do_splash (const char *cmd, const char *arg1, const char *arg2)
-{
- char *c;
- int l;
- char *soft = getenv ("RC_SOFTLEVEL");
-
- if (! cmd || ! soft)
- return (-1);
-
- l = strlen (SPLASH_CMD) + strlen (soft) + strlen (cmd);
- if (arg1)
- l += strlen (arg1);
- if (arg2)
- l += strlen (arg2);
- c = malloc (sizeof (char *) * l);
- if (! c)
- return (-1);
-
- snprintf (c, l, SPLASH_CMD,
- arg1 ? strcmp (arg1, RC_LEVEL_SYSINIT) == 0 ? RC_LEVEL_BOOT : soft : soft,
- cmd, arg1 ? arg1 : "", arg2 ? arg2 : "");
- l = system (c);
- free (c);
- return (l);
-}
-
-int _splash_hook (rc_hook_t hook, const char *name)
-{
- switch (hook)
- {
- case rc_hook_runlevel_stop_in:
- if (strcmp (name, RC_LEVEL_SYSINIT) != 0)
- return (_do_splash ("rc_init", name, NULL));
- break;
- case rc_hook_runlevel_start_out:
- if (strcmp (name, RC_LEVEL_SYSINIT) == 0)
- return (_do_splash ("rc_init", name, NULL));
- else
- return (_do_splash ("rc_exit", name, NULL));
- default: ;
- }
-
- /* We don't care about splash unless we're changing runlevels */
- if (! rc_runlevel_starting () &&
- ! rc_runlevel_stopping ())
- return (0);
-
- switch (hook)
- {
- case rc_hook_service_stop_in:
- /* We need to stop localmount from unmounting our cache dir.
- Luckily plugins can add to the unmount list. */
- if (name && strcmp (name, "localmount") == 0)
- {
- char *umounts = getenv ("RC_NO_UMOUNTS");
- char *new;
- int i = strlen (SPLASH_CACHEDIR) + 1;
-
- if (umounts)
- i += strlen (umounts) + 1;
-
- new = malloc (sizeof (char *) * i);
- if (new)
- {
- if (umounts)
- snprintf (new, i, "%s:%s", umounts, SPLASH_CACHEDIR);
- else
- snprintf (new, i, "%s", SPLASH_CACHEDIR);
- }
-
- /* We unsetenv first as some libc's leak memory if we overwrite
- a var with a bigger value */
- if (umounts)
- unsetenv ("RC_NO_UMOUNTS");
- setenv ("RC_NO_UMOUNTS", new, 1);
-
- free (new);
- }
- return (_do_splash ("svc_stop", name, NULL));
- case rc_hook_service_stop_out:
- if (rc_service_state (name, rc_service_stopped))
- return (_do_splash ("svc_stopped", name, "0"));
- else
- return (_do_splash ("svc_started", name, "1"));
- case rc_hook_service_start_in:
- return (_do_splash ("svc_start", name, NULL));
- case rc_hook_service_start_out:
- if (rc_service_state (name, rc_service_stopped))
- return (_do_splash ("svc_started", name, "1"));
- else
- return (_do_splash ("svc_started", name, "0"));
- default: ;
- }
-
- return (0);
-}