]> git.sur5r.net Git - openldap/blobdiff - clients/fax500/rp500.c
modify ldap_dn2ufn() to return completely typeless UFNs
[openldap] / clients / fax500 / rp500.c
index 6d5d955e060e855ee1cd4a0d8327675824623a34..9ac3b3f8ffc3e7cde3c57478c48322cd23a68a9f 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1990 Regents of the University of Michigan.
  * All rights reserved.
 
 #include "portable.h"
 
-#include <stdlib.h>
+#include <stdio.h>
 
+#include <ac/stdlib.h>
+
+#include <ac/ctype.h>
 #include <ac/signal.h>
 #include <ac/socket.h>
 #include <ac/string.h>
 #include <sys/resource.h>
 #endif
 
-#include <lber.h>
 #include <ldap.h>
 
 #include "fax500.h"
-
-#include <ldapconfig.h>
+#include "ldap_defaults.h"
 
 #define DEFAULT_PORT           79
 #define DEFAULT_SIZELIMIT      50
@@ -108,8 +110,12 @@ main( int argc, char **argv )
                exit( -1 );
        }
 
-       if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
-               perror( "ldap_open" );
+#ifdef SIGPIPE
+       (void) SIGNAL( SIGPIPE, SIG_IGN );
+#endif
+
+       if ( (ld = ldap_init( ldaphost, 0 )) == NULL ) {
+               perror( "ldap_init" );
                exit( -1 );
        }
 
@@ -182,7 +188,7 @@ main( int argc, char **argv )
                                cn = ldap_get_values( ld, e, "cn" );
                                for ( i = 0; cn[i] != NULL; i++ ) {
                                        last = strlen( cn[i] ) - 1;
-                                       if ( isdigit( cn[i][last] ) ) {
+                                       if ( isdigit((unsigned char) cn[i][last]) ) {
                                                rdn = strdup( cn[i] );
                                                break;
                                        }
@@ -212,7 +218,7 @@ main( int argc, char **argv )
 
                if ( fgets( buf, sizeof(buf), stdin ) == NULL
                    || buf[0] == '\n' ) {
-                       exit( 1 );
+                       exit( EXIT_FAILURE );
                }
                i = atoi( buf ) - 1;
                e = ldap_first_entry( ld, result );
@@ -221,13 +227,13 @@ main( int argc, char **argv )
                }
                if ( e == NULL ) {
                        fprintf( stderr, "Invalid choice!\n" );
-                       exit( 1 );
+                       exit( EXIT_FAILURE );
                }
 
                print_entry( ld, e );
        } else if ( matches == 0 ) {
                fprintf( stderr, "No matches found for \"%s\"\n", key );
-               exit( 1 );
+               exit( EXIT_FAILURE );
        } else {
                fprintf( stderr, "Error return from ldap_count_entries\n" );
                exit( -1 );
@@ -253,7 +259,7 @@ print_entry( LDAP *ld, LDAPMessage *e )
        if ( (fax = ldap_get_values( ld, e, "facsimileTelephoneNumber" ))
            == NULL ) {
                fprintf( stderr, "Entry \"%s\" has no fax number.\n", dn );
-               exit( 1 );
+               exit( EXIT_FAILURE );
        }
        faxmail = faxtotpc( fax[0], NULL );
        title = ldap_get_values( ld, e, "title" );