/*
 * Lua safe functions
 *
 * Copyright 2015-2016 Thierry Fournier <tfournier@arpalert.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 *
 *
 * All the functions in this file runs with a Lua stack, and can
 * return with a longjmp. All of these function must be launched
 * in an environment able to catch a longjmp, otherwise a
 * critical error can be raised.
 */

#define _GNU_SOURCE

#include <lauxlib.h>
#include <lua.h>
#include <lualib.h>

#include <import/ebmbtree.h>

#include <haproxy/cli-t.h>
#include <haproxy/errors.h>
#include <haproxy/hlua.h>
#include <haproxy/hlua_fcn.h>
#include <haproxy/http.h>
#include <haproxy/net_helper.h>
#include <haproxy/pattern-t.h>
#include <haproxy/proxy.h>
#include <haproxy/regex.h>
#include <haproxy/server.h>
#include <haproxy/stats.h>
#include <haproxy/stick_table.h>
#include <haproxy/event_hdl.h>
#include <haproxy/stream-t.h>
#include <haproxy/time.h>
#include <haproxy/tools.h>
#include <haproxy/mailers.h>

/* Contains the class reference of the concat object. */
static int class_concat_ref;
static int class_queue_ref;
static int class_proxy_ref;
static int class_server_ref;
static int class_listener_ref;
static int class_event_sub_ref;
static int class_regex_ref;
static int class_stktable_ref;
static int class_proxy_list_ref;
static int class_server_list_ref;

#define STATS_LEN (MAX((int)ST_F_TOTAL_FIELDS, (int)INF_TOTAL_FIELDS))

static THREAD_LOCAL struct field stats[STATS_LEN];

int hlua_checkboolean(lua_State *L, int index)
{
	if (!lua_isboolean(L, index))
		luaL_argerror(L, index, "boolean expected");
	return lua_toboolean(L, index);
}

/* Helper to push unsigned integers to Lua stack, respecting Lua limitations  */
static int hlua_fcn_pushunsigned(lua_State *L, unsigned int val)
{
#if (LUA_MAXINTEGER == LLONG_MAX || ((LUA_MAXINTEGER == LONG_MAX) && (__WORDSIZE == 64)))
	lua_pushinteger(L, val);
#else
	if (val > INT_MAX)
		lua_pushnumber(L, (lua_Number)val);
	else
		lua_pushinteger(L, (int)val);
#endif
	return 1;
}

/* Helper to push unsigned long long to Lua stack, respecting Lua limitations  */
static int hlua_fcn_pushunsigned_ll(lua_State *L, unsigned long long val) {
#if (LUA_MAXINTEGER == LLONG_MAX || ((LUA_MAXINTEGER == LONG_MAX) && (__WORDSIZE == 64)))
	/* 64 bits case, U64 is supported until LLONG_MAX */
	if (val > LLONG_MAX)
		lua_pushnumber(L, (lua_Number)val);
	else
		lua_pushinteger(L, val);
#else
	/* 32 bits case, U64 is supported until INT_MAX */
	if (val > INT_MAX)
		lua_pushnumber(L, (lua_Number)val);
	else
		lua_pushinteger(L, (int)val);
#endif
	return 1;
}

/* This function gets a struct field and converts it in Lua
 * variable. The variable is pushed at the top of the stack.
 */
int hlua_fcn_pushfield(lua_State *L, struct field *field)
{
	/* The lua_Integer is always signed. Its length depends on
	 * compilation options, so the following code is conditioned
	 * by some macros. Windows maros are not supported.
	 * If the number cannot be represented as integer, we try to
	 * convert to float.
	 */
	switch (field_format(field, 0)) {

	case FF_EMPTY:
		lua_pushnil(L);
		return 1;

	case FF_S32:
		/* S32 is always supported. */
		lua_pushinteger(L, field->u.s32);
		return 1;

	case FF_U32:
#if (LUA_MAXINTEGER == LLONG_MAX || ((LUA_MAXINTEGER == LONG_MAX) && (__WORDSIZE == 64)))
		/* 64 bits case, U32 is always supported */
		lua_pushinteger(L, field->u.u32);
#else
		/* 32 bits case, U32 is supported until INT_MAX. */
		if (field->u.u32 > INT_MAX)
			lua_pushnumber(L, (lua_Number)field->u.u32);
		else
			lua_pushinteger(L, field->u.u32);
#endif
		return 1;

	case FF_S64:
#if (LUA_MAXINTEGER == LLONG_MAX || ((LUA_MAXINTEGER == LONG_MAX) && (__WORDSIZE == 64)))
		/* 64 bits case, S64 is always supported */
		lua_pushinteger(L, field->u.s64);
#else
		/* 64 bits case, S64 is supported between INT_MIN and INT_MAX */
		if (field->u.s64 < INT_MIN || field->u.s64 > INT_MAX)
			lua_pushnumber(L, (lua_Number)field->u.s64);
		else
			lua_pushinteger(L, (int)field->u.s64);
#endif
		return 1;

	case FF_U64:
#if (LUA_MAXINTEGER == LLONG_MAX || ((LUA_MAXINTEGER == LONG_MAX) && (__WORDSIZE == 64)))
		/* 64 bits case, U64 is supported until LLONG_MAX */
		if (field->u.u64 > LLONG_MAX)
			lua_pushnumber(L, (lua_Number)field->u.u64);
		else
			lua_pushinteger(L, field->u.u64);
#else
		/* 64 bits case, U64 is supported until INT_MAX */
		if (field->u.u64 > INT_MAX)
			lua_pushnumber(L, (lua_Number)field->u.u64);
		else
			lua_pushinteger(L, (int)field->u.u64);
#endif
		return 1;

	case FF_STR:
		lua_pushstring(L, field->u.str);
		return 1;

	default:
		break;
	}

	/* Default case, never reached. */
	lua_pushnil(L);
	return 1;
}

/* Some string are started or terminated by blank chars,
 * this function removes the spaces, tabs, \r and
 * \n at the begin and at the end of the string "str", and
 * push the result in the lua stack.
 * Returns a pointer to the Lua internal copy of the string.
 */
const char *hlua_pushstrippedstring(lua_State *L, const char *str)
{
	const char *p;
	int l;

	for (p = str; HTTP_IS_LWS(*p); p++);

	for (l = strlen(p); l && HTTP_IS_LWS(p[l-1]); l--);

	return lua_pushlstring(L, p, l);
}

/* The three following functions are useful for adding entries
 * in a table. These functions takes a string and respectively an
 * integer, a string or a function and add it to the table in the
 * top of the stack.
 *
 * These functions throws an error if no more stack size is
 * available.
 */
void hlua_class_const_int(lua_State *L, const char *name, int value)
{
	lua_pushstring(L, name);
	lua_pushinteger(L, value);
	lua_rawset(L, -3);
}
void hlua_class_const_str(lua_State *L, const char *name, const char *value)
{
	lua_pushstring(L, name);
	lua_pushstring(L, value);
	lua_rawset(L, -3);
}
void hlua_class_function(lua_State *L, const char *name, int (*function)(lua_State *L))
{
	lua_pushstring(L, name);
	lua_pushcclosure(L, function, 0);
	lua_rawset(L, -3);
}

/* This function returns a string containing the HAProxy object name. */
int hlua_dump_object(struct lua_State *L)
{
	const char *name = (const char *)lua_tostring(L, lua_upvalueindex(1));
	lua_pushfstring(L, "HAProxy class %s", name);
	return 1;
}

/* This function register a table as metatable and. It names
 * the metatable, and returns the associated reference.
 * The original table is popped from the top of the stack.
 * "name" is the referenced class name.
 */
int hlua_register_metatable(struct lua_State *L, char *name)
{
	/* Check the type of the top element. it must be
	 * a table.
	 */
	if (lua_type(L, -1) != LUA_TTABLE)
		luaL_error(L, "hlua_register_metatable() requires a type Table "
		              "in the top of the stack");

	/* Add the __tostring function which identify the
	 * created object.
	 */
	lua_pushstring(L, "__tostring");
	lua_pushstring(L, name);
	lua_pushcclosure(L, hlua_dump_object, 1);
	lua_rawset(L, -3);

	/* Register a named entry for the table. The table
	 * reference is copied first because the function
	 * lua_setfield() pop the entry.
	 */
	lua_pushvalue(L, -1);
	lua_setfield(L, LUA_REGISTRYINDEX, name);

	/* Creates the reference of the object. The
	 * function luaL_ref pop the top of the stack.
	 */
	return luaL_ref(L, LUA_REGISTRYINDEX);
}

/* Return an object of the expected type, or throws an error. */
void *hlua_checkudata(lua_State *L, int ud, int class_ref)
{
	void *p;
	int ret;

	/* Check if the stack entry is an array. */
	if (!lua_istable(L, ud))
		luaL_argerror(L, ud, NULL);

	/* pop the metatable of the referencecd object. */
	if (!lua_getmetatable(L, ud))
		luaL_argerror(L, ud, NULL);

	/* pop the expected metatable. */
	lua_rawgeti(L, LUA_REGISTRYINDEX, class_ref);

	/* Check if the metadata have the expected type. */
	ret = lua_rawequal(L, -1, -2);
	lua_pop(L, 2);
	if (!ret)
		luaL_argerror(L, ud, NULL);

	/* Push on the stack at the entry [0] of the table. */
	lua_rawgeti(L, ud, 0);

	/* Check if this entry is userdata. */
	p = lua_touserdata(L, -1);
	if (!p)
		luaL_argerror(L, ud, NULL);

	/* Remove the entry returned by lua_rawgeti(). */
	lua_pop(L, 1);

	/* Return the associated struct. */
	return p;
}

