*** empty log message ***

This commit is contained in:
eknauel 2003-10-28 15:27:54 +00:00
commit a25a3daae0
4 changed files with 232 additions and 0 deletions

28
.gitignore vendored Normal file
View File

@ -0,0 +1,28 @@
# CVS default ignores begin
tags
TAGS
.make.state
.nse_depinfo
*~
\#*
.#*
,*
_$*
*$
*.old
*.bak
*.BAK
*.orig
*.rej
.del-*
*.a
*.olb
*.o
*.obj
*.so
*.exe
*.Z
*.elc
*.ln
core
# CVS default ignores end

126
c/ldap.c Normal file
View File

@ -0,0 +1,126 @@
#include "scsh-ldap.h"
s48_value scsh_enter_ldap(LDAP *ldap)
{
s48_value rec = S48_FALSE;
S48_DECLARE_GC_PROTECT(1);
S48_GC_PROTECT_1(rec);
rec = s48_make_record(scsh_ldap_record_type);
S48_RECORD_SET(rec, 0, s48_enter_integer((long) ldap));
S48_GC_UNPROTECT();
return rec;
}
s48_value scsh_enter_ldapmessage(LDAPMessage *lm)
{
s48_value rec = S48_FALSE;
S48_DECLARE_GC_PROTECT(1);
S48_GC_PROTECT_1(rec);
rec = s48_make_record(scsh_ldapmessage_record_type);
S48_RECORD_SET(rec, 0, s48_enter_integer((long) lm));
S48_GC_UNPROTECT();
return rec;
}
s48_value scsh_ldap_open(s48_value host, s48_value port)
{
LDAP *ldap;
S48_DECLARE_GC_PROTECT(2);
S48_GC_PROTECT_2(host, port);
ldap = ldap_open(s48_extract_string(host), s48_extract_integer(port));
S48_GC_UNPROTECT();
return ldap == NULL ? S48_FALSE : scsh_enter_ldap(ldap);
}
s48_value scsh_ldap_init(s48_value host, s48_value port)
{
LDAP *ldap;
S48_DECLARE_GC_PROTECT(2);
S48_GC_PROTECT_2(host, port);
ldap = ldap_init(s48_extract_string(host), s48_extract_integer(port));
S48_GC_UNPROTECT();
return ldap == NULL ? S48_FALSE : scsh_enter_ldap(ldap);
}
s48_value scsh_ldap_bind_s(s48_value ldap, s48_value user,
s48_value cred, s48_value method)
{
int r;
S48_DECLARE_GC_PROTECT(4);
S48_GC_PROTECT_4(ldap, user, cred, method);
r = ldap_bind_s(scsh_extract_ldap(ldap), s48_extract_string(user),
s48_extract_string(cred), s48_extract_integer(method));
S48_GC_UNPROTECT();
return s48_enter_integer(r);
}
s48_value scsh_ldap_simple_bind_s(s48_value ldap, s48_value user, s48_value cred)
{
int r;
S48_DECLARE_GC_PROTECT(3);
S48_GC_PROTECT_3(ldap, user, cred);
r = ldap_simple_bind_s(scsh_extract_ldap(ldap), s48_extract_string(user),
s48_extract_string(cred));
S48_GC_UNPROTECT();
return r;
}
s48_value scsh_ldap_unbind_s(s48_value ldap)
{
return s48_enter_integer(ldap_unbind_s(scsh_extract_ldap(ldap)));
}
s48_value scsh_ldap_error_string(s48_value errcode)
{
return s48_enter_string(ldap_err2string(s48_extract_integer(errcode)));
}
s48_value scsh_ldap_result_error(s48_value ldap, s48_value res)
{
int r;
S48_DECLARE_GC_PROTECT(2);
S48_GC_PROTECT_2(ldap, res);
r = s48_enter_integer(ldap_result2error(scsh_extract_ldap(ldap),
scsh_extract_ldapmessage(res), 0));
S48_GC_UNPROTECT();
return s48_enter_integer(r);
}
s48_value scsh_ldap_memfree(s48_value ldap)
{
ldap_memfree(scsh_extract_ldap(ldap));
return S48_UNSPECIFIC;
}
s48_value scsh_ldap_msgfree(s48_value ldapmsg)
{
ldap_msgfree(scsh_extract_ldapmessage(ldapmsg));
return S48_UNSPECIFIC;
}
void scsh_ldap_main(void)
{
S48_GC_PROTECT_GLOBAL(scsh_ldap_record_type);
scsh_ldap_record_type = s48_get_imported_binding("ldap");
S48_GC_PROTECT_GLOBAL(scsh_ldapmessage_record_type);
scsh_ldapmessage_record_type = s48_get_imported_binding("ldap-message");
S48_EXPORT_FUNCTION(scsh_ldap_open);
S48_EXPORT_FUNCTION(scsh_ldap_init);
S48_EXPORT_FUNCTION(scsh_ldap_bind_s);
S48_EXPORT_FUNCTION(scsh_ldap_simple_bind_s);
S48_EXPORT_FUNCTION(scsh_ldap_unbind_s);
S48_EXPORT_FUNCTION(scsh_ldap_error_string);
S48_EXPORT_FUNCTION(scsh_ldap_result_error);
S48_EXPORT_FUNCTION(scsh_ldap_memfree);
S48_EXPORT_FUNCTION(scsh_ldap_msgfree);
}

