Process integer options for configuration functions */
| 218 | |
| 219 | /* Process integer options for configuration functions */ |
| 220 | static int json_integer_option(lua_State *l, int optindex, int *setting, |
| 221 | int min, int max) |
| 222 | { |
| 223 | char errmsg[64]; |
| 224 | int value; |
| 225 | |
| 226 | if (!lua_isnil(l, optindex)) { |
| 227 | value = luaL_checkinteger(l, optindex); |
| 228 | snprintf(errmsg, sizeof(errmsg), "expected integer between %d and %d", min, max); |
| 229 | luaL_argcheck(l, min <= value && value <= max, 1, errmsg); |
| 230 | *setting = value; |
| 231 | } |
| 232 | |
| 233 | lua_pushinteger(l, *setting); |
| 234 | |
| 235 | return 1; |
| 236 | } |
| 237 | |
| 238 | /* Process enumerated arguments for a configuration function */ |
| 239 | static int json_enum_option(lua_State *l, int optindex, int *setting, |
no test coverage detected