/* This function return the current date at epoch format in milliseconds. */
int hlua_now(lua_State *L)
{
	/* WT: the doc says "returns the current time" and later says that it's
	 * monotonic. So the best fit is to use start_date+(now-start_time).
	 */
	struct timeval tv;

	tv = NS_TO_TV(now_ns - start_time_ns);
	tv_add(&tv, &tv, &start_date);

	lua_newtable(L);
	lua_pushstring(L, "sec");
	lua_pushinteger(L, tv.tv_sec);
	lua_rawset(L, -3);
	lua_pushstring(L, "usec");
	lua_pushinteger(L, tv.tv_usec);
	lua_rawset(L, -3);
	return 1;
}

/* This functions expects a Lua string as HTTP date, parse it and
 * returns an integer containing the epoch format of the date, or
 * nil if the parsing fails.
 */
static int hlua_parse_date(lua_State *L, int (*fcn)(const char *, int, struct tm*))
{
	const char *str;
	size_t len;
	struct tm tm;
	time_t time;

	str = luaL_checklstring(L, 1, &len);

	if (!fcn(str, len, &tm)) {
		lua_pushnil(L);
		return 1;
	}

	/* This function considers the content of the broken-down time
	 * is exprimed in the UTC timezone. timegm don't care about
	 * the gnu variable tm_gmtoff. If gmtoff is set, or if you know
	 * the timezone from the broken-down time, it must be fixed
	 * after the conversion.
	 */
	time = my_timegm(&tm);
	if (time == -1) {
		lua_pushnil(L);
		return 1;
	}

	lua_pushinteger(L, (int)time);
	return 1;
}
static int hlua_http_date(lua_State *L)
{
	return hlua_parse_date(L, parse_http_date);
}
static int hlua_imf_date(lua_State *L)
{
	return hlua_parse_date(L, parse_imf_date);
}
static int hlua_rfc850_date(lua_State *L)
{
	return hlua_parse_date(L, parse_rfc850_date);
}
static int hlua_asctime_date(lua_State *L)
{
	return hlua_parse_date(L, parse_asctime_date);
}

static int hlua_get_info(lua_State *L)
{
	int i;

	stats_fill_info(stats, STATS_LEN, 0);

	lua_newtable(L);
	for (i=0; i<INF_TOTAL_FIELDS; i++) {
		lua_pushstring(L, info_fields[i].name);
		hlua_fcn_pushfield(L, &stats[i]);
		lua_settable(L, -3);
	}
	return 1;
}

static struct hlua_concat *hlua_check_concat(lua_State *L, int ud)
{
	return (hlua_checkudata(L, ud, class_concat_ref));
}

static int hlua_concat_add(lua_State *L)
{
	struct hlua_concat *b;
	char *buffer;
	char *new;
	const char *str;
	size_t l;

	/* First arg must be a concat object. */
	b = hlua_check_concat(L, 1);

	/* Second arg must be a string. */
	str = luaL_checklstring(L, 2, &l);

	/* Get the buffer. */
	lua_rawgeti(L, 1, 1);
	buffer = lua_touserdata(L, -1);
	lua_pop(L, 1);

	/* Update the buffer size if it s required. The old buffer
	 * is crushed by the new in the object array, so it will
	 * be deleted by the GC.
	 * Note that in the first loop, the "new" variable is only
	 * used as a flag.
	 */
	new = NULL;
	while (b->size - b->len < l) {
		b->size += HLUA_CONCAT_BLOCSZ;
		new = buffer;
	}
	if (new) {
		new = lua_newuserdata(L, b->size);
		memcpy(new, buffer, b->len);
		lua_rawseti(L, 1, 1);
		buffer = new;
	}

	/* Copy string, and update metadata. */
	memcpy(buffer + b->len, str, l);
	b->len += l;
	return 0;
}

static int hlua_concat_dump(lua_State *L)
{
	struct hlua_concat *b;
	char *buffer;

	/* First arg must be a concat object. */
	b = hlua_check_concat(L, 1);

	/* Get the buffer. */
	lua_rawgeti(L, 1, 1);
	buffer = lua_touserdata(L, -1);
	lua_pop(L, 1);

	/* Push the soncatenated string in the stack. */
	lua_pushlstring(L, buffer, b->len);
	return 1;
}

int hlua_concat_new(lua_State *L)
{
	struct hlua_concat *b;

	lua_newtable(L);
	b = lua_newuserdata(L, sizeof(*b));
	b->size = HLUA_CONCAT_BLOCSZ;
	b->len = 0;
	lua_rawseti(L, -2, 0);
	lua_newuserdata(L, HLUA_CONCAT_BLOCSZ);
	lua_rawseti(L, -2, 1);

	lua_rawgeti(L, LUA_REGISTRYINDEX, class_concat_ref);
	lua_setmetatable(L, -2);

	return 1;
}

static int concat_tostring(lua_State *L)
{
	const void *ptr = lua_topointer(L, 1);
	lua_pushfstring(L, "Concat object: %p", ptr);
	return 1;
}

static void hlua_concat_init(lua_State *L)
{
	/* Creates the buffered concat object. */
	lua_newtable(L);

	lua_pushstring(L, "__tostring");
	lua_pushcclosure(L, concat_tostring, 0);
	lua_settable(L, -3);

	lua_pushstring(L, "__index"); /* Creates the index entry. */
	lua_newtable(L); /* The "__index" content. */

	lua_pushstring(L, "add");
	lua_pushcclosure(L, hlua_concat_add, 0);
	lua_settable(L, -3);

	lua_pushstring(L, "dump");
	lua_pushcclosure(L, hlua_concat_dump, 0);
	lua_settable(L, -3);

	lua_settable(L, -3); /* Sets the __index entry. */
	class_concat_ref = luaL_ref(L, LUA_REGISTRYINDEX);
}

/* C backing storage for lua Queue class */
struct hlua_queue {
	uint32_t size;
	struct mt_list list;
	struct mt_list wait_tasks;
};

/* used to store lua objects in queue->list */
struct hlua_queue_item {
	int ref; /* lua object reference id */
	struct mt_list list;
};

/* used to store wait entries in queue->wait_tasks */
struct hlua_queue_wait
{
	struct task *task;
	struct mt_list entry;
};

/* This is the memory pool containing struct hlua_queue_item (queue items)
 */
DECLARE_STATIC_POOL(pool_head_hlua_queue, "hlua_queue", sizeof(struct hlua_queue_item));

/* This is the memory pool containing struct hlua_queue_wait
 * (queue waiting tasks)
 */
DECLARE_STATIC_POOL(pool_head_hlua_queuew, "hlua_queuew", sizeof(struct hlua_queue_wait));

static struct hlua_queue *hlua_check_queue(lua_State *L, int ud)
{
	return hlua_checkudata(L, ud, class_queue_ref);
}

/* queue:size(): returns an integer containing the current number of queued
 * items.
 */
static int hlua_queue_size(lua_State *L)
{
	struct hlua_queue *queue = hlua_check_queue(L, 1);

	BUG_ON(!queue);
	lua_pushinteger(L, queue->size);

	return 1;
}

/* queue:push(): push an item (any type, except nil) at the end of the queue
 *
 * Returns boolean:true for success and boolean:false on error
 */
static int hlua_queue_push(lua_State *L)
{
	struct hlua_queue *queue = hlua_check_queue(L, 1);
	struct hlua_queue_item *item;
	struct mt_list *elt1, elt2;
	struct hlua_queue_wait *waiter;

	if (lua_gettop(L) != 2 || lua_isnoneornil(L, 2)) {
		luaL_error(L, "unexpected argument");
		/* not reached */
		return 0;
	}
	BUG_ON(!queue);
	item = pool_alloc(pool_head_hlua_queue);
	if (!item) {
		lua_pushboolean(L, 0);
		return 1;
	}
	item->ref = hlua_ref(L);
	MT_LIST_INIT(&item->list);
	HA_ATOMIC_INC(&queue->size);
	MT_LIST_APPEND(&queue->list, &item->list);

	/* notify tasks waiting on queue:pop_wait() (if any) */
	mt_list_for_each_entry_safe(waiter, &queue->wait_tasks, entry, elt1, elt2) {
		task_wakeup(waiter->task, TASK_WOKEN_MSG);
	}

	lua_pushboolean(L, 1);
	return 1;
}

/* queue:pop(): returns the first item at the top of que queue or nil if
 * the queue is empty.
 */
static int _hlua_queue_pop(lua_State *L, struct hlua_queue *queue)
{
	struct hlua_queue_item *item;

	item = MT_LIST_POP(&queue->list, typeof(item), list);
	if (!item) {
		lua_pushnil(L);
		return 1; /* nothing in queue, return nil */
	}

	HA_ATOMIC_DEC(&queue->size);
	/* push lua obj on the stack */
	hlua_pushref(L, item->ref);

	/* free the queue item */
	pool_free(pool_head_hlua_queue, item);

	return 1;
}
static int hlua_queue_pop(lua_State *L)
{
	struct hlua_queue *queue = hlua_check_queue(L, 1);

	BUG_ON(!queue);
	return _hlua_queue_pop(L, queue);
}

/* queue:pop_wait(): same as queue:pop() but doesn't return on empty queue.
 *
 * Aborts if used incorrectly and returns nil in case of memory error.
 */
