From 225833da1fba742ef3c0316f342b6e06388041f6 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 7 Jan 2010 08:14:19 +0000 Subject: implement service_extra_commands --- rc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'rc.c') diff --git a/rc.c b/rc.c index 3660d5f..18e257f 100644 --- a/rc.c +++ b/rc.c @@ -95,6 +95,26 @@ static int Pservice_resolve(lua_State *L) return 1; } +/** service_extra_commands(service) - Lists the extra commands a service has. */ +static int Pservice_extra_commands(lua_State *L) +{ + int i = 1; + RC_STRING *item; + const char *service = luaL_checkstring(L, 1); + RC_STRINGLIST *list = rc_service_extra_commands(service); + lua_newtable(L); + TAILQ_FOREACH(item, list, entries) { + if (item->value == NULL || item->value[0] == '\0') + continue; + lua_pushnumber(L, i++); + lua_pushstring(L, item->value); + lua_settable(L, -3); + } + rc_stringlist_free(list); + return 1; +} + + static const luaL_reg R[] = { {"runlevel_get", Prunlevel_get}, @@ -107,6 +127,7 @@ static const luaL_reg R[] = {"service_exists", Pservice_exists}, {"service_in_runlevel", Pservice_in_runlevel}, {"service_resolve", Pservice_resolve}, + {"service_extra_commands", Pservice_extra_commands}, {NULL, NULL} }; -- cgit v1.2.3