/* ** Perform a search operation. ** @return #1 Function to iterate over the result entries. ** @return #2 nil. ** @return #3 nil as first entry. ** The search result is defined as an upvalue of the iterator. */ static int lualdap_search (lua_State *L) { conn_data *conn = getconnection (L); ldap_pchar_t base; ldap_pchar_t filter; char *attrs[LUALDAP_MAX_ATTRS]; int scope, attrsonly, msgid, rc, sizelimit; struct timeval st, *timeout; if (!lua_istable (L, 2)) return luaL_error (L, LUALDAP_PREFIX"no search specification"); if (!get_attrs_param (L, attrs)) return 2; /* get other parameters */ attrsonly = booltabparam (L, "attrsonly", 0); base = (ldap_pchar_t) strtabparam (L, "base", NULL); filter = (ldap_pchar_t) strtabparam (L, "filter", NULL); scope = string2scope (L, strtabparam (L, "scope", NULL)); sizelimit = longtabparam (L, "sizelimit", LDAP_NO_LIMIT); timeout = get_timeout_param (L, &st); rc = ldap_search_ext (conn->ld, base, scope, filter, attrs, attrsonly, NULL, NULL, timeout, sizelimit, &msgid); if (rc != LDAP_SUCCESS) return luaL_error (L, LUALDAP_PREFIX"%s", ldap_err2string (rc)); create_search (L, 1, msgid); lua_pushcclosure (L, next_message, 1); return 1; }
static void* ui_context_cmd (int argc, char **argv, void *data) { if(argc<2){ cli_outfunf("usage: %s <contextname>",argv[0]); return data; } ui_current_scope = string2scope (argv[1]); return data; }