]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/apitest.c
* build/top.mk: removed references to TMPROOT and added DESTDIR support
[openldap] / libraries / libldap / apitest.c
index 0cb60e47a203c0c18eac0ff438cc24c6e598ec90..b14f563d4bfdf62671a2efa8d811193ba9a19f60 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 #include "portable.h"
 
+#include <ac/stdlib.h>
+
 #include <stdio.h>
-#include <stdlib.h>
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
 
 int
 main(int argc, char **argv)
@@ -64,7 +65,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 +76,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 +128,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 +163,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 +181,12 @@ 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:         <not set>");
+       }
 
        return EXIT_SUCCESS;
 }