static int _hlua_queue_pop_wait(lua_State *L, int status, lua_KContext ctx)
{
	struct hlua_queue *queue = hlua_check_queue(L, 1);

	/* new pop attempt */
	if (!_hlua_queue_pop(L, queue))
		hlua_yieldk(L, 0, 0, _hlua_queue_pop_wait, TICK_ETERNITY, 0); // wait retry
	return 1; // success
}
static int hlua_queue_pop_wait(lua_State *L)
{
	struct hlua_queue *queue = hlua_check_queue(L, 1);
	struct hlua_queue_wait *wait;
	struct hlua *hlua;

	BUG_ON(!queue);

	/* Get hlua struct, or NULL if we execute from main lua state */
	hlua = hlua_gethlua(L);

	if (!hlua || HLUA_CANT_YIELD(hlua)) {
		luaL_error(L, "pop_wait() may only be used within task context "
			      "(requires yielding)");
		return 0; /* not reached */
	}

	wait = pool_alloc(pool_head_hlua_queuew);
	if (!wait) {
		lua_pushnil(L);
		return 1; /* memory error, return nil */
	}

	wait->task = hlua->task;
	MT_LIST_INIT(&wait->entry);

	/* add task to queue's wait list */
	MT_LIST_TRY_APPEND(&queue->wait_tasks, &wait->entry);

	/* push queue on the top of the stack */
	lua_pushlightuserdata(L, queue);

	/* try to pop without waiting (there could be already pending items) */
	if (!_hlua_queue_pop(L, queue)) {
		/* no item immediately available, go to waiting loop */
		hlua_yieldk(L, 0, 0, _hlua_queue_pop_wait, TICK_ETERNITY, 0);
	}

	/* remove task from waiting list */
	MT_LIST_DELETE(&wait->entry);
	pool_free(pool_head_hlua_queuew, wait);

	return 1;
}

static int hlua_queue_new(lua_State *L)
{
	struct hlua_queue *q;

	lua_newtable(L);

	/* set class metatable */
	lua_rawgeti(L, LUA_REGISTRYINDEX, class_queue_ref);
	lua_setmetatable(L, -2);

	/* index:0 is queue userdata (c data) */
	q = lua_newuserdata(L, sizeof(*q));
	MT_LIST_INIT(&q->list);
	MT_LIST_INIT(&q->wait_tasks);
	q->size = 0;
	lua_rawseti(L, -2, 0);

	/* class methods */
	hlua_class_function(L, "size", hlua_queue_size);
	hlua_class_function(L, "pop", hlua_queue_pop);
	hlua_class_function(L, "pop_wait", hlua_queue_pop_wait);
	hlua_class_function(L, "push", hlua_queue_push);

	return 1;
}

static int hlua_queue_gc(struct lua_State *L)
{
	struct hlua_queue *queue = hlua_check_queue(L, 1);
	struct hlua_queue_wait *wait;
	struct hlua_queue_item *item;

	/* Purge waiting tasks (if any)
	 *
	 * It is normally not expected to have waiting tasks, except if such
	 * task has been aborted while in the middle of a queue:pop_wait()
	 * function call.
	 */
	while ((wait = MT_LIST_POP(&queue->wait_tasks, typeof(wait), entry))) {
		/* free the wait entry */
		pool_free(pool_head_hlua_queuew, wait);
	}

	/* purge remaining (unconsumed) items in the queue */
	while ((item = MT_LIST_POP(&queue->list, typeof(item), list))) {
		/* free the queue item */
		pool_free(pool_head_hlua_queue, item);
	}

	/* queue (userdata) will automatically be freed by lua gc */

	return 0;
}

static void hlua_queue_init(lua_State *L)
{
	/* Creates the queue object. */
	lua_newtable(L);

	hlua_class_function(L, "__gc", hlua_queue_gc);

	class_queue_ref = luaL_ref(L, LUA_REGISTRYINDEX);
}

int hlua_fcn_new_stktable(lua_State *L, struct stktable *tbl)
{
	lua_newtable(L);

	/* Pop a class stktbl metatable and affect it to the userdata. */
	lua_rawgeti(L, LUA_REGISTRYINDEX, class_stktable_ref);
	lua_setmetatable(L, -2);

	lua_pushlightuserdata(L, tbl);
	lua_rawseti(L, -2, 0);
	return 1;
}

static struct stktable *hlua_check_stktable(lua_State *L, int ud)
{
	return hlua_checkudata(L, ud, class_stktable_ref);
}

/* Extract stick table attributes into Lua table */
int hlua_stktable_info(lua_State *L)
{
	struct stktable *tbl;
	int dt;

	tbl = hlua_check_stktable(L, 1);

	if (!tbl->id) {
		lua_pushnil(L);
		return 1;
	}

	lua_newtable(L);

	lua_pushstring(L, "type");
	lua_pushstring(L, stktable_types[tbl->type].kw);
	lua_settable(L, -3);

	lua_pushstring(L, "length");
	lua_pushinteger(L, tbl->key_size);
	lua_settable(L, -3);

	lua_pushstring(L, "size");
	hlua_fcn_pushunsigned(L, tbl->size);
	lua_settable(L, -3);

	lua_pushstring(L, "used");
	hlua_fcn_pushunsigned(L, tbl->current);
	lua_settable(L, -3);

	lua_pushstring(L, "nopurge");
	lua_pushboolean(L, tbl->nopurge > 0);
	lua_settable(L, -3);

	lua_pushstring(L, "expire");
	lua_pushinteger(L, tbl->expire);
	lua_settable(L, -3);

	/* Save data types periods (if applicable) in 'data' table */
	lua_pushstring(L, "data");
	lua_newtable(L);

	for (dt = 0; dt < STKTABLE_DATA_TYPES; dt++) {
		if (tbl->data_ofs[dt] == 0)
			continue;

		lua_pushstring(L, stktable_data_types[dt].name);

		if (stktable_data_types[dt].arg_type == ARG_T_DELAY)
			lua_pushinteger(L, tbl->data_arg[dt].u);
		else
			lua_pushinteger(L, -1);

		lua_settable(L, -3);
	}

	lua_settable(L, -3);

	return 1;
}

/* Helper to get extract stick table entry into Lua table */
static void hlua_stktable_entry(lua_State *L, struct stktable *t, struct stksess *ts)
{
	int dt;
	void *ptr;

	for (dt = 0; dt < STKTABLE_DATA_TYPES; dt++) {

		if (t->data_ofs[dt] == 0)
			continue;

		lua_pushstring(L, stktable_data_types[dt].name);

		ptr = stktable_data_ptr(t, ts, dt);
		switch (stktable_data_types[dt].std_type) {
		case STD_T_SINT:
			lua_pushinteger(L, stktable_data_cast(ptr, std_t_sint));
			break;
		case STD_T_UINT:
			hlua_fcn_pushunsigned(L, stktable_data_cast(ptr, std_t_uint));
			break;
		case STD_T_ULL:
			hlua_fcn_pushunsigned_ll(L, stktable_data_cast(ptr, std_t_ull));
			break;
		case STD_T_FRQP:
			lua_pushinteger(L, read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
			                t->data_arg[dt].u));
			break;
		case STD_T_DICT: {
			struct dict_entry *de;
			de = stktable_data_cast(ptr, std_t_dict);
			lua_pushstring(L, de ? (char *)de->value.key : "-");
			break;
		}
		}

		lua_settable(L, -3);
	}
}

/* Looks in table <t> for a sticky session matching key <key>
 * Returns table with session data or nil
 *
 * The returned table always contains 'use' and 'expire' (integer) fields.
 * For frequency/rate counters, each data entry is returned as table with
 * 'value' and 'period' fields.
 */
int hlua_stktable_lookup(lua_State *L)
{
	struct stktable *t;
	struct sample smp;
	struct stktable_key *skey;
	struct stksess *ts;

	t = hlua_check_stktable(L, 1);
	smp.data.type = SMP_T_STR;
	smp.flags = SMP_F_CONST;
	smp.data.u.str.area = (char *)lua_tolstring(L, 2, &smp.data.u.str.data);

	skey = smp_to_stkey(&smp, t);
	if (!skey) {
		lua_pushnil(L);
		return 1;
	}

	ts = stktable_lookup_key(t, skey);
	if (!ts) {
		lua_pushnil(L);
		return 1;
	}

	lua_newtable(L);
	lua_pushstring(L, "use");
	lua_pushinteger(L, ts->ref_cnt - 1);
	lua_settable(L, -3);

	lua_pushstring(L, "expire");
	lua_pushinteger(L, tick_remain(now_ms, ts->expire));
	lua_settable(L, -3);

	hlua_stktable_entry(L, t, ts);
	HA_RWLOCK_WRLOCK(STK_TABLE_LOCK, &t->lock);
	ts->ref_cnt--;
	HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &t->lock);

	return 1;
}

struct stk_filter {
	long long val;
	int type;
	int op;
};


/* Helper for returning errors to callers using Lua convention (nil, err) */
static int hlua_error(lua_State *L, const char *fmt, ...)  {
	char buf[256];
	int len;
	va_list args;
	va_start(args, fmt);
        len = vsnprintf(buf, sizeof(buf), fmt, args);
	va_end(args);

	if (len < 0) {
		ha_alert("hlua_error(): Could not write error message.\n");
		lua_pushnil(L);
		return 1;
	} else if (len >= sizeof(buf))
		ha_alert("hlua_error(): Error message was truncated.\n");

	lua_pushnil(L);
	lua_pushstring(L, buf);

	return 2;
}

