/* This function creates and push in the stack a fetch object according
* with a current TXN.
*/
-static int hlua_fetches_new(lua_State *L, struct hlua_txn *txn, int stringsafe)
+static int hlua_fetches_new(lua_State *L, struct hlua_txn *txn, unsigned int flags)
{
struct hlua_smp *hsmp;
hsmp->s = txn->s;
hsmp->p = txn->p;
hsmp->dir = txn->dir;
- hsmp->stringsafe = stringsafe;
+ hsmp->flags = flags;
/* Pop a class sesison metatable and affect it to the userdata. */
lua_rawgeti(L, LUA_REGISTRYINDEX, class_fetches_ref);
smp.strm = hsmp->s;
smp.opt = hsmp->dir & SMP_OPT_DIR;
if (!f->process(args, &smp, f->kw, f->private)) {
- if (hsmp->stringsafe)
+ if (hsmp->flags & HLUA_F_AS_STRING)
lua_pushstring(L, "");
else
lua_pushnil(L);
}
/* Convert the returned sample in lua value. */
- if (hsmp->stringsafe)
+ if (hsmp->flags & HLUA_F_AS_STRING)
hlua_smp2lua_str(L, &smp);
else
hlua_smp2lua(L, &smp);
/* This function creates and push in the stack a Converters object
* according with a current TXN.
*/
-static int hlua_converters_new(lua_State *L, struct hlua_txn *txn, int stringsafe)
+static int hlua_converters_new(lua_State *L, struct hlua_txn *txn, unsigned int flags)
{
struct hlua_smp *hsmp;
hsmp->s = txn->s;
hsmp->p = txn->p;
hsmp->dir = txn->dir;
- hsmp->stringsafe = stringsafe;
+ hsmp->flags = flags;
/* Pop a class stream metatable and affect it to the table. */
lua_rawgeti(L, LUA_REGISTRYINDEX, class_converters_ref);
smp.strm = hsmp->s;
smp.opt = hsmp->dir & SMP_OPT_DIR;
if (!conv->process(args, &smp, conv->private)) {
- if (hsmp->stringsafe)
+ if (hsmp->flags & HLUA_F_AS_STRING)
lua_pushstring(L, "");
else
lua_pushnil(L);
}
/* Convert the returned sample in lua value. */
- if (hsmp->stringsafe)
+ if (hsmp->flags & HLUA_F_AS_STRING)
hlua_smp2lua_str(L, &smp);
else
hlua_smp2lua(L, &smp);
/* Create the "sf" field that contains a list of stringsafe fetches. */
lua_pushstring(L, "sf");
- if (!hlua_fetches_new(L, &appctx->htxn, 1))
+ if (!hlua_fetches_new(L, &appctx->htxn, HLUA_F_AS_STRING))
return 0;
lua_settable(L, -3);
/* Create the "sc" field that contains a list of stringsafe converters. */
lua_pushstring(L, "sc");
- if (!hlua_converters_new(L, &appctx->htxn, 1))
+ if (!hlua_converters_new(L, &appctx->htxn, HLUA_F_AS_STRING))
return 0;
lua_settable(L, -3);
/* Create the "sf" field that contains a list of stringsafe fetches. */
lua_pushstring(L, "sf");
- if (!hlua_fetches_new(L, &appctx->htxn, 1))
+ if (!hlua_fetches_new(L, &appctx->htxn, HLUA_F_AS_STRING))
return 0;
lua_settable(L, -3);
/* Create the "sc" field that contains a list of stringsafe converters. */
lua_pushstring(L, "sc");
- if (!hlua_converters_new(L, &appctx->htxn, 1))
+ if (!hlua_converters_new(L, &appctx->htxn, HLUA_F_AS_STRING))
return 0;
lua_settable(L, -3);
/* Create the "sf" field that contains a list of stringsafe fetches. */
lua_pushstring(L, "sf");
- if (!hlua_fetches_new(L, htxn, 1))
+ if (!hlua_fetches_new(L, htxn, HLUA_F_AS_STRING))
return 0;
lua_rawset(L, -3);
/* Create the "sc" field that contains a list of stringsafe converters. */
lua_pushstring(L, "sc");
- if (!hlua_converters_new(L, htxn, 1))
+ if (!hlua_converters_new(L, htxn, HLUA_F_AS_STRING))
return 0;
lua_rawset(L, -3);