19
c/scsh-ldap.h Normal file
View File

@ -0,0 +1,19 @@
#include "scheme48.h"
#include <stddef.h>
#include <ldap.h>
static s48_value scsh_ldap_record_type = S48_FALSE;
static s48_value scsh_ldapmessage_record_type = S48_FALSE;
s48_value scsh_enter_ldap(LDAP *ldap);
#define scsh_extract_ldap(x) \
((LDAP *) \
s48_extract_integer(S48_RECORD_REF(x, 0)))
s48_value scsh_enter_ldapmessage(LDAPMessage *lm);
#define scsh_extract_ldapmessage(x) \
((LDAPMessage *) \
s48_extract_integer(S48_RECORD_REF(x, 0)))
void scsh_ldap_main(void);

59
scheme/ldap.scm Normal file
View File

@ -0,0 +1,59 @@
(define-record-type ldap :ldap
(make-ldap c-pointer)
ldap?
(c-pointer ldap-c-pointer))
(define-exported-binding "ldap" :ldap)
(define-record-type ldap-message :ldap-message
(make-ldap-message c-pointer)
ldap-message?
(c-pointer ldap-message-c-pointer))
(define-exported-binding "ldap-message" :ldap-message)
(define (ldap-open host port)
(let ((ldap (ldap-open-internal host port)))
(if ldap (add-finalizer! ldap ldap-memfree))
ldap))
(define (ldap-init host port)
(let ((ldap (ldap-init-internal host port)))
(if ldap (add-finalizer! ldap ldap-memfree))
ldap))
(import-lambda-definition ldap-open-internal
(host port)
"scsh_ldap_open")
(import-lambda-definition ldap-init-internal
(host port)
"scsh_ldap_init")
(import-lambda-definition ldap-bind-sync
(ldap user password method)
"scsh_ldap_bind_s")
(import-lambda-definition ldap-simple-bind-sync
(ldap user password)
"scsh_ldap_simple_bind_s")
(import-lambda-definition ldap-unbind-sync
(ldap)
"scsh_ldap_unbind_s")
(import-lambda-definition ldap-error-string
(error-code)
"scsh_ldap_error_string")
(import-lambda-definition ldap-result-error
(ldap result)
"scsh_ldap_result_error")
(import-lambda-definition ldap-memfree
(ldap)
"scsh_ldap_memfree")
(import-lambda-definition ldap-msgfree
(ldap)
"scsh_ldap_msgfree")