/* Dump the contents of stick table <t>*/
int hlua_stktable_dump(lua_State *L)
{
	struct stktable *t;
	struct ebmb_node *eb;
	struct ebmb_node *n;
	struct stksess *ts;
	int type;
	int op;
	int dt;
	long long val;
	struct stk_filter filter[STKTABLE_FILTER_LEN];
	int filter_count = 0;
	int i;
	int skip_entry;
	void *ptr;

	t = hlua_check_stktable(L, 1);
	type = lua_type(L, 2);

	switch (type) {
	case LUA_TNONE:
	case LUA_TNIL:
		break;
	case LUA_TTABLE:
		lua_pushnil(L);
		while (lua_next(L, 2) != 0) {
			int entry_idx = 0;

			if (filter_count >= STKTABLE_FILTER_LEN)
				return hlua_error(L, "Filter table too large (len > %d)", STKTABLE_FILTER_LEN);

			if (lua_type(L, -1) != LUA_TTABLE  || lua_rawlen(L, -1) != 3)
				return hlua_error(L, "Filter table entry must be a triplet: {\"data_col\", \"op\", val} (entry #%d)", filter_count + 1);

			lua_pushnil(L);
			while (lua_next(L, -2) != 0) {
				switch (entry_idx) {
				case 0:
					if (lua_type(L, -1) != LUA_TSTRING)
						return hlua_error(L, "Filter table data column must be string (entry #%d)", filter_count + 1);

					dt = stktable_get_data_type((char *)lua_tostring(L, -1));
					if (dt < 0 || t->data_ofs[dt] == 0)
						return hlua_error(L, "Filter table data column not present in stick table (entry #%d)", filter_count + 1);
					filter[filter_count].type = dt;
					break;
				case 1:
					if (lua_type(L, -1) != LUA_TSTRING)
						return hlua_error(L, "Filter table operator must be string (entry #%d)", filter_count + 1);

					op = get_std_op(lua_tostring(L, -1));
					if (op < 0)
						return hlua_error(L, "Unknown operator in filter table (entry #%d)", filter_count + 1);
					filter[filter_count].op = op;
					break;
				case 2:
					val = lua_tointeger(L, -1);
					filter[filter_count].val = val;
					filter_count++;
					break;
				default:
					break;
				}
				entry_idx++;
				lua_pop(L, 1);
			}
			lua_pop(L, 1);
		}
		break;
	default:
		return hlua_error(L, "filter table expected");
	}

	lua_newtable(L);

	HA_RWLOCK_WRLOCK(STK_TABLE_LOCK, &t->lock);
	eb = ebmb_first(&t->keys);
	for (n = eb; n; n = ebmb_next(n)) {
		ts = ebmb_entry(n, struct stksess, key);
		if (!ts) {
			HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &t->lock);
			return 1;
		}
		ts->ref_cnt++;
		HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &t->lock);

		/* multi condition/value filter */
		skip_entry = 0;
		for (i = 0; i < filter_count; i++) {
			if (t->data_ofs[filter[i].type] == 0)
				continue;

			ptr = stktable_data_ptr(t, ts, filter[i].type);

			switch (stktable_data_types[filter[i].type].std_type) {
			case STD_T_SINT:
				val = stktable_data_cast(ptr, std_t_sint);
				break;
			case STD_T_UINT:
				val = stktable_data_cast(ptr, std_t_uint);
				break;
			case STD_T_ULL:
				val = stktable_data_cast(ptr, std_t_ull);
				break;
			case STD_T_FRQP:
				val = read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
						           t->data_arg[filter[i].type].u);
				break;
			default:
				continue;
				break;
			}

			op = filter[i].op;

			if ((val < filter[i].val && (op == STD_OP_EQ || op == STD_OP_GT || op == STD_OP_GE)) ||
			    (val == filter[i].val && (op == STD_OP_NE || op == STD_OP_GT || op == STD_OP_LT)) ||
			    (val > filter[i].val && (op == STD_OP_EQ || op == STD_OP_LT || op == STD_OP_LE))) {
				skip_entry = 1;
				break;
			}
		}

		if (skip_entry) {
			HA_RWLOCK_WRLOCK(STK_TABLE_LOCK, &t->lock);
			ts->ref_cnt--;
			continue;
		}

		if (t->type == SMP_T_IPV4) {
			char addr[INET_ADDRSTRLEN];
			inet_ntop(AF_INET, (const void *)&ts->key.key, addr, sizeof(addr));
			lua_pushstring(L, addr);
		} else if (t->type == SMP_T_IPV6) {
			char addr[INET6_ADDRSTRLEN];
			inet_ntop(AF_INET6, (const void *)&ts->key.key, addr, sizeof(addr));
			lua_pushstring(L, addr);
		} else if (t->type == SMP_T_SINT) {
			lua_pushinteger(L, *ts->key.key);
		} else if (t->type == SMP_T_STR) {
			lua_pushstring(L, (const char *)ts->key.key);
		} else {
			return hlua_error(L, "Unsupported stick table key type");
		}

		lua_newtable(L);
		hlua_stktable_entry(L, t, ts);
		lua_settable(L, -3);
		HA_RWLOCK_WRLOCK(STK_TABLE_LOCK, &t->lock);
		ts->ref_cnt--;
	}
	HA_RWLOCK_WRUNLOCK(STK_TABLE_LOCK, &t->lock);

	return 1;
}

int hlua_fcn_new_listener(lua_State *L, struct listener *lst)
{
	lua_newtable(L);

	/* Pop a class sesison metatable and affect it to the userdata. */
	lua_rawgeti(L, LUA_REGISTRYINDEX, class_listener_ref);
	lua_setmetatable(L, -2);

	lua_pushlightuserdata(L, lst);
	lua_rawseti(L, -2, 0);
	return 1;
}

static struct listener *hlua_check_listener(lua_State *L, int ud)
{
	return hlua_checkudata(L, ud, class_listener_ref);
}

int hlua_listener_get_stats(lua_State *L)
{
	struct listener *li;
	int i;

	li = hlua_check_listener(L, 1);

	if (!li->bind_conf->frontend) {
		lua_pushnil(L);
		return 1;
	}

	stats_fill_li_stats(li->bind_conf->frontend, li, STAT_SHLGNDS, stats,
			    STATS_LEN, NULL);

	lua_newtable(L);
	for (i=0; i<ST_F_TOTAL_FIELDS; i++) {
		lua_pushstring(L, stat_fields[i].name);
		hlua_fcn_pushfield(L, &stats[i]);
		lua_settable(L, -3);
	}
	return 1;

}

int hlua_server_gc(lua_State *L)
{
	struct server *srv = hlua_checkudata(L, 1, class_server_ref);

	srv_drop(srv); /* srv_drop allows NULL srv */
	return 0;
}

static struct server *hlua_check_server(lua_State *L, int ud)
{
	struct server *srv = hlua_checkudata(L, ud, class_server_ref);
	if (srv->flags & SRV_F_DELETED) {
		return NULL;
	}
	return srv;
}

int hlua_server_get_stats(lua_State *L)
{
	struct server *srv;
	int i;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	if (!srv->proxy) {
		lua_pushnil(L);
		return 1;
	}

	stats_fill_sv_stats(srv->proxy, srv, STAT_SHLGNDS, stats,
			    STATS_LEN, NULL);

	lua_newtable(L);
	for (i=0; i<ST_F_TOTAL_FIELDS; i++) {
		lua_pushstring(L, stat_fields[i].name);
		hlua_fcn_pushfield(L, &stats[i]);
		lua_settable(L, -3);
	}
	return 1;

}

int hlua_server_get_proxy(lua_State *L)
{
	struct server *srv;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	if (!srv->proxy) {
		lua_pushnil(L);
		return 1;
	}

	hlua_fcn_new_proxy(L, srv->proxy);
	return 1;
}

int hlua_server_get_addr(lua_State *L)
{
	struct server *srv;
	char addr[INET6_ADDRSTRLEN];
	luaL_Buffer b;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	luaL_buffinit(L, &b);

	switch (srv->addr.ss_family) {
	case AF_INET:
		inet_ntop(AF_INET, &((struct sockaddr_in *)&srv->addr)->sin_addr,
		          addr, INET_ADDRSTRLEN);
		luaL_addstring(&b, addr);
		luaL_addstring(&b, ":");
		snprintf(addr, INET_ADDRSTRLEN, "%d", srv->svc_port);
		luaL_addstring(&b, addr);
		break;
	case AF_INET6:
		inet_ntop(AF_INET6, &((struct sockaddr_in6 *)&srv->addr)->sin6_addr,
		          addr, INET6_ADDRSTRLEN);
		luaL_addstring(&b, addr);
		luaL_addstring(&b, ":");
		snprintf(addr, INET_ADDRSTRLEN, "%d", srv->svc_port);
		luaL_addstring(&b, addr);
		break;
	case AF_UNIX:
		luaL_addstring(&b, (char *)((struct sockaddr_un *)&srv->addr)->sun_path);
		break;
	default:
		luaL_addstring(&b, "<unknown>");
		break;
	}

	luaL_pushresult(&b);
	return 1;
}

int hlua_server_get_puid(lua_State *L)
{
	struct server *srv;
	char buffer[12];

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	snprintf(buffer, sizeof(buffer), "%d", srv->puid);
	lua_pushstring(L, buffer);
	return 1;
}

int hlua_server_get_rid(lua_State *L)
{
	struct server *srv;
	char buffer[12];

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	snprintf(buffer, sizeof(buffer), "%d", srv->rid);
	lua_pushstring(L, buffer);
	return 1;
}

int hlua_server_get_name(lua_State *L)
{
	struct server *srv;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	lua_pushstring(L, srv->id);
	return 1;
}

/* __index metamethod for server class
 * support for additional keys that are missing from the main table
 * stack:1 = table (server class), stack:2 = requested key
 * Returns 1 if key is supported
 * else returns 0 to make lua return NIL value to the caller
 */
static int hlua_server_index(struct lua_State *L)
{
	const char *key = lua_tostring(L, 2);

	if (!strcmp(key, "name")) {
		if (ONLY_ONCE())
			ha_warning("hlua: use of server 'name' attribute is deprecated and will eventually be removed, please use get_name() function instead: %s\n", hlua_traceback(L, ", "));
		lua_pushvalue(L, 1);
		hlua_server_get_name(L);
		return 1;
	}
	if (!strcmp(key, "puid")) {
		if (ONLY_ONCE())
			ha_warning("hlua: use of server 'puid' attribute is deprecated and will eventually be removed, please use get_puid() function instead: %s\n", hlua_traceback(L, ", "));
		lua_pushvalue(L, 1);
		hlua_server_get_puid(L);
		return 1;
	}
	/* unknown attribute */
	return 0;
}

