]> git.sur5r.net Git - openldap/blob - libraries/libldap/apitest.c
ab183bf0b00db9c41183fa2d5dcac79da40da5d0
[openldap] / libraries / libldap / apitest.c
1 #include "portable.h"
2
3 #include <stdio.h>
4 #include <ac/time.h>
5
6 #include "lber.h"
7 #include "ldap.h"
8
9 void
10 main(int argc, char **argv)
11 {
12         LDAPAPIInfo api;
13         int ival;
14         int sval;
15
16 #ifdef LDAP_API_INFO_VERSION
17         api.ldapai_info_version = LDAP_API_INFO_VERSION;
18 #else
19         api.ldapai_info_version = 1;
20 #endif
21
22         printf("Compile time API Information\n");
23         printf("  API Info version:  %d\n", api.ldapai_info_version);
24         printf("  API version:       %d\n", LDAP_API_VERSION);
25 #ifdef LDAP_VERSION
26         printf("  Protocol Version:  %d\n", LDAP_VERSION);
27 #else
28         printf("  Protocol Version:  unknown\n");
29 #endif
30 #ifdef LDAP_VERSION_MIN
31         printf("  Protocol Min:      %d\n", LDAP_VERSION_MIN);
32 #else
33         printf("  Protocol Min:      unknown\n");
34 #endif
35 #ifdef LDAP_VERSION_MAX
36         printf("  Protocol Max:      %d\n", LDAP_VERSION_MAX);
37 #else
38         printf("  Protocol Max:      unknown\n");
39 #endif
40 #ifdef LDAP_VENDOR_NAME
41         printf("  Vendor Name:       %s\n", LDAP_VENDOR_NAME);
42 #else
43         printf("  Vendor Name:       unknown\n");
44 #endif
45 #ifdef LDAP_VENDOR_VERSION
46         printf("  Vendor Version:    %d\n", LDAP_VENDOR_VERSION);
47 #else
48         printf("  Vendor Version:    unknown\n");
49 #endif
50
51         if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) != LDAP_SUCCESS) {
52                 fprintf(stderr, "%s: ldap_get_option(api) failed", argv[0]);
53                 exit(-1);
54         }
55
56         printf("\nExecution time API Information\n");
57         printf("  API Info version:  %d\n", api.ldapai_info_version);
58
59         if (api.ldapai_info_version != LDAP_API_INFO_VERSION) {
60                 printf(" API INFO version mismatch!");
61                 exit(-1);
62         }
63
64         printf("  API Version:       %d\n", api.ldapai_api_version);
65         printf("  Protocol Max:      %d\n", api.ldapai_protocol_version);
66         if(api.ldapai_extensions == NULL) {
67                 printf("  Extensions:        none\n");
68         } else {
69                 int i;
70                 for(i=0; api.ldapai_extensions[i] != NULL; i++) {
71                         printf("                     %s\n",
72                                 api.ldapai_extensions[i]);
73                 }
74                 printf("  #Extensions:       %d\n", i);
75         }
76         printf("  Vendor Name:       %s\n", api.ldapai_vendor_name);
77         printf("  Vendor Version:    %d\n", api.ldapai_vendor_version);
78
79         printf("\nExecution time Default Options\n");
80
81         if(ldap_get_option(NULL, LDAP_OPT_DEREF, &ival) != LDAP_SUCCESS) {
82                 fprintf(stderr, "%s: ldap_get_option(api) failed", argv[0]);
83                 exit(-1);
84         }
85         printf("  DEREF:             %d\n", ival);
86
87         if(ldap_get_option(NULL, LDAP_OPT_SIZELIMIT, &ival) != LDAP_SUCCESS) {
88                 fprintf(stderr, "%s: ldap_get_option(sizelimit) failed", argv[0]);
89                 exit(-1);
90         }
91         printf("  SIZELIMIT:         %d\n", ival);
92
93         if(ldap_get_option(NULL, LDAP_OPT_TIMELIMIT, &ival) != LDAP_SUCCESS) {
94                 fprintf(stderr, "%s: ldap_get_option(timelimit) failed", argv[0]);
95                 exit(-1);
96         }
97         printf("  TIMELIMIT:         %d\n", ival);
98 }