]> git.sur5r.net Git - openldap/blobdiff - clients/ud/mod.c
Don't depend error handling on exact resultCode.
[openldap] / clients / ud / mod.c
index b0539ba79f486017d0571acfa872e6a5580625f0..a955b17161a42b375ec3dbb357e4971e39771bad 100644 (file)
@@ -1,3 +1,8 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 /*
  * Copyright (c) 1991,1993  Regents of the University of Michigan.
  * All rights reserved.
@@ -13,7 +18,8 @@
 #include "portable.h"
 
 #include <stdio.h>
-#include <stdlib.h>
+
+#include <ac/stdlib.h>
 
 #include <ac/ctype.h>
 #include <ac/string.h>
@@ -147,7 +153,7 @@ modify( char *who )
                parse_answer(mp);
                (void) ldap_msgfree(mp);
        }
-       (void) Free(dn);
+       ldap_memfree(dn);
        ldap_value_free(rdns);
        return;
 }
@@ -374,7 +380,7 @@ get_value( char *id, char *prompt )
        int count;              /* line # of new value -- if multiline */
        int multiline = 0;      /* 1 if this value is multiline */
        static char line[LINE_SIZE];    /* raw line from user */
-       static char buffer[MAX_DESC_LINES * LINE_SIZE]; /* holds ALL of the 
+       static char buffer[MAX_DESC_LINES * (LINE_SIZE+2)]; /* holds ALL of the
                                                           lines we get */
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -483,7 +489,7 @@ mail_is_good:
                        }
                        tmp = ldap_get_dn(ld, elmp);
                        strcpy(buffer, tmp);
-                       Free(tmp);
+                       ldap_memfree(tmp);
                        (void) ldap_msgfree(lmp);
                        break;
                }
@@ -504,7 +510,7 @@ mail_is_good:
                 *  are done.
                 */
                if (count++ > 1)
-                       (void) strcat(buffer, "$");
+                       (void) strcat(buffer, " $ ");
                (void) strcat(buffer, line);
                if (!multiline)
                        break;
@@ -782,23 +788,22 @@ check_URL( char *url )
 void
 mod_perror( LDAP *ld )
 {
-       int ld_errno = 0;
+       int ld_errno = LDAP_SUCCESS;
+       char *ld_errtext = NULL;
 
-       if(ld != NULL) {
-               ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
-       }
+       ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno );
 
-       if (( ld == NULL ) || ( ld_errno != LDAP_UNAVAILABLE &&
-           ld_errno != LDAP_UNWILLING_TO_PERFORM ))
-       {
-               ldap_perror( ld, "modify" );
-               return;
-       }
+       if( ld_errno != LDAP_SUCCESS ) {
+               ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &ld_errtext );
+       }       
 
-       fprintf( stderr, "\n  modify: failed because part of the online directory is not able\n" );
-       fprintf( stderr, "  to be modified right now" );
-       if ( ld_errno == LDAP_UNAVAILABLE ) {
-               fprintf( stderr, " or is temporarily unavailable" );
+       fprintf( stderr, "  modify failed: %s (%d)\n",
+               ldap_err2string( ld_errno ), ld_errno );
+
+       if( ld_errtext != NULL ) {
+               fprintf( stderr, "    additional information: %s\n",
+                       ld_errtext );
        }
-       fprintf( stderr, ".\n  Please try again later.\n" );
+
+       fprintf( stderr, "  Please try again later.\n" );
 }