int hlua_server_is_draining(lua_State *L)
{
	struct server *srv;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	lua_pushboolean(L, server_is_draining(srv));
	return 1;
}

int hlua_server_is_backup(lua_State *L)
{
	struct server *srv;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	lua_pushboolean(L, (srv->flags & SRV_F_BACKUP));
	return 1;
}

int hlua_server_is_dynamic(lua_State *L)
{
	struct server *srv;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	lua_pushboolean(L, (srv->flags & SRV_F_DYNAMIC));
	return 1;
}

int hlua_server_get_cur_sess(lua_State *L)
{
	struct server *srv;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	lua_pushinteger(L, srv->cur_sess);
	return 1;
}

int hlua_server_get_pend_conn(lua_State *L)
{
	struct server *srv;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	lua_pushinteger(L, srv->queue.length);
	return 1;
}

int hlua_server_set_maxconn(lua_State *L)
{
	struct server *srv;
	const char *maxconn;
	const char *err;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	maxconn = luaL_checkstring(L, 2);

	HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
	err = server_parse_maxconn_change_request(srv, maxconn);
	HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
	if (!err)
		lua_pushnil(L);
	else
		hlua_pushstrippedstring(L, err);
	return 1;
}

int hlua_server_get_maxconn(lua_State *L)
{
	struct server *srv;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	lua_pushinteger(L, srv->maxconn);
	return 1;
}

int hlua_server_set_weight(lua_State *L)
{
	struct server *srv;
	const char *weight;
	const char *err;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	weight = luaL_checkstring(L, 2);

	HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
	err = server_parse_weight_change_request(srv, weight);
	HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
	if (!err)
		lua_pushnil(L);
	else
		hlua_pushstrippedstring(L, err);
	return 1;
}

int hlua_server_get_weight(lua_State *L)
{
	struct server *srv;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	lua_pushinteger(L, srv->uweight);
	return 1;
}

int hlua_server_set_addr(lua_State *L)
{
	struct server *srv;
	const char *addr;
	const char *port;
	const char *err;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	addr = luaL_checkstring(L, 2);
	if (lua_gettop(L) >= 3)
		port = luaL_checkstring(L, 3);
	else
		port = NULL;

	HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
	err = srv_update_addr_port(srv, addr, port, "Lua script");
	HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
	if (!err)
		lua_pushnil(L);
	else
		hlua_pushstrippedstring(L, err);
	return 1;
}

int hlua_server_shut_sess(lua_State *L)
{
	struct server *srv;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		return 0;
	}
	HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
	srv_shutdown_streams(srv, SF_ERR_KILLED);
	HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
	return 0;
}

int hlua_server_set_drain(lua_State *L)
{
	struct server *srv;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		return 0;
	}
	HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
	srv_adm_set_drain(srv);
	HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
	return 0;
}

int hlua_server_set_maint(lua_State *L)
{
	struct server *srv;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		return 0;
	}
	HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
	srv_adm_set_maint(srv);
	HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
	return 0;
}

int hlua_server_set_ready(lua_State *L)
{
	struct server *srv;

	srv = hlua_check_server(L, 1);
	if (srv == NULL) {
		return 0;
	}
	HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
	srv_adm_set_ready(srv);
	HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
	return 0;
}

int hlua_server_check_enable(lua_State *L)
{
	struct server *sv;

	sv = hlua_check_server(L, 1);
	if (sv == NULL) {
		return 0;
	}
	HA_SPIN_LOCK(SERVER_LOCK, &sv->lock);
	if (sv->check.state & CHK_ST_CONFIGURED) {
		sv->check.state |= CHK_ST_ENABLED;
	}
	HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock);
	return 0;
}

int hlua_server_check_disable(lua_State *L)
{
	struct server *sv;

	sv = hlua_check_server(L, 1);
	if (sv == NULL) {
		return 0;
	}
	HA_SPIN_LOCK(SERVER_LOCK, &sv->lock);
	if (sv->check.state & CHK_ST_CONFIGURED) {
		sv->check.state &= ~CHK_ST_ENABLED;
	}
	HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock);
	return 0;
}

int hlua_server_check_force_up(lua_State *L)
{
	struct server *sv;

	sv = hlua_check_server(L, 1);
	if (sv == NULL) {
		return 0;
	}
	HA_SPIN_LOCK(SERVER_LOCK, &sv->lock);
	if (!(sv->track)) {
		sv->check.health = sv->check.rise + sv->check.fall - 1;
		srv_set_running(sv, SRV_OP_STCHGC_LUA);
	}
	HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock);
	return 0;
}

int hlua_server_check_force_nolb(lua_State *L)
{
	struct server *sv;

	sv = hlua_check_server(L, 1);
	if (sv == NULL) {
		return 0;
	}
	HA_SPIN_LOCK(SERVER_LOCK, &sv->lock);
	if (!(sv->track)) {
		sv->check.health = sv->check.rise + sv->check.fall - 1;
		srv_set_stopping(sv, SRV_OP_STCHGC_LUA);
	}
	HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock);
	return 0;
}

int hlua_server_check_force_down(lua_State *L)
{
	struct server *sv;

	sv = hlua_check_server(L, 1);
	if (sv == NULL) {
		return 0;
	}
	HA_SPIN_LOCK(SERVER_LOCK, &sv->lock);
	if (!(sv->track)) {
		sv->check.health = 0;
		srv_set_stopped(sv, SRV_OP_STCHGC_LUA);
	}
	HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock);
	return 0;
}

int hlua_server_agent_enable(lua_State *L)
{
	struct server *sv;

	sv = hlua_check_server(L, 1);
	if (sv == NULL) {
		return 0;
	}
	HA_SPIN_LOCK(SERVER_LOCK, &sv->lock);
	if (sv->agent.state & CHK_ST_CONFIGURED) {
		sv->agent.state |= CHK_ST_ENABLED;
	}
	HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock);
	return 0;
}

int hlua_server_agent_disable(lua_State *L)
{
	struct server *sv;

	sv = hlua_check_server(L, 1);
	if (sv == NULL) {
		return 0;
	}
	HA_SPIN_LOCK(SERVER_LOCK, &sv->lock);
	if (sv->agent.state & CHK_ST_CONFIGURED) {
		sv->agent.state &= ~CHK_ST_ENABLED;
	}
	HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock);
	return 0;
}

int hlua_server_agent_force_up(lua_State *L)
{
	struct server *sv;

	sv = hlua_check_server(L, 1);
	if (sv == NULL) {
		return 0;
	}
	HA_SPIN_LOCK(SERVER_LOCK, &sv->lock);
	if (sv->agent.state & CHK_ST_ENABLED) {
		sv->agent.health = sv->agent.rise + sv->agent.fall - 1;
		srv_set_running(sv, SRV_OP_STCHGC_LUA);
	}
	HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock);
	return 0;
}

int hlua_server_agent_force_down(lua_State *L)
{
	struct server *sv;

	sv = hlua_check_server(L, 1);
	if (sv == NULL) {
		return 0;
	}
	HA_SPIN_LOCK(SERVER_LOCK, &sv->lock);
	if (sv->agent.state & CHK_ST_ENABLED) {
		sv->agent.health = 0;
		srv_set_stopped(sv, SRV_OP_STCHGC_LUA);
	}
	HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock);
	return 0;
}

/* returns the tracked server, if any */
int hlua_server_tracking(lua_State *L)
{
	struct server *sv;
	struct server *tracked;

	sv = hlua_check_server(L, 1);
	if (sv == NULL) {
		return 0;
	}

	tracked = sv->track;
	if (tracked == NULL)
		lua_pushnil(L);
	else
		hlua_fcn_new_server(L, tracked);

	return 1;
}

/* returns an array of servers tracking the current server */
int hlua_server_get_trackers(lua_State *L)
{
	struct server *sv;
	struct server *cur_tracker;
	int index;

	sv = hlua_check_server(L, 1);
	if (sv == NULL) {
		return 0;
	}

	lua_newtable(L);
	cur_tracker = sv->trackers;
	for (index = 1; cur_tracker; cur_tracker = cur_tracker->tracknext, index++) {
		if (!lua_checkstack(L, 5))
			luaL_error(L, "Lua out of memory error.");
		hlua_fcn_new_server(L, cur_tracker);
		/* array index starts at 1 in Lua */
		lua_rawseti(L, -2, index);
	}
	return 1;
}

/* hlua_event_sub wrapper for per-server subscription:
 *
 * hlua_event_sub() is called with sv->e_subs subscription list and
 * lua arguments are passed as-is (skipping the first argument which
 * is the server ctx)
 */
int hlua_server_event_sub(lua_State *L)
{
	struct server *sv;

	sv = hlua_check_server(L, 1);
	if (sv == NULL) {
		return 0;
	}
	/* remove first argument from the stack (server) */
	lua_remove(L, 1);

	/* try to subscribe within server's subscription list */
	return hlua_event_sub(L, &sv->e_subs);
}

