comparison src/eldap.c @ 440:8de8e3f6228a r21-2-28

Import from CVS: tag r21-2-28
author cvs
date Mon, 13 Aug 2007 11:33:38 +0200
parents 3ecd8885ac67
children abe6d1db359e
comparison
equal deleted inserted replaced
439:357dd071b03c 440:8de8e3f6228a
87 /************************************************************************/ 87 /************************************************************************/
88 /* ldap lrecord basic functions */ 88 /* ldap lrecord basic functions */
89 /************************************************************************/ 89 /************************************************************************/
90 90
91 static Lisp_Object 91 static Lisp_Object
92 make_ldap (struct Lisp_LDAP *ldap) 92 make_ldap (Lisp_LDAP *ldap)
93 { 93 {
94 Lisp_Object lisp_ldap; 94 Lisp_Object lisp_ldap;
95 XSETLDAP (lisp_ldap, ldap); 95 XSETLDAP (lisp_ldap, ldap);
96 return lisp_ldap; 96 return lisp_ldap;
97 } 97 }
105 static void 105 static void
106 print_ldap (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) 106 print_ldap (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
107 { 107 {
108 char buf[32]; 108 char buf[32];
109 109
110 struct Lisp_LDAP *ldap = XLDAP (obj); 110 Lisp_LDAP *ldap = XLDAP (obj);
111 111
112 if (print_readably) 112 if (print_readably)
113 error ("printing unreadable object #<ldap %s>", 113 error ("printing unreadable object #<ldap %s>",
114 XSTRING_DATA (ldap->host)); 114 XSTRING_DATA (ldap->host));
115 115
119 write_c_string ("(dead) ",printcharfun); 119 write_c_string ("(dead) ",printcharfun);
120 sprintf (buf, " 0x%x>", (unsigned int)ldap); 120 sprintf (buf, " 0x%x>", (unsigned int)ldap);
121 write_c_string (buf, printcharfun); 121 write_c_string (buf, printcharfun);
122 } 122 }
123 123
124 static struct Lisp_LDAP * 124 static Lisp_LDAP *
125 allocate_ldap (void) 125 allocate_ldap (void)
126 { 126 {
127 struct Lisp_LDAP *ldap = 127 Lisp_LDAP *ldap = alloc_lcrecord_type (Lisp_LDAP, &lrecord_ldap);
128 alloc_lcrecord_type (struct Lisp_LDAP, &lrecord_ldap);
129 128
130 ldap->ld = NULL; 129 ldap->ld = NULL;
131 ldap->host = Qnil; 130 ldap->host = Qnil;
132 return ldap; 131 return ldap;
133 } 132 }
134 133
135 static void 134 static void
136 finalize_ldap (void *header, int for_disksave) 135 finalize_ldap (void *header, int for_disksave)
137 { 136 {
138 struct Lisp_LDAP *ldap = (struct Lisp_LDAP *) header; 137 Lisp_LDAP *ldap = (Lisp_LDAP *) header;
139 138
140 if (for_disksave) 139 if (for_disksave)
141 signal_simple_error ("Can't dump an emacs containing LDAP objects", 140 signal_simple_error ("Can't dump an emacs containing LDAP objects",
142 make_ldap (ldap)); 141 make_ldap (ldap));
143 142
146 ldap->ld = NULL; 145 ldap->ld = NULL;
147 } 146 }
148 147
149 DEFINE_LRECORD_IMPLEMENTATION ("ldap", ldap, 148 DEFINE_LRECORD_IMPLEMENTATION ("ldap", ldap,
150 mark_ldap, print_ldap, finalize_ldap, 149 mark_ldap, print_ldap, finalize_ldap,
151 NULL, NULL, 0, struct Lisp_LDAP); 150 NULL, NULL, 0, Lisp_LDAP);
152 151
153 152
154 153
155 154
156 /************************************************************************/ 155 /************************************************************************/
203 `sizelimit' is the maximum number of matches to return. 202 `sizelimit' is the maximum number of matches to return.
204 */ 203 */
205 (host, plist)) 204 (host, plist))
206 { 205 {
207 /* This function can GC */ 206 /* This function can GC */
208 struct Lisp_LDAP *ldap; 207 Lisp_LDAP *ldap;
209 LDAP *ld; 208 LDAP *ld;
210 int ldap_port = 0; 209 int ldap_port = 0;
211 int ldap_auth = LDAP_AUTH_SIMPLE; 210 int ldap_auth = LDAP_AUTH_SIMPLE;
212 char *ldap_binddn = NULL; 211 char *ldap_binddn = NULL;
213 char *ldap_passwd = NULL; 212 char *ldap_passwd = NULL;
246 } 245 }
247 /* Bind DN */ 246 /* Bind DN */
248 else if (EQ (keyword, Qbinddn)) 247 else if (EQ (keyword, Qbinddn))
249 { 248 {
250 CHECK_STRING (value); 249 CHECK_STRING (value);
251 GET_C_STRING_OS_DATA_ALLOCA (value, ldap_binddn); 250 TO_EXTERNAL_FORMAT (LISP_STRING, value,
251 C_STRING_ALLOCA, ldap_binddn,
252 Qnative);
252 } 253 }
253 /* Password */ 254 /* Password */
254 else if (EQ (keyword, Qpasswd)) 255 else if (EQ (keyword, Qpasswd))
255 { 256 {
256 CHECK_STRING (value); 257 CHECK_STRING (value);
257 GET_C_STRING_OS_DATA_ALLOCA (value, ldap_passwd); 258 TO_EXTERNAL_FORMAT (LISP_STRING, value,
259 C_STRING_ALLOCA, ldap_passwd,
260 Qnative);
258 } 261 }
259 /* Deref */ 262 /* Deref */
260 else if (EQ (keyword, Qderef)) 263 else if (EQ (keyword, Qderef))
261 { 264 {
262 if (EQ (value, Qnever)) 265 if (EQ (value, Qnever))
344 DEFUN ("ldap-close", Fldap_close, 1, 1, 0, /* 347 DEFUN ("ldap-close", Fldap_close, 1, 1, 0, /*
345 Close an LDAP connection. 348 Close an LDAP connection.
346 */ 349 */
347 (ldap)) 350 (ldap))
348 { 351 {
349 struct Lisp_LDAP *lldap; 352 Lisp_LDAP *lldap;
350 CHECK_LIVE_LDAP (ldap); 353 CHECK_LIVE_LDAP (ldap);
351 lldap = XLDAP (ldap); 354 lldap = XLDAP (ldap);
352 ldap_unbind (lldap->ld); 355 ldap_unbind (lldap->ld);
353 lldap->ld = NULL; 356 lldap->ld = NULL;
354 return Qnil; 357 return Qnil;
461 i = 0; 464 i = 0;
462 EXTERNAL_LIST_LOOP (attrs, attrs) 465 EXTERNAL_LIST_LOOP (attrs, attrs)
463 { 466 {
464 Lisp_Object current = XCAR (attrs); 467 Lisp_Object current = XCAR (attrs);
465 CHECK_STRING (current); 468 CHECK_STRING (current);
466 GET_C_STRING_OS_DATA_ALLOCA (current, ldap_attributes[i]); 469 TO_EXTERNAL_FORMAT (LISP_STRING, current,
470 C_STRING_ALLOCA, ldap_attributes[i],
471 Qnative);
467 ++i; 472 ++i;
468 } 473 }
469 ldap_attributes[i] = NULL; 474 ldap_attributes[i] = NULL;
470 } 475 }
471 476
510 if (! NILP (withdn)) 515 if (! NILP (withdn))
511 { 516 {
512 dn = ldap_get_dn (ld, e); 517 dn = ldap_get_dn (ld, e);
513 if (dn == NULL) 518 if (dn == NULL)
514 signal_ldap_error (ld, e, 0); 519 signal_ldap_error (ld, e, 0);
515 entry = Fcons (build_ext_string (dn, FORMAT_OS), Qnil); 520 entry = Fcons (build_ext_string (dn, Qnative), Qnil);
516 } 521 }
517 for (a= ldap_first_attribute (ld, e, &ptr); 522 for (a= ldap_first_attribute (ld, e, &ptr);
518 a != NULL; 523 a != NULL;
519 a = ldap_next_attribute (ld, e, ptr) ) 524 a = ldap_next_attribute (ld, e, ptr) )
520 { 525 {
521 list = Fcons (build_ext_string (a, FORMAT_OS), Qnil); 526 list = Fcons (build_ext_string (a, Qnative), Qnil);
522 unwind.vals = ldap_get_values_len (ld, e, a); 527 unwind.vals = ldap_get_values_len (ld, e, a);
523 if (unwind.vals != NULL) 528 if (unwind.vals != NULL)
524 { 529 {
525 for (i = 0; unwind.vals[i] != NULL; i++) 530 for (i = 0; unwind.vals[i] != NULL; i++)
526 { 531 {
527 list = Fcons (make_ext_string (unwind.vals[i]->bv_val, 532 list = Fcons (make_ext_string (unwind.vals[i]->bv_val,
528 unwind.vals[i]->bv_len, 533 unwind.vals[i]->bv_len,
529 FORMAT_OS), 534 Qnative),
530 list); 535 list);
531 } 536 }
532 } 537 }
533 entry = Fcons (Fnreverse (list), 538 entry = Fcons (Fnreverse (list),
534 entry); 539 entry);