|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
/* (find-es "lua" "pio_fontx")
* (find-angg "LUA/vtutil.lua")
* (find-man "2 ioctl" "On success, zero is returned")
* (find-node "(libc)Error Messages" "char * strerror (int ERRNUM)")
* (find-man "4 console_ioctl" " PIO_FONTX")
* (find-luafile "include/lua.h" "push functions (C -> stack)")
cd ~/LUA; gcc -g -Wall -shared -o pio_fontx.so pio_fontx.c
*/
#include <dllua.h>
#include <sys/ioctl.h>
#include <linux/kd.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
/* #include <fcntl.h> */
/* #include <stdio.h> */
static int lua_pio_fontx(lua_State* L) {
struct consolefontdesc cfd;
int len;
cfd.chardata = (char *) luaL_check_lstr(L, 1, &len);
cfd.charcount = luaL_check_int(L, 2);
cfd.charheight = luaL_check_int(L, 3);
if(ioctl(STDIN_FILENO, PIO_FONTX, &cfd)) {
lua_pushstring(L, strerror(errno));
return 1;
}
return 0;
}
void pio_fontx_init(lua_State *L) {
lua_register(L, "pio_fontx", lua_pio_fontx);
}