int hlua_fcn_new_server(lua_State *L, struct server *srv)
{
	lua_newtable(L);

	/* Pop a class server metatable and affect it to the userdata. */
	lua_rawgeti(L, LUA_REGISTRYINDEX, class_server_ref);
	lua_setmetatable(L, -2);

	lua_pushlightuserdata(L, srv);
	lua_rawseti(L, -2, 0);

	/* userdata is affected: increment server refcount */
	srv_take(srv);

	/* set public methods */
	hlua_class_function(L, "get_name", hlua_server_get_name);
	hlua_class_function(L, "get_puid", hlua_server_get_puid);
	hlua_class_function(L, "get_rid", hlua_server_get_rid);
	hlua_class_function(L, "is_draining", hlua_server_is_draining);
	hlua_class_function(L, "is_backup", hlua_server_is_backup);
	hlua_class_function(L, "is_dynamic", hlua_server_is_dynamic);
	hlua_class_function(L, "get_cur_sess", hlua_server_get_cur_sess);
	hlua_class_function(L, "get_pend_conn", hlua_server_get_pend_conn);
	hlua_class_function(L, "set_maxconn", hlua_server_set_maxconn);
	hlua_class_function(L, "get_maxconn", hlua_server_get_maxconn);
	hlua_class_function(L, "set_weight", hlua_server_set_weight);
	hlua_class_function(L, "get_weight", hlua_server_get_weight);
	hlua_class_function(L, "set_addr", hlua_server_set_addr);
	hlua_class_function(L, "get_addr", hlua_server_get_addr);
	hlua_class_function(L, "get_stats", hlua_server_get_stats);
	hlua_class_function(L, "get_proxy", hlua_server_get_proxy);
	hlua_class_function(L, "shut_sess", hlua_server_shut_sess);
	hlua_class_function(L, "set_drain", hlua_server_set_drain);
	hlua_class_function(L, "set_maint", hlua_server_set_maint);
	hlua_class_function(L, "set_ready", hlua_server_set_ready);
	hlua_class_function(L, "check_enable", hlua_server_check_enable);
	hlua_class_function(L, "check_disable", hlua_server_check_disable);
	hlua_class_function(L, "check_force_up", hlua_server_check_force_up);
	hlua_class_function(L, "check_force_nolb", hlua_server_check_force_nolb);
	hlua_class_function(L, "check_force_down", hlua_server_check_force_down);
	hlua_class_function(L, "agent_enable", hlua_server_agent_enable);
	hlua_class_function(L, "agent_disable", hlua_server_agent_disable);
	hlua_class_function(L, "agent_force_up", hlua_server_agent_force_up);
	hlua_class_function(L, "agent_force_down", hlua_server_agent_force_down);
	hlua_class_function(L, "tracking", hlua_server_tracking);
	hlua_class_function(L, "get_trackers", hlua_server_get_trackers);
	hlua_class_function(L, "event_sub", hlua_server_event_sub);

	return 1;
}

static struct hlua_server_list *hlua_check_server_list(lua_State *L, int ud)
{
	return hlua_checkudata(L, ud, class_server_list_ref);
}

/* does nothing and returns 0, only prevents insertions in the
 * table which represents the list of servers
 */
int hlua_listable_servers_newindex(lua_State *L) {
	return 0;
}

/* first arg is the table (struct hlua_server_list * in metadata)
 * second arg is the required index
 */
int hlua_listable_servers_index(lua_State *L)
{
	struct hlua_server_list *hlua_srv;
	const char *name;
	struct server *srv;

	hlua_srv = hlua_check_server_list(L, 1);
	name = luaL_checkstring(L, 2);

	/* Perform a server lookup in px list */
	srv = server_find_by_name(hlua_srv->px, name);
	if (srv == NULL) {
		lua_pushnil(L);
		return 1;
	}

	hlua_fcn_new_server(L, srv);
	return 1;
}

/* iterator must return key as string and value as server
 * object, if we reach end of list, it returns nil.
 * The context knows the last returned server. if the
 * context contains srv == NULL, we start enumeration.
 * Then, use 'srv->next' ptr to iterate through the list
 */
int hlua_listable_servers_pairs_iterator(lua_State *L)
{
	int context_index;
	struct hlua_server_list_iterator_context *ctx;

	context_index = lua_upvalueindex(1);
	ctx = lua_touserdata(L, context_index);

	if (ctx->cur == NULL) {
		/* First iteration, initialize list on the first server */
		ctx->cur = ctx->px->srv;
	} else {

		/* Next server (next ptr is always valid, even if current
		 * server has the SRV_F_DELETED flag set)
		 */
		ctx->cur = ctx->cur->next;
	}

	/* next server is null, end of iteration */
	if (ctx->cur == NULL) {
		lua_pushnil(L);
		return 1;
	}

	lua_pushstring(L, ctx->cur->id);
	hlua_fcn_new_server(L, ctx->cur);
	return 2;
}

/* init the iterator context, return iterator function
 * with context as closure. The only argument is a
 * server list object.
 */
int hlua_listable_servers_pairs(lua_State *L)
{
	struct hlua_server_list_iterator_context *ctx;
	struct hlua_server_list *hlua_srv_list;

	hlua_srv_list = hlua_check_server_list(L, 1);

	ctx = lua_newuserdata(L, sizeof(*ctx));
	ctx->px = hlua_srv_list->px;
	ctx->cur = NULL;

	lua_pushcclosure(L, hlua_listable_servers_pairs_iterator, 1);
	return 1;
}

void hlua_listable_servers(lua_State *L, struct proxy *px)
{
	struct hlua_server_list *list;

	lua_newtable(L);
	list = lua_newuserdata(L, sizeof(*list));
	list->px = px;
	lua_rawseti(L, -2, 0);
	lua_rawgeti(L, LUA_REGISTRYINDEX, class_server_list_ref);
	lua_setmetatable(L, -2);
}

static struct proxy *hlua_check_proxy(lua_State *L, int ud)
{
	return hlua_checkudata(L, ud, class_proxy_ref);
}

int hlua_proxy_get_name(lua_State *L)
{
	struct proxy *px;

	px = hlua_check_proxy(L, 1);
	lua_pushstring(L, px->id);
	return 1;
}

int hlua_proxy_get_uuid(lua_State *L)
{
	struct proxy *px;
	char buffer[17];

	px = hlua_check_proxy(L, 1);
	snprintf(buffer, sizeof(buffer), "%d", px->uuid);
	lua_pushstring(L, buffer);
	return 1;
}

/* __index metamethod for proxy class
 * support for additional keys that are missing from the main table
 * stack:1 = table (proxy class), stack:2 = requested key
 * Returns 1 if key is supported
 * else returns 0 to make lua return NIL value to the caller
 */
static int hlua_proxy_index(struct lua_State *L)
{
	const char *key = lua_tostring(L, 2);

	if (!strcmp(key, "name")) {
		if (ONLY_ONCE())
			ha_warning("hlua: use of proxy 'name' attribute is deprecated and will eventually be removed, please use get_name() function instead: %s\n", hlua_traceback(L, ", "));
		lua_pushvalue(L, 1);
		hlua_proxy_get_name(L);
		return 1;
	}
	if (!strcmp(key, "uuid")) {
		if (ONLY_ONCE())
			ha_warning("hlua: use of proxy 'uuid' attribute is deprecated and will eventually be removed, please use get_uuid() function instead: %s\n", hlua_traceback(L, ", "));
		lua_pushvalue(L, 1);
		hlua_proxy_get_uuid(L);
		return 1;
	}
	/* unknown attribute */
	return 0;
}

int hlua_proxy_pause(lua_State *L)
{
	struct proxy *px;

	px = hlua_check_proxy(L, 1);
	/* safe to call without PROXY_LOCK - pause_proxy takes it */
	pause_proxy(px);
	return 0;
}

int hlua_proxy_resume(lua_State *L)
{
	struct proxy *px;

	px = hlua_check_proxy(L, 1);
	/* safe to call without PROXY_LOCK - resume_proxy takes it */
	resume_proxy(px);
	return 0;
}

int hlua_proxy_stop(lua_State *L)
{
	struct proxy *px;

	px = hlua_check_proxy(L, 1);
	/* safe to call without PROXY_LOCK - stop_proxy takes it */
	stop_proxy(px);
	return 0;
}

int hlua_proxy_get_cap(lua_State *L)
{
	struct proxy *px;
	const char *str;

	px = hlua_check_proxy(L, 1);
	str = proxy_cap_str(px->cap);
	lua_pushstring(L, str);
	return 1;
}

int hlua_proxy_get_stats(lua_State *L)
{
	struct proxy *px;
	int i;

	px = hlua_check_proxy(L, 1);
	if (px->cap & PR_CAP_BE)
		stats_fill_be_stats(px, STAT_SHLGNDS, stats, STATS_LEN, NULL);
	else
		stats_fill_fe_stats(px, stats, STATS_LEN, NULL);
	lua_newtable(L);
	for (i=0; i<ST_F_TOTAL_FIELDS; i++) {
		lua_pushstring(L, stat_fields[i].name);
		hlua_fcn_pushfield(L, &stats[i]);
		lua_settable(L, -3);
	}
	return 1;
}

int hlua_proxy_get_mode(lua_State *L)
{
	struct proxy *px;
	const char *str;

	px = hlua_check_proxy(L, 1);
	str = proxy_mode_str(px->mode);
	lua_pushstring(L, str);
	return 1;
}

int hlua_proxy_shut_bcksess(lua_State *L)
{
	struct proxy *px;

	px = hlua_check_proxy(L, 1);
	srv_shutdown_backup_streams(px, SF_ERR_KILLED);
	return 0;
}

int hlua_proxy_get_srv_act(lua_State *L)
{
	struct proxy *px;

	px = hlua_check_proxy(L, 1);
	lua_pushinteger(L, px->srv_act);
	return 1;
}

int hlua_proxy_get_srv_bck(lua_State *L)
{
	struct proxy *px;

	px = hlua_check_proxy(L, 1);
	lua_pushinteger(L, px->srv_bck);
	return 1;
}

/* Get mailers config info, used to implement email alert sending
 * according to mailers config from lua.
 */
