diff options
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 | } | ||
