X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fapitest.c;h=6f463c93197d71d0777da2ad77f2c2a1de7ee68d;hb=0ea43c9d7d2fbf08b2078931bebfcaf443230878;hp=0cb60e47a203c0c18eac0ff438cc24c6e598ec90;hpb=dc07e765f263ef459dcd2afd1ece01cfc85a0edd;p=openldap
diff --git a/libraries/libldap/apitest.c b/libraries/libldap/apitest.c
index 0cb60e47a2..6f463c9319 100644
--- a/libraries/libldap/apitest.c
+++ b/libraries/libldap/apitest.c
@@ -1,22 +1,30 @@
-/*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-/*
- * OpenLDAP API Test
- * Written by: Kurt Zeilenga
+/* apitest.c -- OpenLDAP API Test Program */
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 1998-2005 The OpenLDAP Foundation.
+ * Portions Copyright 1998-2003 Kurt D. Zeilenga.
+ * All rights reserved.
*
- * This program is designed to test API features of implementations
- * of the IETF draft specifications.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
*
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * .
+ */
+/* ACKNOWLEDGEMENTS:
+ * This program was orignally developed by Kurt D. Zeilenga for inclusion in
+ * OpenLDAP Software.
*/
#include "portable.h"
+#include
+
#include
-#include
-#include "lber.h"
-#include "ldap.h"
+#include
int
main(int argc, char **argv)
@@ -64,7 +72,7 @@ main(int argc, char **argv)
printf(" Protocol Max: unknown\n");
#endif
#ifdef LDAP_VENDOR_NAME
- printf(" Vendor Name: %s\n", (int) LDAP_VENDOR_NAME);
+ printf(" Vendor Name: %s\n", LDAP_VENDOR_NAME);
#else
printf(" Vendor Name: unknown\n");
#endif
@@ -75,7 +83,7 @@ main(int argc, char **argv)
#endif
if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) != LDAP_SUCCESS) {
- fprintf(stderr, "%s: ldap_get_option(api) failed\n", argv[0]);
+ fprintf(stderr, "%s: ldap_get_option(API_INFO) failed\n", argv[0]);
return EXIT_FAILURE;
}
@@ -127,10 +135,15 @@ main(int argc, char **argv)
printf(" %s\n",
api.ldapai_extensions[i]);
#endif
+
+ ldap_memfree(api.ldapai_extensions[i]);
}
+ ldap_memfree(api.ldapai_extensions);
}
printf(" Vendor Name: %s\n", api.ldapai_vendor_name);
+ ldap_memfree(api.ldapai_vendor_name);
+
printf(" Vendor Version: %d\n", api.ldapai_vendor_version);
printf("\nExecution time Default Options\n");
@@ -157,15 +170,13 @@ main(int argc, char **argv)
fprintf(stderr, "%s: ldap_get_option(referrals) failed\n", argv[0]);
return EXIT_FAILURE;
}
- printf(" REFERRALS: %s\n",
- ival == (int) LDAP_OPT_ON ? "on" : "off");
+ printf(" REFERRALS: %s\n", ival ? "on" : "off");
if(ldap_get_option(NULL, LDAP_OPT_RESTART, &ival) != LDAP_SUCCESS) {
fprintf(stderr, "%s: ldap_get_option(restart) failed\n", argv[0]);
return EXIT_FAILURE;
}
- printf(" RESTART: %s\n",
- ival == (int) LDAP_OPT_ON ? "on" : "off");
+ printf(" RESTART: %s\n", ival ? "on" : "off");
if(ldap_get_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ival) != LDAP_SUCCESS) {
fprintf(stderr, "%s: ldap_get_option(protocol version) failed\n", argv[0]);
@@ -177,7 +188,54 @@ main(int argc, char **argv)
fprintf(stderr, "%s: ldap_get_option(host name) failed\n", argv[0]);
return EXIT_FAILURE;
}
- printf(" HOST NAME: %s\n", sval);
+ if( sval != NULL ) {
+ printf(" HOST NAME: %s\n", sval);
+ ldap_memfree(sval);
+ } else {
+ puts(" HOST NAME: ");
+ }
+
+#if 0
+ /* API tests */
+ { /* bindless unbind */
+ LDAP *ld;
+ int rc;
+
+ ld = ldap_init( "localhost", 389 );
+ if( ld == NULL ) {
+ perror("ldap_init");
+ return EXIT_FAILURE;
+ }
+
+ rc = ldap_unbind( ld );
+ if( rc != LDAP_SUCCESS ) {
+ perror("ldap_unbind");
+ return EXIT_FAILURE;
+ }
+ }
+ { /* bindless unbind */
+ LDAP *ld;
+ int rc;
+
+ ld = ldap_init( "localhost", 389 );
+ if( ld == NULL ) {
+ perror("ldap_init");
+ return EXIT_FAILURE;
+ }
+
+ rc = ldap_abandon_ext( ld, 0, NULL, NULL );
+ if( rc != LDAP_SERVER_DOWN ) {
+ ldap_perror( ld, "ldap_abandon");
+ return EXIT_FAILURE;
+ }
+
+ rc = ldap_unbind( ld );
+ if( rc != LDAP_SUCCESS ) {
+ perror("ldap_unbind");
+ return EXIT_FAILURE;
+ }
+ }
+#endif
return EXIT_SUCCESS;
}