int hlua_proxy_get_mailers(lua_State *L)
{
	struct proxy *px;
	int it;
	struct mailer *mailer;

	px = hlua_check_proxy(L, 1);

	if (!px->email_alert.mailers.m)
		return 0; /* email-alert mailers not found on proxy */

	lua_newtable(L);

	/* option log-health-checks */
	lua_pushstring(L, "track_server_health");
	lua_pushboolean(L, (px->options2 & PR_O2_LOGHCHKS));
	lua_settable(L, -3);

	/* email-alert level */
	lua_pushstring(L, "log_level");
	lua_pushinteger(L, px->email_alert.level);
	lua_settable(L, -3);

	/* email-alert mailers */
	lua_pushstring(L, "mailservers");
	lua_newtable(L);
	for (it = 0, mailer = px->email_alert.mailers.m->mailer_list;
	     it < px->email_alert.mailers.m->count; it++, mailer = mailer->next) {
		char *srv_address;

		lua_pushstring(L, mailer->id);

		/* For now, we depend on mailer->addr to restore mailer's address which
		 * was converted using str2sa_range() on startup.
		 *
		 * FIXME?:
		 * It could be a good idea to pass the raw address (unparsed) to allow fqdn
		 * to be resolved at runtime, unless we consider this as a pure legacy mode
		 * and mailers config support is going to be removed in the future?
		 */
		srv_address = sa2str(&mailer->addr, get_host_port(&mailer->addr), 0);
		if (srv_address) {
			lua_pushstring(L, srv_address);
			ha_free(&srv_address);
			lua_settable(L, -3);
		}
	}
	lua_settable(L, -3);

	/* email-alert myhostname */
	lua_pushstring(L, "smtp_hostname");
	lua_pushstring(L, px->email_alert.myhostname);
	lua_settable(L, -3);

	/* email-alert from */
	lua_pushstring(L, "smtp_from");
	lua_pushstring(L, px->email_alert.from);
	lua_settable(L, -3);

	/* email-alert to */
	lua_pushstring(L, "smtp_to");
	lua_pushstring(L, px->email_alert.to);
	lua_settable(L, -3);

	return 1;
}

int hlua_fcn_new_proxy(lua_State *L, struct proxy *px)
{
	struct listener *lst;
	int lid;
	char buffer[17];

	lua_newtable(L);

	/* Pop a class proxy metatable and affect it to the userdata. */
	lua_rawgeti(L, LUA_REGISTRYINDEX, class_proxy_ref);
	lua_setmetatable(L, -2);

	lua_pushlightuserdata(L, px);
	lua_rawseti(L, -2, 0);

	/* set public methods */
	hlua_class_function(L, "get_name", hlua_proxy_get_name);
	hlua_class_function(L, "get_uuid", hlua_proxy_get_uuid);
	hlua_class_function(L, "pause", hlua_proxy_pause);
	hlua_class_function(L, "resume", hlua_proxy_resume);
	hlua_class_function(L, "stop", hlua_proxy_stop);
	hlua_class_function(L, "shut_bcksess", hlua_proxy_shut_bcksess);
	hlua_class_function(L, "get_cap", hlua_proxy_get_cap);
	hlua_class_function(L, "get_mode", hlua_proxy_get_mode);
	hlua_class_function(L, "get_srv_act", hlua_proxy_get_srv_act);
	hlua_class_function(L, "get_srv_bck", hlua_proxy_get_srv_bck);
	hlua_class_function(L, "get_stats", hlua_proxy_get_stats);
	hlua_class_function(L, "get_mailers", hlua_proxy_get_mailers);

	/* Browse and register servers. */
	lua_pushstring(L, "servers");
	hlua_listable_servers(L, px);
	lua_settable(L, -3);

	/* Browse and register listeners. */
	lua_pushstring(L, "listeners");
	lua_newtable(L);
	lid = 1;
	list_for_each_entry(lst, &px->conf.listeners, by_fe) {
		if (lst->name)
			lua_pushstring(L, lst->name);
		else {
			snprintf(buffer, sizeof(buffer), "sock-%d", lid);
			lid++;
			lua_pushstring(L, buffer);
		}
		hlua_fcn_new_listener(L, lst);
		lua_settable(L, -3);
	}
	lua_settable(L, -3);

	if (px->table && px->table->id) {
		lua_pushstring(L, "stktable");
		hlua_fcn_new_stktable(L, px->table);
		lua_settable(L, -3);
	}

	return 1;
}

static struct hlua_proxy_list *hlua_check_proxy_list(lua_State *L, int ud)
{
	return hlua_checkudata(L, ud, class_proxy_list_ref);
}

/* does nothing and returns 0, only prevents insertions in the
 * table which represent list of proxies
 */
int hlua_listable_proxies_newindex(lua_State *L) {
	return 0;
}

/* first arg is the table (struct hlua_proxy_list * in metadata)
 * second arg is the required index
 */
int hlua_listable_proxies_index(lua_State *L)
{
	struct hlua_proxy_list *hlua_px;
	const char *name;
	struct proxy *px;

	hlua_px = hlua_check_proxy_list(L, 1);
	name = luaL_checkstring(L, 2);

	px = NULL;
	if (hlua_px->capabilities & PR_CAP_FE) {
		px = proxy_find_by_name(name, PR_CAP_FE, 0);
	}
	if (!px && hlua_px->capabilities & PR_CAP_BE) {
		px = proxy_find_by_name(name, PR_CAP_BE, 0);
	}
	if (px == NULL) {
		lua_pushnil(L);
		return 1;
	}

	hlua_fcn_new_proxy(L, px);
	return 1;
}

static inline int hlua_listable_proxies_match(struct proxy *px, char cap) {
	return ((px->cap & cap) && !(px->cap & (PR_CAP_DEF | PR_CAP_INT)));
}

/* iterator must return key as string and value as proxy
 * object, if we reach end of list, it returns nil
 */
int hlua_listable_proxies_pairs_iterator(lua_State *L)
{
	int context_index;
	struct hlua_proxy_list_iterator_context *ctx;

	context_index = lua_upvalueindex(1);
	ctx = lua_touserdata(L, context_index);

	if (ctx->next == NULL) {
		lua_pushnil(L);
		return 1;
	}

	lua_pushstring(L, ctx->next->id);
	hlua_fcn_new_proxy(L, ctx->next);

	for (ctx->next = ctx->next->next;
	     ctx->next && !hlua_listable_proxies_match(ctx->next, ctx->capabilities);
	     ctx->next = ctx->next->next);

	return 2;
}

/* init the iterator context, return iterator function
 * with context as closure. The only argument is a
 * proxy object.
 */
int hlua_listable_proxies_pairs(lua_State *L)
{
	struct hlua_proxy_list_iterator_context *ctx;
	struct hlua_proxy_list *hlua_px;

	hlua_px = hlua_check_proxy_list(L, 1);

	ctx = lua_newuserdata(L, sizeof(*ctx));

	ctx->capabilities = hlua_px->capabilities;
	for (ctx->next = proxies_list;
	     ctx->next && !hlua_listable_proxies_match(ctx->next, ctx->capabilities);
	     ctx->next = ctx->next->next);
	lua_pushcclosure(L, hlua_listable_proxies_pairs_iterator, 1);
	return 1;
}

void hlua_listable_proxies(lua_State *L, char capabilities)
{
	struct hlua_proxy_list *list;

	lua_newtable(L);
	list = lua_newuserdata(L, sizeof(*list));
	list->capabilities = capabilities;
	lua_rawseti(L, -2, 0);
	lua_rawgeti(L, LUA_REGISTRYINDEX, class_proxy_list_ref);
	lua_setmetatable(L, -2);
}

int hlua_event_sub_unsub(lua_State *L)
{
	struct event_hdl_sub *sub = hlua_checkudata(L, 1, class_event_sub_ref);

	BUG_ON(!sub);
	event_hdl_take(sub); /* keep a reference on sub until the item is GCed */
	event_hdl_unsubscribe(sub); /* will automatically call event_hdl_drop() */
	return 0;
}

int hlua_event_sub_gc(lua_State *L)
{
	struct event_hdl_sub *sub = hlua_checkudata(L, 1, class_event_sub_ref);

	BUG_ON(!sub);
	event_hdl_drop(sub); /* final drop of the reference */
	return 0;
}

int hlua_fcn_new_event_sub(lua_State *L, struct event_hdl_sub *sub)
{
	lua_newtable(L);

	/* Pop a class event_sub metatable and affect it to the userdata. */
	lua_rawgeti(L, LUA_REGISTRYINDEX, class_event_sub_ref);
	lua_setmetatable(L, -2);

	lua_pushlightuserdata(L, sub);
	lua_rawseti(L, -2, 0);

	/* userdata is affected: increment sub refcount */
	event_hdl_take(sub);

	/* set public methods */
	hlua_class_function(L, "unsub", hlua_event_sub_unsub);

	return 1;
}

/* This Lua function take a string, a list of separators.
 * It tokenize the input string using the list of separators
 * as separator.
 *
 * The functionreturns a table filled with tokens.
 */
int hlua_tokenize(lua_State *L)
{
	const char *str;
	const char *sep;
	int index;
	const char *token;
	const char *p;
	const char *c;
	int ignore_empty;

	ignore_empty = 0;

	str = luaL_checkstring(L, 1);
	sep = luaL_checkstring(L, 2);
	if (lua_gettop(L) == 3)
		ignore_empty = hlua_checkboolean(L, 3);

	lua_newtable(L);
	index = 1;
	token = str;
	p = str;
	while(1) {
		for (c = sep; *c != '\0'; c++)
			if (*p == *c)
				break;
		if (*p == *c) {
			if ((!ignore_empty) || (p - token > 0)) {
				lua_pushlstring(L, token, p - token);
				lua_rawseti(L, -2, index);
				index++;
			}
			token = p + 1;
		}
		if (*p == '\0')
			break;
		p++;
	}

	return 1;
}

