1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/*
* iwinfo - Wireless Information Library - Lua Headers
*
* Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
*
* The iwinfo library is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* The iwinfo library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the iwinfo library. If not, see http://www.gnu.org/licenses/.
*/
#ifndef __IWINFO_LUALUB_H_
#define __IWINFO_LUALIB_H_
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include "iwinfo.h"
#define IWINFO_META "iwinfo"
#define IWINFO_WL_META "iwinfo.wl"
#define IWINFO_MADWIFI_META "iwinfo.madwifi"
#define IWINFO_WEXT_META "iwinfo.wext"
#define LUA_REG(type,op) \
{ #op, iwinfo_L_##type##_##op }
#define LUA_WRAP_INT(type,op) \
static int iwinfo_L_##type##_##op(lua_State *L) \
{ \
const char *ifname = luaL_checkstring(L, 1); \
int rv; \
if( !type##_get_##op(ifname, &rv) ) \
lua_pushnumber(L, rv); \
else \
lua_pushnil(L); \
return 1; \
}
#define LUA_WRAP_STRING(type,op) \
static int iwinfo_L_##type##_##op(lua_State *L) \
{ \
const char *ifname = luaL_checkstring(L, 1); \
char rv[IWINFO_BUFSIZE]; \
memset(rv, 0, IWINFO_BUFSIZE); \
if( !type##_get_##op(ifname, rv) ) \
lua_pushstring(L, rv); \
else \
lua_pushnil(L); \
return 1; \
}
#define LUA_WRAP_ASSOCLIST(type) \
static int iwinfo_L_##type##_assoclist(lua_State *L)\
{ \
return iwinfo_L_assoclist(L, \
type##_get_assoclist); \
}
#define LUA_WRAP_TXPWRLIST(type) \
static int iwinfo_L_##type##_txpwrlist(lua_State *L)\
{ \
return iwinfo_L_txpwrlist(L, \
type##_get_txpwrlist); \
}
#endif
|