+/* $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.
#include <stdio.h>
+#include <ac/stdlib.h>
+
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/time.h>
#include <lber.h>
#include <ldap.h>
#include "ud.h"
-extern void Free();
-
-extern struct entry Entry;
-extern int verbose;
-extern LDAP *ld;
-extern LDAPMessage *find();
-extern void * Malloc();
+static char *get_URL( void );
+static int check_URL( char *url );
-static char * get_URL();
-static int check_URL();
-#ifdef DEBUG
-extern int debug;
-#endif
-
-modify(who)
-char *who;
+void
+modify( char *who )
{
-#ifdef UOFM
- void set_updates(); /* routine to modify noBatchUpdates */
-#endif
LDAPMessage *mp; /* returned from find() */
char *dn; /* distinguished name */
char **rdns; /* for fiddling with the DN */
#ifdef UOFM
static char printed_warning = 0; /* for use with the */
struct attribute no_batch_update_attr;
- extern char * fetch_boolean_value();
int ld_errno;
#endif
int is_a_group; /* TRUE if it is; FALSE otherwise */
- extern void Free();
- extern int bind_status;
#ifdef DEBUG
if (debug & D_TRACE)
parse_answer(mp);
(void) ldap_msgfree(mp);
}
- (void) Free(dn);
+ ldap_memfree(dn);
ldap_value_free(rdns);
return;
}
/* generic routine for changing any field */
-void change_field(who, attr)
-char *who; /* DN of entry we are changing */
-struct attribute attr; /* attribute to change */
+void
+change_field(
+ char *who, /* DN of entry we are changing */
+ int attr_idx /* attribute to change */
+)
{
+ struct attribute attr = Entry.attrs[attr_to_index(attrlist[attr_idx].quipu_name)];
#define IS_MOD(x) (!strncasecmp(resp, (x), strlen(resp)))
- char *get_value(); /* routine to extract values */
static char buf[MED_BUF_SIZE]; /* for printing things */
static char resp[SMALL_BUF_SIZE]; /* for user input */
char *prompt, *prompt2, *more;
static LDAPMod mod;
static LDAPMod *mods[2] = { &mod }; /* passed to ldap_modify */
static char *values[MAX_VALUES]; /* passed to ldap_modify */
- extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
#define MAX_DESC_LINES 24
#define INTL_ADDR_LIMIT 30
-char *get_value(id, prompt)
-char *id, *prompt;
+char *
+get_value( char *id, char *prompt )
{
char *cp; /* for the Malloc() */
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)
}
tmp = ldap_get_dn(ld, elmp);
strcpy(buffer, tmp);
- Free(tmp);
+ ldap_memfree(tmp);
(void) ldap_msgfree(lmp);
break;
}
* are done.
*/
if (count++ > 1)
- (void) strcat(buffer, "$");
+ (void) strcat(buffer, " $ ");
(void) strcat(buffer, line);
if (!multiline)
break;
return(cp);
}
-void set_boolean(who, attr)
-char *who; /* DN of entry we are changing */
-struct attribute attr; /* boolean attribute to change */
+void
+set_boolean(
+ char *who, /* DN of entry we are changing */
+ int attr_idx /* boolean attribute to change */
+)
{
+ struct attribute attr = Entry.attrs[attr_to_index(attrlist[attr_idx].quipu_name)];
+
char *cp, *s;
- extern char * fetch_boolean_value();
static char response[16];
static char *newsetting[2] = { NULL, NULL };
LDAPMod mod, *mods[2];
printf(" Please enter Y for yes, N for no, or RETURN to cancel: ");
fflush(stdout);
(void) fetch_buffer(response, sizeof(response), stdin);
- for (s = response; isspace(*s); s++)
+ for (s = response; isspace((unsigned char)*s); s++)
;
if ((*s == 'y') || (*s == 'Y')) {
if (ldap_modify_s(ld, who, mods)) {
#ifdef UOFM
-void set_updates(who)
-char *who;
+void
+set_updates( char *who, int dummy )
{
char *cp, *s;
- extern char * fetch_boolean_value();
static char response[16];
static char value[6];
static char *newsetting[2] = { value, NULL };
printf("\n Change this setting [no]? ");
fflush(stdout);
(void) fetch_buffer(response, sizeof(response), stdin);
- for (s = response; isspace(*s); s++)
+ for (s = response; isspace((unsigned char)*s); s++)
;
if ((*s == 'y') || (*s == 'Y')) {
if (!strcmp(cp, "TRUE"))
#endif
-print_mod_list(group)
-int group;
+void
+print_mod_list( int group )
{
register int i, j = 1;
- extern struct attribute attrlist[];
if (group == TRUE) {
for (i = 0; attrlist[i].quipu_name != NULL; i++) {
#endif
}
-perform_action(choice, dn, group)
-char choice[];
-char *dn;
-int group;
+int
+perform_action( char *choice, char *dn, int group )
{
int selection;
register int i, j = 1;
- extern struct attribute attrlist[];
- extern void mod_addrDN(), change_field(), set_boolean();
selection = atoi(choice);
if (selection < 1) {
return(1);
/* NOTREACHED */
}
- if (attrlist[i].mod_func == change_field)
- (*attrlist[i].mod_func)(dn, Entry.attrs[attr_to_index(attrlist[i].quipu_name)]);
- else if (attrlist[i].mod_func == mod_addrDN)
- (*attrlist[i].mod_func)(dn, i);
- else if (attrlist[i].mod_func == set_boolean)
- (*attrlist[i].mod_func)(dn, Entry.attrs[attr_to_index(attrlist[i].quipu_name)]);
- else
- (*attrlist[i].mod_func)(dn);
+ (*attrlist[i].mod_func)(dn, i);
return(0);
}
-static char * get_URL()
+static char *
+get_URL( void )
{
char *rvalue, label[MED_BUF_SIZE], url[MED_BUF_SIZE];
return((char *) rvalue);
}
-static check_URL(url)
-char *url;
+static int
+check_URL( char *url )
{
register char *cp;
for (cp = url; *cp != '\n' && *cp != '\0'; cp++) {
- if (isspace(*cp))
+ if (isspace((unsigned char)*cp))
return(-1);
/*NOTREACHED*/
}
}
+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, " modify failed: %s (%d)\n",
+ ldap_err2string( ld_errno ), ld_errno );
- 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" );
+ 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" );
}