! Copyright (C) 2005, 2008 Chris Double, Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien arrays assocs classes compiler db
-hashtables io.files io.files.tmp kernel math math.parser namespaces
+hashtables io.files kernel math math.parser namespaces
prettyprint sequences strings tuples alien.c-types
continuations db.sqlite.lib db.sqlite.ffi db.tuples
-words combinators.lib db.types combinators tools.walker
+words combinators.lib db.types combinators
combinators.cleave io namespaces.lib ;
IN: db.sqlite
: with-sqlite ( path quot -- )
sqlite-db swap with-db ; inline
-: with-tmp-sqlite ( quot -- )
- ".db" [
- swap with-sqlite
- ] with-tmpfile ;
-
TUPLE: sqlite-statement ;
TUPLE: sqlite-result-set has-more? ;
-USING: alien alien.c-types io kernel ldap ldap.libldap namespaces prettyprint
-tools.test ;
+USING: alien alien.c-types io kernel ldap ldap.libldap
+namespaces prettyprint tools.test ;
+IN: ldap.tests
"void*" <c-object> "ldap://localhost:389" initialize
get-ldp LDAP_OPT_PROTOCOL_VERSION LDAP_VERSION3 <int> set-option
-[ 3 ] [
+[ 3 ] [
get-ldp LDAP_OPT_PROTOCOL_VERSION "int*" <c-object> [ get-option ] keep
*int
] unit-test
[
-get-ldp "cn=jimbob,dc=example,dc=com" "secret" [
+ get-ldp "cn=jimbob,dc=example,dc=com" "secret" [
- ! get-ldp "dc=example,dc=com" LDAP_SCOPE_ONELEVEL "(objectclass=*)" f 0
- ! "void*" <c-object> [ search-s ] keep *int .
+ ! get-ldp "dc=example,dc=com" LDAP_SCOPE_ONELEVEL "(objectclass=*)" f 0
+ ! "void*" <c-object> [ search-s ] keep *int .
- [ 2 ] [
- get-ldp "dc=example,dc=com" LDAP_SCOPE_SUBTREE "(objectclass=*)" f 0
- search
- ] unit-test
+ [ 2 ] [
+ get-ldp "dc=example,dc=com" LDAP_SCOPE_SUBTREE "(objectclass=*)" f 0
+ search
+ ] unit-test
- ! get-ldp LDAP_RES_ANY 0 f "void*" <c-object> result .
+ ! get-ldp LDAP_RES_ANY 0 f "void*" <c-object> result .
- get-ldp LDAP_RES_ANY LDAP_MSG_ALL f "void*" <c-object> result
+ get-ldp LDAP_RES_ANY LDAP_MSG_ALL f "void*" <c-object> result
- ! get-message *int .
+ ! get-message *int .
- "Message ID: " write
+ "Message ID: " write
- get-message msgid .
+ get-message msgid .
- get-ldp get-message get-dn .
+ get-ldp get-message get-dn .
- "Entries count: " write
+ "Entries count: " write
- get-ldp get-message count-entries .
+ get-ldp get-message count-entries .
- SYMBOL: entry
- SYMBOL: attr
+ SYMBOL: entry
+ SYMBOL: attr
- "Attribute: " write
+ "Attribute: " write
- get-ldp get-message first-entry entry set get-ldp entry get
- "void*" <c-object> first-attribute dup . attr set
+ get-ldp get-message first-entry entry set get-ldp entry get
+ "void*" <c-object> first-attribute dup . attr set
- "Value: " write
+ "Value: " write
- get-ldp entry get attr get get-values *char* .
+ get-ldp entry get attr get get-values *char* .
- get-ldp get-message first-message msgtype result-type
+ get-ldp get-message first-message msgtype result-type
- get-ldp get-message next-message msgtype result-type
+ get-ldp get-message next-message msgtype result-type
-] with-bind
+ ] with-bind
] drop
! Based on org.gjt.sp.jedit.syntax.Token
SYMBOL: tokens
-[
- { "COMMENT1" "COMMENT2" "COMMENT3" "COMMENT4" "DIGIT" "FUNCTION" "INVALID" "KEYWORD1" "KEYWORD2" "KEYWORD3" "KEYWORD4" "LABEL" "LITERAL1" "LITERAL2" "LITERAL3" "LITERAL4" "MARKUP" "OPERATOR" "END" "NULL" } [
- create-in dup define-symbol
- dup word-name swap
- ] H{ } map>assoc tokens set-global
-] with-compilation-unit
+<<
+{ "COMMENT1" "COMMENT2" "COMMENT3" "COMMENT4" "DIGIT" "FUNCTION" "INVALID" "KEYWORD1" "KEYWORD2" "KEYWORD3" "KEYWORD4" "LABEL" "LITERAL1" "LITERAL2" "LITERAL3" "LITERAL4" "MARKUP" "OPERATOR" "END" "NULL" } [
+ create-in dup define-symbol
+ dup word-name swap
+] H{ } map>assoc tokens set-global
+>>
: string>token ( string -- id ) tokens get at ;