コード例 #1
0
ファイル: filters_lua.c プロジェクト: AlexShiLucky/lighttpd2
static int lua_filter_index(lua_State *L) {
	liFilter *f;
	const char *key;
	int i;

	if (lua_gettop(L) != 2) {
		lua_pushstring(L, "incorrect number of arguments");
		lua_error(L);
	}

	if (li_lua_metatable_index(L)) return 1;

	f = li_lua_get_filter(L, 1);
	if (!f) return 0;

	if (lua_isnumber(L, 2)) return 0;
	if (!lua_isstring(L, 2)) return 0;

	key = lua_tostring(L, 2);
	for (i = 0; filter_attribs[i].key ; i++) {
		if (0 == strcmp(key, filter_attribs[i].key)) {
			if (filter_attribs[i].read_attr)
				return filter_attribs[i].read_attr(f, L);
			break;
		}
	}

	lua_pushstring(L, "cannot read attribute ");
	lua_pushstring(L, key);
	lua_pushstring(L, " in filter");
	lua_concat(L, 3);
	lua_error(L);

	return 0;
}
コード例 #2
0
ファイル: virtualrequest_lua.c プロジェクト: Sciumo/lighttpd2
static int lua_vrequest_index(lua_State *L) {
	liVRequest *vr;
	const char *key;
	int i;

	if (lua_gettop(L) != 2) {
		lua_pushstring(L, "incorrect number of arguments");
		lua_error(L);
	}

	if (li_lua_metatable_index(L)) return 1;

	vr = li_lua_get_vrequest(L, 1);
	if (!vr) return 0;

	if (lua_isnumber(L, 2)) return 0;
	if (!lua_isstring(L, 2)) return 0;

	key = lua_tostring(L, 2);
	for (i = 0; vrequest_attribs[i].key ; i++) {
		if (0 == strcmp(key, vrequest_attribs[i].key)) {
			if (vrequest_attribs[i].read_attr)
				return vrequest_attribs[i].read_attr(vr, L);
			break;
		}
	}

	lua_pushstring(L, "cannot read attribute ");
	lua_pushstring(L, key);
	lua_pushstring(L, " in vrequest");
	lua_concat(L, 3);
	lua_error(L);

	return 0;
}
コード例 #3
0
ファイル: physical_lua.c プロジェクト: Aivaras/lighttpd2
static int lua_physical_index(lua_State *L) {
	liPhysical *phys;
	const char *key;
	int i;

	if (lua_gettop(L) != 2) {
		lua_pushstring(L, "incorrect number of arguments");
		lua_error(L);
	}

	if (li_lua_metatable_index(L)) return 1;

	phys = li_lua_get_physical(L, 1);
	if (!phys) return 0;

	if (lua_isnumber(L, 2)) return 0;
	if (!lua_isstring(L, 2)) return 0;

	key = lua_tostring(L, 2);
	for (i = 0; physical_attribs[i].key ; i++) {
		if (0 == strcmp(key, physical_attribs[i].key)) {
			if (physical_attribs[i].read_attr)
				return physical_attribs[i].read_attr(phys, L);
			break;
		}
	}

	lua_pushstring(L, "cannot read attribute ");
	lua_pushstring(L, key);
	lua_pushstring(L, " in physical");
	lua_concat(L, 3);
	lua_error(L);

	return 0;
}
コード例 #4
0
ファイル: virtualrequest_lua.c プロジェクト: Sciumo/lighttpd2
static int lua_coninfo_index(lua_State *L) {
	liConInfo *coninfo;
	const char *key;
	int i;

	if (lua_gettop(L) != 2) {
		lua_pushstring(L, "incorrect number of arguments");
		lua_error(L);
	}

	if (li_lua_metatable_index(L)) return 1;

	coninfo = li_lua_get_coninfo(L, 1);
	if (!coninfo) return 0;

	if (lua_isnumber(L, 2)) return 0;
	if (!lua_isstring(L, 2)) return 0;

	key = lua_tostring(L, 2);
	for (i = 0; coninfo_attribs[i].key ; i++) {
		if (0 == strcmp(key, coninfo_attribs[i].key)) {
			if (coninfo_attribs[i].read_attr)
				return coninfo_attribs[i].read_attr(coninfo, L);
			break;
		}
	}

	lua_pushstring(L, "cannot read attribute ");
	lua_pushstring(L, key);
	lua_pushstring(L, " in coninfo");
	lua_concat(L, 3);
	lua_error(L);

	return 0;
}
コード例 #5
0
ファイル: request_lua.c プロジェクト: Sciumo/lighttpd2
static int lua_requesturi_index(lua_State *L) {
	liRequestUri *uri;
	const char *key;
	int i;

	if (lua_gettop(L) != 2) {
		lua_pushstring(L, "incorrect number of arguments");
		lua_error(L);
	}

	if (li_lua_metatable_index(L)) return 1;

	uri = li_lua_get_requesturi(L, 1);
	if (!uri) return 0;

	if (lua_isnumber(L, 2)) return 0;
	if (!lua_isstring(L, 2)) return 0;

	key = lua_tostring(L, 2);
	for (i = 0; requesturi_attribs[i].key ; i++) {
		if (0 == strcmp(key, requesturi_attribs[i].key)) {
			if (requesturi_attribs[i].read_attr)
				return requesturi_attribs[i].read_attr(uri, L);
			break;
		}
	}

	lua_pushstring(L, "cannot read attribute ");
	lua_pushstring(L, key);
	lua_pushstring(L, " in request uri");
	lua_concat(L, 3);
	lua_error(L);

	return 0;
}