diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2010-01-07 08:14:19 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2010-01-07 08:14:19 +0000 |
commit | 225833da1fba742ef3c0316f342b6e06388041f6 (patch) | |
tree | 62cb4fef382b548e3d668d5f1e1b9dd211f91a96 /rc.c | |
parent | cefe7e4ce2ea3dceb1cf667e8397ef285a80d0c9 (diff) | |
download | lua-openrc-225833da1fba742ef3c0316f342b6e06388041f6.tar.bz2 lua-openrc-225833da1fba742ef3c0316f342b6e06388041f6.tar.xz |
implement service_extra_commands
Diffstat (limited to 'rc.c')
-rw-r--r-- | rc.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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} }; |