Process enumerated arguments for a configuration function */
| 237 | |
| 238 | /* Process enumerated arguments for a configuration function */ |
| 239 | static int json_enum_option(lua_State *l, int optindex, int *setting, |
| 240 | const char **options, int bool_true) |
| 241 | { |
| 242 | static const char *bool_options[] = { "off", "on", NULL }; |
| 243 | |
| 244 | if (!options) { |
| 245 | options = bool_options; |
| 246 | bool_true = 1; |
| 247 | } |
| 248 | |
| 249 | if (!lua_isnil(l, optindex)) { |
| 250 | if (bool_true && lua_isboolean(l, optindex)) |
| 251 | *setting = lua_toboolean(l, optindex) * bool_true; |
| 252 | else |
| 253 | *setting = luaL_checkoption(l, optindex, NULL, options); |
| 254 | } |
| 255 | |
| 256 | if (bool_true && (*setting == 0 || *setting == bool_true)) |
| 257 | lua_pushboolean(l, *setting); |
| 258 | else |
| 259 | lua_pushstring(l, options[*setting]); |
| 260 | |
| 261 | return 1; |
| 262 | } |
| 263 | |
| 264 | /* Configures handling of extremely sparse arrays: |
| 265 | * convert: Convert extremely sparse arrays into objects? Otherwise error. |
no test coverage detected