print_internal (ldap->host, printcharfun, 1);
if (!ldap->ld)
write_c_string ("(dead) ",printcharfun);
- sprintf (buf, " 0x%x>", (unsigned int)ldap);
+ sprintf (buf, " 0x%lx>", (long)ldap);
write_c_string (buf, printcharfun);
}
int ldap_sizelimit = 0;
int err;
- Lisp_Object list, keyword, value;
-
CHECK_STRING (host);
- EXTERNAL_PROPERTY_LIST_LOOP (list, keyword, value, plist)
- {
- /* TCP Port */
- if (EQ (keyword, Qport))
- {
- CHECK_INT (value);
- ldap_port = XINT (value);
- }
- /* Authentication method */
- if (EQ (keyword, Qauth))
- {
- if (EQ (value, Qsimple))
- ldap_auth = LDAP_AUTH_SIMPLE;
+ {
+ EXTERNAL_PROPERTY_LIST_LOOP_3 (keyword, value, plist)
+ {
+ /* TCP Port */
+ if (EQ (keyword, Qport))
+ {
+ CHECK_INT (value);
+ ldap_port = XINT (value);
+ }
+ /* Authentication method */
+ if (EQ (keyword, Qauth))
+ {
+ if (EQ (value, Qsimple))
+ ldap_auth = LDAP_AUTH_SIMPLE;
#ifdef LDAP_AUTH_KRBV41
- else if (EQ (value, Qkrbv41))
- ldap_auth = LDAP_AUTH_KRBV41;
+ else if (EQ (value, Qkrbv41))
+ ldap_auth = LDAP_AUTH_KRBV41;
#endif
#ifdef LDAP_AUTH_KRBV42
- else if (EQ (value, Qkrbv42))
- ldap_auth = LDAP_AUTH_KRBV42;
+ else if (EQ (value, Qkrbv42))
+ ldap_auth = LDAP_AUTH_KRBV42;
#endif
- else
- signal_simple_error ("Invalid authentication method", value);
- }
- /* Bind DN */
- else if (EQ (keyword, Qbinddn))
- {
- CHECK_STRING (value);
- TO_EXTERNAL_FORMAT (LISP_STRING, value,
- C_STRING_ALLOCA, ldap_binddn,
- Qnative);
- }
- /* Password */
- else if (EQ (keyword, Qpasswd))
- {
- CHECK_STRING (value);
- TO_EXTERNAL_FORMAT (LISP_STRING, value,
- C_STRING_ALLOCA, ldap_passwd,
- Qnative);
- }
- /* Deref */
- else if (EQ (keyword, Qderef))
- {
- if (EQ (value, Qnever))
- ldap_deref = LDAP_DEREF_NEVER;
- else if (EQ (value, Qsearch))
- ldap_deref = LDAP_DEREF_SEARCHING;
- else if (EQ (value, Qfind))
- ldap_deref = LDAP_DEREF_FINDING;
- else if (EQ (value, Qalways))
- ldap_deref = LDAP_DEREF_ALWAYS;
- else
- signal_simple_error ("Invalid deref value", value);
- }
- /* Timelimit */
- else if (EQ (keyword, Qtimelimit))
- {
- CHECK_INT (value);
- ldap_timelimit = XINT (value);
- }
- /* Sizelimit */
- else if (EQ (keyword, Qsizelimit))
- {
- CHECK_INT (value);
- ldap_sizelimit = XINT (value);
- }
- }
+ else
+ signal_simple_error ("Invalid authentication method", value);
+ }
+ /* Bind DN */
+ else if (EQ (keyword, Qbinddn))
+ {
+ CHECK_STRING (value);
+ LISP_STRING_TO_EXTERNAL (value, ldap_binddn, Qnative);
+ }
+ /* Password */
+ else if (EQ (keyword, Qpasswd))
+ {
+ CHECK_STRING (value);
+ LISP_STRING_TO_EXTERNAL (value, ldap_passwd, Qnative);
+ }
+ /* Deref */
+ else if (EQ (keyword, Qderef))
+ {
+ if (EQ (value, Qnever))
+ ldap_deref = LDAP_DEREF_NEVER;
+ else if (EQ (value, Qsearch))
+ ldap_deref = LDAP_DEREF_SEARCHING;
+ else if (EQ (value, Qfind))
+ ldap_deref = LDAP_DEREF_FINDING;
+ else if (EQ (value, Qalways))
+ ldap_deref = LDAP_DEREF_ALWAYS;
+ else
+ signal_simple_error ("Invalid deref value", value);
+ }
+ /* Timelimit */
+ else if (EQ (keyword, Qtimelimit))
+ {
+ CHECK_INT (value);
+ ldap_timelimit = XINT (value);
+ }
+ /* Sizelimit */
+ else if (EQ (keyword, Qsizelimit))
+ {
+ CHECK_INT (value);
+ ldap_sizelimit = XINT (value);
+ }
+ }
+ }
if (ldap_port == 0)
{
/* Connect to the server and bind */
slow_down_interrupts ();
- ld = ldap_open ((char *)XSTRING_DATA (host), ldap_port);
+ ld = ldap_open ((char *) XSTRING_DATA (host), ldap_port);
speed_up_interrupts ();
if (ld == NULL )
LDAPMessage *e;
BerElement *ptr;
char *a, *dn;
- int i, rc, rc2;
+ int i, rc;
int matches;
struct ldap_unwind_struct unwind;
int speccount = specpdl_depth ();
- Lisp_Object list, entry, result;
+ Lisp_Object list = Qnil;
+ Lisp_Object entry = Qnil;
+ Lisp_Object result = Qnil;
struct gcpro gcpro1, gcpro2, gcpro3;
- list = entry = result = Qnil;
GCPRO3 (list, entry, result);
unwind.res = NULL;
{
Lisp_Object current = XCAR (attrs);
CHECK_STRING (current);
- TO_EXTERNAL_FORMAT (LISP_STRING, current,
- C_STRING_ALLOCA, ldap_attributes[i],
- Qnative);
+ LISP_STRING_TO_EXTERNAL (current, ldap_attributes[i], Qnative);
++i;
}
ldap_attributes[i] = NULL;
/* Perform the search */
if (ldap_search (ld,
- NILP (base) ? "" : (char *) XSTRING_DATA (base),
+ NILP (base) ? (char *) "" : (char *) XSTRING_DATA (base),
ldap_scope,
- NILP (filter) ? "" : (char *) XSTRING_DATA (filter),
+ NILP (filter) ? (char *) "" : (char *) XSTRING_DATA (filter),
ldap_attributes,
NILP (attrsonly) ? 0 : 1)
== -1)
{
for (i = 0; unwind.vals[i] != NULL; i++)
{
- list = Fcons (make_ext_string (unwind.vals[i]->bv_val,
+ list = Fcons (make_ext_string ((Extbyte *) unwind.vals[i]->bv_val,
unwind.vals[i]->bv_len,
Qnative),
list);
}
#if defined HAVE_LDAP_PARSE_RESULT
- rc2 = ldap_parse_result (ld, unwind.res,
- &rc,
- NULL, NULL, NULL, NULL, 0);
- if (rc2 != LDAP_SUCCESS)
- rc = rc2;
+ {
+ int rc2 = ldap_parse_result (ld, unwind.res,
+ &rc,
+ NULL, NULL, NULL, NULL, 0);
+ if (rc2 != LDAP_SUCCESS)
+ rc = rc2;
+ }
#else
if (rc == 0)
signal_ldap_error (ld, NULL, LDAP_TIMELIMIT_EXCEEDED);
struct berval *bervals;
int rc;
int i, j;
+ size_t len;
- Lisp_Object current, values;
+ Lisp_Object current = Qnil;
+ Lisp_Object values = Qnil;
struct gcpro gcpro1, gcpro2;
+
GCPRO2 (current, values);
/* Do all the parameter checking */
signal_simple_error ("Cannot add void entry", entry);
/* Build the ldap_mods array */
- ldap_mods = alloca_array (LDAPMod, XINT (Flength (entry)));
- ldap_mods_ptrs = alloca_array (LDAPMod *, 1 + XINT (Flength (entry)));
+ len = XINT (Flength (entry));
+ ldap_mods = alloca_array (LDAPMod, len);
+ ldap_mods_ptrs = alloca_array (LDAPMod *, 1 + len);
i = 0;
EXTERNAL_LIST_LOOP (entry, entry)
{
CHECK_CONS (current);
CHECK_STRING (XCAR (current));
ldap_mods_ptrs[i] = &(ldap_mods[i]);
- TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (current),
- C_STRING_ALLOCA, ldap_mods[i].mod_type,
- Qnative);
+ LISP_STRING_TO_EXTERNAL (XCAR (current), ldap_mods[i].mod_type, Qnative);
ldap_mods[i].mod_op = LDAP_MOD_ADD | LDAP_MOD_BVALUES;
values = XCDR (current);
if (CONSP (values))
{
- bervals =
- alloca_array (struct berval, XINT (Flength (values)));
+ len = XINT (Flength (values));
+ bervals = alloca_array (struct berval, len);
ldap_mods[i].mod_vals.modv_bvals =
- alloca_array (struct berval *, 1 + XINT (Flength (values)));
+ alloca_array (struct berval *, 1 + len);
j = 0;
EXTERNAL_LIST_LOOP (values, values)
{
signal_ldap_error (ld, NULL, rc);
UNGCPRO;
+ return Qnil;
}
DEFUN ("ldap-modify", Fldap_modify, 3, 3, 0, /*
A modification is a list of the form (MOD-OP ATTR VALUE1 VALUE2 ...)
MOD-OP and ATTR are mandatory, VALUEs are optional depending on MOD-OP.
MOD-OP is the type of modification, one of the symbols `add', `delete'
-or `replace'. ATTR is the LDAP attribute type to modify
+or `replace'. ATTR is the LDAP attribute type to modify.
*/
(ldap, dn, mods))
{
LDAPMod *ldap_mods, **ldap_mods_ptrs;
struct berval *bervals;
int i, j, rc;
+ Lisp_Object mod_op;
+ size_t len;
- Lisp_Object current, mod_op, values;
+ Lisp_Object current = Qnil;
+ Lisp_Object values = Qnil;
struct gcpro gcpro1, gcpro2;
- GCPRO2 (current, values);
-
/* Do all the parameter checking */
CHECK_LIVE_LDAP (ldap);
ld = XLDAP (ldap)->ld;
return Qnil;
/* Build the ldap_mods array */
- ldap_mods = alloca_array (LDAPMod, XINT (Flength (mods)));
- ldap_mods_ptrs = alloca_array (LDAPMod *, 1 + XINT (Flength (mods)));
+ len = XINT (Flength (mods));
+ ldap_mods = alloca_array (LDAPMod, len);
+ ldap_mods_ptrs = alloca_array (LDAPMod *, 1 + len);
i = 0;
+
+ GCPRO2 (current, values);
EXTERNAL_LIST_LOOP (mods, mods)
{
current = XCAR (mods);
signal_simple_error ("Invalid LDAP modification type", mod_op);
current = XCDR (current);
CHECK_STRING (XCAR (current));
- TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (current),
- C_STRING_ALLOCA, ldap_mods[i].mod_type,
- Qnative);
+ LISP_STRING_TO_EXTERNAL (XCAR (current), ldap_mods[i].mod_type, Qnative);
values = XCDR (current);
- bervals = alloca_array (struct berval, XINT (Flength (values)));
+ len = XINT (Flength (values));
+ bervals = alloca_array (struct berval, len);
ldap_mods[i].mod_vals.modv_bvals =
- alloca_array (struct berval *, 1 + XINT (Flength (values)));
+ alloca_array (struct berval *, 1 + len);
j = 0;
EXTERNAL_LIST_LOOP (values, values)
{
signal_ldap_error (ld, NULL, rc);
UNGCPRO;
+ return Qnil;
}
rc = ldap_delete_s (ld, (char *) XSTRING_DATA (dn));
if (rc != LDAP_SUCCESS)
signal_ldap_error (ld, NULL, rc);
+
+ return Qnil;
}
void