diff options
| author | David M. Syzdek <syzdek@bindlebinaries.com> | 2017-01-14 13:23:34 -0900 |
|---|---|---|
| committer | David M. Syzdek <syzdek@bindlebinaries.com> | 2017-01-14 13:23:34 -0900 |
| commit | 6f3ba5f58ca2ffb344387c0d030b830340e37a4b (patch) | |
| tree | 6e0538698f923cc0f9840f81849e244f617c3c5e /tests | |
| parent | f17c521125374c4fc3d7264421accd2dbb0c08d4 (diff) | |
| download | ldap-utils-6f3ba5f58ca2ffb344387c0d030b830340e37a4b.tar.gz ldap-utils-6f3ba5f58ca2ffb344387c0d030b830340e37a4b.tar.bz2 ldap-utils-6f3ba5f58ca2ffb344387c0d030b830340e37a4b.tar.xz ldap-utils-6f3ba5f58ca2ffb344387c0d030b830340e37a4b.zip | |
Committing uncommitted changes in order to start significant refactoring
Renewing interest in the project after a hiatus. I plan on refactoring the
code in order to simplify the configuration options and to rely more heavily
on libldap's built in config parsing and global option support.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ldaptest.c | 47 | ||||
| -rw-r--r-- | tests/readline.c | 30 |
2 files changed, 77 insertions, 0 deletions
diff --git a/tests/ldaptest.c b/tests/ldaptest.c new file mode 100644 index 0000000..70d9723 --- /dev/null +++ b/tests/ldaptest.c | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | |||
| 2 | #include <stdio.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | #include <ldap.h> | ||
| 5 | |||
| 6 | int main(void); | ||
| 7 | int main(void) | ||
| 8 | { | ||
| 9 | int opt; | ||
| 10 | int lerr; | ||
| 11 | int count; | ||
| 12 | LDAP * ld; | ||
| 13 | LDAPMessage * res; | ||
| 14 | //LDAPMessage * entry; | ||
| 15 | |||
| 16 | printf("running: ldap_initialize()\n"); | ||
| 17 | if (ldap_initialize(&ld, NULL)) | ||
| 18 | { | ||
| 19 | perror("ldap_initialize()"); | ||
| 20 | return(1); | ||
| 21 | }; | ||
| 22 | |||
| 23 | opt = 0xffff; | ||
| 24 | ldap_set_option(ld, LDAP_OPT_DEBUG_LEVEL, &opt); | ||
| 25 | |||
| 26 | printf("running: ldap_search_ext_s()\n"); | ||
| 27 | if ((lerr = ldap_search_ext_s(ld, NULL, LDAP_SCOPE_SUB, "(mail=syzdek@mosquitonet.com)", NULL, 0, NULL, NULL, NULL, -1, &res))) | ||
| 28 | { | ||
| 29 | fprintf(stderr, "ldap_search_ext_s(): %s\n", ldap_err2string(lerr)); | ||
| 30 | ldap_unbind_ext_s(ld, NULL, NULL); | ||
| 31 | return(1); | ||
| 32 | }; | ||
| 33 | |||
| 34 | printf("running: ldap_count_entries()\n"); | ||
| 35 | if (!(count = ldap_count_entries(ld, res))) | ||
| 36 | { | ||
| 37 | ldap_msgfree(res); | ||
| 38 | ldap_unbind_ext_s(ld, NULL, NULL); | ||
| 39 | return(1); | ||
| 40 | }; | ||
| 41 | printf("# %i entries found\n", count); | ||
| 42 | |||
| 43 | printf("running: ldap_unbind_ext_s()\n"); | ||
| 44 | ldap_unbind_ext_s(ld, NULL, NULL); | ||
| 45 | |||
| 46 | return(0); | ||
| 47 | } | ||
diff --git a/tests/readline.c b/tests/readline.c new file mode 100644 index 0000000..a27de67 --- /dev/null +++ b/tests/readline.c | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | |||
| 2 | #include <stdio.h> | ||
| 3 | #include <string.h> | ||
| 4 | #include <readline/readline.h> | ||
| 5 | #include <readline/history.h> | ||
| 6 | |||
| 7 | int main(void); | ||
| 8 | |||
| 9 | int main(void) | ||
| 10 | { | ||
| 11 | char * data; | ||
| 12 | char * old; | ||
| 13 | |||
| 14 | data = strdup(""); | ||
| 15 | |||
| 16 | while(strcmp(data, "exit")) | ||
| 17 | { | ||
| 18 | old = data; | ||
| 19 | printf("Enter text [%s]: ", data); | ||
| 20 | data = readline(NULL); | ||
| 21 | if(!(strlen(data))) | ||
| 22 | data = old; | ||
| 23 | else | ||
| 24 | free(old); | ||
| 25 | printf("you typed: %s\n", data); | ||
| 26 | old = data; | ||
| 27 | }; | ||
| 28 | |||
| 29 | return(0); | ||
| 30 | } | ||
