Comparison

util-src/windows.c @ 7889:b8d694646597

util-src/*.c: Attach pointer * to name instead of type
author Kim Alvefur <zash@zash.se>
date Sun, 12 Feb 2017 16:42:29 +0100
parent 7818:54669df178c2
child 10921:6eb5d2bb11af
comparison
equal deleted inserted replaced
7888:74187ee6ed55 7889:b8d694646597
21 21
22 #if (LUA_VERSION_NUM == 501) 22 #if (LUA_VERSION_NUM == 501)
23 #define luaL_setfuncs(L, R, N) luaL_register(L, NULL, R) 23 #define luaL_setfuncs(L, R, N) luaL_register(L, NULL, R)
24 #endif 24 #endif
25 25
26 static int Lget_nameservers(lua_State* L) { 26 static int Lget_nameservers(lua_State *L) {
27 char stack_buffer[1024]; // stack allocated buffer 27 char stack_buffer[1024]; // stack allocated buffer
28 IP4_ARRAY* ips = (IP4_ARRAY*) stack_buffer; 28 IP4_ARRAY *ips = (IP4_ARRAY *) stack_buffer;
29 DWORD len = sizeof(stack_buffer); 29 DWORD len = sizeof(stack_buffer);
30 DNS_STATUS status; 30 DNS_STATUS status;
31 31
32 status = DnsQueryConfig(DnsConfigDnsServerList, FALSE, NULL, NULL, ips, &len); 32 status = DnsQueryConfig(DnsConfigDnsServerList, FALSE, NULL, NULL, ips, &len);
33 33
49 lua_pushfstring(L, "DnsQueryConfig returned %d", status); 49 lua_pushfstring(L, "DnsQueryConfig returned %d", status);
50 return 2; 50 return 2;
51 } 51 }
52 } 52 }
53 53
54 static int lerror(lua_State* L, char* string) { 54 static int lerror(lua_State *L, char *string) {
55 lua_pushnil(L); 55 lua_pushnil(L);
56 lua_pushfstring(L, "%s: %d", string, GetLastError()); 56 lua_pushfstring(L, "%s: %d", string, GetLastError());
57 return 2; 57 return 2;
58 } 58 }
59 59
60 static int Lget_consolecolor(lua_State* L) { 60 static int Lget_consolecolor(lua_State *L) {
61 HWND console = GetStdHandle(STD_OUTPUT_HANDLE); 61 HWND console = GetStdHandle(STD_OUTPUT_HANDLE);
62 WORD color; 62 WORD color;
63 DWORD read_len; 63 DWORD read_len;
64 64
65 CONSOLE_SCREEN_BUFFER_INFO info; 65 CONSOLE_SCREEN_BUFFER_INFO info;
77 } 77 }
78 78
79 lua_pushnumber(L, color); 79 lua_pushnumber(L, color);
80 return 1; 80 return 1;
81 } 81 }
82 static int Lset_consolecolor(lua_State* L) { 82 static int Lset_consolecolor(lua_State *L) {
83 int color = luaL_checkint(L, 1); 83 int color = luaL_checkint(L, 1);
84 HWND console = GetStdHandle(STD_OUTPUT_HANDLE); 84 HWND console = GetStdHandle(STD_OUTPUT_HANDLE);
85 85
86 if(console == INVALID_HANDLE_VALUE) { 86 if(console == INVALID_HANDLE_VALUE) {
87 return lerror(L, "GetStdHandle"); 87 return lerror(L, "GetStdHandle");
100 { "get_consolecolor", Lget_consolecolor }, 100 { "get_consolecolor", Lget_consolecolor },
101 { "set_consolecolor", Lset_consolecolor }, 101 { "set_consolecolor", Lset_consolecolor },
102 { NULL, NULL } 102 { NULL, NULL }
103 }; 103 };
104 104
105 LUALIB_API int luaopen_util_windows(lua_State* L) { 105 LUALIB_API int luaopen_util_windows(lua_State *L) {
106 #if (LUA_VERSION_NUM > 501) 106 #if (LUA_VERSION_NUM > 501)
107 luaL_checkversion(L); 107 luaL_checkversion(L);
108 #endif 108 #endif
109 lua_newtable(L); 109 lua_newtable(L);
110 luaL_setfuncs(L, Reg, 0); 110 luaL_setfuncs(L, Reg, 0);