Process integer options for configuration functions */
| 229 | |
| 230 | /* Process integer options for configuration functions */ |
| 231 | static int json_integer_option(lua_State *l, int optindex, int *setting, |
| 232 | int min, int max) |
| 233 | { |
| 234 | char errmsg[64]; |
| 235 | int value; |
| 236 | |
| 237 | if (!lua_isnil(l, optindex)) { |
| 238 | value = luaL_checkinteger(l, optindex); |
| 239 | snprintf(errmsg, sizeof(errmsg), "expected integer between %d and %d", min, max); |
| 240 | luaL_argcheck(l, min <= value && value <= max, 1, errmsg); |
| 241 | *setting = value; |
| 242 | } |
| 243 | |
| 244 | lua_pushinteger(l, *setting); |
| 245 | |
| 246 | return 1; |
| 247 | } |
| 248 | |
| 249 | /* Process enumerated arguments for a configuration function */ |
| 250 | static int json_enum_option(lua_State *l, int optindex, int *setting, |
no test coverage detected