int hlua_parse_addr(lua_State *L)
{
	struct net_addr *addr;
	const char *str = luaL_checkstring(L, 1);
	unsigned char mask;

	addr = lua_newuserdata(L, sizeof(struct net_addr));
	if (!addr) {
		lua_pushnil(L);
		return 1;
	}

	if (str2net(str, PAT_MF_NO_DNS, &addr->addr.v4.ip, &addr->addr.v4.mask)) {
		addr->family = AF_INET;
		return 1;
	}

	if (str62net(str, &addr->addr.v6.ip, &mask)) {
		len2mask6(mask, &addr->addr.v6.mask);
		addr->family = AF_INET6;
		return 1;
	}

	lua_pop(L, 1);
	lua_pushnil(L);
	return 1;
}

int hlua_match_addr(lua_State *L)
{
	struct net_addr *addr1;
	struct net_addr *addr2;

	if (!lua_isuserdata(L, 1) ||
	    !lua_isuserdata(L, 2)) {
		lua_pushboolean(L, 0);
		return 1;
	}

	addr1 = lua_touserdata(L, 1);
	addr2 = lua_touserdata(L, 2);

	if (addr1->family != addr2->family) {
		lua_pushboolean(L, 0);
		return 1;
	}

	if (addr1->family == AF_INET) {
		if ((addr1->addr.v4.ip.s_addr & addr2->addr.v4.mask.s_addr) ==
		    (addr2->addr.v4.ip.s_addr & addr1->addr.v4.mask.s_addr)) {
			lua_pushboolean(L, 1);
			return 1;
		}
	} else {
		int i;

		for (i = 0; i < 16; i += 4) {
			if ((read_u32(&addr1->addr.v6.ip.s6_addr[i]) &
			     read_u32(&addr2->addr.v6.mask.s6_addr[i])) !=
			    (read_u32(&addr2->addr.v6.ip.s6_addr[i]) &
			     read_u32(&addr1->addr.v6.mask.s6_addr[i])))
				break;
		}
		if (i == 16) {
			lua_pushboolean(L, 1);
			return 1;
		}
	}

	lua_pushboolean(L, 0);
	return 1;
}

static struct my_regex **hlua_check_regex(lua_State *L, int ud)
{
	return (hlua_checkudata(L, ud, class_regex_ref));
}

static int hlua_regex_comp(struct lua_State *L)
{
	struct my_regex **regex;
	const char *str;
	int cs;
	char *err;

	str = luaL_checkstring(L, 1);
	luaL_argcheck(L, lua_isboolean(L, 2), 2, NULL);
	cs = lua_toboolean(L, 2);

	regex = lua_newuserdata(L, sizeof(*regex));

	err = NULL;
	if (!(*regex = regex_comp(str, cs, 1, &err))) {
		lua_pushboolean(L, 0); /* status error */
		lua_pushstring(L, err); /* Reason */
		free(err);
		return 2;
	}

	lua_pushboolean(L, 1); /* Status ok */

	/* Create object */
	lua_newtable(L);
	lua_pushvalue(L, -3); /* Get the userdata pointer. */
	lua_rawseti(L, -2, 0);
	lua_rawgeti(L, LUA_REGISTRYINDEX, class_regex_ref);
	lua_setmetatable(L, -2);
	return 2;
}

static int hlua_regex_exec(struct lua_State *L)
{
	struct my_regex **regex;
	const char *str;
	size_t len;
	struct buffer *tmp;

	regex = hlua_check_regex(L, 1);
	str = luaL_checklstring(L, 2, &len);

	if (!*regex) {
		lua_pushboolean(L, 0);
		return 1;
	}

	/* Copy the string because regex_exec2 require a 'char *'
	 * and not a 'const char *'.
	 */
	tmp = get_trash_chunk();
	if (len >= tmp->size) {
		lua_pushboolean(L, 0);
		return 1;
	}
	memcpy(tmp->area, str, len);

	lua_pushboolean(L, regex_exec2(*regex, tmp->area, len));

	return 1;
}

static int hlua_regex_match(struct lua_State *L)
{
	struct my_regex **regex;
	const char *str;
	size_t len;
	regmatch_t pmatch[20];
	int ret;
	int i;
	struct buffer *tmp;

	regex = hlua_check_regex(L, 1);
	str = luaL_checklstring(L, 2, &len);

	if (!*regex) {
		lua_pushboolean(L, 0);
		return 1;
	}

	/* Copy the string because regex_exec2 require a 'char *'
	 * and not a 'const char *'.
	 */
	tmp = get_trash_chunk();
	if (len >= tmp->size) {
		lua_pushboolean(L, 0);
		return 1;
	}
	memcpy(tmp->area, str, len);

	ret = regex_exec_match2(*regex, tmp->area, len, 20, pmatch, 0);
	lua_pushboolean(L, ret);
	lua_newtable(L);
	if (ret) {
		for (i = 0; i < 20 && pmatch[i].rm_so != -1; i++) {
			lua_pushlstring(L, str + pmatch[i].rm_so, pmatch[i].rm_eo - pmatch[i].rm_so);
			lua_rawseti(L, -2, i + 1);
		}
	}
	return 2;
}

static int hlua_regex_free(struct lua_State *L)
{
	struct my_regex **regex;

	regex = hlua_check_regex(L, 1);
	regex_free(*regex);
	*regex = NULL;
	return 0;
}

void hlua_fcn_reg_core_fcn(lua_State *L)
{
	hlua_concat_init(L);
	hlua_queue_init(L);

	hlua_class_function(L, "now", hlua_now);
	hlua_class_function(L, "http_date", hlua_http_date);
	hlua_class_function(L, "imf_date", hlua_imf_date);
	hlua_class_function(L, "rfc850_date", hlua_rfc850_date);
	hlua_class_function(L, "asctime_date", hlua_asctime_date);
	hlua_class_function(L, "concat", hlua_concat_new);
	hlua_class_function(L, "queue", hlua_queue_new);
	hlua_class_function(L, "get_info", hlua_get_info);
	hlua_class_function(L, "parse_addr", hlua_parse_addr);
	hlua_class_function(L, "match_addr", hlua_match_addr);
	hlua_class_function(L, "tokenize", hlua_tokenize);

	/* Create regex object. */
	lua_newtable(L);
	hlua_class_function(L, "new", hlua_regex_comp);

	lua_newtable(L); /* The metatable. */
	lua_pushstring(L, "__index");
	lua_newtable(L);
	hlua_class_function(L, "exec", hlua_regex_exec);
	hlua_class_function(L, "match", hlua_regex_match);
	lua_rawset(L, -3); /* -> META["__index"] = TABLE */
	hlua_class_function(L, "__gc", hlua_regex_free);

	lua_pushvalue(L, -1); /* Duplicate the metatable reference. */
	class_regex_ref = hlua_register_metatable(L, CLASS_REGEX);

	lua_setmetatable(L, -2);
	lua_setglobal(L, CLASS_REGEX); /* Create global object called Regex */

	/* Create stktable object. */
	lua_newtable(L);
	lua_pushstring(L, "__index");
	lua_newtable(L);
	hlua_class_function(L, "info", hlua_stktable_info);
	hlua_class_function(L, "lookup", hlua_stktable_lookup);
	hlua_class_function(L, "dump", hlua_stktable_dump);
	lua_settable(L, -3); /* -> META["__index"] = TABLE */
	class_stktable_ref = hlua_register_metatable(L, CLASS_STKTABLE);

	/* Create listener object. */
	lua_newtable(L);
	lua_pushstring(L, "__index");
	lua_newtable(L);
	hlua_class_function(L, "get_stats", hlua_listener_get_stats);
	lua_settable(L, -3); /* -> META["__index"] = TABLE */
	class_listener_ref = hlua_register_metatable(L, CLASS_LISTENER);

	/* Create event_sub object. */
	lua_newtable(L);
	hlua_class_function(L, "__gc", hlua_event_sub_gc);
	class_event_sub_ref = hlua_register_metatable(L, CLASS_EVENT_SUB);

	/* Create server object. */
	lua_newtable(L);
	hlua_class_function(L, "__gc", hlua_server_gc);
	hlua_class_function(L, "__index", hlua_server_index);
	class_server_ref = hlua_register_metatable(L, CLASS_SERVER);

	/* Create proxy object. */
	lua_newtable(L);
	hlua_class_function(L, "__index", hlua_proxy_index);
	class_proxy_ref = hlua_register_metatable(L, CLASS_PROXY);

	/* list of proxy objects. Instead of having a static array
	 * of proxies, we use special metamethods that rely on internal
	 * proxies list so that the array is resolved at runtime.
	 *
	 * To emulate the same behavior than Lua array, we implement some
	 * metatable functions:
	 *  - __newindex : prevent the insertion of a new item in the array
	 *  - __index : find a proxy in the list using "name" index
	 *  - __pairs : iterate through available proxies in the list
	 */
	lua_newtable(L);
	hlua_class_function(L, "__index", hlua_listable_proxies_index);
	hlua_class_function(L, "__newindex", hlua_listable_proxies_newindex);
	hlua_class_function(L, "__pairs", hlua_listable_proxies_pairs);
	class_proxy_list_ref = hlua_register_metatable(L, CLASS_PROXY_LIST);

	/* Create proxies entry. */
	lua_pushstring(L, "proxies");
	hlua_listable_proxies(L, PR_CAP_LISTEN);
	lua_settable(L, -3);

	/* Create frontends entry. */
	lua_pushstring(L, "frontends");
	hlua_listable_proxies(L, PR_CAP_FE);
	lua_settable(L, -3);

	/* Create backends entry. */
	lua_pushstring(L, "backends");
	hlua_listable_proxies(L, PR_CAP_BE);
	lua_settable(L, -3);

	/* list of server. This object is similar to
	 * CLASS_PROXY_LIST
	 */
	lua_newtable(L);
	hlua_class_function(L, "__index", hlua_listable_servers_index);
	hlua_class_function(L, "__newindex", hlua_listable_servers_newindex);
	hlua_class_function(L, "__pairs", hlua_listable_servers_pairs);
	class_server_list_ref = hlua_register_metatable(L, CLASS_SERVER_LIST);
}
