4 #define ldmilib_c /* Define the library */
6 /* Include the Lua API header files */
12 static int dmi_gettable(lua_State
*L
)
18 if ( ! dmi_iterate(&dmi
) ) {
19 printf("No DMI Structure found\n");
26 lua_pushstring(L
, "bios.vendor");
27 lua_pushstring(L
, dmi
.bios
.vendor
);
30 lua_pushstring(L
, "bios.version");
31 lua_pushstring(L
, dmi
.bios
.version
);
34 lua_pushstring(L
, "bios.release_date");
35 lua_pushstring(L
, dmi
.bios
.release_date
);
38 lua_pushstring(L
, "bios.bios_revision");
39 lua_pushstring(L
, dmi
.bios
.bios_revision
);
42 lua_pushstring(L
, "bios.firmware_revision");
43 lua_pushstring(L
, dmi
.bios
.firmware_revision
);
46 lua_pushstring(L
, "bios.address");
47 lua_pushnumber(L
, dmi
.bios
.address
);
50 lua_pushstring(L
, "bios.runtime_size");
51 lua_pushnumber(L
, dmi
.bios
.runtime_size
);
54 lua_pushstring(L
, "bios.runtime_size_unit");
55 lua_pushstring(L
, dmi
.bios
.runtime_size_unit
);
58 lua_pushstring(L
, "bios.rom_size");
59 lua_pushnumber(L
, dmi
.bios
.rom_size
);
62 lua_pushstring(L
, "bios.rom_size_unit");
63 lua_pushstring(L
, dmi
.bios
.rom_size_unit
);
67 lua_pushstring(L
, "system.manufacturer");
68 lua_pushstring(L
, dmi
.system
.manufacturer
);
71 lua_pushstring(L
, "system.product_name");
72 lua_pushstring(L
, dmi
.system
.product_name
);
75 lua_pushstring(L
, "system.version");
76 lua_pushstring(L
, dmi
.system
.version
);
79 lua_pushstring(L
, "system.serial");
80 lua_pushstring(L
, dmi
.system
.serial
);
83 lua_pushstring(L
, "system.uuid");
84 lua_pushstring(L
, dmi
.system
.uuid
);
87 lua_pushstring(L
, "system.wakeup_type");
88 lua_pushstring(L
, dmi
.system
.wakeup_type
);
91 lua_pushstring(L
, "system.sku_number");
92 lua_pushstring(L
, dmi
.system
.sku_number
);
95 lua_pushstring(L
, "system.family");
96 lua_pushstring(L
, dmi
.system
.family
);
100 lua_pushstring(L
, "base_board.manufacturer");
101 lua_pushstring(L
, dmi
.base_board
.manufacturer
);
104 lua_pushstring(L
, "base_board.product_name");
105 lua_pushstring(L
, dmi
.base_board
.product_name
);
108 lua_pushstring(L
, "base_board.version");
109 lua_pushstring(L
, dmi
.base_board
.version
);
112 lua_pushstring(L
, "base_board.serial");
113 lua_pushstring(L
, dmi
.base_board
.serial
);
116 lua_pushstring(L
, "base_board.asset_tag");
117 lua_pushstring(L
, dmi
.base_board
.asset_tag
);
120 lua_pushstring(L
, "base_board.location");
121 lua_pushstring(L
, dmi
.base_board
.location
);
124 lua_pushstring(L
, "base_board.type");
125 lua_pushstring(L
, dmi
.base_board
.type
);
129 lua_pushstring(L
, "chassis.manufacturer");
130 lua_pushstring(L
, dmi
.chassis
.manufacturer
);
133 lua_pushstring(L
, "chassis.type");
134 lua_pushstring(L
, dmi
.chassis
.type
);
137 lua_pushstring(L
, "chassis.lock");
138 lua_pushstring(L
, dmi
.chassis
.lock
);
141 lua_pushstring(L
, "chassis.version");
142 lua_pushstring(L
, dmi
.chassis
.version
);
145 lua_pushstring(L
, "chassis.serial");
146 lua_pushstring(L
, dmi
.chassis
.serial
);
149 lua_pushstring(L
, "chassis.asset_tag");
150 lua_pushstring(L
, dmi
.chassis
.asset_tag
);
153 lua_pushstring(L
, "chassis.boot_up_state");
154 lua_pushstring(L
, dmi
.chassis
.boot_up_state
);
157 lua_pushstring(L
, "chassis.power_supply_state");
158 lua_pushstring(L
, dmi
.chassis
.power_supply_state
);
161 lua_pushstring(L
, "chassis.thermal_state");
162 lua_pushstring(L
, dmi
.chassis
.thermal_state
);
165 lua_pushstring(L
, "chassis.security_status");
166 lua_pushstring(L
, dmi
.chassis
.security_status
);
169 lua_pushstring(L
, "chassis.oem_information");
170 lua_pushstring(L
, dmi
.chassis
.oem_information
);
173 lua_pushstring(L
, "chassis.height");
174 lua_pushnumber(L
, dmi
.chassis
.height
);
177 lua_pushstring(L
, "chassis.nb_power_cords");
178 lua_pushnumber(L
, dmi
.chassis
.nb_power_cords
);
182 lua_pushstring(L
, "processor.socket_designation");
183 lua_pushstring(L
, dmi
.processor
.socket_designation
);
186 lua_pushstring(L
, "processor.type");
187 lua_pushstring(L
, dmi
.processor
.type
);
190 lua_pushstring(L
, "processor.family");
191 lua_pushstring(L
, dmi
.processor
.family
);
194 lua_pushstring(L
, "processor.manufacturer");
195 lua_pushstring(L
, dmi
.processor
.manufacturer
);
198 lua_pushstring(L
, "processor.version");
199 lua_pushstring(L
, dmi
.processor
.version
);
202 lua_pushstring(L
, "processor.external_clock");
203 lua_pushnumber(L
, dmi
.processor
.external_clock
);
206 lua_pushstring(L
, "processor.max_speed");
207 lua_pushnumber(L
, dmi
.processor
.max_speed
);
210 lua_pushstring(L
, "processor.current_speed");
211 lua_pushnumber(L
, dmi
.processor
.current_speed
);
214 lua_pushstring(L
, "processor.signature.type");
215 lua_pushnumber(L
, dmi
.processor
.signature
.type
);
218 lua_pushstring(L
, "processor.signature.family");
219 lua_pushnumber(L
, dmi
.processor
.signature
.family
);
222 lua_pushstring(L
, "processor.signature.model");
223 lua_pushnumber(L
, dmi
.processor
.signature
.model
);
226 lua_pushstring(L
, "processor.signature.stepping");
227 lua_pushnumber(L
, dmi
.processor
.signature
.stepping
);
230 lua_pushstring(L
, "processor.signature.minor_stepping");
231 lua_pushnumber(L
, dmi
.processor
.signature
.minor_stepping
);
234 lua_pushstring(L
, "processor.voltage_mv");
235 lua_pushnumber(L
, dmi
.processor
.voltage_mv
);
238 lua_pushstring(L
, "processor.status");
239 lua_pushstring(L
, dmi
.processor
.status
);
242 lua_pushstring(L
, "processor.upgrade");
243 lua_pushstring(L
, dmi
.processor
.upgrade
);
246 lua_pushstring(L
, "processor.cache1");
247 lua_pushstring(L
, dmi
.processor
.cache1
);
250 lua_pushstring(L
, "processor.cache2");
251 lua_pushstring(L
, dmi
.processor
.cache2
);
254 lua_pushstring(L
, "processor.cache3");
255 lua_pushstring(L
, dmi
.processor
.cache3
);
258 lua_pushstring(L
, "processor.serial");
259 lua_pushstring(L
, dmi
.processor
.serial
);
262 lua_pushstring(L
, "processor.part_number");
263 lua_pushstring(L
, dmi
.processor
.part_number
);
266 lua_pushstring(L
, "processor.id");
267 lua_pushstring(L
, dmi
.processor
.id
);
270 lua_pushstring(L
, "processor.core_count");
271 lua_pushnumber(L
, dmi
.processor
.core_count
);
274 lua_pushstring(L
, "processor.core_enabled");
275 lua_pushnumber(L
, dmi
.processor
.core_enabled
);
278 lua_pushstring(L
, "processor.thread_count");
279 lua_pushnumber(L
, dmi
.processor
.thread_count
);
282 /* set global variable: lua_setglobal(L, "dmitable"); */
284 /* return number of return values on stack */
289 static int dmi_supported(lua_State
*L
)
293 if ( dmi_iterate(&dmi
) ) {
294 lua_pushboolean(L
, 1);
296 lua_pushboolean(L
, 0);
302 static const luaL_Reg dmilib
[] = {
303 {"gettable", dmi_gettable
},
304 {"supported", dmi_supported
},
309 LUALIB_API
int luaopen_dmi (lua_State
*L
) {
310 luaL_openlib(L
, LUA_DMILIBNAME
, dmilib
, 0);