Comparison

util-src/pposix.c @ 796:63f56696c66c

util.pposix: Fix incompatible pointer type compiler warnings
author Matthew Wild <mwild1@gmail.com>
date Fri, 13 Feb 2009 15:01:46 +0000
parent 766:433a5226267f
child 804:9bc1544c99b7
comparison
equal deleted inserted replaced
795:e27a48e35bbb 796:63f56696c66c
83 return 2; 83 return 2;
84 } 84 }
85 85
86 /* Syslog support */ 86 /* Syslog support */
87 87
88 char *facility_strings[] = { "auth", 88 const char * const facility_strings[] = {
89 "auth",
89 "authpriv", 90 "authpriv",
90 "cron", 91 "cron",
91 "daemon", 92 "daemon",
92 "ftp", 93 "ftp",
93 "kern", 94 "kern",
140 */ 141 */
141 char* syslog_ident = NULL; 142 char* syslog_ident = NULL;
142 143
143 int lc_syslog_open(lua_State* L) 144 int lc_syslog_open(lua_State* L)
144 { 145 {
145 int facility = luaL_checkoption(L, 2, "daemon", &facility_strings); 146 int facility = luaL_checkoption(L, 2, "daemon", facility_strings);
146 facility = facility_constants[facility]; 147 facility = facility_constants[facility];
147 148
148 luaL_checkstring(L, 1); 149 luaL_checkstring(L, 1);
149 150
150 if(syslog_ident) 151 if(syslog_ident)
154 155
155 openlog(syslog_ident, LOG_PID, facility); 156 openlog(syslog_ident, LOG_PID, facility);
156 return 0; 157 return 0;
157 } 158 }
158 159
159 char *level_strings[] = { 160 const char * const level_strings[] = {
160 "debug", 161 "debug",
161 "info", 162 "info",
162 "notice", 163 "notice",
163 "warn", 164 "warn",
164 "error", 165 "error",
172 LOG_EMERG, 173 LOG_EMERG,
173 -1 174 -1
174 }; 175 };
175 int lc_syslog_log(lua_State* L) 176 int lc_syslog_log(lua_State* L)
176 { 177 {
177 int level = luaL_checkoption(L, 1, "notice", &level_strings); 178 int level = luaL_checkoption(L, 1, "notice", level_strings);
178 level = level_constants[level]; 179 level = level_constants[level];
179 180
180 luaL_checkstring(L, 2); 181 luaL_checkstring(L, 2);
181 182
182 syslog(level, "%s", lua_tostring(L, 2)); 183 syslog(level, "%s", lua_tostring(L, 2));
194 return 0; 195 return 0;
195 } 196 }
196 197
197 int lc_syslog_setmask(lua_State* L) 198 int lc_syslog_setmask(lua_State* L)
198 { 199 {
199 int level_idx = luaL_checkoption(L, 1, "notice", &level_strings); 200 int level_idx = luaL_checkoption(L, 1, "notice", level_strings);
200 int mask = 0; 201 int mask = 0;
201 do 202 do
202 { 203 {
203 mask |= LOG_MASK(level_constants[level_idx]); 204 mask |= LOG_MASK(level_constants[level_idx]);
204 } while (++level_idx<=4); 205 } while (++level_idx<=4);