static void process_request(struct http_thread_env *hte) { gchar *method; XmlTag *ans; method = hte->method; if (method != NULL) { if (hte->root_tag == NULL) hte->root_tag = xml_tag_newc("request"); xml_tag_set_attr(hte->root_tag, "name", variant_new_static_string(method) ); if (mbb_func_call(method, hte->root_tag, &ans) == FALSE) ans = mbb_xml_msg(MBB_MSG_UNKNOWN_METHOD, method); } else { Variant *var; XmlTag *tag; XmlTag *xt; ans = mbb_xml_msg_ok(); xt = xml_tag_get_child(hte->root_tag, "request"); xml_tag_reorder(xt); for (; xt != NULL; xt = xt->next) { var = xml_tag_get_attr(xt, "name"); if (var == NULL) continue; method = variant_get_string(var); if (mbb_func_call(method, xt, &tag) == FALSE) tag = mbb_xml_msg(MBB_MSG_UNKNOWN_METHOD, method); else if (tag == NULL) tag = mbb_xml_msg_ok(); xml_tag_set_attr(tag, "origin", variant_new_static_string(method) ); xml_tag_add_child(ans, tag); } xml_tag_reorder(xml_tag_get_child(ans, "response")); } push_http_xml_msg(hte, ans); }
static gint c_xml_tag_get_child(lua_State *ls) { XmlTag *tag; gchar *name; arg_check(ls, 2, 2); tag = c_get_xml_tag(ls); name = (gchar *) luaL_checkstring(ls, 2); tag = xml_tag_get_child(tag, name); if (tag == NULL) lua_pushnil(ls); else lua_push_xml_tag(ls, tag); return 1; }