Fix language selection broken after po file merges
[project/luci.git] / libs / luanet / src / main.c
1 /*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 *
14 * Copyright (C) 2008 John Crispin <blogic@openwrt.org>
15 * Copyright (C) 2008 Steven Barth <steven@midlink.org>
16 * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
17 */
18
19 #include <stdio.h>
20 #include <unistd.h>
21
22 #include <lua.h>
23 #include <lualib.h>
24 #include <lauxlib.h>
25
26 #include "route.h"
27 #include "bridge.h"
28 #include "ifconfig.h"
29 #include "iwconfig.h"
30 #include "vconfig.h"
31 #include "df.h"
32 #include "base64.h"
33
34 int psleep(lua_State *L)
35 {
36 int s;
37 if(lua_gettop(L) != 1)
38 {
39 lua_pushstring(L, "invalid arg list");
40 lua_error(L);
41 return 0;
42 }
43
44 s = (int)lua_tointeger (L, 1);
45 sleep(s);
46 return 0;
47 }
48
49 static luaL_reg func[] = {
50 {"ifc_getall", ifc_getall},
51 {"ifc_setip", ifc_setip},
52 {"ifc_setnetmask", ifc_setnetmask},
53 {"ifc_setbroadcast", ifc_setbroadcast},
54 {"ifc_setmtu", ifc_setmtu},
55 {"ifc_up", ifc_up},
56 {"ifc_down", ifc_down},
57 {"bridge_getall", bridge_getall},
58 {"bridge_new", bridge_new},
59 {"bridge_del", bridge_del},
60 {"bridge_addif", bridge_addif},
61 {"bridge_delif", bridge_delif},
62 {"iwc_getall", iwc_getall},
63 {"iwc_set_essid", iwc_set_essid},
64 {"iwc_set_mode", iwc_set_mode},
65 {"iwc_set_channel", iwc_set_channel},
66 {"iwc_scan", iwc_scan},
67 {"iwc_frequencies", iwc_frequencies},
68 {"vlan_getall", vlan_getall},
69 {"vlan_add", vlan_add},
70 {"vlan_del", vlan_del},
71 {"df", df},
72 {"b64_encode", b64_encode},
73 {"b64_decode", b64_decode},
74 {"sleep", psleep},
75 {NULL, NULL}
76 };
77
78 int luaopen_luanet(lua_State *L)
79 {
80 ifc_startup();
81 bridge_startup();
82 iwc_startup();
83 luaL_openlib(L, "luanet", func, 0);
84 lua_pushstring(L, "_VERSION");
85 lua_pushstring(L, "1.0");
86 lua_rawset(L, -3);
87 return 1;
88 }
89
90 int luaclose_luanet(lua_State *L)
91 {
92 ifc_shutdown();
93 bridge_shutdown();
94 iwc_shutdown();
95 lua_pushstring(L, "Called");
96 return 1;
97 }