]> git.sur5r.net Git - openldap/commitdiff
Update for Alpha3 from -devel as of OPENLDAP_DEVEL_981116.
authorKurt Zeilenga <kurt@openldap.org>
Tue, 17 Nov 1998 00:24:13 +0000 (00:24 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 17 Nov 1998 00:24:13 +0000 (00:24 +0000)
Includes everything but ldapext & ldap.conf changes.

198 files changed:
CHANGES
clients/fax500/fax500.h [new file with mode: 0644]
clients/fax500/faxtotpc.c
clients/fax500/main.c
clients/fax500/rp500.c
clients/finger/main.c
clients/gopher/detach.c [deleted file]
clients/gopher/go500.c
clients/gopher/go500gw.c
clients/gopher/setproctitle.c [deleted file]
clients/mail500/main.c
clients/rcpt500/help.c
clients/rcpt500/main.c
clients/rcpt500/query.c
clients/rcpt500/rcpt500.h
clients/tools/ldapdelete.c
clients/tools/ldapmodify.c
clients/tools/ldapmodrdn.c
clients/tools/ldapsearch.c
clients/ud/auth.c
clients/ud/edit.c
clients/ud/find.c
clients/ud/globals.c
clients/ud/group.c
clients/ud/help.c
clients/ud/main.c
clients/ud/mod.c
clients/ud/print.c
clients/ud/string_to_key.c
clients/ud/ud.h
clients/ud/util.c
configure
configure.in
contrib/whois++/command.c
contrib/whois++/config.c
contrib/whois++/help.c
contrib/whois++/template.c
contrib/whois++/util.c
contrib/whois++/version.c
contrib/whois++/whois++.h
include/ac/string.h [new file with mode: 0644]
include/ac/unistd.h [new file with mode: 0644]
include/avl.h
include/ldap.h
include/lthread.h
include/lutil.h
include/portable.h.in
libraries/libavl/avl.c
libraries/libavl/testavl.c
libraries/liblber/decode.c
libraries/liblber/dtest.c
libraries/liblber/etest.c
libraries/liblber/io.c
libraries/libldap/cldap.c
libraries/libldap/ldap-int.h
libraries/libldap/os-ip.c
libraries/libldap/sort.c
libraries/libldap/test.c
libraries/libldap/tmplout.c
libraries/libldap/tmpltest.c
libraries/libldap/ufn.c
libraries/libldap/url.c
libraries/libldbm/ldbm.c
libraries/liblthread/stack.c
libraries/liblthread/thread.c
libraries/liblutil/md5.c [new file with mode: 0644]
libraries/liblutil/setproctitle.c
libraries/liblutil/sha1.c [new file with mode: 0644]
libraries/liblutil/strdup.c [new file with mode: 0644]
libraries/liblutil/tempnam.c [new file with mode: 0644]
servers/ldapd/add.c
servers/ldapd/association.c
servers/ldapd/bind.c
servers/ldapd/certificate.c
servers/ldapd/common.h
servers/ldapd/compare.c
servers/ldapd/delete.c
servers/ldapd/detach.c [deleted file]
servers/ldapd/error.c
servers/ldapd/kerberos.c
servers/ldapd/main.c
servers/ldapd/modify.c
servers/ldapd/modrdn.c
servers/ldapd/proto-ldapd.h
servers/ldapd/request.c
servers/ldapd/result.c
servers/ldapd/search.c
servers/ldapd/setproctitle.c [deleted file]
servers/ldapd/syntax.c
servers/ldapd/util.c
servers/slapd/abandon.c
servers/slapd/acl.c
servers/slapd/aclparse.c
servers/slapd/add.c
servers/slapd/attr.c
servers/slapd/back-ldbm/abandon.c
servers/slapd/back-ldbm/add.c
servers/slapd/back-ldbm/attr.c
servers/slapd/back-ldbm/bind.c
servers/slapd/back-ldbm/cache.c
servers/slapd/back-ldbm/close.c
servers/slapd/back-ldbm/compare.c
servers/slapd/back-ldbm/config.c
servers/slapd/back-ldbm/dbcache.c
servers/slapd/back-ldbm/delete.c
servers/slapd/back-ldbm/dn2id.c
servers/slapd/back-ldbm/filterindex.c
servers/slapd/back-ldbm/group.c
servers/slapd/back-ldbm/id2children.c
servers/slapd/back-ldbm/id2entry.c
servers/slapd/back-ldbm/idl.c
servers/slapd/back-ldbm/index.c
servers/slapd/back-ldbm/init.c
servers/slapd/back-ldbm/modify.c
servers/slapd/back-ldbm/modrdn.c
servers/slapd/back-ldbm/nextid.c
servers/slapd/back-ldbm/proto-back-ldbm.h
servers/slapd/back-ldbm/search.c
servers/slapd/back-ldbm/unbind.c
servers/slapd/back-passwd/config.c
servers/slapd/back-passwd/search.c
servers/slapd/back-shell/add.c
servers/slapd/back-shell/bind.c
servers/slapd/back-shell/compare.c
servers/slapd/back-shell/config.c
servers/slapd/back-shell/delete.c
servers/slapd/back-shell/fork.c
servers/slapd/back-shell/init.c
servers/slapd/back-shell/modify.c
servers/slapd/back-shell/modrdn.c
servers/slapd/back-shell/result.c
servers/slapd/back-shell/search.c
servers/slapd/back-shell/shell.h
servers/slapd/back-shell/unbind.c
servers/slapd/backend.c
servers/slapd/bind.c
servers/slapd/ch_malloc.c
servers/slapd/compare.c
servers/slapd/config.c
servers/slapd/configinfo.c
servers/slapd/connection.c
servers/slapd/daemon.c
servers/slapd/delete.c
servers/slapd/detach.c [deleted file]
servers/slapd/dn.c
servers/slapd/entry.c
servers/slapd/filter.c
servers/slapd/filterentry.c
servers/slapd/init.c
servers/slapd/lock.c
servers/slapd/main.c
servers/slapd/modify.c
servers/slapd/modrdn.c
servers/slapd/monitor.c
servers/slapd/operation.c
servers/slapd/proto-slap.h
servers/slapd/repl.c
servers/slapd/result.c
servers/slapd/schema.c
servers/slapd/schemaparse.c
servers/slapd/search.c
servers/slapd/shell-backends/passwd-shell.c
servers/slapd/shell-backends/shellutil.c
servers/slapd/shell-backends/shellutil.h
servers/slapd/slap.h
servers/slapd/str2filter.c
servers/slapd/suffixalias.c
servers/slapd/tools/centipede.c
servers/slapd/tools/chlog2replog.c
servers/slapd/tools/edb2ldif.c
servers/slapd/tools/ldbmcat.c
servers/slapd/tools/ldbmtest.c
servers/slapd/tools/ldif.c
servers/slapd/tools/ldif2id2children.c
servers/slapd/tools/ldif2id2entry.c
servers/slapd/tools/ldif2index.c
servers/slapd/tools/ldif2ldbm.c
servers/slapd/tools/sizecount.c
servers/slapd/unbind.c
servers/slurpd/admin.c
servers/slurpd/args.c
servers/slurpd/ch_malloc.c
servers/slurpd/config.c
servers/slurpd/detach.c [deleted file]
servers/slurpd/fm.c
servers/slurpd/globals.c
servers/slurpd/ldap_op.c
servers/slurpd/lock.c
servers/slurpd/main.c
servers/slurpd/proto-slurp.h [new file with mode: 0644]
servers/slurpd/re.c
servers/slurpd/replica.c
servers/slurpd/replog.c
servers/slurpd/ri.c
servers/slurpd/rq.c
servers/slurpd/sanity.c
servers/slurpd/slurp.h
servers/slurpd/tsleep.c

diff --git a/CHANGES b/CHANGES
index 46bafb85f8b7939233d11ba1203b3c64ac17d90c..dc8ea5dbdfd4bf99138e731d8cb6fa303d2997df 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,14 +1,15 @@
 OpenLDAP Change Log
 
 Changes included in OpenLDAP 1.1-Alpha (from -devel)
-       CVS Tag: OPENLDAP_REL_ENG_1_1
+       CVS Tag: OPENLDAP_REL_ENG_1_1_ALPHA3
        Changed LDBM default to sync on writes
        Added mail500 BOUNCEFROM patch
        Added dbcachenowsync option
        Fixed slapd/ldbm id2children bug
        Fixed slapd/shell newline bug
        Fixed whois++ get_dn leak
-       Fixed DEC OSF1 (alpha) support
+       Fixed pointer truncation to int bugs
+       Fixed DEC OSF/1 support bugs
        Fixed r/w lock initialization on non-final Pthreads
        Fixed slapd/slurpd file unlock bugs
        Fixed slurpd string translation bug
@@ -24,6 +25,8 @@ Changes included in OpenLDAP 1.1-Alpha (from -devel)
                Added pwd.h &  getpwuid() tests
                Added sys/resource.h test
        Updated NT support (now builds ud)
+       Added function prototypes
+       Removed library externs
        Removed lint
 
 
diff --git a/clients/fax500/fax500.h b/clients/fax500/fax500.h
new file mode 100644 (file)
index 0000000..74c8809
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef FAX500_H
+#define FAX500_H 1
+
+/* in faxtotpc.c */
+void  strip_nonnum ( char *str );
+char *remove_parens( char *ibuf, char *obuf );
+char *munge_phone  ( char *ibuf, char *obuf );
+char *faxtotpc     ( char *phone, char *userinfo );
+
+#endif
index 727020f85f7adbdf434d20945aca24cd72f7e743..b5b677b5a02290226416043cc813a34f532be56f 100644 (file)
 #include "portable.h"
 
 #include <stdio.h>
-#include <ctype.h>
-
 #include <sys/types.h>
+
+#include <ac/ctype.h>
 #include <ac/string.h>
 
+#include "fax500.h"
+
 #define        TPCDOMAIN       "tpc.int"
 
 /*
  * Remove everything from 'str' which is not a digit
  */
-void strip_nonnum(str)
-char *str;
+void
+strip_nonnum( char *str )
 {
        char *p, *q;
        p = q = str;
@@ -58,9 +60,8 @@ char *str;
  * Remove anything of the form (blah) where
  * "blah" contains a non-numeric character.
  */
-char *remove_parens(ibuf, obuf)
-char *ibuf;
-char *obuf;
+char *
+remove_parens( char *ibuf, char *obuf )
 {
        char *p = ibuf;
        char *q = obuf;
@@ -129,9 +130,8 @@ char *obuf;
  * 6                  93
  * 8                  99
  */
-char *munge_phone(ibuf, obuf)
-char *ibuf;
-char *obuf;
+char *
+munge_phone( char *ibuf, char *obuf )
 {
 #define        UMAREACODE      "1313"
 
@@ -173,17 +173,11 @@ char *obuf;
 
 
 
-
-
-
-
-
 /* 
  * Convert string to "tpc.int" domain name.
  */
-char *faxtotpc(phone, userinfo)
-char *phone;
-char *userinfo;
+char *
+faxtotpc( char *phone, char *userinfo )
 {
        char *p;
        char *q;
@@ -241,5 +235,4 @@ char *userinfo;
        strcat(obuf, TPCDOMAIN);        /* tack on domain name */
        p = strdup(obuf);
        return(p);
-                               
 }
index d82859cb03bf4b567d56a9e239ec9c528df3ad42..66c3fecc6bb331907cde41a269fabe57a184ee0b 100644 (file)
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <ctype.h>
 
 #include <ac/socket.h>
 #include <ac/string.h>
 #include <ac/syslog.h>
 #include <ac/time.h>
 #include <ac/wait.h>
+#include <ac/unistd.h>
+#include <ac/errno.h>
 
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
-
+#ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
+#endif
+
 #include <sysexits.h>
 
 #include "lber.h"
 #include "ldap.h"
+
+#include "fax500.h"
+
 #include <ldapconfig.h>
 
 #define USER           0
@@ -47,7 +53,6 @@ char  *errorsfrom = NULL;
 char   *mailfrom = NULL;
 char   *host = NULL;
 int    hostlen = 0;
-char   *faxtotpc();
 
 int    identity;
 #define        MAIL500 1       
@@ -103,27 +108,33 @@ static char       *attrs[] = { "objectClass", "title", "postaladdress",
                        "rfc822RequestsTo", "joinable", "cn", "member",
                        "facsimileTelephoneNumber", NULL };
 
-static do_address();
-static do_group();
-static do_group_members();
-static send_message();
-static send_errors();
-static do_noemailorfax();
-static do_ambiguous();
-static add_to();
-static isgroup();
-static add_error();
-static add_group();
-static unbind_and_exit();
-static group_loop();
-static send_group();
-static has_attributes();
-static char **get_attributes_mail_dn();
-static char *canonical();
-
-main (argc, argv)
-int    argc;
-char   **argv;
+
+static void do_address(char *name, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr, int type);
+static int  do_group(LDAPMessage *e, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr);
+static void do_group_members(LDAPMessage *e, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr);
+static void send_message(char **to);
+static void send_errors(Error *err, int nerr);
+static void do_noemailorfax(FILE *fp, Error *err, int namelen, int errtype);
+static void do_ambiguous(FILE *fp, Error *err, int namelen);
+static int  count_values(char **list);
+static void add_to(char ***list, int *nlist, char **new);
+static int  isgroup(LDAPMessage *e);
+static void add_error(Error **err, int *nerr, int code, char *addr, LDAPMessage *msg);
+static void add_group(char *dn, Group **list, int *nlist);
+static void unbind_and_exit(int rc);
+static int  group_loop(char *dn);
+static void send_group(Group *group, int ngroup);
+static int  has_attributes(LDAPMessage *e, char *attr1, char *attr2);
+static char **get_attributes_mail_dn(LDAPMessage *e, char *attr1, char *attr2);
+static char *canonical(char *s);
+static int  connect_to_x500 (void);
+static void do_group_errors (LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr);
+static void do_group_request (LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr);
+static void add_member (char *gdn, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr);
+
+
+int
+main ( int argc, char **argv )
 {
        char            *myname;
        char            **tolist;
@@ -131,9 +142,6 @@ char        **argv;
        Group           *togroups;
        int             numto, ngroups, numerr, nargs;
        int             i, j;
-       FILE            *fp;
-       extern int      optind, errno;
-       extern char     *optarg;
 
        while ( (i = getopt( argc, argv, "f:h:m:" )) != EOF ) {
                switch( i ) {
@@ -255,7 +263,7 @@ char        **argv;
         */
 
        if ( numerr > 0 && numto > nargs || ngroups > 0 ) {
-               int     fd;
+               FILE    *fp;
                char    buf[BUFSIZ];
 
                umask( 077 );
@@ -303,7 +311,8 @@ char        **argv;
        return( EX_OK );
 }
 
-connect_to_x500()
+static int
+connect_to_x500( void )
 {
        if ( (ld = ldap_open( LDAPHOST, LDAP_PORT )) == NULL ) {
                syslog( LOG_ALERT, "ldap_open failed" );
@@ -321,16 +330,17 @@ connect_to_x500()
 }
 
 
-static
-do_address( name, to, nto, togroups, ngroups, err, nerr, type )
-    char       *name;
-    char       ***to;
-    int                *nto;
-    Group      **togroups;
-    int                *ngroups;
-    Error      **err;
-    int                *nerr;
-    int                type;
+static void
+do_address(
+       char            *name,
+       char            ***to,
+       int             *nto,
+       Group           **togroups,
+       int             *ngroups,
+       Error           **err,
+       int             *nerr,
+       int             type
+)
 {
        int             rc, b, f, match;
        LDAPMessage     *e, *res;
@@ -572,16 +582,17 @@ do_address( name, to, nto, togroups, ngroups, err, nerr, type )
        return;
 }
 
-static
-do_group( e, dn, to, nto, togroups, ngroups, err, nerr )
-    LDAPMessage        *e;
-    char       *dn;
-    char       ***to;
-    int                *nto;
-    Group      **togroups;
-    int                *ngroups;
-    Error      **err;
-    int                *nerr;
+static int
+do_group(
+       LDAPMessage     *e,
+       char            *dn,
+       char            ***to,
+       int             *nto,
+       Group           **togroups,
+       int             *ngroups,
+       Error           **err,
+       int             *nerr
+)
 {
        /*
         * If this group has an rfc822ErrorsTo attribute, we need to
@@ -610,16 +621,17 @@ do_group( e, dn, to, nto, togroups, ngroups, err, nerr )
 }
 
 /* ARGSUSED */
-static
-do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
-    LDAPMessage        *e;
-    char       *dn;
-    char       ***to;
-    int                *nto;
-    Group      **togroups;
-    int                *ngroups;
-    Error      **err;
-    int                *nerr;
+static void
+do_group_members(
+       LDAPMessage     *e,
+       char            *dn,
+       char            ***to,
+       int             *nto,
+       Group           **togroups,
+       int             *ngroups,
+       Error           **err,
+       int             *nerr
+)
 {
        int             i, rc;
        char            *ndn;
@@ -785,15 +797,17 @@ do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
        return;
 }
 
-add_member( gdn, dn, to, nto, togroups, ngroups, err, nerr )
-    char       *gdn;
-    char       *dn;
-    char       ***to;
-    int                *nto;
-    Group      **togroups;
-    int                *ngroups;
-    Error      **err;
-    int                *nerr;
+static void
+add_member(
+       char            *gdn,
+       char            *dn,
+       char            ***to,
+       int             *nto,
+       Group           **togroups,
+       int             *ngroups,
+       Error           **err,
+       int             *nerr
+)
 {
        char            *ndn;
        char            **mail;
@@ -876,13 +890,15 @@ add_member( gdn, dn, to, nto, togroups, ngroups, err, nerr )
        return;
 }
 
-do_group_request( e, dn, to, nto, err, nerr )
-    LDAPMessage        *e;
-    char       *dn;
-    char       ***to;
-    int                *nto;
-    Error      **err;
-    int                *nerr;
+static void
+do_group_request(
+       LDAPMessage     *e,
+       char            *dn,
+       char            ***to,
+       int             *nto,
+       Error           **err,
+       int             *nerr
+)
 {
        char            **requeststo;
 
@@ -894,17 +910,17 @@ do_group_request( e, dn, to, nto, err, nerr )
        } else {
                add_error( err, nerr, E_NOREQUEST, dn, NULLMSG );
        }
-
-       return;
 }
 
-do_group_errors( e, dn, to, nto, err, nerr )
-    LDAPMessage        *e;
-    char       *dn;
-    char       ***to;
-    int                *nto;
-    Error      **err;
-    int                *nerr;
+static void
+do_group_errors(
+       LDAPMessage     *e,
+       char            *dn,
+       char            ***to,
+       int             *nto,
+       Error           **err,
+       int             *nerr
+)
 {
        char            **errorsto;
 
@@ -916,13 +932,10 @@ do_group_errors( e, dn, to, nto, err, nerr )
        } else {
                add_error( err, nerr, E_NOERRORS, dn, NULLMSG );
        }
-
-       return;
 }
 
-static
-send_message( to )
-    char       **to;
+static void
+send_message( char **to )
 {
        int     pid;
 #ifndef HAVE_WAITPID
@@ -931,7 +944,7 @@ send_message( to )
 
 
        /* parent */
-       if ( pid = fork() ) {
+       if ( (pid = fork()) != 0 ) {
 #ifdef HAVE_WAITPID
                waitpid( pid, (int *) NULL, 0 );
 #else
@@ -948,10 +961,8 @@ send_message( to )
        }
 }
 
-static
-send_group( group, ngroup )
-    Group      *group;
-    int                ngroup;
+static void
+send_group( Group *group, int ngroup )
 {
        int     i, pid;
        char    **argv;
@@ -979,7 +990,7 @@ send_group( group, ngroup )
 
 
                /* parent */
-               if ( pid = fork() ) {
+               if ( (pid = fork()) != 0 ) {
 #ifdef HAVE_WAITPID
                        waitpid( pid, (int *) NULL, 0 );
 #else
@@ -998,10 +1009,8 @@ send_group( group, ngroup )
        return;
 }
 
-static
-send_errors( err, nerr )
-    Error      *err;
-    int                nerr;
+static void
+send_errors( Error *err, int nerr )
 {
        int             i, namelen;
        FILE            *fp;
@@ -1097,12 +1106,8 @@ send_errors( err, nerr )
 }
 
 
-static
-do_noemailorfax( fp, err, namelen, errtype )
-    FILE       *fp;
-    Error      *err;
-    int                namelen;
-    int                errtype;
+static void
+do_noemailorfax( FILE *fp, Error *err, int namelen, int errtype )
 {
        int             i, last;
        char            *dn, *rdn;
@@ -1191,11 +1196,8 @@ do_noemailorfax( fp, err, namelen, errtype )
 }
 
 /* ARGSUSED */
-static
-do_ambiguous( fp, err, namelen )
-    FILE       *fp;
-    Error      *err;
-    int                namelen;
+static void
+do_ambiguous( FILE *fp, Error *err, int namelen )
 {
        int             i, last;
        char            *dn, *rdn;
@@ -1246,9 +1248,8 @@ do_ambiguous( fp, err, namelen )
        }
 }
 
-static
-count_values( list )
-    char       **list;
+static int
+count_values( char **list )
 {
        int     i;
 
@@ -1258,11 +1259,8 @@ count_values( list )
        return( i );
 }
 
-static
-add_to( list, nlist, new )
-    char       ***list;
-    int                *nlist;
-    char       **new;
+static void
+add_to( char ***list, int *nlist, char **new )
 {
        int     i, nnew, oldnlist;
 
@@ -1286,9 +1284,8 @@ add_to( list, nlist, new )
        return;
 }
 
-static
-isgroup( e )
-    LDAPMessage        *e;
+static int
+isgroup( LDAPMessage *e )
 {
        int     i;
        char    **oclist;
@@ -1306,13 +1303,8 @@ isgroup( e )
        return( 0 );
 }
 
-static
-add_error( err, nerr, code, addr, msg )
-    Error      **err;
-    int                *nerr;
-    int                code;
-    char       *addr;
-    LDAPMessage        *msg;
+static void
+add_error( Error **err, int *nerr, int code, char *addr, LDAPMessage *msg )
 {
        if ( *nerr == 0 ) {
                *err = (Error *) malloc( sizeof(Error) );
@@ -1328,11 +1320,8 @@ add_error( err, nerr, code, addr, msg )
        return;
 }
 
-static
-add_group( dn, list, nlist )
-    char       *dn;
-    Group      **list;
-    int                *nlist;
+static void
+add_group( char *dn, Group **list, int *nlist )
 {
        int     i, namelen;
        char    **ufn;
@@ -1379,9 +1368,8 @@ add_group( dn, list, nlist )
        return;
 }
 
-static
-unbind_and_exit( rc )
-    int        rc;
+static void
+unbind_and_exit( int rc )
 {
        int     i;
 
@@ -1392,8 +1380,7 @@ unbind_and_exit( rc )
 }
 
 static char *
-canonical( s )
-    char       *s;
+canonical( char *s )
 {
        char    *saves = s;
 
@@ -1405,9 +1392,8 @@ canonical( s )
        return( saves );
 }
 
-static
-group_loop( dn )
-    char       *dn;
+static int
+group_loop( char *dn )
 {
        int             i;
        static char     **groups;
@@ -1429,11 +1415,8 @@ group_loop( dn )
        return( 0 );
 }
 
-static
-has_attributes( e, attr1, attr2 )
-    LDAPMessage        *e;
-    char       *attr1;
-    char       *attr2;
+static int
+has_attributes( LDAPMessage *e, char *attr1, char *attr2 )
 {
        char    **attr;
 
@@ -1451,10 +1434,7 @@ has_attributes( e, attr1, attr2 )
 }
 
 static char **
-get_attributes_mail_dn( e, attr1, attr2 )
-    LDAPMessage        *e;
-    char       *attr1;
-    char       *attr2;         /* this one is dn-valued */
+get_attributes_mail_dn( LDAPMessage *e, char *attr1, char *attr2 )
 {
        LDAPMessage     *ee, *res;
        char            **vals, **dnlist, **mail;
index 0347369baed0ee5b2c9c781be2b633ea87e19bc4..00d1e4ec1ecb853dac19fa3202038f94384e72bc 100644 (file)
 
 #include "portable.h"
 
-#include <stdio.h>
-#include <signal.h>
+#include <stdlib.h>
 
+#include <ac/signal.h>
 #include <ac/socket.h>
 #include <ac/string.h>
 #include <ac/syslog.h>
 #include <ac/time.h>
+#include <ac/unistd.h>
 #include <ac/wait.h>
 
+#ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
+#endif
 
 #include <lber.h>
 #include <ldap.h>
 
+#include "fax500.h"
+
 #include <ldapconfig.h>
 
 #define DEFAULT_PORT           79
@@ -38,23 +43,20 @@ int         deref;
 int            sizelimit;
 LDAPFiltDesc   *filtd;
 
-static print_entry();
+static void    print_entry(LDAP *ld, LDAPMessage *e);
 
-static
-usage( name )
-    char       *name;
+static void
+usage( char *name )
 {
        fprintf( stderr, "usage: %s [-d debuglevel] [-x ldaphost] [-b searchbase] [-a] [-z sizelimit] [-f filterfile] searchstring\r\n", name );
        exit( -1 );
 }
 
-main (argc, argv)
-    int                argc;
-    char       **argv;
+int
+main( int argc, char **argv )
 {
        int             i, rc, matches;
        char            *filterfile = FILTERFILE;
-       struct timeval  timeout;
        char            buf[10];
        char            *key;
        LDAP            *ld;
@@ -64,8 +66,6 @@ main (argc, argv)
        static char     *attrs[] = { "title", "o", "ou", "postalAddress",
                                        "telephoneNumber", "mail",
                                        "facsimileTelephoneNumber", NULL };
-       extern char     *optarg;
-       extern int      optind;
 
        deref = LDAP_DEREF_ALWAYS;
        while ( (i = getopt( argc, argv, "ab:d:f:x:z:" )) != EOF ) {
@@ -176,7 +176,6 @@ main (argc, argv)
                                rdn++;
                        if ( strcasecmp( rdn, buf ) == 0 ) {
                                char    **cn;
-                               char    *s;
                                int     i, last;
 
                                cn = ldap_get_values( ld, e, "cn" );
@@ -237,16 +236,14 @@ main (argc, argv)
        return( 0 );
 }
 
-static
-print_entry( ld, e )
-    LDAP       *ld;
-    LDAPMessage        *e;
+static void
+print_entry( LDAP *ld, LDAPMessage *e )
 {
        int     i;
        char    *dn, *rdn;
        char    **ufn;
        char    **title, **dept, **addr, **phone, **fax, **mail;
-       char    *faxmail, *org, *faxtotpc();
+       char    *faxmail, *org;
 
        dn = ldap_get_dn( ld, e );
        ufn = ldap_explode_dn( dn, 0 );
index 38c8dfc7696b0a4e8e7c3dd4c08f888f8e12b8f3..f119b7dd0219cf1fa145d250b62478397eedc532 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/signal.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/syslog.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+#include <ac/wait.h>
+
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
 #include "lber.h"
 #include "ldap.h"
 #include "disptmpl.h"
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <syslog.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-#ifdef aix
-#include <sys/select.h>
-#endif /* aix */
-#include <signal.h>
-#include "portable.h"
+
 #include "ldapconfig.h"
 
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
 
 int    dosyslog = 1;
 char   *ldaphost = LDAPHOST;
@@ -45,21 +44,19 @@ char        *filterfile = FILTERFILE;
 char   *templatefile = TEMPLATEFILE;
 int    rdncount = FINGER_RDNCOUNT;
 
-static do_query();
-static do_search();
-static do_read();
-static print_attr();
+static void do_query(void);
+static void do_search(LDAP *ld, char *buf);
+static void do_read(LDAP *ld, LDAPMessage *e);
 
-static usage( name )
-char   *name;
+static void
+usage( char *name )
 {
        fprintf( stderr, "usage: %s [-l] [-x ldaphost] [-p ldapport] [-f filterfile] [-t templatefile] [-c rdncount]\r\n", name );
        exit( 1 );
 }
 
-main (argc, argv)
-int    argc;
-char   **argv;
+int
+main( int argc, char **argv )
 {
        int                     i;
        char                    *myname;
@@ -68,7 +65,6 @@ char  **argv;
        struct sockaddr_in      peername;
        int                     peernamelen;
        int                     interactive = 0;
-       extern char             *optarg;
 
        deref = FINGER_DEREF;
        while ( (i = getopt( argc, argv, "f:ilp:t:x:p:c:" )) != EOF ) {
@@ -136,7 +132,7 @@ char        **argv;
 #endif
        }
 
-       if ( dosyslog && mypeer != -1 ) {
+       if ( dosyslog && mypeer != (unsigned long) -1 ) {
                struct in_addr  addr;
 
                hp = gethostbyaddr( (char *) &mypeer, sizeof(mypeer), AF_INET );
@@ -150,7 +146,8 @@ char        **argv;
        return( 0 );
 }
 
-static do_query()
+static void
+do_query( void )
 {
        char            buf[256];
        int             len, rc, tblsize;
@@ -166,17 +163,27 @@ static do_query()
        ld->ld_sizelimit = FINGER_SIZELIMIT;
        ld->ld_deref = deref;
 
-       if ( ldap_simple_bind_s( ld, FINGER_BINDDN, NULL ) != LDAP_SUCCESS ) {
+       if ( ldap_simple_bind_s( ld, FINGER_BINDDN, FINGER_BIND_CRED )
+               != LDAP_SUCCESS )
+       {
                fprintf( stderr, FINGER_UNAVAILABLE );
                ldap_perror( ld, "ldap_simple_bind_s" );
                exit( 1 );
        }
 
-#ifdef USE_SYSCONF
+#ifdef HAVE_SYSCONF
        tblsize = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
+#elif HAVE_GETDTABLESIZE
        tblsize = getdtablesize();
-#endif /* USE_SYSCONF */
+#else
+       tblsize = FD_SETSIZE;
+#endif
+
+#ifdef FD_SETSIZE
+       if (tblsize > FD_SETSIZE) {
+               tblsize = FD_SETSIZE;
+       }
+#endif /* FD_SETSIZE*/
 
        timeout.tv_sec = FINGER_TIMEOUT;
        timeout.tv_usec = 0;
@@ -228,8 +235,7 @@ static do_query()
 }
 
 static void
-spaces2dots( s )
-    char       *s;
+spaces2dots( char *s )
 {
        for ( ; *s; s++ ) {
                if ( *s == ' ' ) {
@@ -238,9 +244,8 @@ spaces2dots( s )
        }
 }
 
-static do_search( ld, buf )
-LDAP   *ld;
-char   *buf;
+static void
+do_search( LDAP *ld, char *buf )
 {
        char            *dn, *rdn;
        char            **title;
@@ -253,7 +258,6 @@ char        *buf;
                                        FINGER_SORT_ATTR,
 #endif
                                        0 };
-       extern int      strcasecmp();
 
        ufn = 0;
 #ifdef FINGER_UFN
@@ -405,9 +409,8 @@ entry2textwrite( void *fp, char *buf, int len )
 }
 
 
-static do_read( ld, e )
-LDAP           *ld;
-LDAPMessage    *e;
+static void
+do_read( LDAP *ld, LDAPMessage *e )
 {
        static struct ldap_disptmpl *tmpllist;
        static char     *defattrs[] = { "mail", NULL };
diff --git a/clients/gopher/detach.c b/clients/gopher/detach.c
deleted file mode 100644 (file)
index f543cc3..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 1990, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <signal.h>
-#include "portable.h"
-
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
-
-detach( debug )
-int    debug;
-{
-       int     i, sd, nbits;
-
-#ifdef USE_SYSCONF
-       nbits = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
-       nbits = getdtablesize();
-#endif /* USE_SYSCONF */
-
-       if ( debug == 0 || !(isatty( 1 )) ) {
-               for ( i = 0; i < 5; i++ ) {
-                       switch ( fork() ) {
-                       case -1:
-                               sleep( 5 );
-                               continue;
-
-                       case 0:
-                               break;
-
-                       default:
-                               _exit( 0 );
-                       }
-                       break;
-               }
-
-               for ( i = 3; i < nbits; i++ )
-                       close( i );
-
-               (void) chdir( "/" );
-
-               if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
-                       if ( debug ) perror( "/dev/null" );
-                       exit( 1 );
-               }
-               if ( isatty( 0 ) )
-                       (void) dup2( sd, 0 );
-               if ( isatty( 1 ) )
-                       (void) dup2( sd, 1 );
-               if ( isatty(2) )
-                       (void) dup2( sd, 2 );
-               close( sd );
-
-#ifdef USE_SETSID
-               (void) setsid();
-#else /* USE_SETSID */
-               if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
-                       (void) ioctl( sd, TIOCNOTTY, NULL );
-                       (void) close( sd );
-               }
-#endif /* USE_SETSID */
-       } 
-
-       (void) signal( SIGPIPE, SIG_IGN );
-}
index 4174d1eda89d5e42c3f0f60566b912587cf530cf..26dc535a5af10431ee3c3f92845dfd62a9af7b26 100644 (file)
@@ -13,6 +13,7 @@
 #include "portable.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <ac/ctype.h>
 #include <ac/signal.h>
@@ -29,7 +30,9 @@
 #include <sys/param.h>
 #endif
 
+#ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
+#endif
 
 #include "ldapconfig.h"
 #include "lber.h"
@@ -52,24 +55,23 @@ char        *templatefile = TEMPLATEFILE;
 char   myhost[MAXHOSTNAMELEN];
 int    myport;
 
-static set_socket();
-static RETSIGTYPE wait4child();
-static do_queries();
-static do_error();
-static do_search();
-static do_read();
-extern int strcasecmp();
+static void usage      ( char *name );
+static int  set_socket (int port);
+static RETSIGTYPE wait4child(int sig);
+static void do_queries (int s);
+static void do_error   (FILE *fp, char *s);
+static void do_search  (LDAP *ld, FILE *fp, char *buf);
+static void do_read    (LDAP *ld, FILE *fp, char *dn);
 
-static usage( name )
-char   *name;
+static void
+usage( char *name )
 {
        fprintf( stderr, "usage: %s [-d debuglevel] [-f filterfile] [-t templatefile]\r\n\t[-a] [-l] [-p port] [-x ldaphost] [-b searchbase] [-c rdncount]\r\n", name );
        exit( 1 );
 }
 
-main (argc, argv)
-int    argc;
-char   **argv;
+int
+main( int argc, char **argv )
 {
        int                     s, ns, rc;
        int                     port = -1;
@@ -79,8 +81,6 @@ char  **argv;
        struct hostent          *hp;
        struct sockaddr_in      from;
        int                     fromlen;
-       RETSIGTYPE                      wait4child();
-       extern char             *optarg;
 
 #if defined( LDAP_PROCTITLE ) && !defined( HAVE_SETPROCTITLE )
        /* for setproctitle */
@@ -260,9 +260,8 @@ char        **argv;
        /* NOT REACHED */
 }
 
-static
-set_socket( port )
-int    port;
+static int
+set_socket( int port )
 {
        int                     s, one;
        struct sockaddr_in      addr;
@@ -305,7 +304,7 @@ int port;
 }
 
 static RETSIGTYPE
-wait4child()
+wait4child( int sig )
 {
 #ifndef HAVE_WAITPID
         WAITSTATUSTYPE     status;
@@ -324,9 +323,8 @@ wait4child()
        (void) SIGNAL( SIGCHLD, wait4child );
 }
 
-static
-do_queries( s )
-int    s;
+static void
+do_queries( int s )
 {
        char            buf[1024], *query;
        int             len;
@@ -426,7 +424,7 @@ int s;
        fprintf( fp, ".\r\n" );
        rewind(fp);
 
-       if( ld == NULL ) {
+       if ( ld != NULL) {
                ldap_unbind( ld );
        }
 
@@ -434,10 +432,8 @@ int        s;
        /* NOT REACHED */
 }
 
-static
-do_error( fp, s )
-FILE   *fp;
-char   *s;
+static void
+do_error( FILE *fp, char *s )
 {
        int     code;
 
@@ -449,11 +445,8 @@ char       *s;
        fprintf( fp, ".\r\n" );
 }
 
-static
-do_search( ld, fp, buf )
-LDAP   *ld;
-FILE   *fp;
-char   *buf;
+static void
+do_search( LDAP *ld, FILE *fp, char *buf )
 {
        char            *dn, *rdn;
        char            **title;
@@ -563,14 +556,11 @@ char      *buf;
 static int
 entry2textwrite( void *fp, char *buf, int len )
 {
-        return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
+       return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
 }
 
-static
-do_read( ld, fp, dn )
-LDAP   *ld;
-FILE   *fp;
-char   *dn;
+static void
+do_read( LDAP *ld, FILE *fp, char *dn )
 {
        static struct ldap_disptmpl *tmpllist;
 
index 8846d0080eda6060dbb1341aa30ea4a65dbc8436..e73b28ce366e66305554b41f389393e06cff6990 100644 (file)
@@ -13,6 +13,7 @@
 #include "portable.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <ac/ctype.h>
 #include <ac/signal.h>
 
 #include <ac/setproctitle.h>
 
-#include <sys/resource.h>
-
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
 
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+
 #include "lber.h"
 #include "ldap.h"
 #include "lutil.h"
@@ -53,31 +57,35 @@ char                *templatefile = TEMPLATEFILE;
 char           *friendlyfile = FRIENDLYFILE;
 int            rdncount = GO500GW_RDNCOUNT;
 
-static set_socket();
-static RETSIGTYPE wait4child();
-static do_queries();
-static do_menu();
-static do_list();
-static do_search();
-static do_read();
-static do_help();
-static do_sizelimit();
-static do_error();
-extern int strcasecmp();
+static void usage      ( char *name );
+static int  set_socket (int port);
+static RETSIGTYPE wait4child(int sig);
+static void do_queries (int s);
+static char *pick_oc   ( char **oclist );
+static int  isnonleaf  ( LDAP *ld, char **oclist, char *dn );
+static void do_menu    (LDAP *ld, FILE *fp, char *dn);
+static void do_list    (LDAP *ld, FILE *fp, char *dn);
+static int  isoc       ( char **ocl, char *oc );
+static int  make_scope ( LDAP *ld, char *dn );
+static void do_search  (LDAP *ld, FILE *fp, char *query);
+static int  entry2textwrite( void *fp, char *buf, int len );
+static void do_read    (LDAP *ld, FILE *fp, char *dn);
+static void do_help    (FILE *op);
+static void do_sizelimit(FILE *fp, char type);
+static void do_error   (FILE *fp, char *s);
 
 char   myhost[MAXHOSTNAMELEN];
 int    myport = GO500GW_PORT;
 
-static usage( name )
-char   *name;
+static void
+usage( char *name )
 {
        fprintf( stderr, "usage: %s [-d debuglevel] [-I] [-p port] [-P ldapport] [-l]\r\n\t[-x ldaphost] [-a] [-h helpfile] [-f filterfile] [-t templatefile] [-c rdncount]\r\n", name );
        exit( 1 );
 }
 
-main (argc, argv)
-int    argc;
-char   **argv;
+int
+main (int  argc, char **argv )
 {
        int                     s, ns, rc;
        int                     port = -1;
@@ -87,8 +95,6 @@ char  **argv;
        struct hostent          *hp;
        struct sockaddr_in      from;
        int                     fromlen;
-       RETSIGTYPE                      wait4child();
-       extern char             *optarg;
 
 #if defined( LDAP_PROCTITLE ) && !defined( HAVE_SETPROCTITLE )
        /* for setproctitle */
@@ -284,8 +290,8 @@ char        **argv;
        /* NOT REACHED */
 }
 
-static set_socket( port )
-int    port;
+static int
+set_socket( int port )
 {
        int                     s, one;
        struct sockaddr_in      addr;
@@ -329,7 +335,7 @@ int port;
 }
 
 static RETSIGTYPE
-wait4child()
+wait4child( int sig )
 {
 #ifndef HAVE_WAITPID
        WAITSTATUSTYPE     status;
@@ -348,8 +354,8 @@ wait4child()
        (void) SIGNAL( SIGCHLD, wait4child );
 }
 
-static do_queries( s )
-int    s;
+static void
+do_queries( int s )
 {
        char            buf[1024], *query;
        int             len;
@@ -452,7 +458,7 @@ int s;
                break;
 
        case 'S':       /* search */
-               do_search( ld, fp, query, 1 );
+               do_search( ld, fp, query );
                break;
 
        case 'M':       /* X.500 menu */
@@ -471,8 +477,8 @@ int s;
        /* NOT REACHED */
 }
 
-static char *pick_oc( oclist )
-char   **oclist;
+static char *
+pick_oc( char **oclist )
 {
        int     i;
 
@@ -489,10 +495,8 @@ char       **oclist;
        return( "unknown" );
 }
 
-static isnonleaf( ld, oclist, dn )
-LDAP   *ld;
-char   **oclist;
-char   *dn;
+static int
+isnonleaf( LDAP *ld, char **oclist, char *dn )
 {
        int     i, quipuobject = 0;
 
@@ -543,10 +547,8 @@ char       *dn;
 #endif
 }
 
-static do_menu( ld, fp, dn )
-LDAP   *ld;
-FILE   *fp;
-char   *dn;
+static void
+do_menu( LDAP *ld, FILE *fp, char *dn )
 {
        char            **s;
        char            *rdn = NULL;
@@ -576,10 +578,8 @@ char       *dn;
        ldap_free_friendlymap( &fm );
 }
 
-static do_list( ld, fp, dn )
-LDAP   *ld;
-FILE   *fp;
-char   *dn;
+static void
+do_list( LDAP *ld, FILE *fp, char *dn )
 {
        int             rc;
        LDAPMessage     *e, *res;
@@ -651,9 +651,8 @@ char        *dn;
        }
 }
 
-static isoc( ocl, oc )
-char   **ocl;
-char   *oc;
+static int
+isoc( char **ocl, char *oc )
 {
        int     i;
 
@@ -665,9 +664,8 @@ char        *oc;
        return( 0 );
 }
 
-static int make_scope( ld, dn )
-LDAP   *ld;
-char   *dn;
+static int
+make_scope( LDAP *ld, char *dn )
 {
        int             scope;
        char            **oc;
@@ -698,10 +696,8 @@ char       *dn;
        return( scope );
 }
 
-static do_search( ld, fp, query )
-LDAP   *ld;
-FILE   *fp;
-char   *query;
+static void
+do_search( LDAP *ld, FILE *fp, char *query )
 {
        int             scope;
        char            *base, *filter;
@@ -768,7 +764,7 @@ char        *query;
                            != LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED ) {
                                fprintf(fp, "0An error occurred (explanation)\tE%d\t%s\t%d\r\n",
                                    rc, myhost, myport );
-                               return( 1 );
+                               return;
                        }
                        if ( (count = ldap_count_entries( ld, res )) != 0 )
                                break;
@@ -780,7 +776,7 @@ char        *query;
 #endif
 
        if ( count == 0 ) {
-               return( 0 );
+               return;
        }
 
        if ( count == 1 ) {
@@ -792,10 +788,10 @@ char      *query;
                dn = ldap_get_dn( ld, e );
 
                if ( isnonleaf( ld, oc, dn ) ) {
-                       rc = do_menu( ld, fp, dn );
+                       do_menu( ld, fp, dn );
 
                        free( dn );
-                       return( rc );
+                       return;
                }
 
                free( dn );
@@ -840,10 +836,8 @@ entry2textwrite( void *fp, char *buf, int len )
         return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
 }
 
-static do_read( ld, fp, dn )
-LDAP   *ld;
-FILE   *fp;
-char   *dn;
+static void
+do_read( LDAP *ld, FILE *fp, char *dn )
 {
        static struct ldap_disptmpl *tmpllist;
 
@@ -863,8 +857,8 @@ char        *dn;
        }
 }
 
-static do_help( op )
-FILE   *op;
+static void
+do_help( FILE *op )
 {
        FILE    *fp;
        char    line[BUFSIZ];
@@ -883,9 +877,8 @@ FILE        *op;
        fclose( fp );
 }
 
-static do_sizelimit( fp, type )
-FILE   *fp;
-char   type;
+static void
+do_sizelimit( FILE *fp, char type )
 {
        if ( type == 'S' ) {
                fprintf( fp, "The query you specified was not specific enough, causing a size limit\r\n" );
@@ -901,9 +894,8 @@ char        type;
        fprintf( fp, ".\r\n" );
 }
 
-static do_error( fp, s )
-FILE   *fp;
-char   *s;
+static void
+do_error( FILE *fp, char *s )
 {
        int     code;
 
diff --git a/clients/gopher/setproctitle.c b/clients/gopher/setproctitle.c
deleted file mode 100644 (file)
index 26b42c0..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1990,1991 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-char   **Argv;         /* pointer to original (main's) argv */
-int    Argc;           /* original argc */
-
-/*
- * takes a printf-style format string (fmt) and up to three parameters (a,b,c)
- * this clobbers the original argv...
- */
-
-/* VARARGS */
-setproctitle( fmt, a, b, c )
-char *fmt;
-{
-       static char *endargv = (char *)0;
-       char    *s;
-       int             i;
-       char    buf[ 1024 ];
-
-       if ( endargv == (char *)0 ) {
-               /* set pointer to end of original argv */
-               endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] );
-       }
-       sprintf( buf, fmt, a, b, c );
-       /* make ps print "([prog name])" */
-       s = Argv[0];
-       *s++ = '-';
-       i = strlen( buf );
-       if ( i > endargv - s - 2 ) {
-               i = endargv - s - 2;
-               buf[ i ] = '\0';
-       }
-       strcpy( s, buf );
-       s += i;
-       while ( s < endargv ) *s++ = ' ';
-}
index 37205d35eae1d4fbad91d05ceccf4cc5f2b88af0..c8fb201a7368cf488fcc0ccc93b60791dbcb37e2 100644 (file)
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <ctype.h>
 
+#include <ac/ctype.h>
 #include <ac/string.h>
 #include <ac/syslog.h>
 #include <ac/time.h>
 #include <ac/wait.h>
+#include <ac/unistd.h>
 
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
 
+#ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
+#endif
 
 #include <sysexits.h>
 
@@ -121,27 +124,32 @@ static char       *attrs[] = { "objectClass", "title", "postaladdress",
                        "moderator", "onVacation", "uid",
                        "suppressNoEmailError", NULL };
 
-static do_address();
-static do_group();
-static do_group_members();
-static send_message();
-static send_errors();
-static do_noemail();
-static do_ambiguous();
-static add_to();
-static isgroup();
-static add_error();
-static add_group();
-static unbind_and_exit();
-static group_loop();
-static send_group();
-static has_attributes();
-static char **get_attributes_mail_dn();
-static char *canonical();
-
-main (argc, argv)
-int    argc;
-char   **argv;
+static void do_address( char *name, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr, int type );
+static int  do_group( LDAPMessage *e, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr );
+static void do_group_members( LDAPMessage *e, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr );
+static void send_message( char **to );
+static void send_errors( Error *err, int nerr );
+static void do_noemail( FILE *fp, Error *err, int namelen );
+static void do_ambiguous( FILE *fp, Error *err, int namelen );
+static void add_to( char ***list, int *nlist, char **new );
+static int  isgroup( LDAPMessage *e );
+static void add_error( Error **err, int *nerr, int code, char *addr, LDAPMessage *msg );
+static void add_group( char *dn, Group **list, int *nlist );
+static void unbind_and_exit( int rc );
+static int  group_loop( char *dn );
+static void send_group( Group *group, int ngroup );
+static int  has_attributes( LDAPMessage *e, char *attr1, char *attr2 );
+static char **get_attributes_mail_dn( LDAPMessage *e, char *attr1, char *attr2 );
+static char *canonical( char *s );
+static int  connect_to_x500( void );
+
+static void do_group_errors( LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr );
+static void do_group_request( LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr );
+static void do_group_owner( LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr );
+static void add_member( char *gdn, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr, char **suppress );
+
+int
+main ( int argc, char **argv )
 {
        char            *myname;
        char            **tolist;
@@ -149,9 +157,6 @@ char        **argv;
        Group           *togroups;
        int             numto, ngroups, numerr, nargs;
        int             i, j;
-       FILE            *fp;
-       extern int      optind, errno;
-       extern char     *optarg;
 
        if ( (myname = strrchr( argv[0], '/' )) == NULL )
                myname = strdup( argv[0] );
@@ -285,7 +290,7 @@ char        **argv;
         */
 
        if ( numerr > 0 && numto > nargs || ngroups > 0 ) {
-               int     fd;
+               FILE    *fp;
                char    buf[BUFSIZ];
 
                umask( 077 );
@@ -342,7 +347,8 @@ char        **argv;
        return( EX_OK );
 }
 
-connect_to_x500()
+static int
+connect_to_x500( void )
 {
        if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
                syslog( LOG_ALERT, "ldap_open failed" );
@@ -359,10 +365,8 @@ connect_to_x500()
        return( 0 );
 }
 
-static
-mailcmp( a, b )
-    char       *a;
-    char       *b;
+static int
+mailcmp( char *a, char *b )
 {
        int     i;
 
@@ -385,16 +389,17 @@ mailcmp( a, b )
        return( 0 );
 }
 
-static
-do_address( name, to, nto, togroups, ngroups, err, nerr, type )
-    char       *name;
-    char       ***to;
-    int                *nto;
-    Group      **togroups;
-    int                *ngroups;
-    Error      **err;
-    int                *nerr;
-    int                type;
+static void
+do_address(
+       char    *name,
+       char    ***to,
+       int     *nto,
+       Group   **togroups,
+       int     *ngroups,
+       Error   **err,
+       int     *nerr,
+       int     type
+)
 {
        int             rc, b, f, match;
        LDAPMessage     *e, *res;
@@ -686,20 +691,19 @@ do_address( name, to, nto, togroups, ngroups, err, nerr, type )
                ldap_value_free( uid );
        }
        free( dn );
-
-       return;
 }
 
-static
-do_group( e, dn, to, nto, togroups, ngroups, err, nerr )
-    LDAPMessage        *e;
-    char       *dn;
-    char       ***to;
-    int                *nto;
-    Group      **togroups;
-    int                *ngroups;
-    Error      **err;
-    int                *nerr;
+static int
+do_group(
+       LDAPMessage *e,
+       char    *dn,
+       char    ***to,
+       int     *nto,
+       Group   **togroups,
+       int     *ngroups,
+       Error   **err,
+       int     *nerr
+)
 {
        int     i;
        char    **moderator;
@@ -757,16 +761,17 @@ do_group( e, dn, to, nto, togroups, ngroups, err, nerr )
 }
 
 /* ARGSUSED */
-static
-do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
-    LDAPMessage        *e;
-    char       *dn;
-    char       ***to;
-    int                *nto;
-    Group      **togroups;
-    int                *ngroups;
-    Error      **err;
-    int                *nerr;
+static void
+do_group_members(
+       LDAPMessage *e,
+       char    *dn,
+       char    ***to,
+       int     *nto,
+       Group   **togroups,
+       int     *ngroups,
+       Error   **err,
+       int     *nerr
+)
 {
        int             i, rc, anymembers;
        char            *ndn;
@@ -898,20 +903,20 @@ do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
        if ( ! anymembers ) {
                add_error( err, nerr, E_NOMEMBERS, dn, NULLMSG );
        }
-
-       return;
 }
 
-add_member( gdn, dn, to, nto, togroups, ngroups, err, nerr, suppress )
-    char       *gdn;
-    char       *dn;
-    char       ***to;
-    int                *nto;
-    Group      **togroups;
-    int                *ngroups;
-    Error      **err;
-    int                *nerr;
-    char       **suppress;
+static void
+add_member(
+       char    *gdn,
+       char    *dn,
+       char    ***to,
+       int     *nto,
+       Group   **togroups,
+       int     *ngroups,
+       Error   **err,
+       int     *nerr,
+       char    **suppress
+)
 {
        char            *ndn;
        char            **mail;
@@ -968,17 +973,17 @@ add_member( gdn, dn, to, nto, togroups, ngroups, err, nerr, suppress )
        }
 
        free( ndn );
-
-       return;
 }
 
-do_group_request( e, dn, to, nto, err, nerr )
-    LDAPMessage        *e;
-    char       *dn;
-    char       ***to;
-    int                *nto;
-    Error      **err;
-    int                *nerr;
+static void
+do_group_request(
+       LDAPMessage *e,
+       char    *dn,
+       char    ***to,
+       int     *nto,
+       Error   **err,
+       int     *nerr
+)
 {
        char            **requeststo;
 
@@ -990,17 +995,17 @@ do_group_request( e, dn, to, nto, err, nerr )
        } else {
                add_error( err, nerr, E_NOREQUEST, dn, NULLMSG );
        }
-
-       return;
 }
 
-do_group_errors( e, dn, to, nto, err, nerr )
-    LDAPMessage        *e;
-    char       *dn;
-    char       ***to;
-    int                *nto;
-    Error      **err;
-    int                *nerr;
+static void
+do_group_errors(
+       LDAPMessage *e,
+       char    *dn,
+       char    ***to,
+       int     *nto,
+       Error   **err,
+       int     *nerr
+)
 {
        char            **errorsto;
 
@@ -1012,17 +1017,17 @@ do_group_errors( e, dn, to, nto, err, nerr )
        } else {
                add_error( err, nerr, E_NOERRORS, dn, NULLMSG );
        }
-
-       return;
 }
 
-do_group_owner( e, dn, to, nto, err, nerr )
-    LDAPMessage        *e;
-    char       *dn;
-    char       ***to;
-    int                *nto;
-    Error      **err;
-    int                *nerr;
+static void
+do_group_owner(
+       LDAPMessage *e,
+       char    *dn,
+       char    ***to,
+       int     *nto,
+       Error   **err,
+       int     *nerr
+)
 {
        char            **owner;
 
@@ -1032,12 +1037,10 @@ do_group_owner( e, dn, to, nto, err, nerr )
        } else {
                add_error( err, nerr, E_NOOWNER, dn, NULLMSG );
        }
-       return;
 }
 
-static
-send_message( to )
-    char       **to;
+static void
+send_message( char **to )
 {
        int     pid;
 #ifndef HAVE_WAITPID
@@ -1058,7 +1061,7 @@ send_message( to )
        }
 
        /* parent */
-       if ( pid = fork() ) {
+       if ( (pid = fork()) != 0 ) {
 #ifdef HAVE_WAITPID
                waitpid( pid, (int *) NULL, 0 );
 #else
@@ -1075,10 +1078,8 @@ send_message( to )
        }
 }
 
-static
-send_group( group, ngroup )
-    Group      *group;
-    int                ngroup;
+static void
+send_group( Group *group, int ngroup )
 {
        int     i, pid;
        char    **argv;
@@ -1118,7 +1119,7 @@ send_group( group, ngroup )
                }
 
                /* parent */
-               if ( pid = fork() ) {
+               if ( (pid = fork()) != 0 ) {
 #ifdef HAVE_WAITPID
                        waitpid( pid, (int *) NULL, 0 );
 #else
@@ -1133,14 +1134,10 @@ send_group( group, ngroup )
                        exit( EX_TEMPFAIL );
                }
        }
-
-       return;
 }
 
-static
-send_errors( err, nerr )
-    Error      *err;
-    int                nerr;
+static void
+send_errors( Error *err, int nerr )
 {
        int     pid, i, namelen;
        FILE    *fp;
@@ -1181,7 +1178,7 @@ send_errors( err, nerr )
                exit( EX_TEMPFAIL );
        }
 
-       if ( pid = fork() ) {
+       if ( (pid = fork()) != 0 ) {
                if ( (fp = fdopen( fd[1], "w" )) == NULL ) {
                        syslog( LOG_ALERT, "cannot fdopen pipe" );
                        exit( EX_TEMPFAIL );
@@ -1284,15 +1281,10 @@ send_errors( err, nerr )
 
                exit( EX_TEMPFAIL );
        }
-
-       return;
 }
 
-static
-do_noemail( fp, err, namelen )
-    FILE       *fp;
-    Error      *err;
-    int                namelen;
+static void
+do_noemail( FILE *fp, Error *err, int namelen )
 {
        int             i, last;
        char            *dn, *rdn;
@@ -1376,11 +1368,8 @@ do_noemail( fp, err, namelen )
 }
 
 /* ARGSUSED */
-static
-do_ambiguous( fp, err, namelen )
-    FILE       *fp;
-    Error      *err;
-    int                namelen;
+static void
+do_ambiguous( FILE *fp, Error *err, int namelen )
 {
        int             i, last;
        char            *dn, *rdn;
@@ -1431,9 +1420,8 @@ do_ambiguous( fp, err, namelen )
        }
 }
 
-static
-count_values( list )
-    char       **list;
+static int
+count_values( char **list )
 {
        int     i;
 
@@ -1443,11 +1431,8 @@ count_values( list )
        return( i );
 }
 
-static
-add_to( list, nlist, new )
-    char       ***list;
-    int                *nlist;
-    char       **new;
+static void
+add_to( char ***list, int *nlist, char **new )
 {
        int     i, nnew, oldnlist;
 
@@ -1466,13 +1451,10 @@ add_to( list, nlist, new )
        for ( i = 0; i < nnew; i++ )
                (*list)[i + oldnlist] = strdup( new[i] );
        (*list)[*nlist] = NULL;
-
-       return;
 }
 
-static
-isgroup( e )
-    LDAPMessage        *e;
+static int
+isgroup( LDAPMessage *e )
 {
        int     i;
        char    **oclist;
@@ -1490,13 +1472,8 @@ isgroup( e )
        return( 0 );
 }
 
-static
-add_error( err, nerr, code, addr, msg )
-    Error      **err;
-    int                *nerr;
-    int                code;
-    char       *addr;
-    LDAPMessage        *msg;
+static void
+add_error( Error **err, int *nerr, int code, char *addr, LDAPMessage *msg )
 {
        if ( *nerr == 0 ) {
                *err = (Error *) malloc( sizeof(Error) );
@@ -1508,15 +1485,10 @@ add_error( err, nerr, code, addr, msg )
        (*err)[*nerr].e_addr = strdup( addr );
        (*err)[*nerr].e_msg = msg;
        (*nerr)++;
-
-       return;
 }
 
-static
-add_group( dn, list, nlist )
-    char       *dn;
-    Group      **list;
-    int                *nlist;
+static void
+add_group( char *dn, Group **list, int *nlist )
 {
        int     i, namelen;
        char    **ufn;
@@ -1559,13 +1531,10 @@ add_group( dn, list, nlist )
        (*nlist)++;
 
        ldap_value_free( ufn );
-
-       return;
 }
 
-static
-unbind_and_exit( rc )
-    int        rc;
+static void
+unbind_and_exit( int rc )
 {
        int     i;
 
@@ -1576,8 +1545,7 @@ unbind_and_exit( rc )
 }
 
 static char *
-canonical( s )
-    char       *s;
+canonical( char *s )
 {
        char    *saves = s;
 
@@ -1589,9 +1557,8 @@ canonical( s )
        return( saves );
 }
 
-static
-group_loop( dn )
-    char       *dn;
+static int
+group_loop( char *dn )
 {
        int             i;
        static char     **groups;
@@ -1613,11 +1580,8 @@ group_loop( dn )
        return( 0 );
 }
 
-static
-has_attributes( e, attr1, attr2 )
-    LDAPMessage        *e;
-    char       *attr1;
-    char       *attr2;
+static int
+has_attributes( LDAPMessage *e, char *attr1, char *attr2 )
 {
        char    **attr;
 
@@ -1635,10 +1599,11 @@ has_attributes( e, attr1, attr2 )
 }
 
 static char **
-get_attributes_mail_dn( e, attr1, attr2 )
-    LDAPMessage        *e;
-    char       *attr1;
-    char       *attr2;         /* this one is dn-valued */
+get_attributes_mail_dn(
+    LDAPMessage *e,
+    char *attr1,
+    char *attr2                        /* this one is dn-valued */
+)
 {
        LDAPMessage     *ee, *res;
        char            **vals, **dnlist, **mail, **grname, **graddr;
index 0f541ab9be1efde1bfd59df0f6f9b195f5c6d899..9485f7dd9f196984ae4d33d17138af0bfd538d0c 100644 (file)
@@ -6,22 +6,24 @@
  * All Rights Reserved
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <syslog.h>
-#include <string.h>
+
+#include <ac/syslog.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
+#endif
 
-#include "portable.h"
 #include "ldapconfig.h"
 #include "rcpt500.h"
 
-extern int dosyslog;
-
 
 int
-help_cmd( msgp, reply )
-    struct msginfo     *msgp;
-    char               *reply;
+help_cmd(struct msginfo *msgp, char *reply)
 {
     int                fd, len;
 
index b6bf01636e91c6553b9a452e91e291808af8595c..4cc86f85f06026818fba713d5e991fcade8153f1 100644 (file)
@@ -14,6 +14,7 @@
 #include <ac/ctype.h>
 #include <ac/string.h>
 #include <ac/syslog.h>
+#include <ac/unistd.h>
 
 #include "ldapconfig.h"
 #include "rcpt500.h"
@@ -32,33 +33,29 @@ char *searchbase = RCPT500_BASE;
 char *dapuser = RCPT500_BINDDN;
 char *filterfile = FILTERFILE;
 char *templatefile = TEMPLATEFILE;
-char reply[ MAXSIZE * RCPT500_LISTLIMIT ];
-
+static char reply[ MAXSIZE * RCPT500_LISTLIMIT ];
 
 
 /*
  * functions
  */
-int    read_msg();
-char   *read_hdr();
-int    send_reply();
+static int  read_msg(FILE *fp, struct msginfo *msgp);
+static char *read_hdr(FILE *fp, int off, char *buf, int MAXSIZEe, char **ln_p);
+static int  send_reply(struct msginfo *msgp, char *body);
+static int  find_command(char *text, char **argp);
 
 /*
  * main is invoked by sendmail via the alias file
  * the entire incoming message gets piped to our standard input
  */
-main( argc, argv )
-    int                argc;
-    char       **argv;
+int
+main( int argc, char **argv )
 {
     char               *prog, *usage = "%s [-l] [-U] [-h ldaphost] [-p ldapport] [-b searchbase] [-a] [-z sizelimit] [-u dapuser] [-f filterfile] [-t templatefile] [-c rdncount]\n";
     struct msginfo     msg;
     int                        c, errflg;
     char               *replytext;
 
-    extern int         optind;
-    extern char                *optarg;
-
     *reply = '\0';
 
     if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) {
@@ -168,10 +165,8 @@ main( argc, argv )
 }
 
 
-int
-read_msg( fp, msgp )
-    FILE               *fp;
-    struct msginfo     *msgp;
+static int
+read_msg( FILE *fp, struct msginfo *msgp )
 {
     char       buf[ MAXSIZE ], *line;
     int                command = -1;
@@ -231,13 +226,8 @@ read_msg( fp, msgp )
 }
 
 
-char *
-read_hdr( fp, offset, buf, MAXSIZEe, linep )
-    FILE       *fp;
-    int                offset;
-    char       *buf;
-    int                MAXSIZEe;
-    char       **linep;
+static char *
+read_hdr( FILE *fp, int offset, char *buf, int MAXSIZEe, char **linep )
 {
     char       *hdr;
 
@@ -272,10 +262,8 @@ read_hdr( fp, offset, buf, MAXSIZEe, linep )
 }
 
 
-int
-send_reply( msgp, body )
-    struct msginfo     *msgp;
-    char               *body;
+static int
+send_reply( struct msginfo *msgp, char *body )
 {
     char       buf[ MAXSIZE ];
     FILE       *cmdpipe;
@@ -353,10 +341,8 @@ send_reply( msgp, body )
 }
 
 
-int
-find_command( text, argp )
-    char       *text;
-    char       **argp;
+static int
+find_command( char *text, char **argp )
 {
     int                i;
     char       *s, *p;
index 1ac78c17c996710554e6b4fe693033a8a4cd2acd..28605e9a259465e7e7bce6d8912908ec43b80211 100644 (file)
@@ -6,43 +6,38 @@
  * All Rights Reserved
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <syslog.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
+#include <stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/syslog.h>
+#include <ac/time.h>
 
 #include "lber.h"
 #include "ldap.h"
-#include "portable.h"
-#include "ldapconfig.h"
 #include "disptmpl.h"
-#include "rcpt500.h"
 
-extern int dosyslog;
-extern int do_cldap;
-extern int rdncount;
-extern int derefaliases;
-extern int sizelimit;
-extern int ldapport;
-extern char *ldaphost;
-extern char *searchbase;
-extern char *dapuser;
-extern char *filterfile;
-extern char *templatefile;
+#include "rcpt500.h"
+#include "ldapconfig.h"
 
 static char buf[ MAXSIZE ];
 static char *errpreface = "Your query failed: ";
 
-extern int      strcasecmp();
+static void close_ldap(LDAP *ld);
+static void append_entry_list(char *rep, char *qu, LDAP *ld, LDAPMessage *msg);
+static int  append_text(void *reply, char *text, int len);
+static int  do_read (LDAP *ld, char *dn, char *rep, struct ldap_disptmpl *tmp);
+static void report_ldap_err (LDAP *ldp, char *reply);
+static void remove_trailing_space (char *s);
 
 void close_ldap();
 
 
 int
-query_cmd( msgp, reply )
-    struct msginfo     *msgp;
-    char               *reply;
+query_cmd( struct msginfo *msgp, char *reply )
 {
     LDAP                       *ldp;
     LDAPMessage                        *ldmsgp, *entry;
@@ -77,11 +72,11 @@ query_cmd( msgp, reply )
     /*
      * open connection to LDAP server and bind as dapuser
      */
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
     if ( do_cldap )
        ldp = cldap_open( ldaphost, ldapport );
     else
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
        ldp = ldap_open( ldaphost, ldapport );
 
     if ( ldp == NULL ) {
@@ -91,9 +86,9 @@ query_cmd( msgp, reply )
        return( 0 );
     }
 
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
     if ( !do_cldap )
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
        if ( ldap_simple_bind_s( ldp, dapuser, NULL ) != LDAP_SUCCESS ) {
            report_ldap_err( ldp, reply );
            close_ldap( ldp );
@@ -110,11 +105,11 @@ query_cmd( msgp, reply )
     matches = 0;
 
 #ifdef RCPT500_UFN
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
     if ( !do_cldap && strchr( msgp->msg_arg, ',' ) != NULL ) {
-#else /* CLDAP */
+#else /* LDAP_CONNECTIONLESS */
     if ( strchr( msgp->msg_arg, ',' ) != NULL ) {
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
        struct timeval  tv;
 
        ldap_ufn_setprefix( ldp, searchbase );
@@ -133,12 +128,12 @@ query_cmd( msgp, reply )
     
        for ( lfi = ldap_getfirstfilter( lfdp, "rcpt500", msgp->msg_arg );
                lfi != NULL; lfi = ldap_getnextfilter( lfdp )) {
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
            if ( do_cldap )
                rc = cldap_search_s( ldp, searchbase, LDAP_SCOPE_SUBTREE,
                        lfi->lfi_filter, attrs, 0, &ldmsgp, dapuser );
            else 
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
                rc = ldap_search_s( ldp, searchbase, LDAP_SCOPE_SUBTREE,
                        lfi->lfi_filter, attrs, 0, &ldmsgp );
 
@@ -217,23 +212,20 @@ query_cmd( msgp, reply )
 }
 
 
-void
+static void
 close_ldap( LDAP *ld )
 {
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
     if ( do_cldap )
        cldap_close( ld );
     else
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
        ldap_unbind( ld );
 }
 
 
-append_entry_list( reply, query, ldp, ldmsgp )
-    char       *reply;
-    char       *query;
-    LDAP       *ldp;
-    LDAPMessage        *ldmsgp;
+static void
+append_entry_list( char *reply, char *query, LDAP *ldp, LDAPMessage *ldmsgp )
 {
     LDAPMessage        *e;
     char       *dn, *rdn, *s, **title;
@@ -294,23 +286,16 @@ append_entry_list( reply, query, ldp, ldmsgp )
 }
 
 
-int
-append_text( reply, text, len )
-    char       *reply;
-    char       *text;
-    int                len;
+static int
+append_text( void *reply, char *text, int len )
 {
-    strcat( reply, text );
+    strcat( (char *) reply, text );
     return( len );
 }
     
 
-int
-do_read( ldp, dn, reply, tmpll )
-    LDAP                       *ldp;
-    char                       *dn;
-    char                       *reply;
-    struct ldap_disptmpl       *tmpll;
+static int
+do_read( LDAP *ldp, char *dn, char *reply, struct ldap_disptmpl *tmpll )
 {
     int                                rc;
     static char        *maildefvals[] = { "None registered in this service", NULL };
@@ -319,16 +304,15 @@ do_read( ldp, dn, reply, tmpll )
 
 
     rc = ldap_entry2text_search( ldp, dn, searchbase, NULLMSG, tmpll,
-           defattrs, defvals, (void *)append_text, (void *)reply, "\n",
+           defattrs, defvals, append_text, (void *)reply, "\n",
            rdncount, LDAP_DISP_OPT_DOSEARCHACTIONS );
 
     return( rc );
 }
 
 
-report_ldap_err( ldp, reply )
-    LDAP       *ldp;
-    char       *reply;
+static void
+report_ldap_err( LDAP *ldp, char *reply )
 {
     strcat( reply, errpreface );
     strcat( reply, ldap_err2string( ldp->ld_errno ));
@@ -336,8 +320,8 @@ report_ldap_err( ldp, reply )
 }
 
 
-remove_trailing_space( s )
-    char       *s;
+static void
+remove_trailing_space( char *s )
 {
     char       *p = s + strlen( s ) - 1;
 
index 537f92c1c483896d308b736deddd605ab1242212..c8d4da822d0f80bd13604a06f6a6a95780e2aff5 100644 (file)
@@ -6,6 +6,10 @@
  * All Rights Reserved
  */
 
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
+
 struct msginfo {
     char       *msg_subject;
     char       *msg_replyto;   /* actually could be from From: line */
@@ -16,8 +20,9 @@ struct msginfo {
 };
 
 struct command {
-    char        *cmd_text;              /* text for command, e.g. "HELP" */
-    int        (*cmd_handler)();        /* pointer to handler function */
+       char    *cmd_text;      /* text for command, e.g. "HELP" */
+       /* pointer to handler function */
+       int     (*cmd_handler) LDAP_P((struct msginfo *msgp, char *reply));
 };
 
 
@@ -27,10 +32,28 @@ struct command {
 /*
  * functions
  */
-int    help_cmd();
-int    query_cmd();
+int    help_cmd  LDAP_P((struct msginfo *msgp, char *reply));
+int    query_cmd LDAP_P((struct msginfo *msgp, char *reply));
 
 /*
  * externs
  */
+
+/* cmds.c */
 extern struct command cmds[];
+/* main.c */
+extern int dosyslog;
+#ifdef LDAP_CONNECTIONLESS
+extern int do_cldap;
+#endif
+extern int derefaliases;
+extern int sizelimit;
+extern int rdncount;
+extern int ldapport;
+extern char *ldaphost;
+extern char *searchbase;
+extern char *dapuser;
+extern char *filterfile;
+extern char *templatefile;
+
+LDAP_END_DECL
index 7b7555298dd160bde7238d7a5092fa2f0838643c..4eb6f7a407d96b9c534b466ea339b38e791c37da 100644 (file)
@@ -23,10 +23,6 @@ static int   ldapport = LDAP_PORT;
 static int     not, verbose, contoper;
 static LDAP    *ld;
 
-#ifdef LDAP_DEBUG
-extern int ldap_debug, lber_debug;
-#endif /* LDAP_DEBUG */
-
 #define safe_realloc( ptr, size )      ( ptr == NULL ? malloc( size ) : \
                                         realloc( ptr, size ))
 
@@ -35,18 +31,13 @@ static int dodelete LDAP_P((
     char       *dn));
 
 int
-main( argc, argv )
-    int                argc;
-    char       **argv;
+main( int argc, char **argv )
 {
     char               *usage = "usage: %s [-n] [-v] [-k] [-d debug-level] [-f file] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [dn]...\n";
     char               buf[ 4096 ];
     FILE               *fp;
     int                        i, rc, kerberos, authmethod;
 
-    extern char        *optarg;
-    extern int optind;
-
     kerberos = not = verbose = contoper = 0;
     fp = NULL;
 
index 2d3506eff129e562540ab682e25150bbbab247b8..b38ec5d167cc2f9d4e241abd062800b82cdc9047 100644 (file)
@@ -33,10 +33,6 @@ static int   ldapport = LDAP_PORT;
 static int     new, replace, not, verbose, contoper, force, valsfromfiles;
 static LDAP    *ld;
 
-#ifdef LDAP_DEBUG
-extern int ldap_debug, lber_debug;
-#endif /* LDAP_DEBUG */
-
 #define safe_realloc( ptr, size )      ( ptr == NULL ? malloc( size ) : \
                                         realloc( ptr, size ))
 
@@ -78,9 +74,6 @@ main( int argc, char **argv )
     int                        rc, i, kerberos, use_ldif, authmethod;
     char               *usage = "usage: %s [-abcknrvF] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile ]\n";
 
-    extern char        *optarg;
-    extern int optind;
-
     if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) {
        prog = argv[ 0 ];
     } else {
index 2bc5d772c1a5e9de4b836ee5255eae715bff38a4..84f2a172af4643f0ba612fa3415e6bb824483d4d 100644 (file)
@@ -23,10 +23,6 @@ static int   ldapport = LDAP_PORT;
 static int     not, verbose, contoper;
 static LDAP    *ld;
 
-#ifdef LDAP_DEBUG
-extern int ldap_debug, lber_debug;
-#endif /* LDAP_DEBUG */
-
 #define safe_realloc( ptr, size )      ( ptr == NULL ? malloc( size ) : \
                                         realloc( ptr, size ))
 
@@ -37,18 +33,13 @@ static int domodrdn LDAP_P((
     int                remove));       /* flag: remove old RDN */
 
 int
-main( argc, argv )
-    int                argc;
-    char       **argv;
+main(int argc, char **argv)
 {
     char               *usage = "usage: %s [-nvkc] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile | dn newrdn ]\n";
     char               *myname,*infile, *entrydn, *rdn, buf[ 4096 ];
     FILE               *fp;
     int                        rc, i, kerberos, remove, havedn, authmethod;
 
-    extern char        *optarg;
-    extern int optind;
-
     infile = NULL;
     kerberos = not = contoper = verbose = remove = 0;
 
index ef39b868e058fb4a0a56228d9a5fd5c0ebe9fd5f..de3904936af37b3eaf0c72a19778ed2a1a7da2e4 100644 (file)
 
 #define DEFSEP         "="
 
-#ifdef LDAP_DEBUG
-extern int ldap_debug, lber_debug;
-#endif /* LDAP_DEBUG */
 
-
-static void usage( s )
-char   *s;
+static void
+usage( char *s )
 {
     fprintf( stderr, "usage: %s [options] filter [attributes...]\nwhere:\n", s );
     fprintf( stderr, "    filter\tRFC-1558 compliant LDAP search filter\n" );
@@ -89,17 +85,13 @@ static int  skipsortattr = 0;
 static int     verbose, not, includeufn, allow_binary, vals2tmp, ldif;
 
 int
-main( argc, argv )
-int    argc;
-char   **argv;
+main( int argc, char **argv )
 {
     char               *infile, *filtpattern, **attrs, line[ BUFSIZ ];
     FILE               *fp;
     int                        rc, i, first, scope, kerberos, deref, attrsonly;
     int                        ldap_options, timelimit, sizelimit, authmethod;
     LDAP               *ld;
-    extern char                *optarg;
-    extern int         optind;
 
     infile = NULL;
     deref = verbose = allow_binary = not = kerberos = vals2tmp =
@@ -375,8 +367,6 @@ static int dosearch(
         ldap_perror( ld, "ldap_search" );
     }
     if ( sortattr != NULL ) {
-           extern int  strcasecmp();
-
            (void) ldap_sort_entries( ld, &res,
                    ( *sortattr == '\0' ) ? NULL : sortattr, strcasecmp );
            matches = 0;
@@ -412,7 +402,6 @@ void print_entry(
     BerElement         *ber;
     struct berval      **bvals;
     FILE               *tmpfp;
-    extern char                *mktemp();
 
     dn = ldap_get_dn( ld, entry );
     if ( ldif ) {
index 1b2474ef663d166b3a4a46d4fe441cbfa750cdd8..8b0ee4c6fc783769fee81694065035e2c9fbeb7f 100644 (file)
@@ -19,6 +19,7 @@
 #include <ac/krb.h>
 #include <ac/string.h>
 #include <ac/time.h>
+#include <ac/unistd.h>
 
 #ifdef HAVE_PWD_H
 #include <pwd.h>
 
 #include "ud.h"
 
-extern LDAP *ld;               /* our LDAP descriptor */
-extern int verbose;            /* verbosity indicator */
-extern char *mygetpass();      /* getpass() passwds are too short */
-
-#ifdef DEBUG
-extern int debug;              /* debug flag */
-#endif
-
 #ifdef HAVE_KERBEROS
 static char tktpath[20];       /* ticket file path */
 static int kinit();
 static int valid_tgt();
 #endif
 
-static void set_bound_dn();
+static void set_bound_dn(char *s);
 
-auth(who, implicit)
-char *who;
-int implicit;
+
+int
+auth( char *who, int implicit )
 {
        int rc;                 /* return code from ldap_bind() */
        char *passwd = NULL;    /* returned by mygetpass() */
@@ -71,13 +64,6 @@ int implicit;
        static char prompt[MED_BUF_SIZE];       /* place for us to sprintf the prompt */
        static char name[MED_BUF_SIZE]; /* place to store the user's name */
        static char password[MED_BUF_SIZE];     /* password entered by user */
-       extern struct entry Entry;      /* look here for a name if needed */
-       extern LDAPMessage *find();     /* for looking up 'name' */
-       extern char *search_base;       /* for printing later */
-       extern char *default_bind_object;       /* bind as this on failure */
-       extern void printbase();        /* used to pretty-print a base */
-       extern int bind_status;
-       extern void Free();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -306,8 +292,8 @@ int implicit;
 #define FIVEMINS       ( 5 * 60 )
 #define TGT            "krbtgt"
 
-static void str2upper( s )
-    char       *s;
+static void
+str2upper( char *s )
 {
        char    *p;
 
@@ -317,8 +303,8 @@ static void str2upper( s )
 }
 
 
-static valid_tgt( names )
-    char       **names;
+static int
+valid_tgt( char **names )
 {
        int             i;
        char            name[ ANAME_SZ ], inst[ INST_SZ ], realm[ REALM_SZ ];
@@ -358,9 +344,7 @@ static char *kauth_name;
 
 /*ARGSUSED*/
 int
-krbgetpass( user, inst, realm, pw, key )
-    char *user, *inst, *realm, *pw;
-    C_Block key;
+krbgetpass( char *user, char *inst, char *realm, char *pw, C_Block key )
 {
        char    *p, lcrealm[ REALM_SZ ], prompt[256], *passwd;
 
@@ -390,8 +374,8 @@ krbgetpass( user, inst, realm, pw, key )
        return( 0 );
 }
 
-static kinit( kname )
-    char       *kname;
+static int
+kinit( char *kname )
 {
        int     rc;
        char    name[ ANAME_SZ ], inst[ INST_SZ ], realm[ REALM_SZ ];
@@ -430,7 +414,8 @@ static kinit( kname )
        return( 0 );
 }
 
-void destroy_tickets(void)
+void
+destroy_tickets( void )
 {
        if ( *tktpath != '\0' ) {
                unlink( tktpath );
@@ -438,11 +423,9 @@ void destroy_tickets(void)
 }
 #endif
 
-static void set_bound_dn(char *s)
+static void
+set_bound_dn( char *s )
 {
-       extern void Free();
-       extern char *bound_dn;
-
        if (bound_dn != NULL)
                Free(bound_dn);
        bound_dn = (s == NULL) ? NULL : strdup(s);
index d780c5ab9e08d4f02e3d454405a8a72dd957cd2a..b34790ca92f4d64ad7e0a0cad28951084d6b7fea 100644 (file)
 
 #include <ac/signal.h>
 #include <ac/string.h>
+#include <ac/ctype.h>
 #include <ac/time.h>
 #include <ac/wait.h>
+#include <ac/unistd.h>
 
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #include <ldap.h>
 #include <ldapconfig.h>
 #include "ud.h"
-extern void *Malloc();
 
-extern struct entry Entry; 
-extern int verbose;
-extern LDAP *ld;
-
-extern LDAPMessage *find();
-
-static int load_editor();
-static int modifiable();
-static int print_attrs_and_values();
-static int ovalues();
-static int write_entry();
+static int  load_editor( void );
+static int  modifiable( char *s, short flag );
+static int  print_attrs_and_values( FILE *fp, struct attribute *attrs, short flag );
+static int  ovalues( char *attr );
+static void write_entry( void );
 
 static char *entry_temp_file;
 
-#ifdef DEBUG
-extern int debug;
-#endif
 
-edit(who)
-char *who;
+void
+edit( char *who )
 {
        LDAPMessage *mp;                        /* returned from find() */
        char *dn, **rdns;                       /* distinguished name */
        char name[MED_BUF_SIZE];                /* entry to modify */
-       extern int bind_status;
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -111,19 +102,18 @@ char *who;
        (void) ldap_value_free(rdns);
        if (load_editor() < 0)
                return;
-       (void) write_entry();
+       write_entry();
        (void) unlink(entry_temp_file);
        ldap_uncache_entry(ld, Entry.DN);
        return;
 }
 
-static load_editor()
+static int
+load_editor( void )
 {
        FILE *fp;
        char *cp, *editor = UD_DEFAULT_EDITOR;
        static char template[MED_BUF_SIZE];
-       extern char * mktemp();
-       extern int isgroup(), fatal();
        int pid;
        int status;
        int rc;
@@ -208,10 +198,8 @@ static load_editor()
        return(0);
 }
 
-static int print_attrs_and_values(fp, attrs, flag)
-FILE *fp;
-struct attribute attrs[];
-short flag;
+static int
+print_attrs_and_values( FILE *fp, struct attribute *attrs, short int flag )
 {
        register int i, j;
 
@@ -231,12 +219,10 @@ short flag;
        return( 0 );
 }
 
-static modifiable(s, flag)
-char *s;
-short flag;
+static int
+modifiable( char *s, short int flag )
 {
        register int i;
-       extern struct attribute attrlist[];
 
        for (i = 0; attrlist[i].quipu_name != NULL; i++) {
                if (strcasecmp(s, attrlist[i].quipu_name))
@@ -249,7 +235,8 @@ short flag;
        return(FALSE);
 }
 
-static write_entry()
+static void
+write_entry( void )
 {
        int i = 0, j, number_of_values = -1;
 
@@ -259,9 +246,6 @@ static write_entry()
        LDAPMod *mods[MAX_ATTRS + 1];
        LDAPMod *modp = NULL;
 
-       extern char * code_to_str();
-       extern void free_mod_struct();
-
        /* parse the file and write the values to the Directory */
        if ((fp = fopen(entry_temp_file, "r")) == NULL) {
                perror("fopen");
@@ -455,8 +439,8 @@ static write_entry()
        return;
 }
 
-static ovalues(attr)
-char *attr;
+static int
+ovalues( char *attr )
 {
        struct attribute *ap;
 
index b057233420cc5646423a65f539165ea365b50f04..8972476c5fc7d43339de7c7966ad4ad6c16e00ed 100644 (file)
@@ -13,6 +13,7 @@
 #include "portable.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <ac/ctype.h>
 #include <ac/string.h>
 
 #include "ud.h"
 
-extern char *search_base;      /* search base */
-extern int verbose;            /* verbose mode flag */
-extern LDAP *ld;               /* our ldap descriptor */
-       
 static int num_picked = 0;     /* used when user picks entry at More prompt */
 
-#ifdef DEBUG
-extern int debug;              /* debug flag */
-#endif
 
-vrfy(dn)
-char *dn;
+int
+vrfy( char *dn )
 {
        LDAPMessage *results;
        static char *attrs[2] = { "objectClass", NULL };
@@ -57,11 +51,8 @@ char *dn;
 }
        
 
-static LDAPMessage * disambiguate( result, matches, read_attrs, who )
-LDAPMessage *result;
-int matches;
-char **read_attrs;
-char *who;
+static LDAPMessage *
+disambiguate( LDAPMessage *result, int matches, char **read_attrs, char *who )
 {
        int choice;                     /* entry that user chooses */
        int i;
@@ -69,7 +60,6 @@ char *who;
        char response[SMALL_BUF_SIZE];  /* results from user */
        char *name = NULL;              /* DN to lookup */
        LDAPMessage *mp;
-       extern void Free();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -153,9 +143,8 @@ char *who;
        }
 }
 
-LDAPMessage * find(who, quiet)
-char *who;
-int quiet;
+LDAPMessage *
+find( char *who, int quiet )
 {
        register int i, j, k;           /* general ints */
        int matches;                    /* from ldap_count_entries() */
@@ -169,9 +158,6 @@ int quiet;
        char response[SMALL_BUF_SIZE];
        char *cp, *dn, **rdns;
        LDAPFiltInfo *fi;
-       extern LDAPFiltDesc *lfdp;              /* LDAP filter descriptor */
-       extern struct attribute attrlist[];     /* complete list of attrs */
-       extern void Free();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -330,8 +316,8 @@ int quiet;
        return(NULL);
 }
 
-pick_one(i)
-int i;
+int
+pick_one( int i )
 {
        int n;
        char user_pick[SMALL_BUF_SIZE];
@@ -356,13 +342,10 @@ int i;
        /* NOTREACHED */
 }
 
-print_list(list, names, matches)
-LDAPMessage *list;
-char *names[];
-int *matches;
+void
+print_list( LDAPMessage *list, char **names, int *matches )
 {
        char **rdns, **cpp;
-       extern int lpp;
        char resp[SMALL_BUF_SIZE];
        register LDAPMessage *ep;
        register int i = 1;
@@ -406,9 +389,8 @@ again:
        return;
 }
 
-find_all_subscribers(sub, group)
-char *sub[];
-char *group;
+int
+find_all_subscribers( char **sub, char *group )
 {
        int count;
        LDAPMessage *result;
@@ -451,9 +433,8 @@ char *group;
        return(count);
 }
 
-char * fetch_boolean_value(who, attr)
-char *who;
-struct attribute attr;
+char *
+fetch_boolean_value( char *who, struct attribute attr )
 {
        LDAPMessage *result;            /* from the search below */
        register LDAPMessage *ep;       /* entry pointer */
index 121f36be21fb2a2ca666349f4d1e5839104f4c8e..9e76d94a2413754c2b287be1fafadec1c1e6b6c5 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
+#include <ac/time.h>           /* portable.h+ldap.h needs time_t */
+#include <lber.h>
+#include <ldap.h>
 #include "ud.h"
 
-extern void    set_boolean(), 
-               change_field(), 
-#ifdef UOFM
-               set_updates(), 
-#endif
-               mod_addrDN();
-
 struct attribute attrlist[] = {
 
        /* 
@@ -28,8 +26,8 @@ struct attribute attrlist[] = {
         *  Field 3 = function used to modify this field (if any)
         *  Field 4 = Flags specifying how this field is displayed
         */
-       { "memberOfGroup", "Subscriptions", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN },
-       { "acl", "Access Control", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
+       { "memberOfGroup", "Subscriptions", 0, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN },
+       { "acl", "Access Control", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
        { "cn", "Aliases", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH | ATTR_FLAG_GROUP_MOD },
        { "title", "Title", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_SEARCH | ATTR_FLAG_PERSON_MOD },
        { "postalAddress", "Business address", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD | ATTR_FLAG_IS_MULTILINE },
@@ -38,18 +36,18 @@ struct attribute attrlist[] = {
        { "member", "Members", mod_addrDN, ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN | ATTR_FLAG_GROUP_MOD },
        { "homePhone", "Home phone", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ  | ATTR_FLAG_PERSON_MOD },
        { "homePostalAddress", "Home address", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ  | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_MULTILINE },
-       { "objectClass", "Object class", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH },
+       { "objectClass", "Object class", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH },
 #ifdef UOFM
        { "multiLineDescription", "Description", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ  | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD | ATTR_FLAG_IS_MULTILINE },
 #endif
-#ifdef KERBEROS
-       { "krbName", "Kerberos name", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_READ },
+#ifdef HAVE_KERBEROS
+       { "krbName", "Kerberos name", 0, ATTR_FLAG_PERSON | ATTR_FLAG_READ },
 #endif
-       { "description", "Brief description", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
+       { "description", "Brief description", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
        { "facsimileTelephoneNumber", "Fax number", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ  | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD },
        { "pager", "Pager number", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ  | ATTR_FLAG_PERSON_MOD },
-       { "uid", "Uniqname", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
-       { "userPassword", "Password", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
+       { "uid", "Uniqname", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
+       { "userPassword", "Password", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
 #ifdef UOFM
        { "noBatchUpdates", "No batch updates", set_updates, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD },
 #endif
@@ -65,7 +63,7 @@ struct attribute attrlist[] = {
        { "onVacation", "On Vacation", set_boolean, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_A_BOOL },
        { "vacationMessage", "Vacation Message", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ  | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_MULTILINE },
        { "drink", "Favorite Beverage", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD },
-       { "lastModifiedBy", "Last modified by", NULL, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_IS_A_DN | ATTR_FLAG_READ },
-       { "lastModifiedTime", "Last modified at", NULL, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DATE },
-       { NULL, NULL, NULL, ATTR_FLAG_NONE }
+       { "lastModifiedBy", "Last modified by", 0, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_IS_A_DN | ATTR_FLAG_READ },
+       { "lastModifiedTime", "Last modified at", 0, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DATE },
+       { NULL, NULL, 0, ATTR_FLAG_NONE }
 };
index 64006170eb356e48dc970f8cd9145162160317c5..dff41cdf7b2841f86fcc92f5d2d964fedb4cbef5 100644 (file)
  *
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
+
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
 #include <lber.h>
 #include <ldap.h>
 #include <ldapconfig.h>
 #include "ud.h"
 
-extern LDAPMessage * find();
-
-#ifdef DEBUG
-extern int debug;
-#endif
-
-extern char *bound_dn, *group_base;
-extern int verbose, bind_status;
-extern struct entry Entry;
-extern LDAP *ld;
+static char * bind_and_fetch(char *name);
 
-extern void Free();
 
-void add_group(name)
-char *name;
+void
+add_group( char *name )
 {
        register int i, idx = 0, prompt = 0;
        char tmp[BUFSIZ], dn[BUFSIZ];
@@ -42,8 +39,6 @@ char *name;
        char *init_rdn_value[2], *init_owner_value[2], *init_domain_value[2],
                *init_errors_value[MAX_VALUES], *init_joinable_value[2],
                *init_request_value[MAX_VALUES];
-       extern void ldap_flush_cache();
-       extern char * strip_ignore_chars();
 
 #ifdef DEBUG
        if (debug & D_TRACE) {
@@ -160,7 +155,6 @@ char *name;
                register LDAPMod **lpp;
                register char **cpp;
                register int j;
-               extern char * code_to_str();
                printf("  About to call ldap_add()\n");
                printf("  ld = 0x%x\n", ld);
                printf("  dn = [%s]\n", dn);
@@ -175,7 +169,7 @@ char *name;
 #endif
 
        /*
-        *  Now add this to the X.500 Directory.
+        *  Now add this to the LDAP Directory.
         */
        if (ldap_add_s(ld, dn, attrs) != 0) {
                ldap_perror(ld, "  ldap_add_s");
@@ -199,11 +193,10 @@ char *name;
        return;
 }
 
-void remove_group(name)
-char *name;
+void
+remove_group( char *name )
 {
        char *dn, tmp[BUFSIZ];
-       static char * bind_and_fetch();
 
 #ifdef DEBUG
        if (debug & D_TRACE) {
@@ -225,7 +218,7 @@ char *name;
                return;
 
        /*
-        *  Now remove this from the X.500 Directory.
+        *  Now remove this from the LDAP Directory.
         */
        if (ldap_delete_s(ld, dn) != 0) {
                if (ld->ld_errno == LDAP_INSUFFICIENT_ACCESS)
@@ -246,15 +239,13 @@ char *name;
        return;
 }
 
-void x_group(action, name)
-int action;
-char *name;
+void
+x_group( int action, char *name )
 {
        char **vp;
        char *values[2], *group_name;
        LDAPMod mod, *mods[2];
        static char *actions[] = { "join", "resign from", NULL };
-       static char * bind_and_fetch();
 
 #ifdef DEBUG
        if (debug & D_TRACE) {
@@ -344,8 +335,8 @@ char *name;
        return;
 }
 
-void bulk_load(group)
-char *group;
+void
+bulk_load( char *group )
 {
        register int idx_mail, idx_x500;
        register int count_mail, count_x500;
@@ -452,7 +443,7 @@ char *group;
                }
 
                /*
-                *  Add the X.500 style names.
+                *  Add the LDAP style names.
                 */
                if (count_x500 > 0) {
                        mods[0] = &mod;
@@ -500,15 +491,13 @@ char *group;
        return;
 }
 
-void purge_group(group)
-char *group;
+void
+purge_group( char *group )
 {
        int isclean = TRUE;
        LDAPMessage *lm;
        LDAPMod mod, *mods[2];
        char dn[BUFSIZ], tmp[BUFSIZ], *values[2], **vp, **rdns;
-       extern char * my_ldap_dn2ufn();
-       extern int col_size;
 
 #ifdef DEBUG
        if (debug & D_TRACE) {
@@ -562,7 +551,7 @@ char *group;
        vp = Entry.attrs[attr_to_index("member")].values;
        if (vp == NULL) {
                if (verbose)
-                       printf("  \"%s\" has no X.500 members.  There is nothing to purge.\n", group);
+                       printf("  \"%s\" has no LDAP members.  There is nothing to purge.\n", group);
                return;
        }
        for (; *vp != NULL; vp++) {
@@ -654,7 +643,8 @@ ask:
        return;
 }
 
-void tidy_up()
+void
+tidy_up( void )
 {
        register int i = 0;
        int found_one = 0;
@@ -729,11 +719,9 @@ void tidy_up()
  *  Names or e-mail addresses.  This includes things like group members,
  *  the errors-to field in groups, and so on.
  */
-void mod_addrDN(group, offset)
-char *group;
-int offset;
+void
+mod_addrDN( char *group, int offset )
 {
-       extern struct attribute attrlist[];
        char s[BUFSIZ], *new_value /* was member */, *values[2];
        char attrtype[ 64 ];
        int i;
@@ -805,7 +793,7 @@ int offset;
        }
        if (verbose) {
                printf("\n");
-               format("Values may be specified as a name (which is then looked up in the X.500 Directory) or as a domain-style (i.e., user@domain) e-mail address.  Simply hit the RETURN key at the prompt when finished.\n", 75, 2);
+               format("Values may be specified as a name (which is then looked up in the LDAP Directory) or as a domain-style (i.e., user@domain) e-mail address.  Simply hit the RETURN key at the prompt when finished.\n", 75, 2);
                printf("\n");
        }
 
@@ -998,10 +986,8 @@ int offset;
        }
 }
 
-my_ldap_modify_s(ldap, group, mods)
-LDAP *ldap;
-char *group;
-LDAPMod *mods[];
+int
+my_ldap_modify_s( LDAP *ldap, char *group, LDAPMod **mods )
 {
        int     was_rfc822member, rc;
 
@@ -1020,8 +1006,8 @@ LDAPMod *mods[];
        return(rc);
 }
 
-void list_groups(who)
-char *who;
+void
+list_groups( char *who )
 {
        LDAPMessage *mp;
        char name[BUFSIZ], filter[BUFSIZ], *search_attrs[2];
@@ -1099,12 +1085,11 @@ char *who;
        return;
 }
 
-static char * bind_and_fetch(name)
-char *name;
+static char *
+bind_and_fetch( char *name )
 {
        LDAPMessage *lm;
        char tmp[MED_BUF_SIZE];
-       extern char * strip_ignore_chars();
 
 #ifdef DEBUG
        if (debug & D_TRACE) {
@@ -1154,8 +1139,8 @@ char *name;
        return(strdup(Entry.DN));
 }
 
-void list_memberships(who)
-char *who;
+void
+list_memberships( char *who )
 {
        LDAPMessage *mp;
        char name[BUFSIZ], filter[BUFSIZ], *search_attrs[2];
index 5a1ff231e07f15675510d0bac6a9fcd3a3755590..b851d49d37e1979a101a0d8c8c797fc3d7e5339b 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <ctype.h>
-#include <string.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
 #include <lber.h>
 #include <ldap.h>
+
 #include "ud.h"
 
-#ifdef DEBUG
-extern int debug;
-#endif
 
-print_help(s)
-char *s;
+void
+print_help( char *s )
 {
        int len;                        /* command length */
 
@@ -88,7 +91,7 @@ char *s;
                format("should be specified as a ordinary name (e.g., 'Friends of maX500').", 75, 15);
                printf("\n");
                printf("  [where]      A place in the Directory needs to be specified.  This name\n");
-               format("should be specified as an X.500-style name (e.g., 'ou=people, o=University of Michigan, c=United States of America').  In most cases, it is easier to omit the [where] and allow the program to guide you.", 75, 15);
+               format("should be specified as an LDAP-style name (e.g., 'ou=people, o=University of Michigan, c=United States of America').  In most cases, it is easier to omit the [where] and allow the program to guide you.", 75, 15);
                printf("\n");
                printf("  [who]        A person in the Directory needs to be specified.  This name\n");
                format("can be specified as either a ordinary name (e.g., 'Jane Doe'), or as some other identifying characteristic (e.g., 'uid=babs').", 75, 15);
@@ -111,7 +114,7 @@ char *s;
        }
        else if (!strncasecmp("groupbase", s, len)) {
                printf("  groupbase [where]\n\n");
-               format("The syntax and use of this command is identical to the more commonly used 'cb' command.  This command sets the base which is used to create groups in the X.500 Directory.  Setting the base to a certain value does not necessarily grant the person write-access to that part of the Directory in order to successfully create a group.", 75, 2);
+               format("The syntax and use of this command is identical to the more commonly used 'cb' command.  This command sets the base which is used to create groups in the LDAP Directory.  Setting the base to a certain value does not necessarily grant the person write-access to that part of the Directory in order to successfully create a group.", 75, 2);
        }
        else if (!strncasecmp("cd", s, len) || !strncasecmp("cb", s,len)) {
                printf("  cb [where]\n");
@@ -125,7 +128,7 @@ char *s;
        printf("\n            * cb default\n\n");
        format("sets the search base to its original default value.", 75, 2);
        printf("\n            * cb o=Merit Computer Network, c=US\n\n");
-       format("sets the search base to organization given, the Merit Computer Network in this case.  This comamnd checks the validity of the specified search base, and rejects it if it is not a valid Distinguished Name (DN).  A DN uniquely identifies a portion of the global X.500 namespace.", 75, 2);
+       format("sets the search base to organization given, the Merit Computer Network in this case.  This comamnd checks the validity of the specified search base, and rejects it if it is not a valid Distinguished Name (DN).  A DN uniquely identifies a portion of the global LDAP namespace.", 75, 2);
        }
        else if (!strncasecmp("quit", s, len) || !strncasecmp("stop",s, len)) {
                printf("  quit\n");
@@ -145,7 +148,7 @@ char *s;
        else if (!strncasecmp("modify", s, len) || !strncasecmp("change", s, len)) {
                printf("  modify [entry]\n");
                printf("  change [entry]\n\n");
-               format("Changes information associated with an entry in the X.500 Directory.  'change' is an alias for 'modify'.", 75, 2);
+               format("Changes information associated with an entry in the LDAP Directory.  'change' is an alias for 'modify'.", 75, 2);
        }
        else if (!strncasecmp("verbose", s, len)) {
                printf("  verbose\n\n");
@@ -182,7 +185,7 @@ char *s;
        }
        else if (!strncasecmp("tidy", s, len)) {
                printf("  tidy\n\n");
-               format("Unsubscribes you from non-existent groups.  Useful when you cannot resign from a group because, while your X.500 entry still contains a pointer to it, someone has removed a group of which you were a subscriber.", 75, 2);
+               format("Unsubscribes you from non-existent groups.  Useful when you cannot resign from a group because, while your LDAP entry still contains a pointer to it, someone has removed a group of which you were a subscriber.", 75, 2);
        }
        else if (*s == '?') {
                format("Prints out a brief description of each command.  Same as typing 'help help'.", 75, 2);
index 7e5f7e8e9280ee1cb2997c4870bb816b7e375f3c..e5e418fa5337c8f2888c836f960ee6ebf20465a9 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <ac/signal.h>
 #include <ac/string.h>
+#include <ac/ctype.h>
 #include <ac/termios.h>
 #include <ac/time.h>
 #include <ac/unistd.h>
@@ -80,15 +81,10 @@ LDAPFiltDesc *lfdp;         /* LDAP filter descriptor */
 int debug;                     /* debug flag */
 #endif
 
-extern void initialize_client();
-extern void initialize_attribute_strings();
 
-main(argc, argv)
-int argc;
-char *argv[];
+int
+main( int argc, char **argv )
 {
-       extern char Version[];                  /* version number */
-       extern char *optarg;                    /* for parsing argv */
        register int c;                         /* for parsing argv */
        register char *cp;                      /* for parsing Version */
 
@@ -163,7 +159,8 @@ char *argv[];
        /* NOTREACHED */
 }
 
-do_commands()
+void
+do_commands( void )
 {
        LDAPMessage *mp;                        /* returned by find() */
        register char *cp;                      /* misc char pointer */
@@ -171,10 +168,6 @@ do_commands()
        static char buf[MED_BUF_SIZE];          /* for prompting */
        static char cmd[MED_BUF_SIZE];          /* holds the command */
        static char input[MED_BUF_SIZE];        /* buffer for input */
-       extern LDAPMessage *find();
-       extern void purge_group(), add_group(), remove_group(), x_group(),
-               tidy_up(), list_groups(), list_memberships(), edit();
-       extern char *nextstr();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -282,9 +275,9 @@ do_commands()
        /* NOTREACHED */
 }
 
-status()
+void
+status( void )
 {
-       void printbase();
        register char **rdns;
 
 #ifdef DEBUG
@@ -311,9 +304,8 @@ status()
        }
 }
 
-change_base(type, base, s)
-int type;
-char **base, *s;
+void
+change_base( int type, char **base, char *s )
 {
        register char *cp;                      /* utility pointers */
        char **rdns;                            /* for parsing */
@@ -327,13 +319,9 @@ char **base, *s;
        static char *choices[MED_BUF_SIZE];     /* bases from which to choose */
        static char resp[SMALL_BUF_SIZE];       /* for prompting user */
        static char buf[MED_BUF_SIZE];
-       void printbase();
        static char *attrs[] = { "objectClass", NULL };
        LDAPMessage *mp;                        /* results from a search */
        LDAPMessage *ep;                        /* for going thru bases */
-       extern char * friendly_name();
-       extern void StrFreeDup();
-       extern void Free();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -528,7 +516,8 @@ char **base, *s;
        }
 }
 
-void initialize_client()
+void
+initialize_client( void )
 {
        FILE *fp;                               /* for config file */
        static char buffer[MED_BUF_SIZE];       /* for input */
@@ -537,9 +526,6 @@ void initialize_client()
        char *term;                             /* for tty set-up */
        char *config;                           /* config file to use */
        static char bp[1024];                   /* for tty set-up */
-       extern RETSIGTYPE attn();                       /* ^C signal handler */
-       extern char *getenv();
-       extern void Free();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -665,7 +651,6 @@ void initialize_client()
 #ifndef NO_TERMCAP
        {
        struct winsize win;                     /* for tty set-up */
-       extern RETSIGTYPE chwinsz();            /* WINSZ signal handler */
 
        if (((term = getenv("TERM")) == NULL) || (tgetent(bp, term) <= 0))
                return;
@@ -693,7 +678,8 @@ void initialize_client()
 #endif
 }
 
-RETSIGTYPE attn()
+RETSIGTYPE
+attn( int sig )
 {
        fflush(stderr);
        fflush(stdout);
@@ -704,8 +690,9 @@ RETSIGTYPE attn()
        longjmp(env, 1);
 }
 
-#ifndef NO_TERMCAP
-RETSIGTYPE chwinsz() 
+#if !defined(NO_TERMCAP) && defined(TIOCGWINSZ)
+RETSIGTYPE
+chwinsz( int sig )
 {
        struct winsize win;
 
index 637084f295488a87ccd13dc811dff86e3b06793a..b6efc6fc02c7dc275d455fdaf397efb9a306648a 100644 (file)
@@ -13,6 +13,7 @@
 #include "portable.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <ac/ctype.h>
 #include <ac/string.h>
 #include <lber.h>
 #include <ldap.h>
 #include "ud.h"
-extern void Free();
 
-extern struct entry Entry; 
-extern int verbose;
-extern LDAP *ld;
+static char *get_URL( void );
+static int  check_URL( char *url );
 
-extern LDAPMessage *find();
-extern void * Malloc();
 
-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 */
@@ -52,11 +39,8 @@ char *who;
 #ifdef UOFM
        static char printed_warning = 0;        /* for use with the */
        struct attribute no_batch_update_attr;
-       extern char * fetch_boolean_value();
 #endif
        int is_a_group;         /* TRUE if it is; FALSE otherwise */
-       extern void Free();
-       extern int bind_status;
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -165,14 +149,16 @@ char *who;
 }
 
 /* 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;
@@ -180,7 +166,6 @@ struct attribute attr;              /* attribute to change */
        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)
@@ -378,8 +363,8 @@ struct attribute attr;              /* attribute to change */
 #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 */
@@ -541,12 +526,15 @@ mail_is_good:
        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];
@@ -600,11 +588,10 @@ struct attribute attr;            /* boolean attribute to change */
 
 #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 };
@@ -670,11 +657,10 @@ char *who;
 
 #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++) {
@@ -699,15 +685,11 @@ int group;
 #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) {
@@ -743,18 +725,12 @@ int group;
                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];
 
@@ -784,8 +760,8 @@ static char * get_URL()
        return((char *) rvalue);
 }
 
-static check_URL(url)
-char *url;
+static int
+check_URL( char *url )
 {
        register char *cp;
 
@@ -799,6 +775,7 @@ char *url;
 }
 
 
+void
 mod_perror( LDAP *ld )
 {
        if ( ld == NULL || ( ld->ld_errno != LDAP_UNAVAILABLE &&
index 4185bdaef367e3580a1911e73831b05d6a4f7331..ba665222b19b15c59a0c7b7d97d7dae5f39aabc0 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#ifndef __STDC__
-#include <memory.h>
-#endif
-#include <time.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
 #include <lber.h>
 #include <ldap.h>
-#include "ud.h"
 
-#ifdef DEBUG
-extern int debug;
-#endif
+#include "ud.h"
 
 struct entry Entry;
-extern LDAP *ld;
 
-extern void * Malloc();
-extern void Free();
-extern char * my_ldap_dn2ufn();
+static char *time2text(char *ldtimestr, int dateonly);
+static long            gtime(struct tm *tm);
 
 /*
  *  When displaying entries, display only these attributes, and in this
@@ -80,15 +76,15 @@ static char *group_attr_print_order[] = {
        NULL
 };
 
-parse_answer(s)
-LDAPMessage *s;
+
+void
+parse_answer( LDAPMessage *s )
 {
        int idx;
        char **rdns;
        BerElement *cookie;
        register LDAPMessage *ep;
        register char *ap;
-       void clear_entry();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -137,10 +133,8 @@ LDAPMessage *s;
 #endif
 }
 
-add_value(attr, ep, ap)
-struct attribute *attr;
-LDAPMessage *ep;
-char *ap;
+void
+add_value( struct attribute *attr, LDAPMessage *ep, char *ap )
 {
        register int i = 0;
        char **vp, **tp, **avp;
@@ -185,13 +179,12 @@ char *ap;
        ldap_value_free(vp);
 }
 
-print_an_entry()
+void
+print_an_entry( void )
 {
        int n = 0, i, idx;
        char is_a_group, **order;
        char *sub_list[MAX_VALUES], buf[SMALL_BUF_SIZE];
-       extern int col_size, isaurl(), isadn();
-       static char *time2text();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -277,8 +270,8 @@ print_an_entry()
 #define OUT_LABEL_LEN  20
 
 /* prints the values associated with an attribute */
-print_values(A)
-struct attribute A;
+void
+print_values( struct attribute A )
 {
        register int i, k;
        register char *cp, **vp;
@@ -370,13 +363,12 @@ struct attribute A;
 }
 
 /* prints the DN's associated with an attribute */
-print_DN(A)
-struct attribute A;
+void
+print_DN( struct attribute A )
 {
        int i, lead;
        register char **vp;
        char out_buf[MED_BUF_SIZE], *padding = NULL;
-       extern int col_size;
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -407,10 +399,10 @@ struct attribute A;
        return;
 }
 
-void clear_entry()
+void
+clear_entry( void )
 {
        register int i;
-       extern struct attribute attrlist[];
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -456,11 +448,10 @@ void clear_entry()
        }
 }
 
-attr_to_index(s)
-char *s;
+int
+attr_to_index( char *s )
 {
        register int i;
-       extern struct attribute attrlist[];
 
        for (i = 0; attrlist[i].quipu_name != NULL; i++)
                if (!strcasecmp(s, attrlist[i].quipu_name))
@@ -468,11 +459,10 @@ char *s;
        return(-1);
 }
 
-void initialize_attribute_strings()
+void
+initialize_attribute_strings( void )
 {
        register int i;
-       extern struct entry Entry;
-       extern struct attribute attrlist[];
 
        for (i = 0; attrlist[i].quipu_name != NULL; i++)
                Entry.attrs[i].quipu_name = attrlist[i].quipu_name;
@@ -481,8 +471,8 @@ void initialize_attribute_strings()
 }
 
 /* prints the URL/label pairs associated with an attribute */
-print_URL(A)
-struct attribute A;
+void
+print_URL( struct attribute A )
 {
        int i, lead;
        register char **vp;
@@ -516,16 +506,11 @@ struct attribute A;
        return;
 }
 
-print_one_URL(s, label_lead, tag, url_lead)
-char *s;
-int label_lead;
-char *tag;
-int url_lead;
+void
+print_one_URL( char *s, int label_lead, char *tag, int url_lead )
 {
        register int i;
        char c, *cp, *url;
-       extern int col_size;
-       extern void Free();
 
        for (cp = s; !isspace(*cp) && (*cp != '\0'); cp++)
                ;
@@ -555,7 +540,6 @@ time2text( char *ldtimestr, int dateonly )
     struct tm          t;
     char               *p, *timestr, zone, *fmterr = "badly formatted time";
     time_t             gmttime;
-    static long                gtime();
 
     memset( (char *)&t, 0, sizeof( struct tm ));
     if ( strlen( ldtimestr ) < 13 ) {
@@ -595,9 +579,7 @@ time2text( char *ldtimestr, int dateonly )
 
 /* gtime.c - inverse gmtime */
 
-#if !defined( MACOS ) && !defined( _WIN32 ) && !defined( DOS )
-#include <sys/time.h>
-#endif /* !MACOS */
+#include <ac/time.h>
 
 /* gtime(): the inverse of localtime().
        This routine was supplied by Mike Accetta at CMU many years ago.
@@ -614,7 +596,8 @@ int dmsize[] = {
 
 /* \f */
 
-static long    gtime ( struct tm *tm )
+static long
+gtime( struct tm *tm )
 {
     register int    i,
                     sec,
index 1d6649c0645a457de92c20b471dbcb7c220d340f..ad194b15faa2a508297dbd72542d885d78cb1be1 100644 (file)
@@ -1,7 +1,9 @@
-#ifdef KERBEROS
+#include "portable.h"
+
+#if defined(HAVE_KERBEROS) && !defined(openbsd)
 /*
- * $Source: /usr/local/src/ldap/clients/ud/RCS/string_to_key.c,v $
- * $Author: lsloan $
+ * $Source: /repo/OpenLDAP/pkg/ldap/clients/ud/string_to_key.c,v $
+ * $Author: hallvard $
  *
  * Copyright 1985, 1986, 1987, 1988, 1989 by the Massachusetts Institute
  * of Technology.
  *     spm     8/85    MIT project athena
  */
 
-#ifndef        lint
-static char rcsid_string_to_key_c[] =
-"$Id: string_to_key.c,v 1.5 1995/11/09 20:29:55 lsloan Exp $";
-#endif
-
-#include <mit-copyright.h>
 #include <stdio.h>
-#include <des.h>
-/* #include "des_internal.h" */
-#if 1
-#include <krb.h>
-#endif
+#include <ac/krb.h>
 
 extern int des_debug;
 extern int des_debug_print();
 extern void des_fixup_key_parity();
 
-#ifndef AFSKERBEROS
+#ifndef HAVE_AFS_KERBEROS
 #define WORLDPEACEINOURTIME
 #endif
 
 #if defined(WORLDPEACEINOURTIME) /* Use original, not ifs version */
+#ifndef HAVE_KERBEROS_V
 /*
  * convert an arbitrary length string to a DES key
  */
 int
-des_string_to_key(str,key)
-    char *str;
-    register des_cblock *key;
+des_string_to_key( char *str, register des_cblock *key )
 {
     register char *in_str;
     register unsigned temp,i;
@@ -132,6 +123,7 @@ des_string_to_key(str,key)
                *((unsigned long *) key+1));
 }
 
+#endif /* HAVE_KERBEROS_V */
 #else /* Use ifs version */
 
 #if 0
@@ -151,10 +143,12 @@ des_string_to_key(str,key)
    encryption key.  It is compatible with the original Andrew authentication
    service password database. */
 
-static void Andrew_StringToKey (str, cell, key)
-  char          *str;
-  char          *cell;                  /* cell for password */
-  des_cblock *key;
+static void
+Andrew_StringToKey(
+  char          *str,
+  char          *cell,                  /* cell for password */
+  des_cblock *key
+)
 {   char  password[8+1];                /* crypt is limited to 8 chars anyway */
     int   i;
     int   passlen;
@@ -190,10 +184,12 @@ static void Andrew_StringToKey (str, cell, key)
     des_fixup_key_parity (key);
 }
 
-static void StringToKey (str, cell, key)
-  char          *str;
-  char          *cell;                  /* cell for password */
-  des_cblock *key;
+static void
+StringToKey(
+  char          *str,
+  char          *cell,                  /* cell for password */
+  des_cblock   *key
+)
 {   des_key_schedule schedule;
     char temp_key[8];
     char ivec[8];
@@ -219,16 +215,19 @@ static void StringToKey (str, cell, key)
     des_fixup_key_parity (key);
 }
 
-/* static */  void
-ka_StringToKey (str, cell, key)
-  char          *str;
-  char          *cell;                  /* cell for password */
-  des_cblock   *key;
+void
+ka_StringToKey (
+  char          *str,
+  char          *cell,                  /* cell for password */
+  des_cblock   *key
+)
 {   char  realm[REALM_SZ];
 
 #if NOWAYOUTTODAY
     long  code;
-    /* code = ka_CellToRealm (cell, realm, 0/*local*/); */
+#if 0
+    code = ka_CellToRealm (cell, realm, 0/*local*/);
+#endif
     if (code) strcpy (realm, "");
     else lcstring (realm, realm, sizeof(realm)); /* for backward compatibility */
 #else
@@ -243,9 +242,7 @@ ka_StringToKey (str, cell, key)
  * convert an arbitrary length string to a DES key
  */
 int
-des_string_to_key(str,key)
-    char *str;
-    register des_cblock *key;
+des_string_to_key( char *str, register des_cblock *key )
 {
        /* NB: i should probably call routine to get local cell here */
        ka_StringToKey(str, "umich.edu", key);
index 56ed57f6c6628af713a3cc98de874055a3fe981e..aeea56ae640c5b24d9e21c18c7e494258c75fd93 100644 (file)
@@ -138,7 +138,7 @@ LDAP_BEGIN_DECL
 struct attribute {
        char *quipu_name;
        char *output_string;
-       void (*mod_func)();
+       void (*mod_func) LDAP_P(( char *who, int attr_idx ));
        unsigned short flags;
        int number_of_values;
        char **values;
@@ -152,4 +152,145 @@ struct entry {
        struct attribute attrs[MAX_ATTRS];
 };
 
+
+
+/*
+ * Variables
+ */
+
+/* in globals.c: */
+extern struct attribute attrlist[];/* complete list of attrs */
+/* in main.c: */
+extern char copyright[];
+extern char *default_bind_object;
+extern char *bound_dn;
+extern char *group_base;
+extern char *search_base;      /* search base */
+extern int lpp;
+extern int verbose;            /* verbose mode flag */
+extern int col_size;
+extern int bind_status;
+extern LDAP *ld;               /* our ldap descriptor */
+extern LDAPFiltDesc *lfdp;     /* LDAP filter descriptor */
+#ifdef DEBUG
+extern int debug;              /* debug flag */
+#endif
+/* in print.c: */
+extern struct entry Entry;
+extern int     dmsize[];
+/* in version.c: */
+extern char Version[];
+
+
+/*
+ * Functions
+ */
+
+/* in auth.c: */
+int  auth      LDAP_P(( char *who, int implicit ));
+#if defined(HAVE_KERBEROS) && defined(_AC_KRB_H)
+int  krbgetpass LDAP_P(( char *u, char *in, char *re, char *pw, C_Block key ));
+void destroy_tickets LDAP_P(( void ));
+#endif
+
+/* in edit.c: */
+void edit      LDAP_P(( char *who ));
+
+/* in find.c: */
+int  vrfy      LDAP_P(( char *dn ));
+LDAPMessage *find      LDAP_P(( char *who, int quiet ));
+int  pick_one  LDAP_P(( int i ));
+void print_list        LDAP_P(( LDAPMessage *list, char **names, int *matches ));
+int  find_all_subscribers      LDAP_P(( char **sub, char *group ));
+char *fetch_boolean_value      LDAP_P(( char *who, struct attribute attr ));
+
+/* in globals.c: */
+
+/* in group.c: */
+void add_group LDAP_P(( char *name ));
+void remove_group      LDAP_P(( char *name ));
+void x_group   LDAP_P(( int action, char *name ));
+void bulk_load LDAP_P(( char *group ));
+void purge_group       LDAP_P(( char *group ));
+void tidy_up   LDAP_P(( void ));
+void mod_addrDN        LDAP_P(( char *group, int offset ));
+int  my_ldap_modify_s  LDAP_P(( LDAP *ldap, char *group, LDAPMod **mods ));
+void list_groups       LDAP_P(( char *who ));
+void list_memberships  LDAP_P(( char *who ));
+
+/* in help.c: */
+void print_help        LDAP_P(( char *s ));
+
+/* in main.c: */
+#ifdef DEBUG
+#endif
+
+void do_commands       LDAP_P(( void ));
+void status    LDAP_P(( void ));
+void change_base       LDAP_P(( int type, char **base, char *s ));
+void initialize_client LDAP_P(( void ));
+RETSIGTYPE  attn       LDAP_P(( int sig ));
+#ifndef NO_TERMCAP
+RETSIGTYPE  chwinsz    LDAP_P(( int sig ));
+#endif
+
+/* in mod.c: */
+void modify    LDAP_P(( char *who ));
+void change_field      LDAP_P(( char *who, int attr_idx ));
+char *get_value        LDAP_P(( char *id, char *prompt ));
+void set_boolean       LDAP_P(( char *who, int attr_idx ));
+#ifdef UOFM
+void set_updates       LDAP_P(( char *who, int dummy ));
+#endif
+void print_mod_list    LDAP_P(( int group ));
+int  perform_action    LDAP_P(( char *choice, char *dn, int group ));
+void mod_perror        LDAP_P(( LDAP *ld ));
+
+/* in print.c: */
+void parse_answer      LDAP_P(( LDAPMessage *s ));
+void add_value LDAP_P(( struct attribute *attr, LDAPMessage *ep, char *ap ));
+void print_an_entry    LDAP_P(( void ));
+void print_values      LDAP_P(( struct attribute A ));
+void print_DN  LDAP_P(( struct attribute A ));
+void clear_entry       LDAP_P(( void ));
+int  attr_to_index     LDAP_P(( char *s ));
+void initialize_attribute_strings      LDAP_P(( void ));
+void print_URL LDAP_P(( struct attribute A ));
+void print_one_URL     LDAP_P(( char *s, int l_lead, char *tag, int u_lead ));
+
+/* in string_to_key.c: */
+#if defined(HAVE_KERBEROS) && !defined(openbsd) && defined(_AC_KRB_H)
+#if defined(HAVE_AFS_KERBEROS) || !defined(HAVE_KERBEROS_V)
+int  des_string_to_key LDAP_P(( char *str, des_cblock *key ));
+#endif
+#if defined(HAVE_AFS_KERBEROS)
+void ka_StringToKey LDAP_P(( char *str, char *cell, des_cblock *key ));
+#endif
+#endif
+
+/* in util.c: */
+char *mygetpass        LDAP_P(( char *prompt ));
+void printbase LDAP_P(( char *lead, char *s ));
+void fetch_buffer      LDAP_P(( char *buffer, int length, FILE *where ));
+void fatal     LDAP_P(( char *s ));
+int  isgroup   LDAP_P(( void ));
+void format    LDAP_P(( char *str, int width, int lead ));
+void format2   LDAP_P(( char *s, char *ft, char *t, int fi, int i, int w ));
+char *strip_ignore_chars       LDAP_P(( char *cp ));
+char *code_to_str      LDAP_P(( int i ));
+char *friendly_name    LDAP_P(( char *s ));
+#ifdef UOFM
+int  isauniqname       LDAP_P(( char *s ));
+#endif
+int  isadn     LDAP_P(( char *s ));
+char *my_ldap_dn2ufn   LDAP_P(( char *s ));
+int  isaurl    LDAP_P(( char *s ));
+int  isadate   LDAP_P(( char *s ));
+void *Malloc   LDAP_P(( unsigned int size ));
+void Free      LDAP_P(( void *ptr ));
+char *nextstr  LDAP_P(( char *s ));
+void free_mod_struct   LDAP_P(( LDAPMod *modp ));
+void StrFreeDup        LDAP_P(( char **ptr, char *new_value ));
+int  confirm_action    LDAP_P(( char *msg ));
+
 LDAP_END_DECL
index 2aa08dd906753d315624fa3785929fd319a1cbc8..4dd0cb223ed68ce4ea3eefd9a6874306151ca6f7 100644 (file)
 
 #include "ud.h"
 
-#ifdef DEBUG
-extern int debug;
-#endif
-
-char * mygetpass(prompt)
-char *prompt;
+char *
+mygetpass( char *prompt )
 {
 #if !defined(HAVE_TERMIOS) && !defined(HAVE_SGTTY_H)
        static char buf[256];
@@ -61,7 +57,7 @@ char *prompt;
        register char *p;
        register int c;
        FILE *fi;
-       RETSIGTYPE (*sig)();
+       RETSIGTYPE (*sig)( int sig );
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -145,12 +141,11 @@ char *prompt;
 #endif /* DOS */
 }
 
-void printbase(lead, s)
-char *lead, *s;
+void
+printbase( char *lead, char *s )
 {
        register char **cp;
        char **rdns;
-       char * friendly_name();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -176,12 +171,9 @@ char *lead, *s;
        return;
 }
 
-fetch_buffer(buffer, length, where)
-char *buffer;
-int length;
-FILE *where;
+void
+fetch_buffer( char *buffer, int length, FILE *where )
 {
-       extern LDAP *ld;
        register int i;
        char *p;
 
@@ -212,8 +204,8 @@ FILE *where;
 
 }
 
-fatal(s)
-char *s;
+void
+fatal( char *s )
 {
        if (errno != 0)
                perror(s);
@@ -223,9 +215,9 @@ char *s;
        exit(-1);
 }
 
-isgroup()
+int
+isgroup( void )
 {
-       extern struct entry Entry;
        char **vp;
        register int i;
        int group = FALSE;
@@ -253,14 +245,11 @@ isgroup()
  *  Print out the string 's' on a field of 'width' chracters.  Each line
  *  should be indented 'lead' characters.
  */
-format(str, width, lead)
-char *str;
-int width, lead;
+void
+format( char *str, int width, int lead )
 {
        char *s, *original, *leader = "";
        register char *cp;
-       void * Malloc();
-       void Free();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -309,14 +298,18 @@ int width, lead;
  *  indented 'indent' spaces, then followed by 'tag', and then followed by
  *  subsequent lines of 's'.
  */
-format2(s, first_tag, tag, first_indent, indent, width)
-char *s, *first_tag, *tag;
-int first_indent, indent, width;
+void
+format2(
+    char *s,
+    char *first_tag,
+    char *tag,
+    int first_indent,
+    int indent,
+    int width
+)
 {
        char c, *fi, *i;
        register char *cp;
-       void * Malloc();
-       void Free();
 
        if (first_tag == NULL)
                first_tag = "";
@@ -411,15 +404,13 @@ int first_indent, indent, width;
 #define IN_A_QUOTE   0
 #define OUT_OF_QUOTE 1
 
-char * strip_ignore_chars(cp)
-char *cp;
+char *
+strip_ignore_chars( char *cp )
 {
        int had_a_comma = FALSE;
        int flag = OUT_OF_QUOTE;
        register char *rcp, *cp1;
        char *tmp;
-       void * Malloc();
-       void Free();
 
 #ifdef DEBUG
        if (debug & D_TRACE)
@@ -464,7 +455,8 @@ char *cp;
        return(tmp);
 }
 
-char * code_to_str(int i)
+char *
+code_to_str( int i )
 {
        switch(i) {
        case LDAP_MOD_ADD : return("ADD");
@@ -474,8 +466,8 @@ char * code_to_str(int i)
        }
 }
 
-char * friendly_name(s)
-char *s;
+char *
+friendly_name( char *s )
 {
        static FriendlyMap *map = NULL;
        static char *cp;
@@ -489,8 +481,8 @@ char *s;
 #ifdef UOFM
 
 /* return TRUE if s has the syntax of a uniqname */
-isauniqname(s)
-char *s;
+int
+isauniqname( char *s )
 {
        int i = strlen(s);
 
@@ -506,11 +498,10 @@ char *s;
 #endif
 
 /* return TRUE if this attribute should be printed as a DN */
-isadn(s)
-char *s;
+int
+isadn( char *s )
 {
        register int i;
-       extern struct attribute attrlist[];
 
        for (i = 0; attrlist[i].quipu_name != NULL; i++)
                if (!strcasecmp(s, attrlist[i].quipu_name))
@@ -520,8 +511,8 @@ char *s;
        return(FALSE);
 }
 
-char * my_ldap_dn2ufn(s)
-char *s;
+char *
+my_ldap_dn2ufn( char *s )
 {
        register char **cpp;
        static char short_DN[BUFSIZ];
@@ -535,11 +526,10 @@ char *s;
 }
 
 /* return TRUE if this attribute should be printed as a URL */
-isaurl(s)
-char *s;
+int
+isaurl( char *s )
 {
        register int i;
-       extern struct attribute attrlist[];
 
        for (i = 0; attrlist[i].quipu_name != NULL; i++)
                if (!strcasecmp(s, attrlist[i].quipu_name))
@@ -550,11 +540,10 @@ char *s;
 }
 
 /* return TRUE if this attribute should be printed as a date and time */
-isadate(s)
-char *s;
+int
+isadate( char *s )
 {
        register int i;
-       extern struct attribute attrlist[];
 
        for (i = 0; attrlist[i].quipu_name != NULL; i++)
                if (!strcasecmp(s, attrlist[i].quipu_name))
@@ -564,8 +553,8 @@ char *s;
        return(FALSE);
 }
 
-void * Malloc(size)
-unsigned int size;
+void *
+Malloc( unsigned int size )
 {
        void *void_ptr;
 
@@ -578,8 +567,8 @@ unsigned int size;
        return(void_ptr);
 }
 
-void Free(ptr)
-char *ptr;
+void
+Free( void *ptr )
 {
 #ifndef STDC_HEADERS
        if (free(ptr) < 0) {
@@ -593,8 +582,8 @@ char *ptr;
        return;
 }
 
-char * nextstr(s)
-char *s;
+char *
+nextstr( char *s )
 {
        while (isspace(*s) && (*s != '\0'))
                s++;
@@ -605,22 +594,18 @@ char *s;
        return(s);
 }
 
-void free_mod_struct(modp)
-LDAPMod *modp;
+void
+free_mod_struct( LDAPMod *modp )
 {
-       void Free();
-
        if (modp->mod_values != NULL)
                (void) ldap_value_free(modp->mod_values);
        Free(modp->mod_type);
        Free(modp);
 }
 
-void StrFreeDup(ptr, new_value)
-char **ptr, *new_value;
+void
+StrFreeDup( char **ptr, char *new_value )
 {
-       void Free();
-
        if (*ptr != NULL)
                Free(*ptr);
        if (new_value == NULL)
@@ -630,8 +615,8 @@ char **ptr, *new_value;
 }
 
 
-confirm_action( msg )
-       char    *msg;
+int
+confirm_action( char *msg )
 { 
         char   tmp[SMALL_BUF_SIZE];
        int     i;
index 1d53fd50bd4e8c6f01c655f3381abfdd62f01f8e..1eda75c183ea781082ad140800392b42749d32df 100755 (executable)
--- a/configure
+++ b/configure
@@ -3487,15 +3487,18 @@ else
 int task(arg)
        int *arg;
 {
+       int i;
        struct timeval tv;
 
-       tv.tv_sec=4;
+       tv.tv_sec=5;
        tv.tv_usec=0;
-       select(0, NULL, NULL, NULL, &tv);
 
-       tv.tv_sec=6;
-       tv.tv_usec=0;
-       select(0, NULL, NULL, NULL, &tv);
+       /* we're not interested in any fds */
+       i = select(FD_SETSIZE, NULL, NULL, NULL, &tv);
+
+       if(i < 0) {
+               perror("select");
+       }
 
        exit(1); /* if we exit here, the select blocked the whole process */
 }
@@ -3527,7 +3530,7 @@ int argc; char **argv;
 }
                                
 EOF
-if { (eval echo configure:3531: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3534: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ol_pthread_preemptive=yes
 else
@@ -3568,17 +3571,17 @@ if test $ol_with_threads = auto -o $ol_with_threads = mach ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3572: checking for $ac_hdr" >&5
+echo "configure:3575: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3577 "configure"
+#line 3580 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3582: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3585: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3608,12 +3611,12 @@ done
                ol_with_threads=found
 
                                echo $ac_n "checking for cthread_fork""... $ac_c" 1>&6
-echo "configure:3612: checking for cthread_fork" >&5
+echo "configure:3615: checking for cthread_fork" >&5
 if eval "test \"`echo '$''{'ac_cv_func_cthread_fork'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3617 "configure"
+#line 3620 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char cthread_fork(); below.  */
@@ -3636,7 +3639,7 @@ cthread_fork();
 
 ; return 0; }
 EOF
-if { (eval echo configure:3640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_cthread_fork=yes"
 else
@@ -3658,7 +3661,7 @@ fi
 
                if test $ol_link_threads = no ; then
                                                                        echo $ac_n "checking for cthread_fork with -all_load""... $ac_c" 1>&6
-echo "configure:3662: checking for cthread_fork with -all_load" >&5
+echo "configure:3665: checking for cthread_fork with -all_load" >&5
 if eval "test \"`echo '$''{'ol_cv_cthread_all_load'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3666,7 +3669,7 @@ else
                                                                save_LIBS="$LIBS"
                                LIBS="-all_load $LIBS"
                                cat > conftest.$ac_ext <<EOF
-#line 3670 "configure"
+#line 3673 "configure"
 #include "confdefs.h"
 #include <mach/cthreads.h>
 int main() {
@@ -3675,7 +3678,7 @@ int main() {
                                        
 ; return 0; }
 EOF
-if { (eval echo configure:3679: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ol_cv_cthread_all_load=yes
 else
@@ -3718,17 +3721,17 @@ if test $ol_with_threads = auto -o $ol_with_threads = lwp ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3722: checking for $ac_hdr" >&5
+echo "configure:3725: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3727 "configure"
+#line 3730 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3732: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3735: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3756,7 +3759,7 @@ done
 
        if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then
                echo $ac_n "checking for thr_create in -lthread""... $ac_c" 1>&6
-echo "configure:3760: checking for thr_create in -lthread" >&5
+echo "configure:3763: checking for thr_create in -lthread" >&5
 ac_lib_var=`echo thread'_'thr_create | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3764,7 +3767,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lthread  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3768 "configure"
+#line 3771 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3775,7 +3778,7 @@ int main() {
 thr_create()
 ; return 0; }
 EOF
-if { (eval echo configure:3779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3782: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3814,17 +3817,17 @@ EOF
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3818: checking for $ac_hdr" >&5
+echo "configure:3821: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3823 "configure"
+#line 3826 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3828: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3831: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3852,7 +3855,7 @@ done
 
        if test $ac_cv_header_lwp_lwp_h = yes ; then
                echo $ac_n "checking for lwp_create in -llwp""... $ac_c" 1>&6
-echo "configure:3856: checking for lwp_create in -llwp" >&5
+echo "configure:3859: checking for lwp_create in -llwp" >&5
 ac_lib_var=`echo lwp'_'lwp_create | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3860,7 +3863,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-llwp  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3864 "configure"
+#line 3867 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3871,7 +3874,7 @@ int main() {
 lwp_create()
 ; return 0; }
 EOF
-if { (eval echo configure:3875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3923,17 +3926,17 @@ if test $ol_with_threads = manual ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3927: checking for $ac_hdr" >&5
+echo "configure:3930: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3932 "configure"
+#line 3935 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3937: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3940: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3962,12 +3965,12 @@ done
        for ac_func in sched_yield pthread_yield
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3966: checking for $ac_func" >&5
+echo "configure:3969: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3971 "configure"
+#line 3974 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3990,7 +3993,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:3994: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4016,7 +4019,7 @@ done
 
        
 echo $ac_n "checking for LinuxThreads""... $ac_c" 1>&6
-echo "configure:4020: checking for LinuxThreads" >&5
+echo "configure:4023: checking for LinuxThreads" >&5
 if eval "test \"`echo '$''{'ol_cv_linux_threads'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4037,17 +4040,17 @@ echo "$ac_t""$ol_cv_linux_threads" 1>&6
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4041: checking for $ac_hdr" >&5
+echo "configure:4044: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4046 "configure"
+#line 4049 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4051: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4054: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4077,17 +4080,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4081: checking for $ac_hdr" >&5
+echo "configure:4084: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4086 "configure"
+#line 4089 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4091: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4094: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4117,17 +4120,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4121: checking for $ac_hdr" >&5
+echo "configure:4124: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4126 "configure"
+#line 4129 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4131: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4134: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4170,13 +4173,13 @@ EOF
 
 
                                        echo $ac_n "checking for thread specific errno""... $ac_c" 1>&6
-echo "configure:4174: checking for thread specific errno" >&5
+echo "configure:4177: checking for thread specific errno" >&5
 if eval "test \"`echo '$''{'ol_cv_errno_thread_specific'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
                cat > conftest.$ac_ext <<EOF
-#line 4180 "configure"
+#line 4183 "configure"
 #include "confdefs.h"
 
 #include <errno.h>
@@ -4187,7 +4190,7 @@ int x = errno;
                        
 ; return 0; }
 EOF
-if { (eval echo configure:4191: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ol_cv_errno_thread_specific=yes
 else
@@ -4233,13 +4236,13 @@ fi
 ol_link_ldbm=no 
 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db2 ; then
        echo $ac_n "checking for DB2 library""... $ac_c" 1>&6
-echo "configure:4237: checking for DB2 library" >&5
+echo "configure:4240: checking for DB2 library" >&5
 if eval "test \"`echo '$''{'ol_cv_lib_db2'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
        ol_LIBS="$LIBS"
        echo $ac_n "checking for db_open in -ldb""... $ac_c" 1>&6
-echo "configure:4243: checking for db_open in -ldb" >&5
+echo "configure:4246: checking for db_open in -ldb" >&5
 ac_lib_var=`echo db'_'db_open | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4247,7 +4250,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldb  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4251 "configure"
+#line 4254 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4258,7 +4261,7 @@ int main() {
 db_open()
 ; return 0; }
 EOF
-if { (eval echo configure:4262: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4289,17 +4292,17 @@ for ac_hdr in db.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4293: checking for $ac_hdr" >&5
+echo "configure:4296: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4298 "configure"
+#line 4301 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4303: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4306: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4327,13 +4330,13 @@ done
 
 if test $ac_cv_header_db_h = yes ; then
        echo $ac_n "checking if db.h is DB2""... $ac_c" 1>&6
-echo "configure:4331: checking if db.h is DB2" >&5
+echo "configure:4334: checking if db.h is DB2" >&5
 if eval "test \"`echo '$''{'ol_cv_header_db2'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
                cat > conftest.$ac_ext <<EOF
-#line 4337 "configure"
+#line 4340 "configure"
 #include "confdefs.h"
 
 #                      include <db.h>
@@ -4365,7 +4368,7 @@ fi
 
  
  echo $ac_n "checking for Berkeley DB2""... $ac_c" 1>&6
-echo "configure:4369: checking for Berkeley DB2" >&5
+echo "configure:4372: checking for Berkeley DB2" >&5
 if eval "test \"`echo '$''{'ol_cv_berkeley_db2'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4411,18 +4414,18 @@ fi
 
 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db ; then
        echo $ac_n "checking for Berkeley DB library""... $ac_c" 1>&6
-echo "configure:4415: checking for Berkeley DB library" >&5
+echo "configure:4418: checking for Berkeley DB library" >&5
 if eval "test \"`echo '$''{'ol_cv_lib_db'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
        ol_LIBS="$LIBS"
        echo $ac_n "checking for dbopen""... $ac_c" 1>&6
-echo "configure:4421: checking for dbopen" >&5
+echo "configure:4424: checking for dbopen" >&5
 if eval "test \"`echo '$''{'ac_cv_func_dbopen'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4426 "configure"
+#line 4429 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbopen(); below.  */
@@ -4445,7 +4448,7 @@ dbopen();
 
 ; return 0; }
 EOF
-if { (eval echo configure:4449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_dbopen=yes"
 else
@@ -4464,7 +4467,7 @@ else
   echo "$ac_t""no" 1>&6
 
                echo $ac_n "checking for dbopen in -ldb""... $ac_c" 1>&6
-echo "configure:4468: checking for dbopen in -ldb" >&5
+echo "configure:4471: checking for dbopen in -ldb" >&5
 ac_lib_var=`echo db'_'dbopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4472,7 +4475,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldb  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4476 "configure"
+#line 4479 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4483,7 +4486,7 @@ int main() {
 dbopen()
 ; return 0; }
 EOF
-if { (eval echo configure:4487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4490: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4518,17 +4521,17 @@ for ac_hdr in db_185.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4522: checking for $ac_hdr" >&5
+echo "configure:4525: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4527 "configure"
+#line 4530 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4532: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4535: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4564,7 +4567,7 @@ fi
 
  
  echo $ac_n "checking for Berkeley DB""... $ac_c" 1>&6
-echo "configure:4568: checking for Berkeley DB" >&5
+echo "configure:4571: checking for Berkeley DB" >&5
 if eval "test \"`echo '$''{'ol_cv_berkeley_db'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4617,17 +4620,17 @@ if test $ol_with_ldbm_api = manual ; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4621: checking for $ac_hdr" >&5
+echo "configure:4624: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4626 "configure"
+#line 4629 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4631: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4634: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4662,18 +4665,18 @@ fi
 
 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = gdbm ; then
        echo $ac_n "checking for GDBM library""... $ac_c" 1>&6
-echo "configure:4666: checking for GDBM library" >&5
+echo "configure:4669: checking for GDBM library" >&5
 if eval "test \"`echo '$''{'ol_cv_lib_gdbm'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
        ol_LIBS="$LIBS"
        echo $ac_n "checking for gdbm_open""... $ac_c" 1>&6
-echo "configure:4672: checking for gdbm_open" >&5
+echo "configure:4675: checking for gdbm_open" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gdbm_open'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4677 "configure"
+#line 4680 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gdbm_open(); below.  */
@@ -4696,7 +4699,7 @@ gdbm_open();
 
 ; return 0; }
 EOF
-if { (eval echo configure:4700: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_gdbm_open=yes"
 else
@@ -4715,7 +4718,7 @@ else
   echo "$ac_t""no" 1>&6
 
                echo $ac_n "checking for gdbm_open in -lgdbm""... $ac_c" 1>&6
-echo "configure:4719: checking for gdbm_open in -lgdbm" >&5
+echo "configure:4722: checking for gdbm_open in -lgdbm" >&5
 ac_lib_var=`echo gdbm'_'gdbm_open | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4723,7 +4726,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgdbm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4727 "configure"
+#line 4730 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4734,7 +4737,7 @@ int main() {
 gdbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:4738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4741: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4769,17 +4772,17 @@ echo "$ac_t""$ol_cv_lib_gdbm" 1>&6
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4773: checking for $ac_hdr" >&5
+echo "configure:4776: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4778 "configure"
+#line 4781 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4783: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4786: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4806,7 +4809,7 @@ fi
 done
 
  echo $ac_n "checking for db""... $ac_c" 1>&6
-echo "configure:4810: checking for db" >&5
+echo "configure:4813: checking for db" >&5
 if eval "test \"`echo '$''{'ol_cv_gdbm'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4840,18 +4843,18 @@ fi
 
 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = ndbm ; then
        echo $ac_n "checking for NDBM library""... $ac_c" 1>&6
-echo "configure:4844: checking for NDBM library" >&5
+echo "configure:4847: checking for NDBM library" >&5
 if eval "test \"`echo '$''{'ol_cv_lib_ndbm'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
        ol_LIBS="$LIBS"
        echo $ac_n "checking for dbm_open""... $ac_c" 1>&6
-echo "configure:4850: checking for dbm_open" >&5
+echo "configure:4853: checking for dbm_open" >&5
 if eval "test \"`echo '$''{'ac_cv_func_dbm_open'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4855 "configure"
+#line 4858 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dbm_open(); below.  */
@@ -4874,7 +4877,7 @@ dbm_open();
 
 ; return 0; }
 EOF
-if { (eval echo configure:4878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4881: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_dbm_open=yes"
 else
@@ -4893,7 +4896,7 @@ else
   echo "$ac_t""no" 1>&6
 
                echo $ac_n "checking for dbm_open in -lndbm""... $ac_c" 1>&6
-echo "configure:4897: checking for dbm_open in -lndbm" >&5
+echo "configure:4900: checking for dbm_open in -lndbm" >&5
 ac_lib_var=`echo ndbm'_'dbm_open | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4901,7 +4904,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lndbm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4905 "configure"
+#line 4908 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4912,7 +4915,7 @@ int main() {
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:4916: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4919: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4932,7 +4935,7 @@ else
   echo "$ac_t""no" 1>&6
 
                        echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6
-echo "configure:4936: checking for dbm_open in -ldbm" >&5
+echo "configure:4939: checking for dbm_open in -ldbm" >&5
 ac_lib_var=`echo dbm'_'dbm_open | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4940,7 +4943,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldbm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4944 "configure"
+#line 4947 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4951,7 +4954,7 @@ int main() {
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:4955: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4958: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4988,17 +4991,17 @@ echo "$ac_t""$ol_cv_lib_ndbm" 1>&6
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4992: checking for $ac_hdr" >&5
+echo "configure:4995: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4997 "configure"
+#line 5000 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5002: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5005: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5025,7 +5028,7 @@ fi
 done
 
  echo $ac_n "checking for db""... $ac_c" 1>&6
-echo "configure:5029: checking for db" >&5
+echo "configure:5032: checking for db" >&5
 if eval "test \"`echo '$''{'ol_cv_ndbm'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5073,7 +5076,7 @@ fi
 
 if test $ol_enable_wrappers = yes ; then
        echo $ac_n "checking for hosts_access in -lwrap""... $ac_c" 1>&6
-echo "configure:5077: checking for hosts_access in -lwrap" >&5
+echo "configure:5080: checking for hosts_access in -lwrap" >&5
 ac_lib_var=`echo wrap'_'hosts_access | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5081,7 +5084,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lwrap  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5085 "configure"
+#line 5088 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5092,7 +5095,7 @@ int main() {
 hosts_access()
 ; return 0; }
 EOF
-if { (eval echo configure:5096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5099: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5138,17 +5141,17 @@ for ac_hdr in termcap.h ncurses.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5142: checking for $ac_hdr" >&5
+echo "configure:5145: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5147 "configure"
+#line 5150 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5152: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5155: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5177,7 +5180,7 @@ done
 
 if test $ol_link_termcap = no ; then
        echo $ac_n "checking for tputs in -ltermcap""... $ac_c" 1>&6
-echo "configure:5181: checking for tputs in -ltermcap" >&5
+echo "configure:5184: checking for tputs in -ltermcap" >&5
 ac_lib_var=`echo termcap'_'tputs | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5185,7 +5188,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ltermcap  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5189 "configure"
+#line 5192 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5196,7 +5199,7 @@ int main() {
 tputs()
 ; return 0; }
 EOF
-if { (eval echo configure:5200: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5203: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5229,7 +5232,7 @@ fi
 
 if test $ol_link_termcap = no ; then
        echo $ac_n "checking for initscr in -lncurses""... $ac_c" 1>&6
-echo "configure:5233: checking for initscr in -lncurses" >&5
+echo "configure:5236: checking for initscr in -lncurses" >&5
 ac_lib_var=`echo ncurses'_'initscr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5237,7 +5240,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lncurses  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5241 "configure"
+#line 5244 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5248,7 +5251,7 @@ int main() {
 initscr()
 ; return 0; }
 EOF
-if { (eval echo configure:5252: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5255: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5290,12 +5293,12 @@ fi
 # FreeBSD (and others) have crypt(3) in -lcrypt
 if test $ol_enable_crypt != no ; then
        echo $ac_n "checking for crypt""... $ac_c" 1>&6
-echo "configure:5294: checking for crypt" >&5
+echo "configure:5297: checking for crypt" >&5
 if eval "test \"`echo '$''{'ac_cv_func_crypt'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5299 "configure"
+#line 5302 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char crypt(); below.  */
@@ -5318,7 +5321,7 @@ crypt();
 
 ; return 0; }
 EOF
-if { (eval echo configure:5322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5325: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_crypt=yes"
 else
@@ -5337,7 +5340,7 @@ else
   echo "$ac_t""no" 1>&6
 
                echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:5341: checking for crypt in -lcrypt" >&5
+echo "configure:5344: checking for crypt in -lcrypt" >&5
 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5345,7 +5348,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5349 "configure"
+#line 5352 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5356,7 +5359,7 @@ int main() {
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:5360: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5363: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5400,12 +5403,12 @@ fi
 # FreeBSD (and others) have setproctitle(3) in -lutil
 if test $ol_enable_proctitle != no ; then
        echo $ac_n "checking for setproctitle""... $ac_c" 1>&6
-echo "configure:5404: checking for setproctitle" >&5
+echo "configure:5407: checking for setproctitle" >&5
 if eval "test \"`echo '$''{'ac_cv_func_setproctitle'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5409 "configure"
+#line 5412 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char setproctitle(); below.  */
@@ -5428,7 +5431,7 @@ setproctitle();
 
 ; return 0; }
 EOF
-if { (eval echo configure:5432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5435: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_setproctitle=yes"
 else
@@ -5447,7 +5450,7 @@ else
   echo "$ac_t""no" 1>&6
 
                echo $ac_n "checking for setproctitle in -lutil""... $ac_c" 1>&6
-echo "configure:5451: checking for setproctitle in -lutil" >&5
+echo "configure:5454: checking for setproctitle in -lutil" >&5
 ac_lib_var=`echo util'_'setproctitle | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5455,7 +5458,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lutil  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5459 "configure"
+#line 5462 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5466,7 +5469,7 @@ int main() {
 setproctitle()
 ; return 0; }
 EOF
-if { (eval echo configure:5470: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5473: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5501,12 +5504,12 @@ EOF
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:5505: checking for ANSI C header files" >&5
+echo "configure:5508: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5510 "configure"
+#line 5513 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -5514,7 +5517,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5518: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5521: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5531,7 +5534,7 @@ rm -f conftest*
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 5535 "configure"
+#line 5538 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -5549,7 +5552,7 @@ fi
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 5553 "configure"
+#line 5556 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -5570,7 +5573,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 5574 "configure"
+#line 5577 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -5581,7 +5584,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:5585: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5588: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -5614,12 +5617,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:5618: checking for $ac_hdr that defines DIR" >&5
+echo "configure:5621: checking for $ac_hdr that defines DIR" >&5
 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5623 "configure"
+#line 5626 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_hdr>
@@ -5627,7 +5630,7 @@ int main() {
 DIR *dirp = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:5631: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5634: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_header_dirent_$ac_safe=yes"
 else
@@ -5652,7 +5655,7 @@ done
 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
 if test $ac_header_dirent = dirent.h; then
 echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:5656: checking for opendir in -ldir" >&5
+echo "configure:5659: checking for opendir in -ldir" >&5
 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5660,7 +5663,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldir  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5664 "configure"
+#line 5667 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5671,7 +5674,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:5675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5693,7 +5696,7 @@ fi
 
 else
 echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:5697: checking for opendir in -lx" >&5
+echo "configure:5700: checking for opendir in -lx" >&5
 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5701,7 +5704,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lx  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5705 "configure"
+#line 5708 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5712,7 +5715,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:5716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5719: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5735,12 +5738,12 @@ fi
 fi
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:5739: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:5742: checking for sys/wait.h that is POSIX.1 compatible" >&5
 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5744 "configure"
+#line 5747 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -5756,7 +5759,7 @@ wait (&s);
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:5760: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5763: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -5779,6 +5782,8 @@ fi
 for ac_hdr in \
        stdarg.h                \
        stddef.h                \
+       string.h                \
+       strings.h               \
        errno.h                 \
        fcntl.h                 \
        filio.h                 \
@@ -5806,17 +5811,17 @@ for ac_hdr in \
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5810: checking for $ac_hdr" >&5
+echo "configure:5815: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5815 "configure"
+#line 5820 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5820: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5825: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5844,12 +5849,12 @@ done
 
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:5848: checking for uid_t in sys/types.h" >&5
+echo "configure:5853: checking for uid_t in sys/types.h" >&5
 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5853 "configure"
+#line 5858 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -5878,7 +5883,7 @@ EOF
 fi
 
 echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6
-echo "configure:5882: checking type of array argument to getgroups" >&5
+echo "configure:5887: checking type of array argument to getgroups" >&5
 if eval "test \"`echo '$''{'ac_cv_type_getgroups'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5886,7 +5891,7 @@ else
   ac_cv_type_getgroups=cross
 else
   cat > conftest.$ac_ext <<EOF
-#line 5890 "configure"
+#line 5895 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Rendell for this test.  */
@@ -5911,7 +5916,7 @@ main()
 }
 
 EOF
-if { (eval echo configure:5915: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5920: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
     ac_cv_type_getgroups=gid_t
 else
@@ -5925,7 +5930,7 @@ fi
 
 if test $ac_cv_type_getgroups = cross; then
         cat > conftest.$ac_ext <<EOF
-#line 5929 "configure"
+#line 5934 "configure"
 #include "confdefs.h"
 #include <unistd.h>
 EOF
@@ -5949,12 +5954,12 @@ EOF
 
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:5953: checking for mode_t" >&5
+echo "configure:5958: checking for mode_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5958 "configure"
+#line 5963 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -5982,12 +5987,12 @@ EOF
 fi
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:5986: checking for off_t" >&5
+echo "configure:5991: checking for off_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5991 "configure"
+#line 5996 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -6015,12 +6020,12 @@ EOF
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:6019: checking for pid_t" >&5
+echo "configure:6024: checking for pid_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6024 "configure"
+#line 6029 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -6048,12 +6053,12 @@ EOF
 fi
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:6052: checking return type of signal handlers" >&5
+echo "configure:6057: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6057 "configure"
+#line 6062 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -6070,7 +6075,7 @@ int main() {
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:6074: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6079: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -6089,12 +6094,12 @@ EOF
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:6093: checking for size_t" >&5
+echo "configure:6098: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6098 "configure"
+#line 6103 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -6122,12 +6127,12 @@ EOF
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:6126: checking for uid_t in sys/types.h" >&5
+echo "configure:6131: checking for uid_t in sys/types.h" >&5
 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6131 "configure"
+#line 6136 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -6156,12 +6161,12 @@ EOF
 fi
 
 echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6
-echo "configure:6160: checking for st_blksize in struct stat" >&5
+echo "configure:6165: checking for st_blksize in struct stat" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6165 "configure"
+#line 6170 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -6169,7 +6174,7 @@ int main() {
 struct stat s; s.st_blksize;
 ; return 0; }
 EOF
-if { (eval echo configure:6173: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6178: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_st_blksize=yes
 else
@@ -6190,12 +6195,12 @@ EOF
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:6194: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:6199: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6199 "configure"
+#line 6204 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -6204,7 +6209,7 @@ int main() {
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:6208: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6213: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -6225,12 +6230,12 @@ EOF
 fi
 
 echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:6229: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:6234: checking whether struct tm is in sys/time.h or time.h" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6234 "configure"
+#line 6239 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <time.h>
@@ -6238,7 +6243,7 @@ int main() {
 struct tm *tp; tp->tm_sec;
 ; return 0; }
 EOF
-if { (eval echo configure:6242: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6247: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
 else
@@ -6261,7 +6266,7 @@ fi
 
 
 echo $ac_n "checking if toupper() requires islower()""... $ac_c" 1>&6
-echo "configure:6265: checking if toupper() requires islower()" >&5
+echo "configure:6270: checking if toupper() requires islower()" >&5
 if eval "test \"`echo '$''{'ol_cv_c_upper_lower'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6270,7 +6275,7 @@ else
   ol_cv_c_upper_lower=safe
 else
   cat > conftest.$ac_ext <<EOF
-#line 6274 "configure"
+#line 6279 "configure"
 #include "confdefs.h"
 
 #include <ctype.h>
@@ -6282,7 +6287,7 @@ main()
                exit(1);
 }
 EOF
-if { (eval echo configure:6286: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6291: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ol_cv_c_upper_lower=no
 else
@@ -6305,12 +6310,12 @@ EOF
 fi
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:6309: checking for working const" >&5
+echo "configure:6314: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6314 "configure"
+#line 6319 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -6359,7 +6364,7 @@ ccp = (char const *const *) p;
 
 ; return 0; }
 EOF
-if { (eval echo configure:6363: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6368: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -6382,7 +6387,7 @@ fi
 
 
 echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
-echo "configure:6386: checking for 8-bit clean memcmp" >&5
+echo "configure:6391: checking for 8-bit clean memcmp" >&5
 if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6390,7 +6395,7 @@ else
   ac_cv_func_memcmp_clean=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 6394 "configure"
+#line 6399 "configure"
 #include "confdefs.h"
 
 main()
@@ -6400,7 +6405,7 @@ main()
 }
 
 EOF
-if { (eval echo configure:6404: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6409: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_memcmp_clean=yes
 else
@@ -6418,12 +6423,12 @@ echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6
 test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.o"
 
 echo $ac_n "checking for strftime""... $ac_c" 1>&6
-echo "configure:6422: checking for strftime" >&5
+echo "configure:6427: checking for strftime" >&5
 if eval "test \"`echo '$''{'ac_cv_func_strftime'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6427 "configure"
+#line 6432 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char strftime(); below.  */
@@ -6446,7 +6451,7 @@ strftime();
 
 ; return 0; }
 EOF
-if { (eval echo configure:6450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_strftime=yes"
 else
@@ -6468,7 +6473,7 @@ else
   echo "$ac_t""no" 1>&6
 # strftime is in -lintl on SCO UNIX.
 echo $ac_n "checking for strftime in -lintl""... $ac_c" 1>&6
-echo "configure:6472: checking for strftime in -lintl" >&5
+echo "configure:6477: checking for strftime in -lintl" >&5
 ac_lib_var=`echo intl'_'strftime | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6476,7 +6481,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lintl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6480 "configure"
+#line 6485 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6487,7 +6492,7 @@ int main() {
 strftime()
 ; return 0; }
 EOF
-if { (eval echo configure:6491: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6514,12 +6519,12 @@ fi
 fi
 
 echo $ac_n "checking for vprintf""... $ac_c" 1>&6
-echo "configure:6518: checking for vprintf" >&5
+echo "configure:6523: checking for vprintf" >&5
 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6523 "configure"
+#line 6528 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char vprintf(); below.  */
@@ -6542,7 +6547,7 @@ vprintf();
 
 ; return 0; }
 EOF
-if { (eval echo configure:6546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6551: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_vprintf=yes"
 else
@@ -6566,12 +6571,12 @@ fi
 
 if test "$ac_cv_func_vprintf" != yes; then
 echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
-echo "configure:6570: checking for _doprnt" >&5
+echo "configure:6575: checking for _doprnt" >&5
 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6575 "configure"
+#line 6580 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char _doprnt(); below.  */
@@ -6594,7 +6599,7 @@ _doprnt();
 
 ; return 0; }
 EOF
-if { (eval echo configure:6598: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6603: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func__doprnt=yes"
 else
@@ -6623,12 +6628,12 @@ if test $ac_cv_func_vprintf = yes ; then
                for ac_func in vsnprintf
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6627: checking for $ac_func" >&5
+echo "configure:6632: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6632 "configure"
+#line 6637 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6651,7 +6656,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:6655: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6660: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -6678,7 +6683,7 @@ done
 fi
 
 echo $ac_n "checking for wait3 that fills in rusage""... $ac_c" 1>&6
-echo "configure:6682: checking for wait3 that fills in rusage" >&5
+echo "configure:6687: checking for wait3 that fills in rusage" >&5
 if eval "test \"`echo '$''{'ac_cv_func_wait3_rusage'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6686,7 +6691,7 @@ else
   ac_cv_func_wait3_rusage=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 6690 "configure"
+#line 6695 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -6717,7 +6722,7 @@ main() {
   }
 }
 EOF
-if { (eval echo configure:6721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_wait3_rusage=yes
 else
@@ -6774,12 +6779,12 @@ for ac_func in \
 
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6778: checking for $ac_func" >&5
+echo "configure:6783: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6783 "configure"
+#line 6788 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6802,7 +6807,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:6806: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6811: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -6830,12 +6835,12 @@ done
 for ac_func in getopt strdup tempnam
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6834: checking for $ac_func" >&5
+echo "configure:6839: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6839 "configure"
+#line 6844 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6858,7 +6863,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:6862: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6867: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -6888,13 +6893,13 @@ done
 # Check Configuration
 
 echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6
-echo "configure:6892: checking declaration of sys_errlist" >&5
+echo "configure:6897: checking declaration of sys_errlist" >&5
 if eval "test \"`echo '$''{'ol_cv_dcl_sys_errlist'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
        cat > conftest.$ac_ext <<EOF
-#line 6898 "configure"
+#line 6903 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -6904,7 +6909,7 @@ int main() {
 char *c = (char *) *sys_errlist
 ; return 0; }
 EOF
-if { (eval echo configure:6908: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6913: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ol_cv_dcl_sys_errlist=yes
 else
@@ -6925,20 +6930,20 @@ if test $ol_cv_dcl_sys_errlist = no ; then
 EOF
 
        echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6
-echo "configure:6929: checking existence of sys_errlist" >&5
+echo "configure:6934: checking existence of sys_errlist" >&5
        if eval "test \"`echo '$''{'ol_cv_have_sys_errlist'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
                cat > conftest.$ac_ext <<EOF
-#line 6935 "configure"
+#line 6940 "configure"
 #include "confdefs.h"
 #include <errno.h>
 int main() {
 char *c = (char *) *sys_errlist
 ; return 0; }
 EOF
-if { (eval echo configure:6942: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6947: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ol_cv_have_sys_errlist=yes
 else
index 8f4ec533497b6381d8308f283ec7275fc1c6f181..f7d79c49fc51b430607f207f0e0e7796018667be 100644 (file)
@@ -502,15 +502,18 @@ if test $ol_with_threads = auto -o $ol_with_threads = posix ; then
 int task(arg)
        int *arg;
 {
+       int i;
        struct timeval tv;
 
-       tv.tv_sec=4;
+       tv.tv_sec=5;
        tv.tv_usec=0;
-       select(0, NULL, NULL, NULL, &tv);
 
-       tv.tv_sec=6;
-       tv.tv_usec=0;
-       select(0, NULL, NULL, NULL, &tv);
+       /* we're not interested in any fds */
+       i = select(FD_SETSIZE, NULL, NULL, NULL, &tv);
+
+       if(i < 0) {
+               perror("select");
+       }
 
        exit(1); /* if we exit here, the select blocked the whole process */
 }
@@ -902,6 +905,8 @@ AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(      \
        stdarg.h                \
        stddef.h                \
+       string.h                \
+       strings.h               \
        errno.h                 \
        fcntl.h                 \
        filio.h                 \
index 7c57b8b83cddfed58c5236c64306286af1e91587..1b109ae65c7a4a132091b0a5135d8a91dacb6b89 100644 (file)
@@ -29,8 +29,8 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
  */
 
 #include "whois++.h"
-
-extern char    *index(), *rindex();
+#include <stdlib.h>
+extern int getdtablesize (void);
 
 #define        isspecial(c)    ( (c) == ',' || (c) == ';' || (c) == ':' || (c) == '=' )
 
@@ -38,9 +38,8 @@ static        char    **component = NULL;
 static int     numberOfComponents;
 static int     components = 10;
 
-static int getToken( token )
-char   *token;
-
+static int
+getToken( char *token )
 {
        static char     *buffer = NULL;
        static int      idx;
@@ -51,6 +50,13 @@ char *token;
 
        if ( buffer == NULL ) {
                tablesize = getdtablesize();
+
+#ifdef FD_SETSIZE
+               if ( tablesize > FD_SETSIZE ) {
+                       tablesize = FD_SETSIZE;
+               }
+#endif /* FD_SETSIZE */
+
                timeout.tv_sec = 60;
                timeout.tv_usec = 0;
                FD_ZERO( &readfds );
@@ -201,10 +207,14 @@ char      *token;
        }
 }
 
-static int term( token, value, attribute, specifier, soundex )
-int    token;
-char   *value, *attribute;
-int    *specifier, *soundex;
+static int
+term(
+       int     token,
+       char    *value,
+       char    *attribute,
+       int     *specifier,
+       int     *soundex
+)
 {
        char    buffer[BUFSIZ], temp[BUFSIZ];
        int     iterations;
@@ -334,10 +344,14 @@ int       *specifier, *soundex;
        return token;
 }
 
-static int processTerm( specifier, soundex, buffer, attribute, value )
-int    specifier, soundex;
-char   *buffer, *attribute, *value;
-
+static int
+processTerm(
+       int     specifier,
+       int     soundex,
+       char    *buffer,
+       char    *attribute,
+       char    *value
+)
 {
        char    *s, *t;
        char    query[BUFSIZ];
@@ -360,7 +374,7 @@ char        *buffer, *attribute, *value;
                        sprintf( query, "(%s%s%s)", attribute,
                                (soundex)?"~=":"=", buffer );
                } else {
-                       if ( ( s = index( buffer, ',' ) ) != NULL ) {
+                       if ( ( s = strchr( buffer, ',' ) ) != NULL ) {
                                *s++ = '\0';
                                while ( *s && isspace( *s ) )
                                        s++;
@@ -368,7 +382,7 @@ char        *buffer, *attribute, *value;
                                        (soundex)?"~=":"=", buffer );
                                component[numberOfComponents++] = strdup( query );
                                /* let's just make sure there is no title */
-                               if ( ( t = rindex( s, ',' ) ) != NULL ) {
+                               if ( ( t = strrchr( s, ',' ) ) != NULL ) {
                                        *t++ = '\0';
                                        while ( *t && isspace( *t ) )
                                                t++;
@@ -382,7 +396,7 @@ char        *buffer, *attribute, *value;
                                sprintf( query, "%s *", &buffer[6] );
                                strcpy( buffer, query );
                        }
-                       if ( ( s = index( buffer, '@' ) ) != NULL ) {
+                       if ( ( s = strchr( buffer, '@' ) ) != NULL ) {
                                *s++ = '\0';
                                if ( *buffer == '\0' ) /* no username */
                                        sprintf( query, "(mail=*@%s)", s );
@@ -395,7 +409,7 @@ char        *buffer, *attribute, *value;
                                if ( soundex )
                                        printFormatted( lineLength, TRUE, stdout,
                                                "Fuzzy matching not supported on e-mail address queries" );
-                       } else if ( index( buffer, ' ' ) == NULL ) {
+                       } else if ( strchr( buffer, ' ' ) == NULL ) {
                                sprintf( query,
                                        "(|(sn%s%s)(userid%s%s)(l%s%s)(ou%s%s)\
 (&(cn%s%s)(!(objectClass=person))))",
@@ -522,8 +536,8 @@ char        *buffer, *attribute, *value;
        return SEARCH;
 }
 
-int    parseCommand( query )
-char   *query;
+int
+parseCommand( char *query )
 {
        /*
         * This procedure reads the string sent by the user and breaks it
index 3c1387d8ef68e4db734518abb372c8281a9cd6a9..a6d0e5c84cfd9ad4224c6c0a60a5d0cf4d24c3dd 100644 (file)
@@ -29,6 +29,7 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
  */
 
 #include "whois++.h"
+#include <stdlib.h>
 
 static struct {
        char    *str;
@@ -59,8 +60,8 @@ static struct {
                NULL,           NULL
        };
 
-static nextLine(fp)
-FILE   *fp;
+static void
+nextLine( FILE *fp )
 {
        /*
         * We probably should check that the user hasn't put anything else
@@ -75,10 +76,8 @@ FILE *fp;
 /*
  * Get next word, skipping blanks & comments.
  */
-static int     getWord(buffer, size, fp)
-char           *buffer;
-int            size;
-FILE           *fp;
+static int
+getWord( char *buffer, int size, FILE *fp )
 {
        char    *cp;
        int     c, string;
@@ -119,9 +118,8 @@ FILE                *fp;
        return (cp != buffer);
 }
 
-void   readConfiguration( config )
-FILE   *config;
-
+void
+readConfiguration( FILE *config )
 {
        char            buffer[BUFSIZ];
        char            *s;
index d18f4b05b3a616f15dacf2f15282f64a0cb4d5b5..499ad3a411955fc6032f51672a667f44f80b1220 100644 (file)
@@ -30,8 +30,8 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
 
 #include "whois++.h"
 
-void   needHelp( reason )
-char   *reason;
+void
+needHelp( char *reason )
 {
        char            filename[MAXPATHLEN];
        char            buffer[BUFSIZ];
index 771fe989b109d4dc5cbe394ef45371a8b90bc2f3..cafbc639576a561a1108b6a9259aa1f96e255298 100644 (file)
@@ -29,10 +29,11 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
  */
 
 #include "whois++.h"
+#include <stdlib.h>
 
-void   showTemplate( template )
-char   *template;
 
+void
+showTemplate( char *template )
 {
        char    filename[MAXPATHLEN], buffer[BUFSIZ];
        FILE    *description;
@@ -57,9 +58,8 @@ char  *template;
        }
 }
 
-void   listTemplates( query )
-char   *query;
-
+void
+listTemplates( char *query )
 {
        char            filename[MAXPATHLEN];
        DIR             *dir;
@@ -89,9 +89,8 @@ char  *query;
        }
 }
 
-char   **specifyAttributes( objectClass )
-char   *objectClass;
-
+char **
+specifyAttributes( char *objectClass )
 {
        FILE    *description;
        char    filename[MAXPATHLEN], buffer[BUFSIZ];
@@ -131,9 +130,8 @@ char        *objectClass;
        return attributes;
 }
 
-char   *templateToObjectClass( template )
-char   *template;
-
+char *
+templateToObjectClass( char *template )
 {
        int     i;
 
@@ -151,9 +149,8 @@ char        *template;
        return template;
 }
 
-char   *objectClassToTemplate( objectClass )
-char   *objectClass;
-
+char *
+objectClassToTemplate( char *objectClass )
 {
        int     i;
 
index 8431878e0ba449e2770f24afc027928fc3605319..5d7b8ebec48deb18763de080fb6e45fc72c6d6e0 100644 (file)
@@ -28,6 +28,8 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
 #include <signal.h>
 #include <ctype.h>
@@ -41,12 +43,12 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
 #include <langinfo.h>
 #include <locale.h>
 #endif
+#include <ac/unistd.h>
 
-static void    handler();
-
-char   *lowerCase( string )
-char   *string;
+static void    handler(int sig);
 
+char *
+lowerCase( char *string )
 {
        char    *s;
 
@@ -56,9 +58,8 @@ char  *string;
        return string;
 }
 
-char   *convertTime( date, locale )
-char   *date, *locale;
-
+char *
+convertTime( char *date, char *locale )
 {
        /*
         * A quick hack to convert the time from the format Quipu uses into
@@ -96,9 +97,8 @@ char  *date, *locale;
 
 static long    interrupt;
 
-char   *getPassword( prompt )
-char   *prompt;
-
+char *
+getPassword( char *prompt )
 {
 #if defined(SYS5) || defined(XOS_2)
        struct termios  ttyb;
@@ -107,7 +107,6 @@ char        *prompt;
 #endif
        FILE            *input;
        struct sigvec   ovec, vec;
-       void            handler();
        unsigned long   flags;
        int             c, idx;
        static char     buffer[BUFSIZ + 1];
@@ -160,8 +159,8 @@ char        *prompt;
        return buffer;
 }
 
-static void    handler()
-
+static void
+handler( int sig )
 {
        ++interrupt;
 }
index 4c747631fc6a5462076f35ccca7cb137db7a5eb7..e15157a144eff30127fb0c420dd6aca5fce99835 100644 (file)
@@ -28,8 +28,7 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-char   *version()
-
+char *version( void )
 {
        return "1.7";
 }
index fe22ee19bbc537a3f705964c5b384bc9f04fab0d..6d148526e9a1831d8f6332ab6980360e3afdb148 100644 (file)
@@ -139,9 +139,10 @@ EXTERN char                *banner;
 EXTERN char            **category;
 EXTERN table           *templateTranslationTable;
 
-extern int             displayDescribe(), parseCommand();
-extern void            needHelp();
-extern void            showTemplate(), listTemplates();
-extern char            **specifyAttributes();
-extern char            *lowerCase(), *version(), *attributeLabel();
+extern int             displayDescribe(), parseCommand(char *query);
+extern void            needHelp(char *reason);
+extern void            showTemplate(char *template), listTemplates(char *query);
+extern char            **specifyAttributes(char *objectClass);
+extern char            *lowerCase(char *string), *version(void), *attributeLabel();
 extern char            *rfc931_name();
+extern char            *templateToObjectClass(char *template);
diff --git a/include/ac/string.h b/include/ac/string.h
new file mode 100644 (file)
index 0000000..8df4116
--- /dev/null
@@ -0,0 +1,54 @@
+/* Generic string.h */
+
+#ifndef _AC_STRING_H
+#define _AC_STRING_H
+
+#ifdef STDC_HEADERS
+#      include <string.h>
+#else
+#      ifdef HAVE_STRING_H
+#              include <string.h>
+#      elif HAVE_STRINGS_H
+#              include <strings.h>
+#      endif
+
+#      ifndef HAVE_STRCHR
+#              define strchr index
+#              define strrchr rindex
+#      endif
+
+#      ifndef HAVE_MEMCPY
+#              define memcpy(d, s, n)                  bcopy ((s), (d), (n))
+#              define memmove(d, s, n)                 bcopy ((s), (d), (n))
+#      endif
+
+#      if !defined(HAVE_STRING_H) && !defined(HAVE_STRINGS_H)
+       /* define prototypes for string functions */
+       /* this could cause problems on some odd ball systems */
+       char    *strchr(), *strrchr();
+       char    *strcpy(), *strncpy();
+       char    *strcat (), *strncat ();
+       int             strcmp(), strncmp();
+       int             strcasecmp(), strncasecmp();
+       char    *strdup();
+       char    *strtok();
+       char    *strpbrk();
+       int             memcmp();
+#      endif
+
+#endif
+
+#ifndef SAFEMEMCPY
+#      if defined( HAVE_MEMMOVE )
+#              define SAFEMEMCPY( d, s, n )    memmove((d), (s), (n))
+#      elif defined( HAVE_BCOPY )
+#              define SAFEMEMCPY( d, s, n )    bcopy((s), (d), (n))
+#      elif defined( MACOS )
+#              define SAFEMEMCPY( d, s, n )    BlockMoveData((Ptr)(s), (Ptr)(d), (n))
+#      else
+               /* nothing left but memcpy() */
+#              define SAFEMEMCPY( d, s, n )    memcpy((d), (s), (n))
+#      endif
+#endif
+
+#endif /* _AC_STRING_H */
diff --git a/include/ac/unistd.h b/include/ac/unistd.h
new file mode 100644 (file)
index 0000000..a52b288
--- /dev/null
@@ -0,0 +1,44 @@
+/* Generic unistd.h */
+
+#ifndef _AC_UNISTD_H
+#define _AC_UNISTD_H
+
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#else
+       /* we really should test for these */
+       char *crypt();
+       char *gethostname();
+       char *getenv();
+       long *random();
+       int flock();
+#endif
+
+/* getopt() defines may be in separate include file */
+#if HAVE_GETOPT_H
+#      include <getopt.h>
+
+#elif !defined(HAVE_GETOPT)
+       /* no getopt, assume we need getopt-compat.h */
+#      include <getopt-compat.h>
+
+#else
+       /* assume we need to declare these externs */
+       extern char *optarg;
+       extern int optind, opterr, optopt;
+#endif
+
+#ifndef HAVE_TEMPNAM
+       extern char *tempnam(const char *tmpdir, const char *prefix);
+#endif
+#ifndef HAVE_MKTEMP
+       extern char *mktemp(char *);
+#endif
+
+/* use _POSIX_VERSION for POSIX.1 code */
+
+#endif /* _AC_UNISTD_H */
index c9dc9b2a25eb0c6a1ed069f774c3b7254bed006b..651b9026d809519c30a678df0b692a48df5428a1 100644 (file)
@@ -64,6 +64,7 @@ LDAP_F caddr_t
 avl_getfirst LDAP_P((Avlnode *));
 
 #ifdef AVL_REENTRANT
+/* ??? avl.c does not provide this version ??? */
 LDAP_F caddr_t
 avl_getnext LDAP_P((Avlnode *, caddr_t ));
 #else
@@ -74,9 +75,15 @@ avl_getnext LDAP_P((void));
 LDAP_F int
 avl_dup_error LDAP_P((void));
 
+LDAP_F int
+avl_dup_ok LDAP_P((void));
+
 LDAP_F int
 avl_apply LDAP_P((Avlnode *, IFP, caddr_t, int, int));
 
+LDAP_F int
+avl_prefixapply LDAP_P((Avlnode *, caddr_t, IFP, caddr_t, IFP, caddr_t, int));
+
 /* apply traversal types */
 #define AVL_PREORDER   1
 #define AVL_INORDER    2
index c139f8eeda9b1e18fe1f2346e90590cd80bd3d4c..54b956fb6c4fd5c2dd4be664e894c12b6b3051e3 100644 (file)
@@ -501,9 +501,8 @@ typedef struct ldap_url_desc {
 #define LDAP_URL_ERR_BADSCOPE  3       /* URL scope string is invalid */
 #define LDAP_URL_ERR_MEM       4       /* can't allocate memory space */
 
-/* this typedef is never used, only exists to rid of declaration
- in function param list warning */
-typedef struct timeval LDAPtv;
+/* avoid pulling in headers */
+struct timeval;
 
 /*
  * in abandon.c:
@@ -718,10 +717,10 @@ LDAP_F void cldap_setretryinfo LDAP_P(( LDAP *ld, int tries, int timeout ));
  */
 LDAP_F int ldap_sort_entries LDAP_P(( LDAP *ld,
        LDAPMessage **chain, char *attr,
-       int (*cmp) LDAP_P((const char *, const char *)) ));
+       int (*cmp) (const char *, const char *) ));
 LDAP_F int ldap_sort_values LDAP_P(( LDAP *ld,
-       char **vals, int (*cmp) LDAP_P((const void *, const void *)) ));
-LDAP_F int ldap_sort_strcasecmp LDAP_P(( char **a, char **b ));
+       char **vals, int (*cmp) (const void *, const void *) ));
+LDAP_F int ldap_sort_strcasecmp LDAP_P(( const void *a, const void *b ));
 
 
 /*
index 52af54ccbf1a9d0eedaad999a52b78ee907ceeda..2a23c7791fdebb36fd5c58731c38ad5753cd8f65 100644 (file)
@@ -148,6 +148,9 @@ LDAP_END_DECL
 
 LDAP_BEGIN_DECL
 
+stkalign_t *get_stack( int *stacknop );
+void free_stack( int *stackno );
+
 typedef void   *(*VFP)();
 
 /* thread attributes and thread type */
index 82023d631a1f205a2818c2974a551a06aaf6d9dd..be0fd47599850b75e2973527c79f5624d6d377f7 100644 (file)
@@ -6,13 +6,15 @@
  * Include file for LDAP utility routine
  */
 
-/* ISC Base64 Routines */
-
 LDAP_BEGIN_DECL
 
+/* ISC Base64 Routines */
+/* base64.c */
 LDAP_F int b64_ntop LDAP_P((u_char const *, size_t, char *, size_t));
 LDAP_F int b64_pton LDAP_P((char const *, u_char *, size_t));
+/* detach.c */
 LDAP_F void lutil_detach LDAP_P((int debug, int do_close));
+/* passwd.c */
 LDAP_F int lutil_passwd LDAP_P((const char *cred, const char *passwd));
 
 LDAP_END_DECL
index 767fdeb7f51e6f22b61591b3296751ee9a991587..68e0d4bbe1c2418603ccc413da7b5b0747930279 100644 (file)
@@ -466,6 +466,12 @@ is provided ``as is'' without express or implied warranty.
 /* Define if you have the <stddef.h> header file.  */
 #undef HAVE_STDDEF_H
 
+/* Define if you have the <string.h> header file.  */
+#undef HAVE_STRING_H
+
+/* Define if you have the <strings.h> header file.  */
+#undef HAVE_STRINGS_H
+
 /* Define if you have the <synch.h> header file.  */
 #undef HAVE_SYNCH_H
 
index 261416770901a67dcde588ab61801fd738e73ddc..7de1e1cbb770dde582101ad9ae1bee3dc60824a6 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #ifndef lint
 static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
 static char avl_version[] = "AVL library version 1.0\n";
 #endif
 
-#include <sys/types.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
 #include "avl.h"
 
 #define ROTATERIGHT(x) { \
        Avlnode *tmp;\
-       if ( *x == NULL || (*x)->avl_left == NULL ) {\
+       if ( *(x) == NULL || (*(x))->avl_left == NULL ) {\
                (void) printf("RR error\n"); exit(1); \
        }\
-       tmp = (*x)->avl_left;\
-       (*x)->avl_left = tmp->avl_right;\
-       tmp->avl_right = *x;\
-       *x = tmp;\
+       tmp = (*(x))->avl_left;\
+       (*(x))->avl_left = tmp->avl_right;\
+       tmp->avl_right = *(x);\
+       *(x) = tmp;\
 }
 #define ROTATELEFT(x)  { \
        Avlnode *tmp;\
-       if ( *x == NULL || (*x)->avl_right == NULL ) {\
+       if ( *(x) == NULL || (*(x))->avl_right == NULL ) {\
                (void) printf("RL error\n"); exit(1); \
        }\
-       tmp = (*x)->avl_right;\
-       (*x)->avl_right = tmp->avl_left;\
+       tmp = (*(x))->avl_right;\
+       (*(x))->avl_right = tmp->avl_left;\
        tmp->avl_left = *x;\
-       *x = tmp;\
+       *(x) = tmp;\
 }
 
 /*
@@ -46,14 +50,15 @@ static char avl_version[] = "AVL library version 1.0\n";
  * and balance of an avl tree.
  */
 
-static
-ravl_insert( iroot, data, taller, fcmp, fdup, depth )
-    Avlnode    **iroot;
-    caddr_t    data;
-    int                *taller;
-    IFP                fcmp;           /* comparison function */
-    IFP                fdup;           /* function to call for duplicates */
-    int                depth;
+static int
+ravl_insert(
+    Avlnode    **iroot,
+    caddr_t    data,
+    int                *taller,
+    IFP                fcmp,                   /* comparison function */
+    IFP                fdup,                   /* function to call for duplicates */
+    int                depth
+)
 {
        int     rc, cmp, tallersub;
        Avlnode *l, *r;
@@ -200,11 +205,8 @@ ravl_insert( iroot, data, taller, fcmp, fdup, depth )
  * NOTE: this routine may malloc memory
  */
 
-avl_insert( root, data, fcmp, fdup )
-    Avlnode    **root;
-    caddr_t    data;
-    IFP                fcmp;
-    IFP                fdup;
+int
+avl_insert( Avlnode **root, caddr_t data, IFP fcmp, IFP fdup )
 {
        int     taller;
 
@@ -216,11 +218,10 @@ avl_insert( root, data, fcmp, fdup )
  * been shortened because of a deletion.
  */
 
-static
-right_balance( root )
-    Avlnode    **root;
+static int
+right_balance( Avlnode **root )
 {
-       int     shorter;
+       int     shorter = -1;
        Avlnode *r, *l;
 
        switch( (*root)->avl_bf ) {
@@ -281,11 +282,10 @@ right_balance( root )
  * been shortened because of a deletion.
  */
 
-static
-left_balance( root )
-    Avlnode    **root;
+static int
+left_balance( Avlnode **root )
 {
-       int     shorter;
+       int     shorter = -1;
        Avlnode *r, *l;
 
        switch( (*root)->avl_bf ) {
@@ -349,11 +349,7 @@ left_balance( root )
  */
 
 static caddr_t
-ravl_delete( root, data, fcmp, shorter )
-    Avlnode    **root;
-    caddr_t    data;
-    IFP                fcmp;
-    int                *shorter;
+ravl_delete( Avlnode **root, caddr_t data, IFP fcmp, int *shorter )
 {
        int     shortersubtree = 0;
        int     cmp;
@@ -442,22 +438,15 @@ ravl_delete( root, data, fcmp, shorter )
  */
 
 caddr_t
-avl_delete( root, data, fcmp )
-    Avlnode    **root;
-    caddr_t    data;
-    IFP                fcmp;
+avl_delete( Avlnode **root, caddr_t data, IFP fcmp )
 {
        int     shorter;
 
        return( ravl_delete( root, data, fcmp, &shorter ) );
 }
 
-static
-avl_inapply( root, fn, arg, stopflag )
-    Avlnode    *root;
-    IFP                fn;
-    caddr_t    arg;
-    int                stopflag;
+static int
+avl_inapply( Avlnode *root, IFP fn, caddr_t arg, int stopflag )
 {
        if ( root == 0 )
                return( AVL_NOMORE );
@@ -476,12 +465,8 @@ avl_inapply( root, fn, arg, stopflag )
                return( avl_inapply( root->avl_right, fn, arg, stopflag ) );
 }
 
-static
-avl_postapply( root, fn, arg, stopflag )
-    Avlnode    *root;
-    IFP                fn;
-    caddr_t    arg;
-    int                stopflag;
+static int
+avl_postapply( Avlnode *root, IFP fn, caddr_t arg, int stopflag )
 {
        if ( root == 0 )
                return( AVL_NOMORE );
@@ -499,12 +484,8 @@ avl_postapply( root, fn, arg, stopflag )
        return( (*fn)( root->avl_data, arg ) );
 }
 
-static
-avl_preapply( root, fn, arg, stopflag )
-    Avlnode    *root;
-    IFP                fn;
-    caddr_t    arg;
-    int                stopflag;
+static int
+avl_preapply( Avlnode *root, IFP fn, caddr_t arg, int stopflag )
 {
        if ( root == 0 )
                return( AVL_NOMORE );
@@ -531,12 +512,8 @@ avl_preapply( root, fn, arg, stopflag )
  * of nodes.
  */
 
-avl_apply( root, fn, arg, stopflag, type )
-    Avlnode    *root;
-    IFP                fn;
-    caddr_t    arg;
-    int                stopflag;
-    int                type;
+int
+avl_apply( Avlnode *root, IFP fn, caddr_t arg, int stopflag, int type )
 {
        switch ( type ) {
        case AVL_INORDER:
@@ -564,14 +541,16 @@ avl_apply( root, fn, arg, stopflag, type )
  * AVL_NOMORE is returned.
  */
 
-avl_prefixapply( root, data, fmatch, marg, fcmp, carg, stopflag )
-    Avlnode    *root;
-    caddr_t    data;
-    IFP                fmatch;
-    caddr_t    marg;
-    IFP                fcmp;
-    caddr_t    carg;
-    int                stopflag;
+int
+avl_prefixapply(
+    Avlnode    *root,
+    caddr_t    data,
+    IFP                fmatch,
+    caddr_t    marg,
+    IFP                fcmp,
+    caddr_t    carg,
+    int                stopflag
+)
 {
        int     cmp;
 
@@ -613,9 +592,8 @@ avl_prefixapply( root, data, fmatch, marg, fcmp, carg, stopflag )
  * number of items actually freed is returned.
  */
 
-avl_free( root, dfree )
-    Avlnode    *root;
-    IFP                dfree;
+int
+avl_free( Avlnode *root, IFP dfree )
 {
        int     nleft, nright;
 
@@ -643,10 +621,7 @@ avl_free( root, dfree )
  */
 
 caddr_t
-avl_find( root, data, fcmp )
-    Avlnode    *root;
-    caddr_t    data;
-    IFP        fcmp;
+avl_find( Avlnode *root, caddr_t data, IFP fcmp )
 {
        int     cmp;
 
@@ -668,10 +643,7 @@ avl_find( root, data, fcmp )
  */
 
 caddr_t
-avl_find_lin( root, data, fcmp )
-    Avlnode    *root;
-    caddr_t    data;
-    IFP                fcmp;
+avl_find_lin( Avlnode *root, caddr_t data, IFP fcmp )
 {
        caddr_t res;
 
@@ -699,10 +671,8 @@ static int avl_nextlist;
 #define AVL_GRABSIZE   100
 
 /* ARGSUSED */
-static
-avl_buildlist( data, arg )
-    caddr_t    data;
-    int        arg;
+static int
+avl_buildlist( caddr_t data, int arg )
 {
        static int      slots;
 
@@ -734,8 +704,7 @@ avl_buildlist( data, arg )
  */
 
 caddr_t
-avl_getfirst( root )
-    Avlnode    *root;
+avl_getfirst( Avlnode *root )
 {
        if ( avl_list ) {
                free( (char *) avl_list);
@@ -753,7 +722,7 @@ avl_getfirst( root )
 }
 
 caddr_t
-avl_getnext()
+avl_getnext( void )
 {
        if ( avl_list == 0 )
                return( 0 );
@@ -767,12 +736,14 @@ avl_getnext()
        return( avl_list[ avl_nextlist++ ] );
 }
 
-avl_dup_error()
+int
+avl_dup_error( void )
 {
        return( -1 );
 }
 
-avl_dup_ok()
+int
+avl_dup_ok( void )
 {
        return( 0 );
 }
index 71939f4985d0d6a4213cbead4d71682c7fa67b40..b551c8ba692d94f95919f212e8ee209b1d95d4b9 100644 (file)
@@ -1,30 +1,25 @@
 /* testavl.c - Test Tim Howes AVL code */
-#include <sys/types.h>
-#include <stdio.h>
-#include "avl.h"
 
-char *strdup( s )
-char   *s;
-{
-       char    *new;
+#include "portable.h"
 
-       if ( (new = (char *) malloc( strlen( s ) + 1 )) == NULL )
-               return( NULL );
+#include <stdio.h>
+#include <stdlib.h>
 
-       strcpy( new, s );
+#include <ac/string.h>
+#include <sys/types.h>
 
-       return( new );
-}
+#include "avl.h"
+
+static void ravl_print LDAP_P(( Avlnode *root, int depth ));
+static void myprint LDAP_P(( Avlnode *root ));
 
-main( argc, argv )
-int    argc;
-char   **argv;
+int
+main( int argc, char **argv )
 {
        Avlnode *tree = NULLAVL;
        char    command[ 10 ];
        char    name[ 80 ];
        char    *p;
-       int     free(), strcmp();
 
        printf( "> " );
        while ( fgets( command, sizeof( command ), stdin ) != NULL ) {
@@ -39,7 +34,7 @@ char  **argv;
                case 't':       /* traverse with first, next */
                        printf( "***\n" );
                        for ( p = (char * ) avl_getfirst( tree );
-                           p != NULL; p = (char *) avl_getnext( tree, p ) )
+                           p != NULL; p = (char *) avl_getnext( /* tree, p */ ) )
                                printf( "%s\n", p );
                        printf( "***\n" );
                        break;
@@ -60,7 +55,7 @@ char  **argv;
                                exit( 0 );
                        name[ strlen( name ) - 1 ] = '\0';
                        if ( avl_insert( &tree, strdup( name ), strcmp, 
-                           avl_dup_error ) != OK )
+                           avl_dup_error ) != 0 )
                                printf( "\nNot inserted!\n" );
                        break;
                case 'd':       /* delete */
@@ -85,9 +80,7 @@ char  **argv;
        /* NOTREACHED */
 }
 
-static ravl_print( root, depth )
-Avlnode        *root;
-int    depth;
+static void ravl_print( Avlnode *root, int depth )
 {
        int     i;
 
@@ -103,15 +96,14 @@ int        depth;
        ravl_print( root->avl_left, depth+1 );
 }
 
-myprint( root )
-Avlnode        *root;
+static void myprint( Avlnode *root )
 {
        printf( "********\n" );
 
        if ( root == 0 )
                printf( "\tNULL\n" );
        else
-               ( void ) ravl_print( root, 0 );
+               ravl_print( root, 0 );
 
        printf( "********\n" );
 }
index e67b288b5572c286140967f449dbecf38b931e00..aab968200776c7ea104ae6da8a47611407c3bb8a 100644 (file)
 #include "portable.h"
 
 #include <stdio.h>
-
-#ifdef STDC_HEADERS
 #include <stdlib.h>
-#endif
 
 #include <ac/stdarg.h>
 
index 57763213214d91f5e7d7532358ee7a2572e29bd6..d2f72154b46b526c9773a11efae4f7e8f1502085 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <ac/string.h>
 #include <ac/socket.h>
+#include <ac/unistd.h>
 
 #ifdef HAVE_CONSOLE_H
 #include <console.h>
@@ -38,7 +39,6 @@ main( int argc, char **argv )
        int             tag;
        BerElement      ber;
        Sockbuf         sb;
-       extern char     *optarg;
 
 #ifdef HAVE_CONSOLE_H
        ccommand( &argv );
index 50ac00d4bfb8f46dd17559f001a62f2b8b663d8f..ca1acc742bcacc81422543ad60389b856cd0e72f 100644 (file)
@@ -4,43 +4,46 @@
  * All rights reserved.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include <unix.h>
-#include <fcntl.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_CONSOLE_H
 #include <console.h>
-#else /* MACOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* MACOS */
+#endif /* HAVE_CONSOLE_H */
+
 #include "lber.h"
 
-static usage( char *name )
+static void usage( char *name )
 {
        fprintf( stderr, "usage: %s fmtstring\n", name );
 }
 
 main( int argc, char **argv )
 {
-       int             i, num, len;
-       char            *s, *p;
+#ifdef notdef
+       int             i, len;
+       char    *s, *p;
+#endif
+       int             num;
        Seqorset        *sos = NULLSEQORSET;
        BerElement      *ber;
        Sockbuf         sb;
-       extern char     *optarg;
 
        if ( argc < 2 ) {
                usage( argv[0] );
                exit( 1 );
        }
 
-       bzero( &sb, sizeof(sb) );
+       memset( &sb, 0, sizeof(sb) );
        sb.sb_sd = 1;
        sb.sb_ber.ber_buf = NULL;
 
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
        ccommand( &argv );
        cshow( stdout );
 
@@ -151,9 +154,9 @@ main( int argc, char **argv )
                        break;
 
                default:
-#ifndef NO_USERINTERFACE
+#ifdef LDAP_LIBUI
                        fprintf( stderr, "unknown fmt %c\n", *fmt );
-#endif /* NO_USERINTERFACE */
+#endif /* LDAP_LIBUI */
                        rc = -1;
                        break;
                }
index 2130c295027bbf853ac3e49c487e2c247f363efc..1cceeb5b4088e4c51d840b20b7156940768c48b2 100644 (file)
@@ -105,7 +105,7 @@ static int BerWrite LDAP_P(( Sockbuf *sb, char *buf, long len ));
 
 #define EXBUFSIZ       1024
 
-int
+static int
 ber_filbuf( Sockbuf *sb, long len )
 {
        short   rc;
@@ -151,7 +151,7 @@ ber_filbuf( Sockbuf *sb, long len )
 }
 
 
-long
+static long
 BerRead( Sockbuf *sb, char *buf, long len )
 {
        int     c;
@@ -340,13 +340,13 @@ ber_alloc_t( int options )
 }
 
 BerElement *
-ber_alloc()
+ber_alloc( void )
 {
        return( ber_alloc_t( 0 ) );
 }
 
 BerElement *
-der_alloc()
+der_alloc( void )
 {
        return( ber_alloc_t( LBER_USE_DER ) );
 }
@@ -467,7 +467,8 @@ ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber )
        unsigned long   tag = 0, netlen, toread;
        unsigned char   lc;
        long            rc;
-       int             noctets, diff;
+       int                     noctets;
+       unsigned int    diff;
 
 #ifdef LDAP_DEBUG
        if ( lber_debug )
index 8e05bf26530dca2c123ab6792e7296ec0752a6ce..889096416597d64972c734c21da7ed107744dbd2 100644 (file)
@@ -20,6 +20,7 @@ static char copyright[] = "@(#) Copyright (c) 1990, 1994 Regents of the Universi
 #include <ac/socket.h>
 #include <ac/string.h>
 #include <ac/time.h>
+#include <ac/unistd.h>
 
 #include "lber.h"
 #include "ldap.h"
@@ -300,8 +301,8 @@ cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
     tv.tv_usec = 0;
 
     Debug( LDAP_DEBUG_TRACE,
-           "cldap_result waiting up to %d seconds for a response\n",
-           tv.tv_sec, 0, 0 );
+           "cldap_result waiting up to %ld seconds for a response\n",
+           (long) tv.tv_sec, 0, 0 );
     ber_init( &ber, 0 );
     ldap_set_ber_options( ld, &ber );
 
@@ -473,7 +474,7 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
            bv = NULL;
                
        } else {
-           Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg got unknown tag %d\n",
+           Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg got unknown tag %lu\n",
                    tag, 0, 0 );
            rc = LDAP_PROTOCOL_ERROR;
            break;      /* return w/error */
index 2de43b7358f57871780fd8f19afdd8df450c65c2..9d6f158f8b8464d3f020a1c0499e7ae2e9f20ee6 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef _LDAP_INT_H 
 #define _LDAP_INT_H 
 
+LDAP_BEGIN_DECL
+
 #define LDAP_URL_PREFIX         "ldap://"
 #define LDAP_URL_PREFIX_LEN     7
 #define LDAP_URL_URLCOLON      "URL:"
@@ -24,7 +26,6 @@
 #endif /* LDAP_DNS */
 #endif /* LDAP_REFERRALS */
 
-LDAP_BEGIN_DECL
 /*
  * in cache.c
  */
@@ -34,7 +35,7 @@ void ldap_add_result_to_cache LDAP_P(( LDAP *ld, LDAPMessage *result ));
 int ldap_check_cache LDAP_P(( LDAP *ld, unsigned long msgtype, BerElement *request ));
 
 /*
- * in dparse.c
+ * in dsparse.c
  */
 int next_line_tokens LDAP_P(( char **bufp, long *blenp, char ***toksp ));
 void free_strarray LDAP_P(( char **sap ));
@@ -105,6 +106,12 @@ int ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadref
 int ldap_append_referral( LDAP *ld, char **referralsp, char *s );
 #endif /* LDAP_REFERRALS */
 
+/*
+ * in result.c:
+ */
+#ifdef LDAP_CONNECTIONLESS
+LDAP_F int cldap_getmsg        ( LDAP *ld, struct timeval *timeout, BerElement *ber );
+#endif
 
 /*
  * in search.c
@@ -142,4 +149,5 @@ int ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input );
 #endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
 #endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
 
+LDAP_END_DECL
 #endif /* _LDAP_INT_H */
index 9d15b1c3429727dba2dcd3edc52fb6bab6473cb2..fc19492c55b8afeb718fe8d951d4bcc19512c160 100644 (file)
@@ -56,7 +56,11 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address,
 
        connected = use_hp = 0;
 
-       if ( host != NULL && ( address = inet_addr( host )) == (unsigned long) -1L ) {
+       if ( host != NULL ) {
+           address = inet_addr( host );
+           /* This was just a test for -1 until OSF1 let inet_addr return
+              unsigned int, which is narrower than 'unsigned long address' */
+           if ( address == 0xffffffff || address == (unsigned long) -1 ) {
                if ( (hp = gethostbyname( host )) == NULL ) {
 #ifdef HAVE_WINSOCK
                        errno = WSAGetLastError();
@@ -66,6 +70,7 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address,
                        return( -1 );
                }
                use_hp = 1;
+           }
        }
 
        rc = -1;
@@ -256,7 +261,7 @@ ldap_is_read_ready( LDAP *ld, Sockbuf *sb )
 
 
 void *
-ldap_new_select_info()
+ldap_new_select_info( void )
 {
        struct selectinfo       *sip;
 
@@ -290,6 +295,8 @@ do_ldap_select( LDAP *ld, struct timeval *timeout )
                tblsize = sysconf( _SC_OPEN_MAX );
 #elif defined( HAVE_GETDTABLESIZE )
                tblsize = getdtablesize();
+#else
+               tblsize = FD_SETSIZE;
 #endif /* !USE_SYSCONF */
 
 #ifdef FD_SETSIZE
index 319cb9ccdfe2c4c07a1949be8b3a6d3d13bc9293..272e84db23384c4feeee70848254b8fd51cdbf83 100644 (file)
@@ -30,17 +30,17 @@ struct entrything {
        LDAPMessage     *et_msg;
 };
 
-static int     (*et_cmp_fn) LDAP_P(( char *a, char *b ));
+static int     (*et_cmp_fn) LDAP_P(( const char *a, const char *b ));
 static int     et_cmp LDAP_P(( const void *aa, const void *bb));
 
 
 int
 ldap_sort_strcasecmp(
-    char       **a,
-    char       **b
+       const void      *a,
+       const void      *b
 )
 {
-       return( strcasecmp( *a, *b ) );
+       return( strcasecmp( *(char *const *)a, *(char *const *)b ) );
 }
 
 static int
@@ -79,7 +79,7 @@ ldap_sort_entries(
     LDAP       *ld,
     LDAPMessage        **chain,
     char       *attr,          /* NULL => sort by DN */
-    int                (*cmp) LDAP_P((const char *, const char *))
+    int                (*cmp) (const char *, const char *)
 )
 {
        int                     i, count;
@@ -132,7 +132,7 @@ int
 ldap_sort_values(
     LDAP       *ld,
     char       **vals,
-    int                (*cmp) LDAP_P((const void *, const void *))
+    int                (*cmp) (const void *, const void *)
 )
 {
        int     nel;
index 84f478da80032c7f52f748f6358cfe7c66f6c0ed..2af816244da30cd5f1614995240402a022338825 100644 (file)
@@ -1,57 +1,51 @@
+#include "portable.h"
+
 #include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
 #include <stdlib.h>
-#ifdef THINK_C
-#include <console.h>
-#include <unix.h>
-#include <fcntl.h>
-#endif /* THINK_C */
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#if defined( WINSOCK ) || defined( _WIN32 )
-#include "console.h"
-#endif /* WINSOCK */
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
 #include <sys/stat.h>
+
+#ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
-#ifndef VMS
+#endif
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+
 #include <fcntl.h>
-#include <unistd.h>
-#endif /* VMS */
-#endif /* DOS */
-#endif /* MACOS */
 
 #include "lber.h"
 #include "ldap.h"
 
-#if !defined( PCNFS ) && !defined( WINSOCK ) && !defined( MACOS )
-#define MOD_USE_BVALS
-#endif /* !PCNFS && !WINSOCK && !MACOS */
+/* including the "internal" defs is legit and nec. since this test routine has 
+ * a-priori knowledge of libldap internal workings.
+ * hodges@stanford.edu 5-Feb-96
+ */
+#include "ldap-int.h"
 
-#ifdef NEEDPROTOS
-static void handle_result( LDAP *ld, LDAPMessage *lm );
-static void print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s );
-static void print_search_entry( LDAP *ld, LDAPMessage *res );
-static void free_list( char **list );
-#else
-static void handle_result();
-static void print_ldap_result();
-static void print_search_entry();
-static void free_list();
-#endif /* NEEDPROTOS */
+/* local functions */
+#ifndef HAVE_GETLINE
+static char *getline LDAP_P(( char *line, int len, FILE *fp, char *prompt ));
+#endif
+static char **get_list LDAP_P(( char *prompt ));
+static int file_read LDAP_P(( char *path, struct berval *bv ));
+static LDAPMod **get_modlist LDAP_P(( char *prompt1, char *prompt2, char *prompt3 ));
+static void handle_result LDAP_P(( LDAP *ld, LDAPMessage *lm ));
+static void print_ldap_result LDAP_P(( LDAP *ld, LDAPMessage *lm, char *s ));
+static void print_search_entry LDAP_P(( LDAP *ld, LDAPMessage *res ));
+static void free_list LDAP_P(( char **list ));
 
-#define NOCACHEERRMSG  "don't compile with -DNO_CACHE if you desire local caching"
+#define NOCACHEERRMSG  "don't compile with -DLDAP_NOCACHE if you desire local caching"
 
-char *dnsuffix;
+static char *dnsuffix;
 
-#ifndef WINSOCK
+#ifndef HAVE_GETLINE
 static char *
 getline( char *line, int len, FILE *fp, char *prompt )
 {
@@ -64,7 +58,7 @@ getline( char *line, int len, FILE *fp, char *prompt )
 
        return( line );
 }
-#endif /* WINSOCK */
+#endif
 
 static char **
 get_list( char *prompt )
@@ -112,7 +106,6 @@ free_list( char **list )
 }
 
 
-#ifdef MOD_USE_BVALS
 static int
 file_read( char *path, struct berval *bv )
 {
@@ -149,7 +142,7 @@ file_read( char *path, struct berval *bv )
        eof = feof( fp );
        fclose( fp );
 
-       if ( rlen != bv->bv_len ) {
+       if ( (unsigned long) rlen != bv->bv_len ) {
                perror( path );
                free( bv->bv_val );
                return( -1 );
@@ -157,7 +150,6 @@ file_read( char *path, struct berval *bv )
 
        return( bv->bv_len );
 }
-#endif /* MOD_USE_BVALS */
 
 
 static LDAPMod **
@@ -167,9 +159,7 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 )
        int             num;
        LDAPMod         tmp;
        LDAPMod         **result;
-#ifdef MOD_USE_BVALS
        struct berval   **bvals;
-#endif /* MOD_USE_BVALS */
 
        num = 0;
        result = NULL;
@@ -188,7 +178,7 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 )
                tmp.mod_type = strdup( buf );
 
                tmp.mod_values = get_list( prompt3 );
-#ifdef MOD_USE_BVALS
+
                if ( tmp.mod_values != NULL ) {
                        int     i;
 
@@ -214,7 +204,6 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 )
                        tmp.mod_bvalues = bvals;
                        tmp.mod_op |= LDAP_MOD_BVALUES;
                }
-#endif /* MOD_USE_BVALS */
 
                if ( result == NULL )
                        result = (LDAPMod **) malloc( sizeof(LDAPMod *) );
@@ -236,14 +225,14 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 )
 
 
 #ifdef LDAP_REFERRALS
-int
+static int
 bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
        int freeit )
 {
        static char     dn[256], passwd[256];
 
        if ( !freeit ) {
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
                getline( dn, sizeof(dn), stdin,
                    "re-bind method (0->simple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " );
                if (( *authmethodp = atoi( dn )) == 3 ) {
@@ -251,9 +240,9 @@ bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
                } else {
                        *authmethodp |= 0x80;
                }
-#else /* KERBEROS */
+#else /* HAVE_KERBEROS */
                *authmethodp = LDAP_AUTH_SIMPLE;
-#endif /* KERBEROS */
+#endif /* HAVE_KERBEROS */
 
                getline( dn, sizeof(dn), stdin, "re-bind dn? " );
                strcat( dn, dnsuffix );
@@ -274,14 +263,9 @@ bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
 
 
 int
-#ifdef WINSOCK
-ldapmain(
-#else /* WINSOCK */
-main(
-#endif /* WINSOCK */
-       int argc, char **argv )
+main( int argc, char **argv )
 {
-       LDAP            *ld;
+       LDAP            *ld = NULL;
        int             i, c, port, cldapflg, errflg, method, id, msgtype;
        char            line[256], command1, command2, command3;
        char            passwd[64], dn[256], rdn[64], attr[64], value[256];
@@ -296,18 +280,6 @@ main(
        int             copyoptions = 0;
        LDAPURLDesc     *ludp;
 
-       extern char     *optarg;
-       extern int      optind;
-
-#ifdef MACOS
-       if (( argv = get_list( "cmd line arg?" )) == NULL ) {
-               exit( 1 );
-       }
-       for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
-               ;
-       }
-#endif /* MACOS */
-
        host = NULL;
        port = LDAP_PORT;
        dnsuffix = "";
@@ -316,11 +288,11 @@ main(
        while (( c = getopt( argc, argv, "uh:d:s:p:t:T:" )) != -1 ) {
                switch( c ) {
                case 'u':
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
                        cldapflg++;
-#else /* CLDAP */
-                       printf( "Compile with -DCLDAP for UDP support\n" );
-#endif /* CLDAP */
+#else /* LDAP_CONNECTIONLESS */
+                       printf( "Compile with -DLDAP_CONNECTIONLESS for UDP support\n" );
+#endif /* LDAP_CONNECTIONLESS */
                        break;
 
                case 'd':
@@ -346,7 +318,6 @@ main(
                        port = atoi( optarg );
                        break;
 
-#if !defined(MACOS) && !defined(DOS)
                case 't':       /* copy ber's to given file */
                        copyfname = strdup( optarg );
                        copyoptions = LBER_TO_FILE;
@@ -356,7 +327,6 @@ main(
                        copyfname = strdup( optarg );
                        copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY);
                        break;
-#endif
 
                default:
                    ++errflg;
@@ -377,9 +347,9 @@ main(
                host == NULL ? "(null)" : host, port );
 
        if ( cldapflg ) {
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
                ld = cldap_open( host, port );
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
        } else {
                ld = ldap_open( host, port );
        }
@@ -389,7 +359,6 @@ main(
                exit(1);
        }
 
-#if !defined(MACOS) && !defined(DOS)
        if ( copyfname != NULL ) {
                if ( (ld->ld_sb.sb_fd = open( copyfname, O_WRONLY | O_CREAT,
                    0600 ))  == -1 ) {
@@ -398,7 +367,6 @@ main(
                }
                ld->ld_sb.sb_options = copyoptions;
        }
-#endif
 
        bound = 0;
        timeout.tv_sec = 0;
@@ -440,13 +408,13 @@ main(
                        break;
 
                case 'b':       /* asynch bind */
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
                        getline( line, sizeof(line), stdin,
                            "method (0->simple, 1->krbv41, 2->krbv42)? " );
                        method = atoi( line ) | 0x80;
-#else /* KERBEROS */
+#else /* HAVE_KERBEROS */
                        method = LDAP_AUTH_SIMPLE;
-#endif /* KERBEROS */
+#endif /* HAVE_KERBEROS */
                        getline( dn, sizeof(dn), stdin, "dn? " );
                        strcat( dn, dnsuffix );
 
@@ -466,7 +434,7 @@ main(
                        break;
 
                case 'B':       /* synch bind */
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
                        getline( line, sizeof(line), stdin,
                            "method 0->simple 1->krbv41 2->krbv42 3->krb? " );
                        method = atoi( line );
@@ -474,9 +442,9 @@ main(
                                method = LDAP_AUTH_KRBV4;
                        else
                                method = method | 0x80;
-#else /* KERBEROS */
+#else /* HAVE_KERBEROS */
                        method = LDAP_AUTH_SIMPLE;
-#endif /* KERBEROS */
+#endif /* HAVE_KERBEROS */
                        getline( dn, sizeof(dn), stdin, "dn? " );
                        strcat( dn, dnsuffix );
 
@@ -567,10 +535,10 @@ main(
                        break;
 
                case 'q':       /* quit */
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
                        if ( cldapflg )
                                cldap_close( ld );
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
 #ifdef LDAP_REFERRALS
                        if ( !cldapflg )
 #else /* LDAP_REFERRALS */
@@ -636,7 +604,7 @@ main(
                        attrsonly = atoi( line );
 
                        if ( cldapflg ) {
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
                            getline( line, sizeof(line), stdin,
                                "Requestor DN (for logging)? " );
                            if ( cldap_search_s( ld, dn, scope, filter, types,
@@ -648,7 +616,7 @@ main(
                                handle_result( ld, res );
                                res = NULLMSG;
                            }
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
                        } else {
                            if (( id = ldap_search( ld, dn, scope, filter,
                                    types, attrsonly  )) == -1 ) {
@@ -749,9 +717,9 @@ main(
                        break;
 
                case 'e':       /* enable cache */
-#ifdef NO_CACHE
+#ifdef LDAP_NOCACHE
                        printf( NOCACHEERRMSG );
-#else /* NO_CACHE */
+#else /* LDAP_NOCACHE */
                        getline( line, sizeof(line), stdin, "Cache timeout (secs)? " );
                        i = atoi( line );
                        getline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " );
@@ -760,25 +728,25 @@ main(
                        } else {
                                printf( "ldap_enable_cache failed\n" ); 
                        }
-#endif /* NO_CACHE */
+#endif /* LDAP_NOCACHE */
                        break;
 
                case 'x':       /* uncache entry */
-#ifdef NO_CACHE
+#ifdef LDAP_NOCACHE
                        printf( NOCACHEERRMSG );
-#else /* NO_CACHE */
+#else /* LDAP_NOCACHE */
                        getline( line, sizeof(line), stdin, "DN? " );
                        ldap_uncache_entry( ld, line );
-#endif /* NO_CACHE */
+#endif /* LDAP_NOCACHE */
                        break;
 
                case 'X':       /* uncache request */
-#ifdef NO_CACHE
+#ifdef LDAP_NOCACHE
                        printf( NOCACHEERRMSG );
-#else /* NO_CACHE */
+#else /* LDAP_NOCACHE */
                        getline( line, sizeof(line), stdin, "request msgid? " );
                        ldap_uncache_request( ld, atoi( line ));
-#endif /* NO_CACHE */
+#endif /* LDAP_NOCACHE */
                        break;
 
                case 'o':       /* set ldap options */
@@ -833,9 +801,9 @@ main(
                        break;
 
                case 'O':       /* set cache options */
-#ifdef NO_CACHE
+#ifdef LDAP_NOCACHE
                        printf( NOCACHEERRMSG );
-#else /* NO_CACHE */
+#else /* LDAP_NOCACHE */
                        getline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" );
                        switch( atoi( line )) {
                        case 0:
@@ -852,7 +820,7 @@ main(
                        default:
                                printf( "not a valid cache option\n" );
                        }
-#endif /* NO_CACHE */
+#endif /* LDAP_NOCACHE */
                        break;
 
                case '?':       /* help */
@@ -956,13 +924,9 @@ print_search_entry( LDAP *ld, LDAPMessage *res )
 
                ufn = ldap_dn2ufn( dn );
                printf( "\tUFN: %s\n", ufn );
-#ifdef WINSOCK
-               ldap_memfree( dn );
-               ldap_memfree( ufn );
-#else /* WINSOCK */
+
                free( dn );
                free( ufn );
-#endif /* WINSOCK */
 
                for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
                    a = ldap_next_attribute( ld, e, ber ) ) {
@@ -975,7 +939,7 @@ print_search_entry( LDAP *ld, LDAPMessage *res )
                                        int     j, nonascii;
 
                                        nonascii = 0;
-                                       for ( j = 0; j < vals[i]->bv_len; j++ )
+                                       for ( j = 0; (unsigned long) j < vals[i]->bv_len; j++ )
                                                if ( !isascii( vals[i]->bv_val[j] ) ) {
                                                        nonascii = 1;
                                                        break;
@@ -1001,23 +965,3 @@ print_search_entry( LDAP *ld, LDAPMessage *res )
            || res->lm_chain != NULLMSG )
                print_ldap_result( ld, res, "search" );
 }
-
-
-#ifdef WINSOCK
-void
-ldap_perror( LDAP *ld, char *s )
-{
-       char    *errs;
-
-       if ( ld == NULL ) {
-               perror( s );
-               return;
-       }
-
-       errs = ldap_err2string( ld->ld_errno );
-       printf( "%s: %s\n", s, errs == NULL ? "unknown error" : errs );
-       if ( ld->ld_error != NULL && *ld->ld_error != '\0' ) {
-               printf( "%s: additional info: %s\n", s, ld->ld_error );
-       }
-}
-#endif /* WINSOCK */
index 6d92f536b1b661775dd3afa8d5e73c5651498ed1..d3784a92fb90055a6472e420ccda126e774d0119 100644 (file)
@@ -8,9 +8,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <ac/ctype.h>
 #include <ac/socket.h>
 #include <ac/string.h>
-#include <ac/ctype.h>
 #include <ac/time.h>
 
 #ifdef HAVE_SYS_FILE_H
@@ -23,6 +23,7 @@
 
 #include "ldapconfig.h"
 
+/* local functions */
 static int do_entry2text LDAP_P((
        LDAP *ld, char *buf, char *base, LDAPMessage *entry,
        struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
index d10837579061a41ed6b0673e88c5c496ece35704..9855317b560cc01d265f28616a87dfaae3e0ef2f 100644 (file)
@@ -1,27 +1,25 @@
-#include <stdio.h>
-#include <sys/types.h>
-#include "lber.h"
-#include "ldap.h"
-#include "disptmpl.h"
-#include "srchpref.h"
+#include "portable.h"
 
-#ifdef MACOS
+#include <stdio.h>
 #include <stdlib.h>
+
+#include <ac/socket.h>
+#include <ac/time.h>
+
+#ifdef HAVE_CONSOLE_H
 #include <console.h>
 #endif /* MACOS */
 
-#ifdef NEEDPROTOS
-void dump_tmpl( struct ldap_disptmpl *tmpl );
-void dump_srchpref( struct ldap_searchobj *sp );
-#else /* NEEDPROTOS */
-void dump_tmpl();
-void dump_srchpref();
-#endif /* NEEDPROTOS */
+#include "lber.h"
+#include "ldap.h"
+#include "disptmpl.h"
+#include "srchpref.h"
 
+static void dump_tmpl   ( struct ldap_disptmpl *tmpl );
+static void dump_srchpref( struct ldap_searchobj *sp );
 
 #define NULLSTRINGIFNULL( s )  ( s == NULL ? "(null)" : s )
 
-
 int
 main( int argc, char **argv )
 {
@@ -29,7 +27,7 @@ main( int argc, char **argv )
     struct ldap_searchobj      *so, *sop;
     int                                err;
 
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
        ccommand( &argv );
        for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
            ;
index e9c533aca538f67444b8ae8552a1ac25fa52edfd..feb036c54e3bdf03b810f5ddbbe79e1f2827fe85 100644 (file)
@@ -26,6 +26,7 @@ static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of
 
 typedef int (*cancelptype) LDAP_P(( void *cancelparm ));
 
+/* local functions */
 static int ldap_ufn_search_ctx LDAP_P(( LDAP *ld, char **ufncomp, int ncomp, 
        char *prefix, char **attrs, int attrsonly, LDAPMessage **res, 
        cancelptype cancelproc, void *cancelparm, char *tag1, char *tag2,
@@ -73,7 +74,6 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix,
        LDAPFiltInfo    *fi;
        LDAPMessage     *tmpcand;
        LDAPMessage     *candidates;
-       LDAPMessage     *ldap_msg_merge(), *ldap_ufn_expand();
        static char     *objattrs[] = { "objectClass", NULL };
 
        /* 
index e96685a02bea46436d1a6368fae4c180b485f60c..aaa8244d7e3ba1f2e1190112bd5413fb2611e9a6 100644 (file)
@@ -36,6 +36,7 @@ static char copyright[] = "@(#) Copyright (c) 1996 Regents of the University of
 #include "ldap-int.h"
 
 
+/* local functions */
 static int skip_url_prefix LDAP_P(( char **urlp, int *enclosedp ));
 static void hex_unescape LDAP_P(( char *s ));
 static int unhex( char c );
index 23e6f842f9e55eba8e2b38c2237011f4a60c22eb..7a49e6b31cc4252fd0905ae7ddd90ce1e44530ec 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <ac/string.h>
 #include <ac/errno.h>
 
 #include "ldbm.h"
@@ -317,7 +318,7 @@ ldbm_datum_dup( LDBM ldbm, Datum data )
                return( dup );
        }
        dup.dsize = data.dsize;
-       if ( dup.dptr = (char *) malloc( data.dsize ) )
+       if ( (dup.dptr = (char *) malloc( data.dsize )) != NULL )
                memcpy( dup.dptr, data.dptr, data.dsize );
 
        return( dup );
index e57b44b25f19667cb576eb1a2ca52058653a5d61..c90eead743dc88fc3460476bcc0fa86bebf64057 100644 (file)
@@ -1,11 +1,17 @@
 /* stack.c - stack handling routines */
 
+#include "portable.h"
+
+#if defined( HAVE_LWP )
+
 #include <stdio.h>
+
+#include <ac/time.h>
+#include <ac/socket.h>
+
 #include "lber.h"
 #include "ldap.h"
 
-#if defined( sunos4 )
-
 #include <lwp/lwp.h>
 #include <lwp/stackdep.h>
 
index 68baf5f30f4a9f60be2de8fb177f47b2eef09115..6c7cff541578593ffc96c41edcde3de3dac45714 100644 (file)
@@ -72,7 +72,7 @@ pthread_create(
 }
 
 void
-pthread_yield()
+pthread_yield( void )
 {
        cthread_yield();
 }
@@ -223,7 +223,7 @@ pthread_create(
 #endif /* ! sunos56 */
 
 void
-pthread_yield()
+pthread_yield( void )
 {
        thr_yield();
 }
@@ -317,9 +317,6 @@ pthread_cond_broadcast( pthread_cond_t *cv )
  *           *
  *************/
 
-extern stkalign_t      *get_stack();
-static void            lwp_create_stack();
-
 int
 pthread_attr_init( pthread_attr_t *attr )
 {
@@ -347,6 +344,14 @@ pthread_attr_setdetachstate( pthread_attr_t *attr, int detachstate )
        return( 0 );
 }
 
+static void
+lwp_create_stack( VFP func, void *arg, int stackno )
+{
+       (*func)( arg );
+
+       free_stack( stackno );
+}
+
 /* ARGSUSED */
 int
 pthread_create(
@@ -366,16 +371,8 @@ pthread_create(
            arg, stackno ) );
 }
 
-static void
-lwp_create_stack( VFP func, void *arg, int stackno )
-{
-       (*func)( arg );
-
-       free_stack( stackno );
-}
-
 void
-pthread_yield()
+pthread_yield( void )
 {
        lwp_yield( SELF );
 }
@@ -528,7 +525,7 @@ pthread_create(
 }
 
 void
-pthread_yield()
+pthread_yield( void )
 {
        return;
 }
diff --git a/libraries/liblutil/md5.c b/libraries/liblutil/md5.c
new file mode 100644 (file)
index 0000000..956b9e5
--- /dev/null
@@ -0,0 +1,318 @@
+/*
+ * Modified by Kurt D. Zeilenga for inclusion into OpenLDAP
+ * I hereby disclaim copyright in any changes I have made; this
+ * code remains in the public domain.
+ */
+
+/*
+ * This code implements the MD5 message-digest algorithm.
+ * The algorithm is due to Ron Rivest.  This code was
+ * written by Colin Plumb in 1993, no copyright is claimed.
+ * This code is in the public domain; do with it what you wish.
+ *
+ * Equivalent code is available from RSA Data Security, Inc.
+ * This code has been tested against that, and is equivalent,
+ * except that you don't need to include two pages of legalese
+ * with every copy.
+ *
+ * To compute the message digest of a chunk of bytes, declare an
+ * MD5Context structure, pass it to MD5Init, call MD5Update as
+ * needed on buffers full of bytes, and then call MD5Final, which
+ * will fill a supplied 16-byte array with the digest.
+ */
+
+/* This code was modified in 1997 by Jim Kingdon of Cyclic Software to
+   not require an integer type which is exactly 32 bits.  This work
+   draws on the changes for the same purpose by Tatu Ylonen
+   <ylo@cs.hut.fi> as part of SSH, but since I didn't actually use
+   that code, there is no copyright issue.  I hereby disclaim
+   copyright in any changes I have made; this code remains in the
+   public domain.  */
+
+#include "portable.h"
+
+#include <ac/string.h>
+
+/* include socket.h to get sys/types.h and/or winsock2.h */
+#include <ac/socket.h>
+
+#include <lutil_md5.h>
+
+/* Little-endian byte-swapping routines.  Note that these do not
+   depend on the size of datatypes such as uint32, nor do they require
+   us to detect the endianness of the machine we are running on.  It
+   is possible they should be macros for speed, but I would be
+   surprised if they were a performance bottleneck for MD5.  */
+
+static uint32
+getu32( const unsigned char *addr )
+{
+       return (((((unsigned long)addr[3] << 8) | addr[2]) << 8)
+               | addr[1]) << 8 | addr[0];
+}
+
+static void
+putu32( uint32 data, unsigned char *addr )
+{
+       addr[0] = (unsigned char)data;
+       addr[1] = (unsigned char)(data >> 8);
+       addr[2] = (unsigned char)(data >> 16);
+       addr[3] = (unsigned char)(data >> 24);
+}
+
+/*
+ * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious
+ * initialization constants.
+ */
+void
+ldap_MD5Init( struct ldap_MD5Context *ctx )
+{
+       ctx->buf[0] = 0x67452301;
+       ctx->buf[1] = 0xefcdab89;
+       ctx->buf[2] = 0x98badcfe;
+       ctx->buf[3] = 0x10325476;
+
+       ctx->bits[0] = 0;
+       ctx->bits[1] = 0;
+}
+
+/*
+ * Update context to reflect the concatenation of another buffer full
+ * of bytes.
+ */
+void
+ldap_MD5Update(
+    struct ldap_MD5Context     *ctx,
+    const unsigned char                *buf,
+    unsigned int               len
+)
+{
+       uint32 t;
+
+       /* Update bitcount */
+
+       t = ctx->bits[0];
+       if ((ctx->bits[0] = (t + ((uint32)len << 3)) & 0xffffffff) < t)
+               ctx->bits[1]++; /* Carry from low to high */
+       ctx->bits[1] += len >> 29;
+
+       t = (t >> 3) & 0x3f;    /* Bytes already in shsInfo->data */
+
+       /* Handle any leading odd-sized chunks */
+
+       if ( t ) {
+               unsigned char *p = ctx->in + t;
+
+               t = 64-t;
+               if (len < t) {
+                       memcpy(p, buf, len);
+                       return;
+               }
+               memcpy(p, buf, t);
+               ldap_MD5Transform(ctx->buf, ctx->in);
+               buf += t;
+               len -= t;
+       }
+
+       /* Process data in 64-byte chunks */
+
+       while (len >= 64) {
+               memcpy(ctx->in, buf, 64);
+               ldap_MD5Transform(ctx->buf, ctx->in);
+               buf += 64;
+               len -= 64;
+       }
+
+       /* Handle any remaining bytes of data. */
+
+       memcpy(ctx->in, buf, len);
+}
+
+/*
+ * Final wrapup - pad to 64-byte boundary with the bit pattern 
+ * 1 0* (64-bit count of bits processed, MSB-first)
+ */
+void
+ldap_MD5Final( unsigned char *digest, struct ldap_MD5Context *ctx )
+{
+       unsigned count;
+       unsigned char *p;
+
+       /* Compute number of bytes mod 64 */
+       count = (ctx->bits[0] >> 3) & 0x3F;
+
+       /* Set the first char of padding to 0x80.  This is safe since there is
+          always at least one byte free */
+       p = ctx->in + count;
+       *p++ = 0x80;
+
+       /* Bytes of padding needed to make 64 bytes */
+       count = 64 - 1 - count;
+
+       /* Pad out to 56 mod 64 */
+       if (count < 8) {
+               /* Two lots of padding:  Pad the first block to 64 bytes */
+               memset(p, 0, count);
+               ldap_MD5Transform(ctx->buf, ctx->in);
+
+               /* Now fill the next block with 56 bytes */
+               memset(ctx->in, 0, 56);
+       } else {
+               /* Pad block to 56 bytes */
+               memset(p, 0, count-8);
+       }
+
+       /* Append length in bits and transform */
+       putu32(ctx->bits[0], ctx->in + 56);
+       putu32(ctx->bits[1], ctx->in + 60);
+
+       ldap_MD5Transform(ctx->buf, ctx->in);
+       putu32(ctx->buf[0], digest);
+       putu32(ctx->buf[1], digest + 4);
+       putu32(ctx->buf[2], digest + 8);
+       putu32(ctx->buf[3], digest + 12);
+       memset(ctx, 0, sizeof(ctx));    /* In case it's sensitive */
+}
+
+#ifndef ASM_MD5
+
+/* The four core functions - F1 is optimized somewhat */
+
+/* #define F1(x, y, z) (x & y | ~x & z) */
+#define F1(x, y, z) (z ^ (x & (y ^ z)))
+#define F2(x, y, z) F1(z, x, y)
+#define F3(x, y, z) (x ^ y ^ z)
+#define F4(x, y, z) (y ^ (x | ~z))
+
+/* This is the central step in the MD5 algorithm. */
+#define MD5STEP(f, w, x, y, z, data, s) \
+       ( w += f(x, y, z) + data, w &= 0xffffffff, w = w<<s | w>>(32-s), w += x )
+
+/*
+ * The core of the MD5 algorithm, this alters an existing MD5 hash to
+ * reflect the addition of 16 longwords of new data.  MD5Update blocks
+ * the data and converts bytes into longwords for this routine.
+ */
+void
+ldap_MD5Transform( uint32 *buf, const unsigned char *inraw )
+{
+       register uint32 a, b, c, d;
+       uint32 in[16];
+       int i;
+
+       for (i = 0; i < 16; ++i)
+               in[i] = getu32 (inraw + 4 * i);
+
+       a = buf[0];
+       b = buf[1];
+       c = buf[2];
+       d = buf[3];
+
+       MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478,  7);
+       MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);
+       MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);
+       MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);
+       MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf,  7);
+       MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);
+       MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);
+       MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);
+       MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8,  7);
+       MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);
+       MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);
+       MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);
+       MD5STEP(F1, a, b, c, d, in[12]+0x6b901122,  7);
+       MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);
+       MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);
+       MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);
+
+       MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562,  5);
+       MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340,  9);
+       MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);
+       MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);
+       MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d,  5);
+       MD5STEP(F2, d, a, b, c, in[10]+0x02441453,  9);
+       MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);
+       MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);
+       MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6,  5);
+       MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6,  9);
+       MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);
+       MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);
+       MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905,  5);
+       MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8,  9);
+       MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);
+       MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);
+
+       MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942,  4);
+       MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);
+       MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);
+       MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);
+       MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44,  4);
+       MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);
+       MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);
+       MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);
+       MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6,  4);
+       MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);
+       MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);
+       MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);
+       MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039,  4);
+       MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);
+       MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);
+       MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);
+
+       MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244,  6);
+       MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);
+       MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);
+       MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);
+       MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3,  6);
+       MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);
+       MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);
+       MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);
+       MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f,  6);
+       MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);
+       MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);
+       MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);
+       MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82,  6);
+       MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);
+       MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);
+       MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);
+
+       buf[0] += a;
+       buf[1] += b;
+       buf[2] += c;
+       buf[3] += d;
+}
+#endif
+
+#ifdef TEST
+/* Simple test program.  Can use it to manually run the tests from
+   RFC1321 for example.  */
+#include <stdio.h>
+
+int
+main (int  argc, char **argv )
+{
+       struct ldap_MD5Context context;
+       unsigned char checksum[16];
+       int i;
+       int j;
+
+       if (argc < 2)
+       {
+               fprintf (stderr, "usage: %s string-to-hash\n", argv[0]);
+               exit (1);
+       }
+       for (j = 1; j < argc; ++j)
+       {
+               printf ("MD5 (\"%s\") = ", argv[j]);
+               ldap_MD5Init (&context);
+               ldap_MD5Update (&context, argv[j], strlen (argv[j]));
+               ldap_MD5Final (checksum, &context);
+               for (i = 0; i < 16; i++)
+               {
+                       printf ("%02x", (unsigned int) checksum[i]);
+               }
+               printf ("\n");
+       }
+       return 0;
+}
+#endif /* TEST */
index d0da848040168f3841b4819f50e409226092f281..0d7f04f881cd82be48dbaaf0c0d0cd70f871ddff 100644 (file)
@@ -2,6 +2,7 @@
 
 #ifndef HAVE_SETPROCTITLE
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <ac/string.h>
 
diff --git a/libraries/liblutil/sha1.c b/libraries/liblutil/sha1.c
new file mode 100644 (file)
index 0000000..d254b3f
--- /dev/null
@@ -0,0 +1,276 @@
+/*     Acquired from:
+ *     $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $       */
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ * 100% Public Domain
+ *
+ * Test Vectors (from FIPS PUB 180-1)
+ * "abc"
+ *   A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+ * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ *   84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+ * A million repetitions of "a"
+ *   34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+ */
+
+
+#include "portable.h"
+#include <ac/string.h>
+
+/* include socket.h to get sys/types.h and/or winsock2.h */
+#include <ac/socket.h>
+
+#if defined(HAVE_SYS_PARAM_H)
+#include <sys/param.h>
+#endif
+
+#include "lutil_sha1.h"
+
+#define SHA1HANDSOFF           /* Copies data before messing with it. */
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/*
+ * blk0() and blk() perform the initial expand.
+ * I got the idea of expanding during the round function from SSLeay
+ */
+#if BYTE_ORDER == LITTLE_ENDIAN
+# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+    |(rol(block->l[i],8)&0x00FF00FF))
+#else
+# define blk0(i) block->l[i]
+#endif
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+    ^block->l[(i+2)&15]^block->l[i&15],1))
+
+/*
+ * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
+ */
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+
+/*
+ * Hash a single 512-bit block. This is the core of the algorithm.
+ */
+void
+ldap_SHA1Transform( uint32 *state, const unsigned char *buffer )
+{
+    uint32 a, b, c, d, e;
+    typedef union {
+       unsigned char c[64];
+       u_int l[16];
+    } CHAR64LONG16;
+    CHAR64LONG16 *block;
+
+#ifdef SHA1HANDSOFF
+    CHAR64LONG16 workspace;
+    block = &workspace;
+    (void)memcpy(block, buffer, 64);
+#else
+    block = (CHAR64LONG16 *)buffer;
+#endif
+
+    /* Copy context->state[] to working vars */
+    a = state[0];
+    b = state[1];
+    c = state[2];
+    d = state[3];
+    e = state[4];
+
+    /* 4 rounds of 20 operations each. Loop unrolled. */
+    R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
+    R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
+    R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
+    R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
+    R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+    R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
+    R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
+    R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
+    R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
+    R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
+    R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
+    R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
+    R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
+    R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
+    R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
+    R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
+    R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
+    R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
+    R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
+    R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+
+    /* Add the working vars back into context.state[] */
+    state[0] += a;
+    state[1] += b;
+    state[2] += c;
+    state[3] += d;
+    state[4] += e;
+
+    /* Wipe variables */
+    a = b = c = d = e = 0;
+}
+
+
+/*
+ * ldap_SHA1Init - Initialize new context
+ */
+void
+ldap_SHA1Init( ldap_SHA1_CTX *context )
+{
+
+    /* SHA1 initialization constants */
+    context->state[0] = 0x67452301;
+    context->state[1] = 0xEFCDAB89;
+    context->state[2] = 0x98BADCFE;
+    context->state[3] = 0x10325476;
+    context->state[4] = 0xC3D2E1F0;
+    context->count[0] = context->count[1] = 0;
+}
+
+
+/*
+ * Run your data through this.
+ */
+void
+ldap_SHA1Update(
+    ldap_SHA1_CTX      *context,
+    const unsigned char        *data,
+    u_int              len
+)
+{
+    u_int i, j;
+
+    j = context->count[0];
+    if ((context->count[0] += len << 3) < j)
+       context->count[1] += (len>>29)+1;
+    j = (j >> 3) & 63;
+    if ((j + len) > 63) {
+       (void)memcpy(&context->buffer[j], data, (i = 64-j));
+       ldap_SHA1Transform(context->state, context->buffer);
+       for ( ; i + 63 < len; i += 64)
+           ldap_SHA1Transform(context->state, &data[i]);
+       j = 0;
+    } else {
+       i = 0;
+    }
+    (void)memcpy(&context->buffer[j], &data[i], len - i);
+}
+
+
+/*
+ * Add padding and return the message digest.
+ */
+void
+ldap_SHA1Final( unsigned char *digest, ldap_SHA1_CTX *context )
+{
+    u_int i;
+    unsigned char finalcount[8];
+
+    for (i = 0; i < 8; i++) {
+       finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
+        >> ((3-(i & 3)) * 8) ) & 255);  /* Endian independent */
+    }
+    ldap_SHA1Update(context, (unsigned char *)"\200", 1);
+    while ((context->count[0] & 504) != 448)
+       ldap_SHA1Update(context, (unsigned char *)"\0", 1);
+    ldap_SHA1Update(context, finalcount, 8);  /* Should cause a SHA1Transform() */
+
+    if (digest) {
+       for (i = 0; i < 20; i++)
+           digest[i] = (unsigned char)
+               ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+    }
+}
+
+
+/* sha1hl.c
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@login.dkuug.dk> wrote this file.  As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: sha1hl.c,v 1.1 1997/07/12 20:06:03 millert Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <ac/errno.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+#ifdef HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif
+
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+
+/* ARGSUSED */
+char *
+ldap_SHA1End( ldap_SHA1_CTX *ctx, char *buf )
+{
+    int i;
+    char *p = buf;
+    unsigned char digest[20];
+    static const char hex[]="0123456789abcdef";
+
+    if (p == NULL && (p = malloc(41)) == NULL)
+       return 0;
+
+    ldap_SHA1Final(digest,ctx);
+    for (i = 0; i < 20; i++) {
+       p[i + i] = hex[digest[i] >> 4];
+       p[i + i + 1] = hex[digest[i] & 0x0f];
+    }
+    p[i + i] = '\0';
+    return(p);
+}
+
+char *
+ldap_SHA1File( char *filename, char *buf )
+{
+    unsigned char buffer[BUFSIZ];
+    ldap_SHA1_CTX ctx;
+    int fd, num, oerrno;
+
+    ldap_SHA1Init(&ctx);
+
+    if ((fd = open(filename,O_RDONLY)) < 0)
+       return(0);
+
+    while ((num = read(fd, buffer, sizeof(buffer))) > 0)
+       ldap_SHA1Update(&ctx, buffer, num);
+
+    oerrno = errno;
+    close(fd);
+    errno = oerrno;
+    return(num < 0 ? 0 : ldap_SHA1End(&ctx, buf));
+}
+
+char *
+ldap_SHA1Data( const unsigned char *data, size_t len, char *buf )
+{
+    ldap_SHA1_CTX ctx;
+
+    ldap_SHA1Init(&ctx);
+    ldap_SHA1Update(&ctx, data, len);
+    return(ldap_SHA1End(&ctx, buf));
+}
diff --git a/libraries/liblutil/strdup.c b/libraries/liblutil/strdup.c
new file mode 100644 (file)
index 0000000..31baa12
--- /dev/null
@@ -0,0 +1,21 @@
+#include "portable.h"
+
+#ifndef HAVE_STRDUP
+
+#include <stdlib.h>
+#include <ac/string.h>
+#include "lutil.h"
+
+char *strdup( const char *s )
+{
+        char    *p;
+
+        if ( (p = (char *) malloc( strlen( s ) + 1 )) == NULL )
+                return( (char *)0 );
+
+        strcpy( p, s );
+
+        return( p );
+}
+
+#endif /* !strdup */
diff --git a/libraries/liblutil/tempnam.c b/libraries/liblutil/tempnam.c
new file mode 100644 (file)
index 0000000..d4aa9cc
--- /dev/null
@@ -0,0 +1,44 @@
+#include "portable.h"
+
+#ifndef HAVE_TEMPNAM
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
+#include "lutil.h"
+
+char *
+tempnam( const char *dir, const char *pfx )
+{
+    char       *s;
+
+    if ( dir == NULL ) {
+       dir = "/tmp";
+    }
+
+/*
+ * allocate space for dir + '/' + pfx (up to 5 chars) + 6 trailing 'X's + 0 byte
+ */
+    if (( s = (char *)malloc( strlen( dir ) + 14 )) == NULL ) {
+       return( NULL );
+    }
+
+    strcpy( s, dir );
+    strcat( s, "/" );
+    if ( pfx != NULL ) {
+       strcat( s, pfx );
+    }
+    strcat( s, "XXXXXX" );
+    mktemp( s );
+
+    if ( *s == '\0' ) {
+       free( s );
+       s = NULL;
+    }
+
+    return( s );
+}
+
+#endif /* TEMPNAM */
index cc76223a734fe5c1227f9a6ffdaa20e078ded799..4b1b6806b1dba1b0086972d355d376fa9d99f8b9 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
+
+#include <ac/socket.h>
+
 #include <quipu/commonarg.h>
 #include <quipu/attrvalue.h>
 #include <quipu/ds_error.h>
 #include <quipu/add.h>
 #include <quipu/dap2.h>
 #include <quipu/dua.h>
-#include <sys/types.h>
-#include <sys/socket.h>
 #include "lber.h"
 #include "ldap.h"
 #include "common.h"
 
-#ifdef COMPAT20
-extern int     ldap_compat;
+#ifdef LDAP_COMPAT20
 #define ADDTAG (ldap_compat == 20 ? OLD_LDAP_RES_ADD : LDAP_RES_ADD)
 #else
 #define ADDTAG LDAP_RES_ADD
@@ -44,7 +46,6 @@ do_add(
        unsigned long                   tag, len;
        struct ds_addentry_arg          aa;
        static CommonArgs               common = default_common_args;
-       extern DN                       ldap_str2dn();
 
        Debug( LDAP_DEBUG_TRACE, "do_add\n", 0, 0, 0 );
 
@@ -87,7 +88,7 @@ do_add(
        aa.ada_entry = NULLATTR;
        for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
            tag = ber_next_element( ber, &len, last ) ) {
-               Attr_Sequence   as, get_as();
+               Attr_Sequence   as;
 
                if ( ber_scanf( ber, "{a{V}}", &type, &bvals ) == LBER_ERROR )
                        break;
index 1af91e2588bb769967c4103c043491986054d4b1..3ca61c9e47a98a1323b83e124841b8abc6e68533 100644 (file)
 
 #include <quipu/commonarg.h>
 #include <quipu/ds_error.h>
-#include "lber.h"
-#include "ldap.h"
-
+#include <quipu/dap.h>                 /* get dap_unbind() */
 #if ISODEPACKAGE == IC
 #include <ll/isoaddrs.h>
 #else
 #include <isoaddrs.h>
 #endif
+
+#include "lber.h"
+#include "ldap.h"
 #include "common.h"
 
 #ifdef HAVE_SYS_IOCTL_H 
 
 struct conn    *conns;
 
-struct conn *conn_dup( struct conn *cn )
+struct conn *
+conn_dup( struct conn *cn )
 {
        struct conn     *new;
-       struct PSAPaddr *psap_cpy();
-
        if ( (new = (struct conn *) malloc( sizeof(struct conn) )) == NULL )
                return( NULL );
 
@@ -70,10 +70,9 @@ struct conn *conn_dup( struct conn *cn )
 }
 
 int
-conn_init()
+conn_init( void )
 {
-       extern char     *dsa_address;
-       struct PSAPaddr *addr, *psap_cpy();
+       struct PSAPaddr *addr;
 
        if ( (conns = (struct conn *) malloc( sizeof(struct conn) )) == NULL ) {
                Debug( LDAP_DEBUG_ANY, "conn_init: malloc failed\n", 0, 0, 0 );
@@ -104,7 +103,6 @@ void
 conn_free( struct conn *conn )
 {
        struct timeval  tv;
-       extern int      referral_connection_timeout;
 
        Debug( LDAP_DEBUG_TRACE, "conn_free (%s): refcnt is %d\n",
            paddr2str( conn->c_paddr, NULLNA ), conn->c_refcnt, 0 );
@@ -173,7 +171,7 @@ conn_setfds( fd_set *fds )
 }
 
 void
-conn_badfds()
+conn_badfds( void )
 {
        struct conn     *tmp;
 
@@ -186,7 +184,8 @@ conn_badfds()
        }
 }
 
-struct conn *conn_getfd( fd_set *fds )
+struct conn *
+conn_getfd( fd_set *fds )
 {
        struct conn     *tmp;
 
@@ -226,7 +225,8 @@ psap_cmp( struct PSAPaddr *a, struct PSAPaddr *b )
        return( bcmp( (char *) a, (char *) b, sizeof(struct PSAPaddr) ) );
 }
 
-struct conn *conn_find( struct conn *c )
+struct conn *
+conn_find( struct conn *c )
 {
        struct conn     *tmp;
 
@@ -263,7 +263,7 @@ struct conn *conn_find( struct conn *c )
 }
 
 void
-conn_close()
+conn_close( void )
 {
        struct conn     *tmp;
 
@@ -277,7 +277,6 @@ int
 isclosed( int ad )
 {
        int             o;
-       extern int      errno;
 
        if ( ioctl( ad, FIOGETOWN, &o ) < 0 )
                return( errno == EBADF ? 1 : 0 );
index 20f97de57621bfa25a91a42d05770d1983faaab7..1d83e1c060798ee25fa47450205f90134b0d87c3 100644 (file)
@@ -28,7 +28,6 @@
 #include "common.h"
 
 #ifdef LDAP_COMPAT20
-extern int     ldap_compat;
 #define BINDTAG        (ldap_compat == 20 ? OLD_LDAP_RES_BIND : LDAP_RES_BIND)
 #else
 #define BINDTAG        LDAP_RES_BIND
@@ -53,9 +52,7 @@ do_bind(
        unsigned long   len;
        char            *dn, *pw;
        char            *matched;
-       struct PSAPaddr *addr, *psap_cpy();
-       extern char     *dsa_address;
-       extern int      version;
+       struct PSAPaddr *addr;
 
        Debug( LDAP_DEBUG_TRACE, "do_bind\n", 0, 0, 0 );
 
@@ -99,7 +96,7 @@ do_bind(
                return( 0 );
        }
 
-       Debug( LDAP_DEBUG_ARGS, "do_bind: version %d dn (%s) method %d\n",
+       Debug( LDAP_DEBUG_ARGS, "do_bind: version %d dn (%s) method %lu\n",
            version, dn, method );
 
        if ( m->m_conn->c_paddr == NULLPA ) {
@@ -147,8 +144,6 @@ do_bind_real(
 #ifdef HAVE_KERBEROS
        u_long                  nonce;
 #endif
-       extern DN               ldap_str2dn();
-
        Debug( LDAP_DEBUG_TRACE, "do_bind_real\n", 0, 0, 0 );
 
        *matched = NULL;
index 01a57d21e29bde4f2083744d410101567568e79d..be12fed1344a16aef6cab2127c52108be5e703b5 100644 (file)
 #include <quipu/ds_search.h>
 #include <quipu/dap2.h>
 #include <quipu/dua.h>
+extern sntx_table *get_syntax_table( short int sntx );
+extern PE asn2pe( char * );
 
 #include "lber.h"
 #include "ldap.h"
 #include "common.h"
 
-int ldap_certif_print( PS ps, struct certificate *parm, int format )
+int
+ldap_certif_print( PS ps, struct certificate *parm, int format )
 {
        Debug( LDAP_DEBUG_TRACE, "ldap_certif_print()\n", 0, 0, 0 );
 
@@ -114,7 +117,8 @@ ldap_print_algid( PS ps, struct alg_id *parm, int format )
    }
 }
 
-struct certificate *ldap_str2cert( char *str )
+struct certificate *
+ldap_str2cert( char *str )
 {
 struct certificate *result;
 char *ptr;
@@ -280,8 +284,6 @@ OID oid;
 void
 ldap_str2alg( char *str, struct alg_id *alg )
 {
-PE asn2pe();
-
   if ((str == NULLCP) || (*str == '\0'))
    {
      alg->asn = NULLPE;
@@ -305,11 +307,10 @@ PE asn2pe();
     }
 }
 
-void certif_init()
+void
+certif_init( void )
 {
-       extern short    ldap_certif_syntax;
        sntx_table      *syntax_table;
-       extern sntx_table *get_syntax_table( short int sntx );
 
        if ((syntax_table = get_syntax_table(ldap_certif_syntax)) != NULL) {
                syntax_table->s_print = (void *) ldap_certif_print;
index 9239a72f7d06d57a3fa5c4ce9c98b0a33653c659..032667a9592b0521dedb5e98c0caf62a0fcb75fc 100644 (file)
@@ -10,6 +10,9 @@
  * is provided ``as is'' without express or implied warranty.
  */
 
+#ifndef _LDAPD_COMMON_H
+#define _LDAPD_COMMON_H 1
+
 /*
  * This structure represents an association to a dsa.  There is one of
  * these for each association open (a new association is made for each
@@ -41,32 +44,77 @@ struct msg {
        LDAPMod         *m_mods;        /* for modify operations only */
        BerElement      *m_ber;         /* the unparsed ber for the op */
        struct conn     *m_conn;        /* connection structure */
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
        int             m_cldap;        /* connectionless transport? (CLDAP) */
        struct sockaddr m_clientaddr;   /* client address (if using CLDAP) */
        DN              m_searchbase;   /* base used in search */
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
        struct msg      *m_next;
 };
 
 #define DEFAULT_TIMEOUT                        3600    /* idle client connections */
 #define DEFAULT_REFERRAL_TIMEOUT       900     /* DSA connections */
 
-#ifdef NEEDPROTOS
 #include "proto-ldapd.h"
-#else
-extern struct msg *add_msg();
-extern struct msg *get_msg();
-extern struct msg *get_cldap_msg();
-extern int       del_msg();
 
-extern struct conn *conn_getfd();
-extern struct conn *conn_find();
-extern struct conn *conn_dup();
-extern void conn_del();
+/* from ISODE */
+extern char    *dsa_address;
+extern char    *bound_dn, *bound_pw;
+struct PSAPaddr        *psap_cpy(struct PSAPaddr *);
+
+/* in association.c */
+extern struct conn     *conns;
+
+/* in main.c */
+#ifdef LDAP_DEBUG
+extern int     ldap_debug;
+#endif
+extern int     version;
+#ifdef LDAP_COMPAT
+extern int     ldap_compat;
+#endif
+extern int     dosyslog;
+extern int     do_tcp;
+#ifdef LDAP_CONNECTIONLESS
+extern int     do_udp;
+#endif
+extern int     idletime;
+extern int     referral_connection_timeout;
+extern struct timeval  conn_start_tv;
+#ifdef HAVE_KERBEROS
+extern char    *krb_ldap_service;
+extern char    *krb_x500_service;
+extern char    *krb_x500_instance;
+extern char    *krb_x500_nonce;
+extern char    *kerberos_keyfile;
+#endif
+
+/* syntax.c */
+extern short   ldap_photo_syntax;
+extern short   ldap_jpeg_syntax;
+extern short   ldap_jpeg_nonfile_syntax;
+extern short   ldap_audio_syntax;
+extern short   ldap_dn_syntax;
+extern short   ldap_postaladdress_syntax;
+extern short   ldap_acl_syntax;
+extern short   ldap_mtai_syntax;
+extern short   ldap_rts_cred_syntax;
+extern short   ldap_rtl_syntax;
+extern short   ldap_mailbox_syntax;
+extern short   ldap_caseignorelist_syntax;
+extern short   ldap_caseexactstring_syntax;
+extern short   ldap_certif_syntax;
+extern short   ldap_iattr_syntax;
+extern short   ldap_telex_syntax;
+extern short   ldap_octetstring_syntax;
+extern short   ldap_deliverymethod_syntax;
+extern short   ldap_facsimileTelephoneNumber_syntax;
+extern short   ldap_presentationAddress_syntax;
+extern short   ldap_teletexTerminalIdentifier_syntax;
+extern short   ldap_searchGuide_syntax;
+extern short   ldap_dLSubmitPermission_syntax;
+
+/* Version.c */
+extern char    Versionstr[];
 
-extern AttributeValue ldap_str2AttrV();
-extern DN ldap_str2dn();
-extern void ldap_str2alg();
-extern void ldap_print_algid();
-#endif /* don't need protos */
+#endif
index 88ac1604f7e4fd2205d1a81b850eed4a7801a39d..b0b8d339b8b3776933ba34cbd494f9210f1e3fe3 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
+
+#include <ac/socket.h>
+
 #include <quipu/commonarg.h>
 #include <quipu/attrvalue.h>
 #include <quipu/ds_error.h>
 #include <quipu/compare.h>
 #include <quipu/dap2.h>
 #include <quipu/dua.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
 #include "lber.h"
 #include "ldap.h"
 #include "common.h"
 
-#ifdef COMPAT20
-extern int     ldap_compat;
+#ifdef HAVE_COMPAT20
 #define COMPTAG        (ldap_compat == 20 ? OLD_LDAP_RES_COMPARE : LDAP_RES_COMPARE)
 #else
 #define COMPTAG        LDAP_RES_COMPARE
@@ -42,7 +45,6 @@ do_compare(
        struct ds_compare_arg   ca;
        AttributeType           type;
        static CommonArgs       common = default_common_args;
-       extern short            ldap_dn_syntax;
 
        Debug( LDAP_DEBUG_TRACE, "do_compare\n", 0, 0, 0 );
 
index 7c7b6ebfe86cb7ef75d62cf050490401cca49ed6..fbc6ac0737569945e1506e880eda518c5e526b8a 100644 (file)
@@ -30,7 +30,6 @@
 #include "common.h"
 
 #ifdef HAVE_COMPAT20
-extern int     ldap_compat;
 #define DELTAG (ldap_compat == 20 ? OLD_LDAP_RES_DELETE : LDAP_RES_DELETE)
 #else
 #define DELTAG LDAP_RES_DELETE
@@ -54,7 +53,6 @@ do_delete(
        int                             rc;
        struct ds_removeentry_arg       ra;
        static CommonArgs               common = default_common_args;
-       extern DN                       ldap_str2dn();
 
        Debug( LDAP_DEBUG_TRACE, "do_delete\n", 0, 0, 0 );
 
diff --git a/servers/ldapd/detach.c b/servers/ldapd/detach.c
deleted file mode 100644 (file)
index ff435ee..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 1990, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#ifdef SVR4
-#include <sys/stat.h>
-#endif /* svr4 */
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <signal.h>
-#include "portable.h"
-
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
-
-
-detach()
-{
-       int             i, sd, nbits;
-#ifdef LDAP_DEBUG
-       extern int      ldap_debug;
-#endif
-
-#ifdef USE_SYSCONF
-       nbits = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
-       nbits = getdtablesize();
-#endif /* USE_SYSCONF */
-
-#ifdef LDAP_DEBUG
-       if ( ldap_debug == 0 ) {
-#endif
-               for ( i = 0; i < 5; i++ ) {
-                       switch ( fork() ) {
-                       case -1:
-                               sleep( 5 );
-                               continue;
-
-                       case 0:
-                               break;
-
-                       default:
-                               _exit( 0 );
-                       }
-                       break;
-               }
-
-               for ( i = 3; i < nbits; i++ )
-                       close( i );
-
-               (void) chdir( "/" );
-
-               if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
-                       perror( "/dev/null" );
-                       exit( 1 );
-               }
-               if ( isatty( 0 ) )
-                       (void) dup2( sd, 0 );
-               if ( isatty( 1 ) )
-                       (void) dup2( sd, 1 );
-               if ( isatty(2) )
-                       (void) dup2( sd, 2 );
-               close( sd );
-
-#ifdef USE_SETSID
-               setsid();
-#else /* USE_SETSID */
-               if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
-                       (void) ioctl( sd, TIOCNOTTY, NULL );
-                       (void) close( sd );
-               }
-#endif /* USE_SETSID */
-#ifdef LDAP_DEBUG
-       } 
-#endif
-
-       (void) signal( SIGPIPE, SIG_IGN );
-}
index e35448c3f17387e39497391fd6a3a9d2c8397504..db4ace3be09f09da1da611647f37b9332e616a3d 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+
 #include <quipu/ds_error.h>
 #include <quipu/attrvalue.h>
 #include <quipu/name.h>
 #include <quipu/commonarg.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <ctype.h>
+
 #include "lber.h"
 #include "ldap.h"
 
+#include "common.h"                    /* get ldap_dn_print() */
+
 void
 print_error( struct DSError *e )
 {
index 937236e29a7f86d12a3b7c3bc9113dc2c3abf8c9..e0de204479885eaed4da9672b31cdc225fa32b09 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
-#ifdef KERBEROS
+#include "portable.h"
+
+#ifdef HAVE_KERBEROS
 
 #include <stdio.h>
-#include <sys/types.h>
-#include "krb.h"
-#include <sys/socket.h>
-#include <netdb.h>
-#include <netinet/in.h>
+
+#include <ac/krb.h>
+#include <ac/socket.h>
+
 #include <quipu/bind.h>
 #if ISODEPACKAGE == IC
 #include <quipu/DAS-types.h>
 #else
 #include <pepsy/DAS-types.h>
 #endif
+
 #include "lber.h"
 #include "ldap.h"
 #include "common.h"
@@ -36,8 +38,6 @@ kerberosv4_ldap_auth( char *cred, long        len )
        char            instance[INST_SZ];
        int             err;
        AUTH_DAT        ad;
-       extern char     *krb_ldap_service;
-       extern char     *kerberos_keyfile;
 
        Debug( LDAP_DEBUG_TRACE, "kerberosv4_ldap_auth\n", 0, 0, 0 );
 
@@ -70,8 +70,6 @@ kerberosv4_bindarg(
        struct timeval                  tv;
        char                            realm[REALM_SZ];
        int                             err;
-       extern char                     *krb_x500_service;
-       extern char                     *krb_x500_instance;
 
        Debug( LDAP_DEBUG_TRACE, "kerberosv4_bindarg\n", 0, 0, 0 );
 
index f16a72b4773eac5c00f9c4eb55a649bf4671feae..a36d16ee68fc630263d71ab1e9f8f103c534b04f 100644 (file)
@@ -48,12 +48,11 @@ int allow_severity = LOG_INFO;
 int deny_severity = LOG_NOTICE;
 #endif /* TCP_WRAPPERS */
 
-void log_and_exit();
-static int     set_socket();
-static void    do_queries();
-static RETSIGTYPE wait4child();
+static int     set_socket( int port, int udp );
+static void    do_queries( int clientsock, int udp );
+static RETSIGTYPE wait4child( int sig );
 #ifdef LDAP_CONNECTIONLESS
-static int     udp_init();
+static int     udp_init( int port, int createsocket );
 #endif
 
 #ifdef LDAP_DEBUG
@@ -82,8 +81,6 @@ char  *kerberos_keyfile;
 int    dtblsize;
 int    RunFromInetd = 0;
 
-extern char Versionstr[];
-
 static void
 usage( char *name )
 {
@@ -101,9 +98,7 @@ usage( char *name )
 }
 
 int
-main (argc, argv)
-int    argc;
-char   **argv;
+main( int argc, char **argv )
 {
        int                     tcps, ns;
 #ifdef LDAP_CONNECTIONLESS
@@ -118,12 +113,9 @@ char       **argv;
        int                     len;
        int                     dsapargc;
        char                    **dsapargv;
-       RETSIGTYPE                      wait4child();
 #ifdef LDAP_PROCTITLE
        char                    title[80];
 #endif
-       extern char             *optarg;
-       extern int              optind;
 
 #ifdef VMS
        /* Pick up socket from inetd-type server on VMS */
@@ -274,8 +266,8 @@ char        **argv;
                lutil_detach( 0, 1 );
 #  endif
 #endif
-               (void) SIGNAL( SIGCHLD, (void *) wait4child );
-               (void) SIGNAL( SIGINT, (void *) log_and_exit );
+               (void) SIGNAL( SIGCHLD, wait4child );
+               (void) SIGNAL( SIGINT, log_and_exit );
        }
 
        /* 
@@ -449,7 +441,7 @@ char        **argv;
                    hp->h_name );
 #endif
                gettimeofday( &conn_start_tv, (struct timezone *) NULL );
-               (void) SIGNAL( SIGPIPE, (void *) log_and_exit );
+               (void) SIGNAL( SIGPIPE, log_and_exit );
 
                do_queries( ns, 0 );
                /* NOT REACHED */
@@ -465,7 +457,7 @@ char        **argv;
                        setproctitle( title );
 #endif
                        gettimeofday( &conn_start_tv, (struct timezone *) NULL );
-                       (void) SIGNAL( SIGPIPE, (void *) log_and_exit );
+                       (void) SIGNAL( SIGPIPE, log_and_exit );
 
                        do_queries( ns, 0 );
                        break;
@@ -538,7 +530,6 @@ do_queries(
        timeout.tv_usec = 0;
        for ( ;; ) {
                struct conn             *dsaconn;
-               extern struct conn      *conns;
 
                FD_ZERO( &readfds );
                FD_SET( clientsock, &readfds );
@@ -651,7 +642,8 @@ set_socket(
        return( s );
 }
 
-static RETSIGTYPE wait4child()
+static RETSIGTYPE
+wait4child( int sig )
 {
 #ifndef HAVE_WAITPID
        WAITSTATUSTYPE     status;
@@ -667,11 +659,11 @@ static RETSIGTYPE wait4child()
                ;       /* NULL */
 #endif
 
-       (void) SIGNAL( SIGCHLD, (void *) wait4child );
+       (void) SIGNAL( SIGCHLD, wait4child );
 }
 
 
-void
+RETSIGTYPE
 log_and_exit( int exitcode )
 {
        struct timeval  tv;
@@ -699,9 +691,6 @@ udp_init(
 {
        int     s, bound;
        char    *matched;
-       extern char             *dsa_address;
-       extern struct PSAPaddr  *psap_cpy();
-       extern struct conn      *conns;
 
        if ( createsocket )
                s = set_socket( port, 1 );
index dd4538c034a0af8f3bd1631dfcdba37e601b2fb7..11a22a1028b227bb4933cd57ff8c3a733a534bea 100644 (file)
@@ -24,6 +24,7 @@
 #include <quipu/modify.h>
 #include <quipu/dap2.h>
 #include <quipu/dua.h>
+extern IFP     merge_acl;
 
 #include "lber.h"
 #include "ldap.h"
 
 static CommonArgs      common = default_common_args;
 
-extern short   ldap_photo_syntax;
-extern short   ldap_jpeg_syntax;
-extern short   ldap_jpeg_nonfile_syntax;
-extern short   ldap_audio_syntax;
-extern short   ldap_dn_syntax;
-extern short   ldap_postaladdress_syntax;
-extern short   ldap_acl_syntax;
-extern short   ldap_mtai_syntax;
-extern short   ldap_rts_cred_syntax;
-extern short   ldap_rtl_syntax;
-extern short   ldap_octetstring_syntax;
-
 static int replace_mod( struct entrymod *, Attr_Sequence, Attr_Sequence );
 
 #ifdef LDAP_COMPAT20
-extern int     ldap_compat;
 #define MODTAG (ldap_compat == 20 ? OLD_LDAP_RES_MODIFY : LDAP_RES_MODIFY)
 #else
 #define MODTAG LDAP_RES_MODIFY
@@ -65,7 +53,6 @@ do_modify(
        unsigned long           tag, len;
        LDAPMod                 *mods, *modtail;
        struct ds_read_arg      ra;
-       extern DN               ldap_str2dn();
 
        Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
 
@@ -183,7 +170,7 @@ do_modify2(
        ma.mea_changes = NULLMOD;
        for ( mods = m->m_mods; mods != NULL; mods = mods->mod_next ) {
                struct entrymod *em;
-               Attr_Sequence   as, new, get_as();
+               Attr_Sequence   as, new;
 
                if ( (em = (struct entrymod *) calloc( 1,
                    sizeof(struct entrymod) )) == NULLMOD ) {
@@ -401,9 +388,6 @@ get_as(
                AttributeValue  av;
                int             t61str, ncomp;
                char            *sval, *s, *news, *n;
-               extern IFP      merge_acl;
-               extern AttributeValue   bv_asn2AttrV(), ldap_strdn2AttrV();
-               extern AttributeValue   ldap_str_at2AttrV(), bv_octet2AttrV();
 
                if ( syntax == ldap_jpeg_syntax ||
                    syntax == ldap_jpeg_nonfile_syntax ||
index d3d939eeb53f4d33215c7279fc840e0d375a3501..1dfa005b7aee666d8bc8db72bf5926597b5c86b2 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
+
+#include <ac/socket.h>
+
 #include <quipu/commonarg.h>
 #include <quipu/attrvalue.h>
 #include <quipu/ds_error.h>
 #include <quipu/modifyrdn.h>
 #include <quipu/dap2.h>
 #include <quipu/dua.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
 #include "lber.h"
 #include "ldap.h"
 #include "common.h"
 
-#ifdef COMPAT20
-extern int     ldap_compat;
+#ifdef LDAP_COMPAT20
 #define MODRDNTAG      (ldap_compat == 20 ? OLD_LDAP_RES_MODRDN : LDAP_RES_MODRDN)
 #else
 #define MODRDNTAG      LDAP_RES_MODRDN
@@ -41,8 +44,6 @@ do_modrdn(
        int                     rc, deleteoldrdn;
        struct ds_modifyrdn_arg ma;
        static CommonArgs       common = default_common_args;
-       extern DN               ldap_str2dn();
-       extern RDN              ldap_str2rdn();
 
        Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
 
index 9556c84e3d52d35c99cda4bbad5def7e39e897b9..57ac6016960983b498a8ed8ce16f7e760b1da804 100644 (file)
-#ifndef _PROTO_LDAPD
-#define _PROTO_LDAPD
+#ifndef _PROTO_LDAPD_H
+#define _PROTO_LDAPD_H
+
+#include <ldap_cdefs.h>
 
 /*
  * abandon.c
  */
 
-int do_abandon( struct conn *dsaconn, BerElement *ber, int msgid );
+int do_abandon LDAP_P(( struct conn *dsaconn, BerElement *ber, int msgid ));
 
 /*
  * add.c
  */
 
-int do_add( Sockbuf *clientsb, struct msg *m, BerElement *ber );
+int do_add LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
+void add_result LDAP_P(( Sockbuf *sb, struct msg *m ));
 
 /*
  * association.c
  */
 
-struct conn *conn_dup( struct conn *cn );
-int conn_init();
-void conn_free( struct conn *conn );
-void conn_del( struct conn *conn );
-void conn_badfds();
-struct conn *conn_getfd( fd_set *fds );
-void conn_add( struct conn *new );
-struct conn *conn_find( struct conn *c );
-void conn_add( struct conn *new );
-void conn_close();
-int isclosed( int ad );
+struct conn *conn_dup LDAP_P(( struct conn *cn ));
+int conn_init LDAP_P(( void ));
+void conn_free LDAP_P(( struct conn *conn ));
+void conn_del LDAP_P(( struct conn *conn ));
+void conn_setfds LDAP_P(( fd_set *fds ));
+void conn_badfds LDAP_P(( void ));
+struct conn *conn_getfd LDAP_P(( fd_set *fds ));
+void conn_add LDAP_P(( struct conn *new ));
+struct conn *conn_find LDAP_P(( struct conn *c ));
+void conn_close LDAP_P(( void ));
+int isclosed LDAP_P(( int ad ));
 
 /*
  * bind.c
  */
 
-int do_bind( Sockbuf *clientsb, struct msg *m, BerElement *ber, int *bound );
-int do_bind_real( struct conn *dsaconn, int *bound, char **matched );
+int do_bind LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber, int *bound ));
+int do_bind_real LDAP_P(( struct conn *dsaconn, int *bound, char **matched ));
 
 /*
  * certificate.c
  */
 
-int ldap_certif_print( PS ps, struct certificate *parm, int format );
-void ldap_print_algid( PS ps, struct alg_id *parm, int format );
-struct certificate *ldap_str2cert( char *str );
-void ldap_str2alg( char *str, struct alg_id *alg );
-void certif_init();
+int ldap_certif_print LDAP_P(( PS ps, struct certificate *parm, int format ));
+void ldap_print_algid LDAP_P(( PS ps, struct alg_id *parm, int format ));
+struct certificate *ldap_str2cert LDAP_P(( char *str ));
+void ldap_str2alg LDAP_P(( char *str, struct alg_id *alg ));
+void certif_init LDAP_P(( void ));
 
 /*
  * compare.c
  */
 
-int do_compare( Sockbuf *clientsb, struct msg *m, BerElement *ber );
+struct ds_compare_result;
+int do_compare LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
+void compare_result LDAP_P(( Sockbuf *sb, struct msg *m,
+                            struct ds_compare_result *cr ));
 
 /*
  * delete.c
  */
 
-int do_delete( Sockbuf *clientsb, struct msg *m, BerElement *ber );
+int do_delete LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
+void delete_result LDAP_P(( Sockbuf *sb, struct msg *m ));
 
 /*
  * error.c
  */
 
-void print_error( struct DSError *e );
-int x500err2ldaperr( struct DSError *e, char **matched );
+void print_error LDAP_P(( struct DSError *e ));
+int x500err2ldaperr LDAP_P(( struct DSError *e, char **matched ));
 
 /*
  * kerberos.c
  */
 
-int kerberosv4_ldap_auth( char *cred, long len );
+struct ds_bind_arg;
+int kerberosv4_ldap_auth LDAP_P(( char *cred, long len ));
+int kerberosv4_bindarg   LDAP_P(( struct ds_bind_arg *ba, DN dn, char *cred,
+                                 long len, u_long *nonce ));
+int kerberos_check_mutual LDAP_P(( struct ds_bind_arg *res, u_long nonce ));
 
 /*
  * main.c
  */
 
-void log_and_exit( int exitcode );
+RETSIGTYPE log_and_exit LDAP_P(( int exitcode ));
 
 /*
  * message.c
  */
 
-struct msg *add_msg( int msgid, int msgtype, BerElement *ber,
-       struct conn *dsaconn, int udp, struct sockaddr *clientaddr );
-struct msg *get_msg( int uniqid );
-int del_msg( struct msg *m );
-void send_msg( struct conn *conn, Sockbuf *clientsb, int err, char *str );
-struct msg * get_cldap_msg( int msgid, int msgtype, struct sockaddr *fromaddr );
+struct msg *add_msg LDAP_P(( int msgid, int msgtype, BerElement *ber,
+       struct conn *dsaconn, int udp, struct sockaddr *clientaddr ));
+struct msg *get_msg LDAP_P(( int uniqid ));
+int del_msg LDAP_P(( struct msg *m ));
+void send_msg LDAP_P(( struct conn *conn, Sockbuf *clientsb, int err, char *str ));
+struct msg * get_cldap_msg LDAP_P(( int msgid, int msgtype, struct sockaddr *fromaddr ));
 
 /*
  * modify.c
  */
 
-int do_modify( Sockbuf *clientsb, struct msg *m, BerElement *ber );
-Attr_Sequence get_as( Sockbuf *clientsb, unsigned long op, struct msg *m,
-       char *type, struct berval **bvals );
-void modlist_free( LDAPMod *mods );
+struct ds_read_result;
+int do_modify LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
+int do_modify2 LDAP_P((Sockbuf *sb, struct msg *m, struct ds_read_result *rr));
+Attr_Sequence get_as LDAP_P(( Sockbuf *clientsb, unsigned long op, struct msg *m,
+                             char *type, struct berval **bvals ));
+void modify_result LDAP_P(( Sockbuf *sb, struct msg *m ));
+void modlist_free LDAP_P(( LDAPMod *mods ));
 
 /*
  * modrdn.c
  */
 
-int do_modrdn( Sockbuf *clientsb, struct msg *m, BerElement *ber );
+int do_modrdn LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
+void modrdn_result  LDAP_P((Sockbuf *sb, struct msg *m));
 
 /*
  * request.c
  */
 
-void client_request( Sockbuf *clientsb, struct conn *dsaconn, int  udp );
-int do_request( Sockbuf *clientsb, struct msg *m, BerElement *ber,
-       int *bound );
-int initiate_dap_operation( int op, struct msg *m, void *arg );
+void client_request LDAP_P(( Sockbuf *clientsb, struct conn *dsaconn, int  udp ));
+int do_request LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber,
+       int *bound ));
+int initiate_dap_operation LDAP_P(( int op, struct msg *m, void *arg ));
+#ifdef LDAP_DEBUG
+int trace_ber LDAP_P(( int tag, int len, char *ber,
+                      FILE *trace_file, int prepend, int read_pdu ));
+#endif
 
 /*
  * result.c
  */
 
-void dsa_response( struct conn *dsaconn, Sockbuf *clientsb );
-int send_ldap_msgresult( Sockbuf *sb, unsigned long tag, struct msg *m,
-       int err, char *matched, char *text );
-int send_ldap_result( Sockbuf *sb, unsigned long tag, int msgid, int err,
-       char *matched, char *text );
+void dsa_response LDAP_P(( struct conn *dsaconn, Sockbuf *clientsb ));
+int send_ldap_msgresult LDAP_P(( Sockbuf *sb, unsigned long tag, struct msg *m,
+       int err, char *matched, char *text ));
+int send_ldap_result LDAP_P(( Sockbuf *sb, unsigned long tag, int msgid, int err,
+       char *matched, char *text ));
 
 /*
  * search.c
  */
 
-int do_search( Sockbuf *clientsb, struct msg *m, BerElement *ber );
+struct ds_search_result;
+int do_search LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
+void search_result LDAP_P(( Sockbuf *sb, struct msg *m,
+                           struct ds_search_result *sr ));
+
 
 /*
  * syntax.c
  */
 
-void get_syntaxes();
-int dn_print_real( PS ps, DN dn, int format);
-void ldap_dn_print( PS ps, DN dn, DN base, int format);
-int encode_dn( BerElement *ber, DN dn, DN base);
-int encode_attrs( BerElement *ber, Attr_Sequence as );
-AttributeValue bv_octet2AttrV( struct berval *bv );
-AttributeValue bv_asn2AttrV( struct berval *bv );
-AttributeValue ldap_strdn2AttrV( char *dnstr );
-DN ldap_str2dn( char *str );
-RDN ldap_str2rdn( char *rdnstr );
-AttributeValue ldap_str_at2AttrV( char *str, AttributeType type );
-AttributeValue ldap_str2AttrV( char *value, short syntax );
+void get_syntaxes LDAP_P(( void ));
+int dn_print_real LDAP_P(( PS ps, DN dn, int format));
+void ldap_dn_print LDAP_P(( PS ps, DN dn, DN base, int format));
+int encode_dn LDAP_P(( BerElement *ber, DN dn, DN base));
+int encode_attrs LDAP_P(( BerElement *ber, Attr_Sequence as ));
+AttributeValue bv_octet2AttrV LDAP_P(( struct berval *bv ));
+AttributeValue bv_asn2AttrV LDAP_P(( struct berval *bv ));
+AttributeValue ldap_strdn2AttrV LDAP_P(( char *dnstr ));
+DN ldap_str2dn LDAP_P(( char *str ));
+RDN ldap_str2rdn LDAP_P(( char *rdnstr ));
+AttributeValue ldap_str_at2AttrV LDAP_P(( char *str, AttributeType type ));
+AttributeValue ldap_str2AttrV LDAP_P(( char *value, short syntax ));
 
 /*
  * util.c
  */
 
-void bprint( char *data, int len );
-void charlist_free( char **cl );
-int get_ava( BerElement *ber, AVA *tava );
-int chase_referral( Sockbuf *clientsb, struct msg *m, struct DSError *err,
-       char **matched );
+void bprint LDAP_P(( char *data, int len ));
+void charlist_free LDAP_P(( char **cl ));
+int get_ava LDAP_P(( BerElement *ber, AVA *tava ));
+int chase_referral LDAP_P(( Sockbuf *clientsb, struct msg *m, struct DSError *err,
+       char **matched ));
 
 #endif /* _proto_ldapd */
index ab1358a992b45abb81b86905192c8bfce3b9d9e9..e9ab02bbb2b960441190f347b4b6fe0ac52244ee 100644 (file)
@@ -30,8 +30,6 @@
 #include "ldap.h"
 #include "common.h"
 
-extern int     dosyslog;
-
 #ifdef PEPSY_DUMP
 #ifndef DEBUG
 #define DEBUG
@@ -69,11 +67,6 @@ client_request(
        BerElement      ber, *copyofber;
        struct msg      *m;
        static int      bound;
-       extern char     *bound_dn, *bound_pw;
-       struct PSAPaddr *psap_cpy();
-#ifdef LDAP_COMPAT
-       extern int      ldap_compat;
-#endif
 
        Debug( LDAP_DEBUG_TRACE, "client_request%s\n",
            udp ? " udp" : "", 0, 0 );
@@ -202,7 +195,7 @@ client_request(
                 * duplicate request: toss this one
                 */
                Debug( LDAP_DEBUG_TRACE,
-                   "client_request tossing dup request id %d from %s\n",
+                   "client_request tossing dup request id %ld from %s\n",
                    msgid, inet_ntoa( ((struct sockaddr_in *)
                    clientsb->sb_fromaddr)->sin_addr ), 0 );
                free( ber.ber_buf );
index 3f77032342c0a02d1762be5d6e5685593336e1f5..e0cddc640c1819907d6056fb95f9d39b98fa6bee 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/syslog.h>
+
 #include <quipu/dsap.h>
 #include <quipu/dap2.h>
 #include <quipu/dua.h>
-#ifdef __hpux
-#include <syslog.h>
-#else
-#include <sys/syslog.h>
-#endif
+
 #include "lber.h"
 #include "ldap.h"
 #include "common.h"
 
-extern int     dosyslog;
-#ifdef COMPAT
-extern int     ldap_compat;
-#endif
-
 /*
  * dsa_response - called by do_queries() when there is activity on one of
  * the DSA associations.  It is passed the association descriptor on which
@@ -131,7 +125,7 @@ dsa_response(
                        return;
                }
                if ( m->m_msgtype == LDAP_REQ_SEARCH 
-#ifdef COMPAT20
+#ifdef LDAP_COMPAT20
                    || m->m_msgtype == OLD_LDAP_REQ_SEARCH
 #endif
                    )
@@ -154,7 +148,7 @@ dsa_response(
                        int     bound, rc;
 
                        switch ( m->m_msgtype ) {
-#ifdef COMPAT20
+#ifdef LDAP_COMPAT20
                        case OLD_LDAP_REQ_ADD:
                        case OLD_LDAP_REQ_MODIFY:
                        case OLD_LDAP_REQ_MODRDN:
@@ -162,7 +156,7 @@ dsa_response(
                        case OLD_LDAP_REQ_COMPARE:
                        case OLD_LDAP_REQ_SEARCH:
 #endif
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
                        case LDAP_REQ_DELETE_30:
 #endif
                        case LDAP_REQ_ADD:
@@ -283,7 +277,7 @@ send_ldap_msgresult(
     char               *text
 )
 {
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
        if ( m->m_cldap ) {
                SAFEMEMCPY( (char *)sb->sb_useaddr, &m->m_clientaddr,
                    sizeof( struct sockaddr ));
@@ -308,19 +302,15 @@ send_ldap_result(
 {
        BerElement      *ber;
        int             rc;
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
        int             cldap;
-#endif
-       extern int      version;
-
-#ifdef CLDAP
        cldap = ( sb->sb_naddr > 0 );
 #endif
 
        Debug( LDAP_DEBUG_TRACE, "send_ldap_result\n", 0, 0, 0 );
 
        if ( tag == LBER_DEFAULT )
-#ifdef COMPAT20
+#ifdef LDAP_COMPAT20
                tag = ldap_compat == 20 ? OLD_LBER_SEQUENCE : LBER_SEQUENCE;
 #else
                tag = LBER_SEQUENCE;
@@ -332,20 +322,20 @@ send_ldap_result(
        }
 
        if ( version != 1 ) {
-#ifdef COMPAT20
+#ifdef LDAP_COMPAT20
                if ( ldap_compat == 20 ) {
                        rc = ber_printf( ber, "t{it{tess}}", OLD_LBER_SEQUENCE,
                            msgid, tag, LBER_INTEGER, err,
                            matched ? matched : "", text );
                } else
 #endif
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
                if ( ldap_compat == 30 ) {
                        rc = ber_printf( ber, "{it{{ess}}}", msgid, tag, err,
                            matched ? matched : "", text );
                } else
 #endif
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
                if ( cldap ) {
                        rc = ber_printf( ber, "{is{t{ess}}}", msgid, "", tag,
                            err, matched ? matched : "", text );
index 3e76c35d4afc6e7e61c3f213e227a255a4935719..784087cab2d49001a7acdf1f393659d125c29ce4 100644 (file)
 #include "ldap.h"
 #include "common.h"
 
-static int     get_filter();
-static int     get_filter_list();
-static int     get_substring_filter();
+static int     get_filter( BerElement *ber, Filter *filt );
+static int     get_filter_list( BerElement *ber, Filter f );
+static int     get_substring_filter( BerElement *ber, Filter f );
 
 #ifdef LDAP_COMPAT
-extern int     version;
-extern int     ldap_compat;
 #define SEARCHRESTAG   (ldap_compat == 20 ? OLD_LDAP_RES_SEARCH_RESULT : LDAP_RES_SEARCH_RESULT)
 #else
 #define SEARCHRESTAG   LDAP_RES_SEARCH_RESULT
@@ -54,7 +52,6 @@ do_search(
        char                    **attrs;
        struct ds_search_arg    sa;
        static CommonArgs       common = default_common_args;
-       extern DN               ldap_str2dn();
 
        Debug( LDAP_DEBUG_TRACE, "do_search\n", 0, 0, 0 );
 
@@ -425,7 +422,6 @@ get_substring_filter( BerElement *ber, Filter f )
        AttributeType   type;
        char            *valstr, *last;
        AttributeValue  value;
-       extern short    ldap_dn_syntax;
 
        Debug( LDAP_DEBUG_TRACE, "get_substring_filter\n", 0, 0, 0 );
 
diff --git a/servers/ldapd/setproctitle.c b/servers/ldapd/setproctitle.c
deleted file mode 100644 (file)
index e1022ee..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef NOSETPROCTITLE
-/*
- * Copyright (c) 1990,1991 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-char   **Argv;         /* pointer to original (main's) argv */
-int    Argc;           /* original argc */
-
-/*
- * takes a printf-style format string (fmt) and up to three parameters (a,b,c)
- * this clobbers the original argv...
- */
-
-/* VARARGS */
-setproctitle( fmt, a, b, c )
-char *fmt;
-{
-       static char *endargv = (char *)0;
-       char    *s;
-       int             i;
-       char    buf[ 1024 ];
-
-       if ( endargv == (char *)0 ) {
-               /* set pointer to end of original argv */
-               endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] );
-       }
-       sprintf( buf, fmt, a, b, c );
-       /* make ps print "([prog name])" */
-       s = Argv[0];
-       *s++ = '-';
-       i = strlen( buf );
-       if ( i > endargv - s - 2 ) {
-               i = endargv - s - 2;
-               buf[ i ] = '\0';
-       }
-       strcpy( s, buf );
-       s += i;
-       while ( s < endargv ) *s++ = ' ';
-}
-#endif /* NOSETPROCTITLE */
index 9470b36934dd9e5e916664661d51632f13ee6946..9b9ee0febce8025b0c51c77190597cfcacb22fda 100644 (file)
@@ -24,6 +24,8 @@
 #include <quipu/ds_search.h>
 #include <quipu/dap2.h>
 #include <quipu/dua.h>
+extern oid_table_attr *name2attr( char * );
+/*extern AttributeValue str_at2AttrV( char *, IF_AttributeType * );*/
 
 #include "lber.h"
 #include "ldap.h"
@@ -59,7 +61,7 @@ static int    syntax_is_string( short syntax );
 static int
 get_one_syntax( char *attrib, int required )
 {
-       oid_table_attr  *p, *name2attr();
+       oid_table_attr  *p;
 
        if ( (p = name2attr( attrib )) != (oid_table_attr *) 0 )
            return( p->oa_syntax );
@@ -74,10 +76,8 @@ get_one_syntax( char *attrib, int required )
 }
 
 void
-get_syntaxes()
+get_syntaxes( void )
 {
-       oid_table_attr  *name2attr();
-
        Debug( LDAP_DEBUG_TRACE, "get_syntaxes\n", 0, 0, 0 );
 
        ldap_photo_syntax = get_one_syntax( "photo", 0 );
@@ -134,7 +134,8 @@ get_syntaxes()
  *       notation.  (e.g., OID.2.6.53).
  *
  */
-static void attr_key_rfc1779 (
+static void
+attr_key_rfc1779(
     AttributeType   at,
     char            *key    /* return key, caller allocated */
 )
@@ -181,7 +182,6 @@ dn_print_real(
        int     firstrdn;
        char    *value;
        PS      rps;
-       void    ldap_dn_print();
         char    key[512];
 
        if ( dn == NULLDN )
@@ -553,9 +553,6 @@ int
 encode_attrs( BerElement *ber, Attr_Sequence as )
 {
        PS              ps;
-#ifdef LDAP_COMPAT20
-       extern int      ldap_compat;
-#endif
 
        Debug( LDAP_DEBUG_TRACE, "encode_attrs\n", 0, 0, 0 );
 
@@ -622,7 +619,8 @@ trim_trailing_spaces( char *s )
        }
 }
 
-DN ldap_str2dn( char *str )
+DN
+ldap_str2dn( char *str )
 {
        DN              dn, save;
        RDN             rdn, newrdn, tmprdn;
@@ -785,7 +783,8 @@ DN ldap_str2dn( char *str )
 #define T61    "{T.61}"
 #define T61LEN 6
 
-static void de_t61( char *s, int t61mark )
+static void
+de_t61( char *s, int t61mark )
 {
        char    *next = s;
        int     c, hex;
@@ -965,7 +964,6 @@ AttributeValue
 ldap_str_at2AttrV( char *str, AttributeType type )
 {
        char            *s, *res, *r;
-       AttributeValue  str_at2AttrV();
 
        Debug( LDAP_DEBUG_TRACE, "ldap_str_at2AttrV str (%s) type (%s)\n", str,
            type->oa_ot.ot_name, 0 );
index 27ecea9a5af394a1bc5187930c95b30cb4956bbf..4baccd6a04ca61ee7bdf4ac43f190082c9f8fc65 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/errno.h>
+
+#include <ac/ctype.h>
+#include <ac/errno.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
 #include <quipu/commonarg.h>
 #include <quipu/ds_error.h>
+
 #include "lber.h"
 #include "ldap.h"
 #include "common.h"
@@ -48,8 +53,8 @@ bprint( char *data, int len )
            out[ i ] = ' ';
            out[ i+1 ] = *data;
        } else {
-           out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
-           out[ i+1 ] = hexdig[ *data & 0x0f ];
+           out[ i ] = hexdig[ ( (unsigned char)*data & 0xf0 ) >> 4 ];
+           out[ i+1 ] = hexdig[ (unsigned char)*data & 0x0f ];
        }
        i += 2;
        len--;
@@ -65,7 +70,8 @@ bprint( char *data, int len )
     }
 }
 
-void charlist_free( char **cl )
+void
+charlist_free( char **cl )
 {
        int     i;
 
@@ -81,7 +87,6 @@ int
 get_ava( BerElement *ber, AVA *tava )
 {
        char                    *type, *value;
-       extern short            ldap_dn_syntax;
 
        Debug( LDAP_DEBUG_TRACE, "get_ava\n", 0, 0, 0 );
 
@@ -127,7 +132,6 @@ chase_referral(
        struct access_point     *ap;
        int                     rc, bound;
        struct conn             *save, *dup, *found;
-       struct PSAPaddr         *psap_cpy();
 
        Debug( LDAP_DEBUG_TRACE, "chase_referral\n", 0, 0, 0 );
 
index d6f7291c7817f83558d1e222cadbd6bc0eb5e647..d3f3cd48962eafb376f3d4b82a5d500d8369088f 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
+#include "portable.h"
 
-extern Backend *select_backend();
+#include <stdio.h>
+#include <ac/socket.h>
 
-extern char    *default_referral;
+#include "slap.h"
 
 void
 do_abandon(
index a9fcc6a1209589b002b85e2698d6c7bed3e5c75d..5bb093fea9c93ca08d48e7d86a3365b00a0b1694 100644 (file)
 
 #include "slap.h"
 
-extern Attribute       *attr_find();
-extern struct acl      *global_acl;
-extern int             global_default_access;
-extern char            *access2str();
-extern char            *dn_normalize_case();
-
-int            acl_access_allowed();
-int            access_allowed();
-struct acl     *acl_get_applicable();
-
-static int     regex_matches();
-
-static string_expand(char *newbuf, int bufsiz, char *pattern,
-       char *match, regmatch_t *matches);
+static int     regex_matches(char *pat, char *str, char *buf, regmatch_t *matches);
+static void    string_expand(char *newbuf, int bufsiz, char *pattern,
+                             char *match, regmatch_t *matches);
 
 
 /*
@@ -472,7 +461,8 @@ acl_check_mods(
        return( LDAP_SUCCESS );
 }
 
-static string_expand(
+static void
+string_expand(
        char *newbuf,
        int bufsiz,
        char *pat,
index f8dea06bd530ebdb348b1325b000ab9ecb4c2702..de66a9fc215d8b19dd1c96b420c2ead7c276135d 100644 (file)
 
 #include "slap.h"
 
-extern Filter          *str2filter();
-extern struct acl      *global_acl;
-extern char            **str2charray();
-extern char            *dn_upcase();
-
-static void            split();
-static void            acl_append();
-static void            access_append();
-static void            acl_usage();
+static void            split(char *line, int splitchar, char **left, char **right);
+static void            acl_append(struct acl **l, struct acl *a);
+static void            access_append(struct access **l, struct access *a);
+static void            acl_usage(void);
 #ifdef LDAP_DEBUG
-static void            print_acl();
-static void            print_access();
+static void            print_acl(struct acl *a);
+static void            print_access(struct access *b);
 #endif
 
-int
+static int
 regtest(char *fname, int lineno, char *pat) {
        int e;
        regex_t re;
 
        char buf[512];
-       int size;
+       unsigned size;
 
        char *sp;
        char *dp;
@@ -369,7 +364,7 @@ str2access( char *str )
 }
 
 static void
-acl_usage()
+acl_usage( void )
 {
        fprintf( stderr, "\n<access clause> ::= access to <what> [ by <who> <access> ]+ \n" );
        fprintf( stderr, "<what> ::= * | [dn=<regex>] [filter=<ldapfilter>] [attrs=<attrlist>]\n" );
index 027e40a8e4d2af935172366a8266aeb7a7bd41ca..5393e3afe939db70a7e6cd7d6a3eab1891240ced 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
 
-extern Backend *select_backend();
-extern char    *dn_normalize();
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/socket.h>
 
-extern char            *default_referral;
-extern time_t          currenttime;
-extern pthread_mutex_t currenttime_mutex;
-extern int             global_lastmod;
+#include "slap.h"
 
-static void    add_created_attrs();
+static void    add_created_attrs(Operation *op, Entry *e);
 
 void
-do_add( conn, op )
-    Connection *conn;
-    Operation  *op;
+do_add( Connection *conn, Operation *op )
 {
        BerElement      *ber = op->o_ber;
        char            *dn, *last;
@@ -53,6 +46,8 @@ do_add( conn, op )
         */
 
        e = (Entry *) ch_calloc( 1, sizeof(Entry) );
+       /* initialize reader/writer lock */
+       entry_rdwr_init(e);
 
        /* get the name */
        if ( ber_scanf( ber, "{a", &dn ) == LBER_ERROR ) {
@@ -117,21 +112,25 @@ do_add( conn, op )
         */
        if ( be->be_add != NULL ) {
                /* do the update here */
-               if ( be->be_updatedn == NULL || strcasecmp( be->be_updatedn,
-                   op->o_dn ) == 0 ) {
-                       if ( (be->be_lastmod == ON || be->be_lastmod == 0 &&
-                           global_lastmod == ON) && be->be_updatedn == NULL ) {
+               if ( be->be_updatedn == NULL ||
+                       strcasecmp( be->be_updatedn, op->o_dn ) == 0 ) {
+
+                       if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED &&
+                               global_lastmod == ON)) && be->be_updatedn == NULL ) {
+
                                add_created_attrs( op, e );
                        }
                        if ( (*be->be_add)( be, conn, op, e ) == 0 ) {
                                replog( be, LDAP_REQ_ADD, e->e_dn, e, 0 );
                        }
+
                } else {
                        entry_free( e );
                        send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
                            default_referral );
                }
        } else {
+           Debug( LDAP_DEBUG_ARGS, "    do_add: HHH\n", 0, 0, 0 );
                entry_free( e );
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
                    "Function not implemented" );
@@ -141,7 +140,7 @@ do_add( conn, op )
 static void
 add_created_attrs( Operation *op, Entry *e )
 {
-       char            buf[20];
+       char            buf[22];
        struct berval   bv;
        struct berval   *bvals[2];
        Attribute       **a, **next;
@@ -155,8 +154,10 @@ add_created_attrs( Operation *op, Entry *e )
 
        /* remove any attempts by the user to add these attrs */
        for ( a = &e->e_attrs; *a != NULL; a = next ) {
-               if ( strcasecmp( (*a)->a_type, "createtimestamp" ) == 0
-                   || strcasecmp( (*a)->a_type, "creatorsname" ) == 0 ) {
+               if ( strcasecmp( (*a)->a_type, "modifiersname" ) == 0 || 
+                       strcasecmp( (*a)->a_type, "modifytimestamp" ) == 0 ||
+                       strcasecmp( (*a)->a_type, "creatorsname" ) == 0 ||
+                       strcasecmp( (*a)->a_type, "createtimestamp" ) == 0 ) {
                        tmp = *a;
                        *a = (*a)->a_next;
                        attr_free( tmp );
@@ -176,8 +177,13 @@ add_created_attrs( Operation *op, Entry *e )
        attr_merge( e, "creatorsname", bvals );
 
        pthread_mutex_lock( &currenttime_mutex );
-        ltm = localtime( &currenttime );
-        strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
+#ifndef LDAP_LOCALTIME
+       ltm = gmtime( &currenttime );
+       strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
+#else
+       ltm = localtime( &currenttime );
+       strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
+#endif
        pthread_mutex_unlock( &currenttime_mutex );
 
        bv.bv_val = buf;
index e4fa388fa99b6a0f32b66d89f7de0b70e2e2ffb9..51752ee9ac4008b37ca6ac5de3907c7e19c94d15 100644 (file)
@@ -9,6 +9,7 @@
 #endif
 
 #include <ac/ctype.h>
+#include <ac/errno.h>
 #include <ac/socket.h>
 #include <ac/string.h>
 #include <ac/time.h>
@@ -21,9 +22,6 @@
 
 #include "slap.h"
 
-extern char    **charray_dup();
-extern int     errno;
-
 void
 attr_free( Attribute *a )
 {
@@ -294,7 +292,7 @@ attr_syntax_config(
        } else {
                Debug( LDAP_DEBUG_ANY,
            "%s: line %d: unknown syntax \"%s\" in attribute line (ignored)\n",
-                   fname, lineno, 0 );
+                   fname, lineno, argv[lasti] );
                Debug( LDAP_DEBUG_ANY,
     "possible syntaxes are \"cis\", \"ces\", \"tel\", \"dn\", or \"bin\"\n",
                    0, 0, 0 );
@@ -325,7 +323,7 @@ attr_syntax_config(
 
 #ifdef LDAP_DEBUG
 
-static
+static int
 attr_syntax_printnode( struct asyntaxinfo *a )
 {
        int     i;
@@ -337,8 +335,8 @@ attr_syntax_printnode( struct asyntaxinfo *a )
        return( 0 );
 }
 
-static
-attr_syntax_print()
+static void
+attr_syntax_print( void )
 {
        (void) avl_apply( attr_syntaxes, attr_syntax_printnode, 0, -1,
            AVL_INORDER );
index 11280148a8fee53e3c6be98fa3c244b1b2e3c354..ef7409ce62cb884396cdcb218babcbf214dfb158 100644 (file)
@@ -2,7 +2,8 @@
 
 #include "portable.h"
 
-int
+/*ARGSUSED*/
+void
 ldbm_back_abandon()
 {
 }
index 3dacd6da3dba445dece437a7eff58708971c2e65..75dd12b1b2506bae216d78f2358a0635931b7f70 100644 (file)
@@ -1,16 +1,15 @@
 /* add.c - ldap ldbm back-end add routine */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include "slap.h"
 #include "back-ldbm.h"
-
-extern int     global_schemacheck;
-extern char    *dn_parent();
-extern char    *dn_normalize();
-extern Entry   *dn2entry();
+#include "proto-back-ldbm.h"
 
 int
 ldbm_back_add(
@@ -21,27 +20,30 @@ ldbm_back_add(
 )
 {
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
-       char            *matched;
        char            *dn = NULL, *pdn = NULL;
-       Entry           *p;
+       Entry           *p = NULL;
+       int                     rc;
 
        dn = dn_normalize( strdup( e->e_dn ) );
-       matched = NULL;
-       if ( (p = dn2entry( be, dn, &matched )) != NULL ) {
-               cache_return_entry( &li->li_cache, p );
+
+       Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_add: %s\n", dn, 0, 0);
+
+       if ( ( dn2id( be, dn ) ) != NOID ) {
                entry_free( e );
                free( dn );
                send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" );
                return( -1 );
        }
-       if ( matched != NULL ) {
-               free( matched );
-       }
+
        /* XXX race condition here til we cache_add_entry_lock below XXX */
 
        if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
-               Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n", 0, 0,
-                   0 );
+               Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n",
+                       0, 0, 0 );
+
+               /* XXX this should be ok, no other thread should have access
+                * because e hasn't been added to the cache yet
+                */
                entry_free( e );
                free( dn );
                send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, "",
@@ -61,6 +63,10 @@ ldbm_back_add(
                Debug( LDAP_DEBUG_ANY, "cache_add_entry_lock failed\n", 0, 0,
                    0 );
                next_id_return( be, e->e_id );
+                
+               /* XXX this should be ok, no other thread should have access
+                * because e hasn't been added to the cache yet
+                */
                entry_free( e );
                free( dn );
                send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" );
@@ -74,17 +80,22 @@ ldbm_back_add(
         */
 
        if ( (pdn = dn_parent( be, dn )) != NULL ) {
+               char *matched;
                /* no parent */
                matched = NULL;
-               if ( (p = dn2entry( be, pdn, &matched )) == NULL ) {
+
+               /* get entry with reader lock */
+               if ( (p = dn2entry_r( be, pdn, &matched )) == NULL ) {
+                       Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0,
+                           0, 0 );
                        send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
                            matched, "" );
                        if ( matched != NULL ) {
                                free( matched );
                        }
-                       Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0,
-                           0, 0 );
-                       goto error_return;
+
+                       rc = -1;
+                       goto return_results;
                }
                if ( matched != NULL ) {
                        free( matched );
@@ -96,7 +107,9 @@ ldbm_back_add(
                            0, 0 );
                        send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
                            "", "" );
-                       goto error_return;
+
+                       rc = -1;
+                       goto return_results;
                }
        } else {
                if ( ! be_isroot( be, op->o_dn ) ) {
@@ -104,9 +117,10 @@ ldbm_back_add(
                            0, 0 );
                        send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
                            "", "" );
-                       goto error_return;
+
+                       rc = -1;
+                       goto return_results;
                }
-               p = NULL;
        }
 
        /*
@@ -116,9 +130,10 @@ ldbm_back_add(
        if ( id2children_add( be, p, e ) != 0 ) {
                Debug( LDAP_DEBUG_TRACE, "id2children_add failed\n", 0,
                    0, 0 );
-               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "",
-                   "" );
-               goto error_return;
+               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
+
+               rc = -1;
+               goto return_results;
        }
 
        /*
@@ -131,7 +146,9 @@ ldbm_back_add(
                Debug( LDAP_DEBUG_TRACE, "index_add_entry failed\n", 0,
                    0, 0 );
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
-               goto error_return;
+
+               rc = -1;
+               goto return_results;
        }
 
        /* dn2id index */
@@ -139,35 +156,44 @@ ldbm_back_add(
                Debug( LDAP_DEBUG_TRACE, "dn2id_add failed\n", 0,
                    0, 0 );
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
-               goto error_return;
+
+               rc = -1;
+               goto return_results;
        }
 
+       /* acquire writer lock */
+       entry_rdwr_lock(e, 1);
+
        /* id2entry index */
        if ( id2entry_add( be, e ) != 0 ) {
                Debug( LDAP_DEBUG_TRACE, "id2entry_add failed\n", 0,
                    0, 0 );
                (void) dn2id_delete( be, dn );
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
-               goto error_return;
+
+               rc = -1;
+               goto return_results;
        }
 
        send_ldap_result( conn, op, LDAP_SUCCESS, "", "" );
+       rc = 0;
+
+return_results:;
+
        if ( dn != NULL )
                free( dn );
        if ( pdn != NULL )
                free( pdn );
+
        cache_set_state( &li->li_cache, e, 0 );
-       cache_return_entry( &li->li_cache, e );
-       return( 0 );
 
-error_return:;
-       if ( dn != NULL )
-               free( dn );
-       if ( pdn != NULL )
-               free( pdn );
-       next_id_return( be, e->e_id );
-       cache_delete_entry( &li->li_cache, e );
-       cache_return_entry( &li->li_cache, e );
+       /* free entry and writer lock */
+       cache_return_entry_w( &li->li_cache, e ); 
+
+       /* free entry and reader lock */
+       if (p != NULL) {
+               cache_return_entry_r( &li->li_cache, p ); 
+       }
 
-       return( -1 );
+       return( rc );
 }
index d0bb831c263337797c0f5ed1e8f2603c35664ec8..1ef4bbd07f8a61f33ec046c4a5d42eda1e160b78 100644 (file)
@@ -1,14 +1,15 @@
 /* attr.c - backend routines for dealing with attributes */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include "slap.h"
 #include "back-ldbm.h"
 
-extern char    **str2charray();
-
 static int
 ainfo_type_cmp(
     char               *type,
@@ -141,7 +142,7 @@ attr_index_config(
                        a->ai_indexmask |= INDEX_FROMINIT;
                }
 
-               switch (avl_insert( &li->li_attrs, a, ainfo_cmp, ainfo_dup )) {
+               switch (avl_insert( &li->li_attrs, (caddr_t) a, ainfo_cmp, ainfo_dup )) {
                case 1:         /* duplicate - updating init version */
                        free( a->ai_type );
                        free( (char *) a );
index 88fd4030c41df52a20815451fdc6491f4f431449..591e488c9cc98e27ef309a81dc5268c8dd8b1965 100644 (file)
 /* bind.c - ldbm backend bind and unbind routines */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/krb.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
 #include "slap.h"
 #include "back-ldbm.h"
-#ifdef KERBEROS
-#include "krb.h"
-#endif
+#include "proto-back-ldbm.h"
+
+#ifdef SLAPD_SHA1
+#include <lutil_sha1.h>
+#endif /* SLAPD_SHA1 */
 
-extern Entry           *dn2entry();
-extern Attribute       *attr_find();
+#ifdef SLAPD_MD5
+#include <lutil_md5.h>
+#endif /* SLAPD_MD5 */
 
-#ifdef KERBEROS
+#include <lutil.h>
+
+#ifdef HAVE_KERBEROS
 extern int     krbv4_ldap_auth();
 #endif
 
+#ifdef SLAPD_CRYPT
+pthread_mutex_t crypt_mutex;
+
+static int
+crypted_value_find(
+       struct berval       **vals,
+       struct berval       *v,
+       int                 syntax,
+       int                 normalize,
+       struct berval           *cred
+)
+{
+       int     i;
+       for ( i = 0; vals[i] != NULL; i++ ) {
+               if ( syntax != SYNTAX_BIN && strncasecmp( "{CRYPT}",
+                       vals[i]->bv_val, (sizeof("{CRYPT}") - 1 ) ) == 0 ) {
+                               char *userpassword = vals[i]->bv_val + sizeof("{CRYPT}") - 1;
+                               pthread_mutex_lock( &crypt_mutex );
+                               if (strcmp(userpassword, crypt(cred->bv_val,
+                                               userpassword)) == 0) {
+                                       pthread_mutex_unlock( &crypt_mutex );
+                                       return ( 0 );
+                               }
+                               pthread_mutex_unlock( &crypt_mutex );
+#ifdef SLAPD_MD5
+               } else if ( syntax != SYNTAX_BIN && strncasecmp( "{MD5}",
+                       vals[i]->bv_val, (sizeof("{MD5}") - 1 ) ) == 0 ) {
+                               ldap_MD5_CTX MD5context;
+                               unsigned char MD5digest[20];
+                               char base64digest[29];  /* ceiling(sizeof(input)/3) * 4 + 1 */
+
+                               char *userpassword = vals[i]->bv_val + sizeof("{MD5}") - 1;
+
+                               ldap_MD5Init(&MD5context);
+                               ldap_MD5Update(&MD5context,
+                                       (unsigned char *) cred->bv_val,
+                                       strlen(cred->bv_val));
+                               ldap_MD5Final(MD5digest, &MD5context);
+
+                               if (b64_ntop(MD5digest, sizeof(MD5digest),
+                                       base64digest, sizeof(base64digest)) < 0)
+                               {
+                                       return ( 1 );
+                               }
+
+                               if (strcmp(userpassword, base64digest) == 0) {
+                                       return ( 0 );
+                               }
+#endif /* SLAPD_MD5 */
+#ifdef SLAPD_SHA1
+               } else if ( syntax != SYNTAX_BIN && strncasecmp( "{SHA}",
+                       vals[i]->bv_val, (sizeof("{SHA}") - 1 ) ) == 0 ) {
+                               ldap_SHA1_CTX SHA1context;
+                               unsigned char SHA1digest[20];
+                               char base64digest[29];  /* ceiling(sizeof(input)/3) * 4 + 1 */
+
+                               char *userpassword = vals[i]->bv_val + sizeof("{SHA}") - 1;
+
+                               ldap_SHA1Init(&SHA1context);
+                               ldap_SHA1Update(&SHA1context,
+                                       (unsigned char *) cred->bv_val,
+                                       strlen(cred->bv_val));
+                               ldap_SHA1Final(SHA1digest, &SHA1context);
+
+                               if (b64_ntop(SHA1digest, sizeof(SHA1digest),
+                                       base64digest, sizeof(base64digest)) < 0)
+                               {
+                                       return ( 1 );
+                               }
+
+                               if (strcmp(userpassword, base64digest) == 0) {
+                                       return ( 0 );
+                               }
+#endif /* SLAPD_SHA1 */
+               } else {
+                if ( value_cmp( vals[i], v, syntax, normalize ) == 0 ) {
+                        return( 0 );
+                }
+        }
+       }
+
+       return( 1 );
+}
+#endif /* SLAPD_CRYPT */
+
 int
 ldbm_back_bind(
     Backend            *be,
@@ -32,12 +127,15 @@ ldbm_back_bind(
        Attribute       *a;
        int             rc;
        char            *matched = NULL;
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
        char            krbname[MAX_K_NAME_SZ + 1];
        AUTH_DAT        ad;
 #endif
 
-       if ( (e = dn2entry( be, dn, &matched )) == NULL ) {
+       Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_bind: dn: %s\n", dn, 0, 0);
+
+       /* get entry with reader lock */
+       if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
                /* allow noauth binds */
                if ( method == LDAP_AUTH_SIMPLE && cred->bv_len == 0 ) {
                        /*
@@ -50,8 +148,7 @@ ldbm_back_bind(
                        /* front end will send result */
                        rc = 0;
                } else {
-                       send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
-                           matched, NULL );
+                       send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, NULL );
                        rc = 1;
                }
                if ( matched != NULL ) {
@@ -60,46 +157,60 @@ ldbm_back_bind(
                return( rc );
        }
 
+       /* check for deleted */
+
        switch ( method ) {
        case LDAP_AUTH_SIMPLE:
                if ( cred->bv_len == 0 ) {
                        send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
-                       return( 1 );
+
+                       /* stop front end from sending result */
+                       rc = 1;
+                       goto return_results;
                } else if ( be_isroot_pw( be, dn, cred ) ) {
                        /* front end will send result */
-                       return( 0 );
+                       rc = 0;
+                       goto return_results;
                }
 
                if ( (a = attr_find( e->e_attrs, "userpassword" )) == NULL ) {
                        if ( be_isroot_pw( be, dn, cred ) ) {
                                /* front end will send result */
-                               return( 0 );
+                               rc = 0;
+                               goto return_results;
                        }
                        send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
                            NULL, NULL );
-                       cache_return_entry( &li->li_cache, e );
-                       return( 1 );
+                       rc = 1;
+                       goto return_results;
                }
 
-               if ( value_find( a->a_vals, cred, a->a_syntax, 0 ) != 0 ) {
+#ifdef SLAPD_CRYPT
+               if ( crypted_value_find( a->a_vals, cred, a->a_syntax, 0, cred ) != 0 )
+#else
+               if ( value_find( a->a_vals, cred, a->a_syntax, 0 ) != 0 )
+#endif
+               {
                        if ( be_isroot_pw( be, dn, cred ) ) {
                                /* front end will send result */
-                               return( 0 );
+                               rc = 0;
+                               goto return_results;
                        }
                        send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
-                           NULL, NULL );
-                       cache_return_entry( &li->li_cache, e );
-                       return( 1 );
+                               NULL, NULL );
+                       rc = 1;
+                       goto return_results;
                }
+               rc = 0;
                break;
 
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
        case LDAP_AUTH_KRBV41:
                if ( krbv4_ldap_auth( be, cred, &ad ) != LDAP_SUCCESS ) {
                        send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
                            NULL, NULL );
-                       cache_return_entry( &li->li_cache, e );
-                       return( 1 );
+                       rc = 0;
+                       goto return_results;
                }
                sprintf( krbname, "%s%s%s@%s", ad.pname, *ad.pinst ? "."
                    : "", ad.pinst, ad.prealm );
@@ -108,43 +219,47 @@ ldbm_back_bind(
                         * no krbName values present:  check against DN
                         */
                        if ( strcasecmp( dn, krbname ) == 0 ) {
+                               rc = 0; /* XXX wild ass guess */
                                break;
                        }
                        send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
                            NULL, NULL );
-                       cache_return_entry( &li->li_cache, e );
-                       return( 1 );
+                       rc = 1;
+                       goto return_results;
                } else {        /* look for krbName match */
                        struct berval   krbval;
 
                        krbval.bv_val = krbname;
                        krbval.bv_len = strlen( krbname );
 
-                       if ( value_find( a->a_vals, &krbval, a->a_syntax, 3 )
-                           != 0 ) {
+                       if ( value_find( a->a_vals, &krbval, a->a_syntax, 3 ) != 0 ) {
                                send_ldap_result( conn, op,
                                    LDAP_INVALID_CREDENTIALS, NULL, NULL );
-                               cache_return_entry( &li->li_cache, e );
-                               return( 1 );
+                               rc = 1;
+                               goto return_results;
                        }
                }
                break;
 
        case LDAP_AUTH_KRBV42:
                send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
-               cache_return_entry( &li->li_cache, e );
-               return( 1 );
+               /* stop front end from sending result */
+               rc = 1;
+               goto return_results;
 #endif
 
        default:
                send_ldap_result( conn, op, LDAP_STRONG_AUTH_NOT_SUPPORTED,
                    NULL, "auth method not supported" );
-               cache_return_entry( &li->li_cache, e );
-               return( 1 );
+               rc = 1;
+               goto return_results;
        }
 
-       cache_return_entry( &li->li_cache, e );
+return_results:;
+       /* free entry and reader lock */
+       cache_return_entry_r( &li->li_cache, e );
 
-       /* success:  front end will send result */
-       return( 0 );
+       /* front end with send result on success (rc==0) */
+       return( rc );
 }
+
index 4f2fa101072f38ccb750adfdb35a151dc9b39770..1674432d69d37b94d78bc80d4290c17e22617a62 100644 (file)
@@ -3,15 +3,16 @@
 #include "portable.h"
 
 #include <stdio.h>
+int strcasecmp( const char *, const char *);
 
 #include <ac/socket.h>
 #include "slap.h"
 
 #include "back-ldbm.h"
 
-static int     cache_delete_entry_internal();
+static int     cache_delete_entry_internal(struct cache *cache, Entry *e);
 #ifdef LDAP_DEBUG
-static void    lru_print();
+static void    lru_print(struct cache *cache);
 #endif
 
 /*
@@ -139,7 +140,7 @@ cache_add_entry_lock(
                cache_entrydn_cmp, avl_dup_error ) != 0 )
        {
                Debug( LDAP_DEBUG_TRACE,
-                       "====> cache_add_entry lock: entry %20s id %d already in dn cache\n",
+                       "====> cache_add_entry lock: entry %20s id %lu already in dn cache\n",
                    e->e_dn, e->e_id, 0 );
 
                /* free cache mutex */
@@ -152,7 +153,7 @@ cache_add_entry_lock(
                cache_entryid_cmp, avl_dup_error ) != 0 )
        {
                Debug( LDAP_DEBUG_ANY,
-                       "====> entry %20s id %d already in id cache\n",
+                       "====> entry %20s id %lu already in id cache\n",
                    e->e_dn, e->e_id, 0 );
 
                /* delete from dn tree inserted above */
@@ -451,12 +452,12 @@ lru_print( struct cache *cache )
 
        fprintf( stderr, "LRU queue (head to tail):\n" );
        for ( e = cache->c_lruhead; e != NULL; e = e->e_lrunext ) {
-               fprintf( stderr, "\tdn %20s id %d refcnt %d\n", e->e_dn,
+               fprintf( stderr, "\tdn %20s id %lu refcnt %d\n", e->e_dn,
                    e->e_id, e->e_refcnt );
        }
        fprintf( stderr, "LRU queue (tail to head):\n" );
        for ( e = cache->c_lrutail; e != NULL; e = e->e_lruprev ) {
-               fprintf( stderr, "\tdn %20s id %d refcnt %d\n", e->e_dn,
+               fprintf( stderr, "\tdn %20s id %lu refcnt %d\n", e->e_dn,
                    e->e_id, e->e_refcnt );
        }
 }
index d6758e143bf2113ef2d35b297eef002bad38332b..4539163b2fb5f5c822785ba88b80cb626fd6ffb1 100644 (file)
@@ -1,11 +1,15 @@
 /* close.c - close ldbm backend */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+
 #include "slap.h"
 #include "back-ldbm.h"
 
+void
 ldbm_back_close( Backend *be )
 {
        Debug( LDAP_DEBUG_TRACE, "ldbm backend syncing\n", 0, 0, 0 );
index d3a4a4d90ba7455cd9293b0764590010b092319f..d17c5da88a9dca191f51405c1b9156816b0842d0 100644 (file)
@@ -11,8 +11,6 @@
 #include "back-ldbm.h"
 #include "proto-back-ldbm.h"
 
-extern Attribute       *attr_find();
-
 int
 ldbm_back_compare(
     Backend    *be,
index a47d7a14a1386e3deeef99fb3c99251223adbbd5..dab1dec4325b2e285f34dc37c21939536e6c5bae 100644 (file)
@@ -10,6 +10,7 @@
 #include "slap.h"
 #include "back-ldbm.h"
 
+void
 ldbm_back_config(
     Backend    *be,
     char       *fname,
index c16c8b160dfdfe210188465c5e9f19fe74636ad4..3da34b0126ffc18cd9793b8b8651e1e5dc335a13 100644 (file)
@@ -1,24 +1,23 @@
 /* ldbmcache.c - maintain a cache of open ldbm files */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/param.h>
+
+#include <ac/errno.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
 #include <sys/stat.h>
-#include <errno.h>
-#include "portable.h"
-#include "slap.h"
-#include "ldapconfig.h"
-#include "back-ldbm.h"
 
-#ifndef SYSERRLIST_IN_STDIO
-extern int             sys_nerr;
-extern char            *sys_errlist[];
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
 #endif
-extern time_t          currenttime;
-extern pthread_mutex_t currenttime_mutex;
+
+#include "ldapconfig.h"
+#include "slap.h"
+#include "back-ldbm.h"
 
 struct dbcache *
 ldbm_cache_open(
@@ -115,7 +114,7 @@ ldbm_cache_open(
            li->li_dbcache[i].dbc_maxids) + 1;
 
        Debug( LDAP_DEBUG_ARGS,
-           "ldbm_cache_open (blksize %d) (maxids %d) (maxindirect %d)\n",
+           "ldbm_cache_open (blksize %ld) (maxids %d) (maxindirect %d)\n",
            li->li_dbcache[i].dbc_blksize, li->li_dbcache[i].dbc_maxids,
            li->li_dbcache[i].dbc_maxindirect );
        Debug( LDAP_DEBUG_TRACE, "<= ldbm_cache_open (opened %d)\n", i, 0, 0 );
@@ -176,6 +175,9 @@ ldbm_cache_fetch(
 )
 {
        Datum   data;
+#ifdef HAVE_BERKELEY_DB2
+       memset( &data, 0, sizeof( data ) );
+#endif
 
        pthread_mutex_lock( &db->dbc_mutex );
 #ifdef reentrant_database
@@ -216,6 +218,24 @@ ldbm_cache_store(
        }
 #endif
 
+#ifdef LDBM_DEBUG
+       Statslog( LDAP_DEBUG_STATS,
+               "=> ldbm_cache_store(): key.dptr=%s, key.dsize=%d\n",
+               key.dptr, key.dsize, 0, 0, 0 );
+
+       Statslog( LDAP_DEBUG_STATS,
+               "=> ldbm_cache_store(): key.dptr=0x%08x, data.dptr=0x%0 8x\n",
+               key.dptr, data.dptr, 0, 0, 0 );
+
+       Statslog( LDAP_DEBUG_STATS,
+               "=> ldbm_cache_store(): data.dptr=%s, data.dsize=%d\n",
+               data.dptr, data.dsize, 0, 0, 0 );
+
+       Statslog( LDAP_DEBUG_STATS,
+               "=> ldbm_cache_store(): flags=0x%08x\n",
+               flags, 0, 0, 0, 0 );
+#endif /* LDBM_DEBUG */
+
        rc = ldbm_store( db->dbc_db, key, data, flags );
 
        pthread_mutex_unlock( &db->dbc_mutex );
index 412566d809ff64ecb1cf0d965fd5c83ad8abaa00..32317c922f1704e2dd36816771492c6677aa0531 100644 (file)
@@ -11,8 +11,6 @@
 #include "back-ldbm.h"
 #include "proto-back-ldbm.h"
 
-extern Attribute       *attr_find();
-
 int
 ldbm_back_delete(
     Backend    *be,
index 4a7da28731e28b7986fd23473304c9658ea792be..593107cc2cc69bd13334b738c5209add6393c592 100644 (file)
 #include "back-ldbm.h"
 #include "proto-back-ldbm.h"
 
-extern struct dbcache  *ldbm_cache_open();
-extern char            *dn_parent();
-extern Datum           ldbm_cache_fetch();
-
 int
 dn2id_add(
     Backend    *be,
@@ -84,7 +80,7 @@ dn2id(
        /* first check the cache */
        if ( (id = cache_find_entry_dn2id( be, &li->li_cache, dn )) != NOID ) {
                free( dn );
-               Debug( LDAP_DEBUG_TRACE, "<= dn2id %d (in cache)\n", id,
+               Debug( LDAP_DEBUG_TRACE, "<= dn2id %lu (in cache)\n", id,
                        0, 0 );
                return( id );
        }
@@ -114,7 +110,7 @@ dn2id(
 
        ldbm_datum_free( db->dbc_db, data );
 
-       Debug( LDAP_DEBUG_TRACE, "<= dn2id %d\n", id, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "<= dn2id %lu\n", id, 0, 0 );
        return( id );
 }
 
index 55aada54e45e9286fa9caf83de36bdb987f9acbd..31d9551e17a64a7bc43a5dbfa88b0c294510fb2b 100644 (file)
@@ -1,27 +1,21 @@
 /* filterindex.c - generate the list of candidate entries from a filter */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include "slap.h"
 #include "back-ldbm.h"
 
-extern char    *first_word();
-extern char    *next_word();
-extern char    *phonetic();
-extern IDList  *index_read();
-extern IDList  *idl_intersection();
-extern IDList  *idl_union();
-extern IDList  *idl_notin();
-extern IDList  *idl_allids();
-
-static IDList  *ava_candidates();
-static IDList  *presence_candidates();
-static IDList  *approx_candidates();
-static IDList  *list_candidates();
-static IDList  *substring_candidates();
-static IDList  *substring_comp_candidates();
+static IDList  *ava_candidates( Backend *be, Ava *ava, int type );
+static IDList  *presence_candidates( Backend *be, char *type );
+static IDList  *approx_candidates( Backend *be, Ava *ava );
+static IDList  *list_candidates( Backend *be, Filter *flist, int ftype );
+static IDList  *substring_candidates( Backend *be, Filter *f );
+static IDList  *substring_comp_candidates( Backend *be, char *type, char *val, int prepost );
 
 /*
  * test_filter - test a filter against a single entry.
@@ -89,7 +83,7 @@ filter_candidates(
                break;
        }
 
-       Debug( LDAP_DEBUG_TRACE, "<= filter_candidates %d\n",
+       Debug( LDAP_DEBUG_TRACE, "<= filter_candidates %lu\n",
            result ? result->b_nids : 0, 0, 0 );
        return( result );
 }
@@ -120,7 +114,7 @@ ava_candidates(
                break;
        }
 
-       Debug( LDAP_DEBUG_TRACE, "<= ava_candidates %d\n",
+       Debug( LDAP_DEBUG_TRACE, "<= ava_candidates %lu\n",
            idl ? idl->b_nids : 0, 0, 0 );
        return( idl );
 }
@@ -137,7 +131,7 @@ presence_candidates(
 
        idl = index_read( be, type, 0, "*" );
 
-       Debug( LDAP_DEBUG_TRACE, "<= presence_candidates %d\n",
+       Debug( LDAP_DEBUG_TRACE, "<= presence_candidates %lu\n",
            idl ? idl->b_nids : 0, 0, 0 );
        return( idl );
 }
@@ -174,7 +168,7 @@ approx_candidates(
                }
        }
 
-       Debug( LDAP_DEBUG_TRACE, "<= approx_candidates %d\n",
+       Debug( LDAP_DEBUG_TRACE, "<= approx_candidates %lu\n",
            idl ? idl->b_nids : 0, 0, 0 );
        return( idl );
 }
@@ -215,7 +209,7 @@ list_candidates(
                }
        }
 
-       Debug( LDAP_DEBUG_TRACE, "<= list_candidates %d\n",
+       Debug( LDAP_DEBUG_TRACE, "<= list_candidates %lu\n",
            idl ? idl->b_nids : 0, 0, 0 );
        return( idl );
 }
@@ -282,7 +276,7 @@ substring_candidates(
                }
        }
 
-       Debug( LDAP_DEBUG_TRACE, "<= substring_candidates %d\n",
+       Debug( LDAP_DEBUG_TRACE, "<= substring_candidates %lu\n",
            idl ? idl->b_nids : 0, 0, 0 );
        return( idl );
 }
@@ -350,7 +344,7 @@ substring_comp_candidates(
                }
        }
 
-       Debug( LDAP_DEBUG_TRACE, "<= substring_comp_candidates %d\n",
+       Debug( LDAP_DEBUG_TRACE, "<= substring_comp_candidates %lu\n",
            idl ? idl->b_nids : 0, 0, 0 );
        return( idl );
 }
index 42a16e4e42bac44e8ac89e6ed898f60c90bd4c17..7def923a4dc5d48dace72223e1b2b9ac8e17572a 100644 (file)
@@ -11,8 +11,6 @@
 #include "back-ldbm.h"
 #include "proto-back-ldbm.h"
 
-extern Attribute        *attr_find();
-
 
 #ifdef SLAPD_ACLGROUPS
 /* return 0 IFF edn is a value in member attribute
@@ -42,12 +40,12 @@ ldbm_back_group(
 
         /* can we find bdn entry with reader lock */
         if ((e = dn2entry_r(be, bdn, &matched )) == NULL) {
-                Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: cannot find bdn: %s matched: %x\n", bdn, matched, 0 ); 
+                Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: cannot find bdn: %s matched: %s\n", bdn, (matched ? matched : ""), 0 ); 
                 if (matched != NULL)
                         free(matched);
                 return( 1 );
         }
-        Debug( LDAP_DEBUG_ARGS, "=> ldbm_back_group: found bdn: %s matched: %x\n", bdn, matched, 0 ); 
+        Debug( LDAP_DEBUG_ARGS, "=> ldbm_back_group: found bdn: %s matched: %s\n", bdn, (matched ? matched : ""), 0 ); 
 
         /* check for deleted */
 
index 7c555bfecbdfb1fb76690fb63e8c5645fb1a1821..cd0cc7a6dfe58d86adf4117c97189e8e5dd75a85 100644 (file)
 #include "slap.h"
 #include "back-ldbm.h"
 
-struct dbcache *ldbm_cache_open();
-extern Datum   ldbm_cache_fetch();
-IDList         *idl_fetch();
-
 int
 id2children_add(
     Backend    *be,
@@ -33,8 +29,8 @@ id2children_add(
        memset( &data, 0, sizeof( data ) );
 #endif
 
-       Debug( LDAP_DEBUG_TRACE, "=> id2children_add( %d, %d )\n", p ? p->e_id
-           : 0, e->e_id, 0 );
+       Debug( LDAP_DEBUG_TRACE, "=> id2children_add( %lu, %lu )\n",
+              p ? p->e_id : 0, e->e_id, 0 );
 
        if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
            LDBM_WRCREAT )) == NULL ) {
@@ -75,7 +71,7 @@ id2children_remove(
        IDList          *idl;
        char            buf[20];
 
-       Debug( LDAP_DEBUG_TRACE, "=> id2children_remove( %d, %d )\n", p ? p->e_id
+       Debug( LDAP_DEBUG_TRACE, "=> id2children_remove( %lu, %lu )\n", p ? p->e_id
            : 0, e->e_id, 0 );
 
        if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
@@ -87,7 +83,7 @@ id2children_remove(
        }
 
        memset( &key, 0, sizeof(key) );
-       sprintf( buf, "%c%d", EQ_PREFIX, p ? p->e_id : 0 );
+       sprintf( buf, "%c%ld", EQ_PREFIX, p ? p->e_id : 0 );
        key.dptr = buf;
        key.dsize = strlen( buf ) + 1;
 
@@ -120,7 +116,7 @@ has_children(
        memset( &key, 0, sizeof( key ) );
 #endif
 
-       Debug( LDAP_DEBUG_TRACE, "=> has_children( %d )\n", p->e_id , 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "=> has_children( %lu )\n", p->e_id , 0, 0 );
 
        if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
            LDBM_WRCREAT )) == NULL ) {
index edc8f4c7b209ee64c3aff293d0eb8f376e9c47ce..ab8ff238f1f9f177eb5fcd17ce13b3ea29c404b1 100644 (file)
@@ -9,13 +9,6 @@
 #include "slap.h"
 #include "back-ldbm.h"
 
-extern struct dbcache  *ldbm_cache_open();
-extern Datum           ldbm_cache_fetch();
-extern char            *dn_parent();
-extern Entry           *str2entry();
-extern char            *entry2str();
-extern pthread_mutex_t entry2str_mutex;
-
 int
 id2entry_add( Backend *be, Entry *e )
 {
@@ -29,7 +22,7 @@ id2entry_add( Backend *be, Entry *e )
        memset( &data, 0, sizeof( data ) );
 #endif
 
-       Debug( LDAP_DEBUG_TRACE, "=> id2entry_add( %d, \"%s\" )\n", e->e_id,
+       Debug( LDAP_DEBUG_TRACE, "=> id2entry_add( %lu, \"%s\" )\n", e->e_id,
            e->e_dn, 0 );
 
        if ( (db = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, LDBM_WRCREAT ))
@@ -70,7 +63,7 @@ id2entry_delete( Backend *be, Entry *e )
        Datum           key;
        int             rc;
 
-       Debug( LDAP_DEBUG_TRACE, "=> id2entry_delete( %d, \"%s\" )\n", e->e_id,
+       Debug(LDAP_DEBUG_TRACE, "=> id2entry_delete( %lu, \"%s\" )\n", e->e_id,
            e->e_dn, 0 );
 
        /* XXX - check for writer lock - should also check no reader pending */
@@ -95,7 +88,7 @@ id2entry_delete( Backend *be, Entry *e )
        }
 
        if ( cache_delete_entry( &li->li_cache, e ) != 0 ) {
-               Debug( LDAP_DEBUG_ANY, "could not delete %d (%s) from cache\n",
+               Debug(LDAP_DEBUG_ANY, "could not delete %lu (%s) from cache\n",
                    e->e_id, e->e_dn, 0 );
        }
 
@@ -128,8 +121,8 @@ id2entry( Backend *be, ID id, int rw )
                rw ? "w" : "r", id, 0 );
 
        if ( (e = cache_find_entry_id( &li->li_cache, id, rw )) != NULL ) {
-               Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s 0x%x (cache)\n",
-                       rw ? "w" : "r", e, 0 );
+               Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s 0x%lx (cache)\n",
+                       rw ? "w" : "r", (unsigned long)e, 0 );
                return( e );
        }
 
@@ -185,7 +178,7 @@ id2entry_r( Backend *be, ID id )
 }
 
 Entry *
-id2entry_2( Backend *be, ID id )
+id2entry_w( Backend *be, ID id )
 {
        return( id2entry( be, id, 1 ) );
 }
index d1e38aa197627da0f01defe370f0e66ade2b7740..4e47e78ada806fb37dab32215625f83c9e981f81 100644 (file)
@@ -7,12 +7,10 @@
 #include <ac/string.h>
 #include <ac/socket.h>
 
-#include "slap.h"
 #include "ldapconfig.h"
+#include "slap.h"
 #include "back-ldbm.h"
 
-extern Datum   ldbm_cache_fetch();
-
 IDList *
 idl_alloc( int nids )
 {
@@ -163,8 +161,8 @@ idl_fetch(
        }
        free( (char *) tmp );
 
-       Debug( LDAP_DEBUG_TRACE, "<= idl_fetch %d ids (%d max)\n", idl->b_nids,
-           idl->b_nmax, 0 );
+       Debug( LDAP_DEBUG_TRACE, "<= idl_fetch %lu ids (%lu max)\n",
+              idl->b_nids, idl->b_nmax, 0 );
        return( idl );
 }
 
@@ -466,7 +464,7 @@ idl_insert_key(
                        case 0:         /* id inserted */
                                if ( rc == 2 ) {
                                        Debug( LDAP_DEBUG_ANY,
-                                           "id %d already in next block\n",
+                                           "id %lu already in next block\n",
                                            id, 0, 0 );
                                }
                                free( kstr );
@@ -628,7 +626,8 @@ idl_delete_key (
 {
        Datum  k2;
        IDList *idl, *tmp;
-       int i, j, nids;
+       unsigned i;
+       int j, nids;
        char    *kstr;
 
        if ( (idl = idl_fetch_one( be, db, key ) ) == NULL )
@@ -666,7 +665,7 @@ idl_delete_key (
        for ( j = 0; idl->b_ids[j] != NOID; j++ ) 
        {
                memset( &k2, 0, sizeof(k2) );
-               sprintf( kstr, "%c%s%d", CONT_PREFIX, key.dptr, idl->b_ids[j] );
+               sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, idl->b_ids[j] );
                k2.dptr = kstr;
                k2.dsize = strlen( kstr ) + 1;
 
index dbe549b924b334ae9dfc983abc19d183d13c0924..c00bd2509c7b021d838060f452461083fe9e6299 100644 (file)
 #include "slap.h"
 #include "back-ldbm.h"
 
-extern char            *first_word();
-extern char            *next_word();
-extern char            *phonetic();
-extern IDList          *idl_fetch();
-extern IDList          *idl_allids();
-extern struct dbcache  *ldbm_cache_open();
-
-int    index_add_values();
-
-static int     add_value();
-static int     index2prefix();
+static int     add_value(Backend *be, struct dbcache *db, char *type, int indextype, char *val, ID id);
+static int     index2prefix(int indextype);
 
 int
 index_add_entry(
@@ -120,7 +111,7 @@ index_read(
        if ( ! (indextype & indexmask) ) {
                idl =  idl_allids( be );
                Debug( LDAP_DEBUG_TRACE,
-                   "<= index_read %d candidates (allids - not indexed)\n",
+                   "<= index_read %lu candidates (allids - not indexed)\n",
                    idl ? idl->b_nids : 0, 0, 0 );
                return( idl );
        }
@@ -160,7 +151,7 @@ index_read(
 
        ldbm_cache_close( be, db );
 
-       Debug( LDAP_DEBUG_TRACE, "<= index_read %d candidates\n",
+       Debug( LDAP_DEBUG_TRACE, "<= index_read %lu candidates\n",
            idl ? idl->b_nids : 0, 0, 0 );
        return( idl );
 }
@@ -231,7 +222,7 @@ index_add_values(
 )
 {
        char            *val, *p, *code, *w;
-       int             i, j, len;
+       unsigned        i, j, len;
        int             indexmask, syntax;
        char            buf[SUBLEN + 1];
        char            vbuf[BUFSIZ];
index 9193f7213c7859e06d1d26f460d29dc4eb261fdd..407e3c74ee63df64a8dfc64e1eb6772eedc271df 100644 (file)
@@ -10,6 +10,7 @@
 #include "slap.h"
 #include "back-ldbm.h"
 
+void
 ldbm_back_init(
     Backend    *be
 )
index 3c16b925d4d78ecf144ce90722ab5a5aca3e0e20..7b0d141d0f131a7d08335fc01e468bcf4bbd9e27 100644 (file)
 #include "back-ldbm.h"
 #include "proto-back-ldbm.h"
 
-extern int             global_schemacheck;
-extern Attribute       *attr_find();
-
-static int     add_values();
-static int     delete_values();
-static int     replace_values();
+static int     add_values(Entry *e, LDAPMod *mod, char *dn);
+static int     delete_values(Entry *e, LDAPMod *mod, char *dn);
+static int     replace_values(Entry *e, LDAPMod *mod, char *dn);
 
 int
 ldbm_back_modify(
index fcd9fcc35a6f6c14ca2444386ed6f2eb48d093fb..4ea74e95331b1797c778e1eda8365625a1e86e7b 100644 (file)
@@ -1,14 +1,15 @@
 /* modrdn.c - ldbm backend modrdn routine */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
 #include "slap.h"
 #include "back-ldbm.h"
-
-extern Entry   *dn2entry();
-extern char    *dn_parent();
+#include "proto-back-ldbm.h"
 
 int
 ldbm_back_modrdn(
@@ -24,10 +25,12 @@ ldbm_back_modrdn(
        char            *matched;
        char            *pdn, *newdn, *p;
        char            sep[2];
-       Entry           *e, *e2;
+       Entry           *e;
 
        matched = NULL;
-       if ( (e = dn2entry( be, dn, &matched )) == NULL ) {
+
+       /* get entry with writer lock */
+       if ( (e = dn2entry_w( be, dn, &matched )) == NULL ) {
                send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" );
                if ( matched != NULL ) {
                        free( matched );
@@ -61,17 +64,12 @@ ldbm_back_modrdn(
        }
        (void) dn_normalize( newdn );
 
-       matched = NULL;
-       if ( (e2 = dn2entry( be, newdn, &matched )) != NULL ) {
+       /* get entry with writer lock */
+       if ( (dn2id ( be, newdn ) ) != NOID ) {
                free( newdn );
                free( pdn );
                send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, NULL, NULL );
-               cache_return_entry( &li->li_cache, e2 );
-               cache_return_entry( &li->li_cache, e );
-               return( -1 );
-       }
-       if ( matched != NULL ) {
-               free( matched );
+               goto error_return;
        }
 
        /* check for abandon */
@@ -80,9 +78,7 @@ ldbm_back_modrdn(
                pthread_mutex_unlock( &op->o_abandonmutex );
                free( newdn );
                free( pdn );
-               cache_return_entry( &li->li_cache, e2 );
-               cache_return_entry( &li->li_cache, e );
-               return( -1 );
+               goto error_return;
        }
        pthread_mutex_unlock( &op->o_abandonmutex );
 
@@ -91,8 +87,7 @@ ldbm_back_modrdn(
                free( newdn );
                free( pdn );
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
-               cache_return_entry( &li->li_cache, e );
-               return( -1 );
+               goto error_return;
        }
 
        /* delete old one */
@@ -100,8 +95,7 @@ ldbm_back_modrdn(
                free( newdn );
                free( pdn );
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
-               cache_return_entry( &li->li_cache, e );
-               return( -1 );
+               goto error_return;
        }
 
        (void) cache_delete_entry( &li->li_cache, e );
@@ -120,13 +114,19 @@ ldbm_back_modrdn(
        /* id2entry index */
        if ( id2entry_add( be, e ) != 0 ) {
                entry_free( e );
-
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
-               return( -1 );
+               goto error_return;
        }
        free( pdn );
-       cache_return_entry( &li->li_cache, e );
+
+       /* free entry and writer lock */
+       cache_return_entry_w( &li->li_cache, e );
        send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
 
        return( 0 );
+
+error_return:
+       /* free entry and writer lock */
+       cache_return_entry_w( &li->li_cache, e );
+       return( -1 );
 }
index e51f4d84e76ce4de24f4dc6a4819befdc4cc3deb..9bb2d605be99868dfb766c6bbc40fed0f3b378d6 100644 (file)
@@ -1,9 +1,15 @@
 /* id.c - keep track of the next id to be given out */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
+#endif
+
 #include "slap.h"
 #include "back-ldbm.h"
 
@@ -23,7 +29,7 @@ next_id( Backend *be )
        if ( li->li_nextid == -1 ) {
                if ( (fp = fopen( buf, "r" )) == NULL ) {
                        Debug( LDAP_DEBUG_ANY,
-                           "next_id %d: could not open \"%s\"\n",
+                           "next_id %lu: could not open \"%s\"\n",
                            li->li_nextid, buf, 0 );
                        li->li_nextid = 1;
                } else {
@@ -31,7 +37,7 @@ next_id( Backend *be )
                                li->li_nextid = atol( buf2 );
                        } else {
                                Debug( LDAP_DEBUG_ANY,
-                           "next_id %d: could not fgets nextid from \"%s\"\n",
+                          "next_id %lu: could not fgets nextid from \"%s\"\n",
                                    li->li_nextid, buf2, 0 );
                                li->li_nextid = 1;
                        }
@@ -41,15 +47,15 @@ next_id( Backend *be )
 
        li->li_nextid++;
        if ( (fp = fopen( buf, "w" )) == NULL ) {
-               Debug( LDAP_DEBUG_ANY, "next_id %d: could not open \"%s\"\n",
+               Debug( LDAP_DEBUG_ANY, "next_id %lu: could not open \"%s\"\n",
                    li->li_nextid, buf, 0 );
        } else {
                if ( fprintf( fp, "%ld\n", li->li_nextid ) == EOF ) {
-                       Debug( LDAP_DEBUG_ANY, "next_id %d: cannot fprintf\n",
+                       Debug( LDAP_DEBUG_ANY, "next_id %lu: cannot fprintf\n",
                            li->li_nextid, 0, 0 );
                }
                if( fclose( fp ) != 0 ) {
-                       Debug( LDAP_DEBUG_ANY, "next_id %d: cannot fclose\n",
+                       Debug( LDAP_DEBUG_ANY, "next_id %lu: cannot fclose\n",
                            li->li_nextid, 0, 0 );
                }
        }
@@ -77,17 +83,17 @@ next_id_return( Backend *be, ID id )
        li->li_nextid--;
        if ( (fp = fopen( buf, "w" )) == NULL ) {
                Debug( LDAP_DEBUG_ANY,
-                   "next_id_return of %d: could not open \"%s\" next id %d\n",
+                 "next_id_return of %lu: could not open \"%s\" next id %lu\n",
                    id, buf, li->li_nextid );
        } else {
                if ( fprintf( fp, "%ld\n", li->li_nextid ) == EOF ) {
                        Debug( LDAP_DEBUG_ANY,
-                   "next_id_return of %d: cannot fprintf \"%s\" next id %d\n",
+                 "next_id_return of %lu: cannot fprintf \"%s\" next id %lu\n",
                            id, buf, li->li_nextid );
                }
                if( fclose( fp ) != 0 ) {
                        Debug( LDAP_DEBUG_ANY,
-                   "next_id_return of %d: cannot fclose \"%s\" next id %d\n",
+                 "next_id_return of %lu: cannot fclose \"%s\" next id %lu\n",
                            id, buf, li->li_nextid );
                }
        }
@@ -110,7 +116,7 @@ next_id_get( Backend *be )
        if ( li->li_nextid == -1 ) {
                if ( (fp = fopen( buf, "r" )) == NULL ) {
                        Debug( LDAP_DEBUG_ANY,
-                           "next_id %d: could not open \"%s\"\n",
+                           "next_id %lu: could not open \"%s\"\n",
                            li->li_nextid, buf, 0 );
                        li->li_nextid = 1;
                } else {
@@ -118,7 +124,7 @@ next_id_get( Backend *be )
                                li->li_nextid = atol( buf2 );
                        } else {
                                Debug( LDAP_DEBUG_ANY,
-                           "next_id %d: cannot fgets nextid from \"%s\"\n",
+                           "next_id %lu: cannot fgets nextid from \"%s\"\n",
                                    li->li_nextid, buf2, 0 );
                                li->li_nextid = 1;
                        }
index acc69ca33c83c30abd2c4371e85d1d19597539c9..b51691eb4cc1443adea2f221a41c3e12bf835c95 100644 (file)
 #ifndef _PROTO_BACK_LDBM
 #define _PROTO_BACK_LDBM
 
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
+
+/*
+ * alias.c
+ */
+Entry *derefAlias_r LDAP_P((
+       Backend     *be,
+       Connection      *conn,
+       Operation       *op,
+       Entry       *e ));
+char *derefDN LDAP_P((
+       Backend     *be,
+       Connection  *conn,
+       Operation   *op,
+       char        *dn ));
+
 /*
  * attr.c
  */
 
-void attr_masks( struct ldbminfo *li, char *type, int *indexmask,
- int *syntaxmask );
-void attr_index_config( struct ldbminfo *li, char *fname, int lineno,
- int argc, char **argv, int init );
+void attr_masks LDAP_P(( struct ldbminfo *li, char *type, int *indexmask,
+ int *syntaxmask ));
+void attr_index_config LDAP_P(( struct ldbminfo *li, char *fname, int lineno,
+ int argc, char **argv, int init ));
 
 /*
  * cache.c
  */
 
-void cache_set_state( struct cache *cache, Entry *e, int state );
-void cache_return_entry( struct cache *cache, Entry *e );
-int cache_add_entry_lock( struct cache *cache, Entry *e, int state );
-Entry * cache_find_entry_dn( struct cache *cache, char *dn );
-Entry * cache_find_entry_id( struct cache *cache, ID id );
-int cache_delete_entry( struct cache *cache, Entry *e );
+void cache_set_state LDAP_P(( struct cache *cache, Entry *e, int state ));
+void cache_return_entry_r LDAP_P(( struct cache *cache, Entry *e ));
+void cache_return_entry_w LDAP_P(( struct cache *cache, Entry *e ));
+int cache_add_entry_lock LDAP_P(( struct cache *cache, Entry *e, int state ));
+ID cache_find_entry_dn2id LDAP_P(( Backend *be, struct cache *cache, char *dn ));
+Entry * cache_find_entry_id LDAP_P(( struct cache *cache, ID id, int rw ));
+int cache_delete_entry LDAP_P(( struct cache *cache, Entry *e ));
 
 /*
  * dbcache.c
  */
 
-struct dbcache * ldbm_cache_open( Backend *be, char *name, char *suffix,
- int flags );
-void ldbm_cache_close( Backend *be, struct dbcache *db );
-void ldbm_cache_flush_all( Backend *be );
-Datum ldbm_cache_fetch( struct dbcache *db, Datum key );
-int ldbm_cache_store( struct dbcache *db, Datum key, Datum data, int flags );
-int ldbm_cache_delete( struct dbcache *db, Datum key );
+struct dbcache * ldbm_cache_open LDAP_P(( Backend *be, char *name, char *suffix,
+ int flags ));
+void ldbm_cache_close LDAP_P(( Backend *be, struct dbcache *db ));
+void ldbm_cache_really_close LDAP_P(( Backend *be, struct dbcache *db ));
+void ldbm_cache_flush_all LDAP_P(( Backend *be ));
+Datum ldbm_cache_fetch LDAP_P(( struct dbcache *db, Datum key ));
+int ldbm_cache_store LDAP_P(( struct dbcache *db, Datum key, Datum data, int flags ));
+int ldbm_cache_delete LDAP_P(( struct dbcache *db, Datum key ));
 
 /*
  * dn2id.c
  */
 
-int dn2id_add( Backend *be, char *dn, ID id );
-ID dn2id( Backend *be, char *dn );
-int dn2id_delete( Backend *be, char *dn );
-Entry * dn2entry( Backend *be, char *dn, char **matched );
+int dn2id_add LDAP_P(( Backend *be, char *dn, ID id ));
+ID dn2id LDAP_P(( Backend *be, char *dn ));
+int dn2id_delete LDAP_P(( Backend *be, char *dn ));
+Entry * dn2entry_r LDAP_P(( Backend *be, char *dn, char **matched ));
+Entry * dn2entry_w LDAP_P(( Backend *be, char *dn, char **matched ));
 
 /*
  * filterindex.c
  */
 
-IDList * filter_candidates( Backend *be, Filter *f );
+IDList * filter_candidates LDAP_P(( Backend *be, Filter *f ));
 
 /*
  * id2children.c
  */
 
-int id2children_add( Backend *be, Entry *p, Entry *e );
-int has_children( Backend *be, Entry *p );
+int id2children_add LDAP_P(( Backend *be, Entry *p, Entry *e ));
+int id2children_remove LDAP_P(( Backend *be, Entry *p, Entry *e ));
+int has_children LDAP_P(( Backend *be, Entry *p ));
 
 /*
  * id2entry.c
  */
 
-int id2entry_add( Backend *be, Entry *e );
-int id2entry_delete( Backend *be, Entry *e );
-Entry * id2entry( Backend *be, ID id );
+int id2entry_add LDAP_P(( Backend *be, Entry *e ));
+int id2entry_delete LDAP_P(( Backend *be, Entry *e ));
+Entry * id2entry LDAP_P(( Backend *be, ID id, int rw )); 
+Entry * id2entry_r LDAP_P(( Backend *be, ID id ));
+Entry * id2entry_w LDAP_P(( Backend *be, ID id ));
 
 /*
  * idl.c
  */
 
-IDList * idl_alloc( int nids );
-IDList * idl_allids( Backend *be );
-void idl_free( IDList *idl );
-IDList * idl_fetch( Backend *be, struct dbcache *db, Datum key );
-int idl_insert_key( Backend *be, struct dbcache *db, Datum key, ID id );
-int idl_insert( IDList **idl, ID id, int maxids );
-IDList * idl_intersection( Backend *be, IDList *a, IDList *b );
-IDList * idl_union( Backend *be, IDList *a, IDList *b );
-IDList * idl_notin( Backend *be, IDList *a, IDList *b );
-ID idl_firstid( IDList *idl );
-ID idl_nextid( IDList *idl, ID id );
+IDList * idl_alloc LDAP_P(( int nids ));
+IDList * idl_allids LDAP_P(( Backend *be ));
+void idl_free LDAP_P(( IDList *idl ));
+IDList * idl_fetch LDAP_P(( Backend *be, struct dbcache *db, Datum key ));
+int idl_insert_key LDAP_P(( Backend *be, struct dbcache *db, Datum key, ID id ));
+int idl_insert LDAP_P(( IDList **idl, ID id, int maxids ));
+int idl_delete_key LDAP_P(( Backend *be, struct dbcache *db, Datum key, ID id ));
+IDList * idl_intersection LDAP_P(( Backend *be, IDList *a, IDList *b ));
+IDList * idl_union LDAP_P(( Backend *be, IDList *a, IDList *b ));
+IDList * idl_notin LDAP_P(( Backend *be, IDList *a, IDList *b ));
+ID idl_firstid LDAP_P(( IDList *idl ));
+ID idl_nextid LDAP_P(( IDList *idl, ID id ));
 
 /*
  * index.c
  */
 
-int index_add_entry( Backend *be, Entry *e );
-int index_add_mods( Backend *be, LDAPMod *mods, ID id );
-IDList * index_read( Backend *be, char *type, int indextype, char *val );
-int index_add_values( Backend *be, char *type, struct berval **vals, ID  id );
+int index_add_entry LDAP_P(( Backend *be, Entry *e ));
+int index_add_mods LDAP_P(( Backend *be, LDAPMod *mods, ID id ));
+IDList * index_read LDAP_P(( Backend *be, char *type, int indextype, char *val ));
+int index_add_values LDAP_P(( Backend *be, char *type, struct berval **vals, ID  id ));
 
 /*
  * kerberos.c
  */
 
-#ifdef KERBEROS
-/* krbv4_ldap_auth( Backend *be, struct berval *cred, AUTH_DAT *ad ); */
+#ifdef HAVE_KERBEROS
+/* krbv4_ldap_auth LDAP_P(( Backend *be, struct berval *cred, AUTH_DAT *ad )); */
 #endif
 
 /*
  * nextid.c
  */
 
-ID next_id( Backend *be );
-void next_id_return( Backend *be, ID id );
-ID next_id_get( Backend *be );
+ID next_id LDAP_P(( Backend *be ));
+void next_id_return LDAP_P(( Backend *be, ID id ));
+ID next_id_get LDAP_P(( Backend *be ));
 
+LDAP_END_DECL
 #endif
index 6b73e802b72c16a04d304f9f02db77ab4ceeba3b..4b25fe66cd7819955f63016c63579ebbf6899d5b 100644 (file)
 #include "back-ldbm.h"
 #include "proto-back-ldbm.h"
 
-extern time_t          currenttime;
-extern pthread_mutex_t currenttime_mutex;
-
-extern IDList          *idl_alloc();
-extern Attribute       *attr_find();
-extern IDList          *filter_candidates();
-extern char            *dn_parent();
-
-static IDList  *base_candidates();
-static IDList  *onelevel_candidates();
-static IDList  *subtree_candidates();
+static IDList  *base_candidates(Backend *be, Connection *conn, Operation *op, char *base, Filter *filter, char **attrs, int attrsonly, char **matched, int *err);
+static IDList  *onelevel_candidates(Backend *be, Connection *conn, Operation *op, char *base, Filter *filter, char **attrs, int attrsonly, char **matched, int *err);
+static IDList  *subtree_candidates(Backend *be, Connection *conn, Operation *op, char *base, Filter *filter, char **attrs, int attrsonly, char **matched, Entry *e, int *err, int lookupbase);
 
 #define GRABSIZE       BUFSIZ
 
@@ -162,7 +154,8 @@ ldbm_back_search(
 
                /* get the entry with reader lock */
                if ( (e = id2entry_r( be, id )) == NULL ) {
-                       Debug( LDAP_DEBUG_ARGS, "candidate %d not found\n", id, 0, 0 );
+                       Debug( LDAP_DEBUG_ARGS, "candidate %lu not found\n",
+                              id, 0, 0 );
                        continue;
                }
 
index 9f3421d5ee6ed53a3d6020dee01696d8319312a6..0241a00b354e7a78510eeaee144094f523271416 100644 (file)
@@ -1,16 +1,17 @@
 /* unbind.c - handle an ldap unbind operation */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+#include <ac/socket.h>
+
 #include "slap.h"
 
-int
+void
 ldbm_back_unbind(
        Backend     *be,
        Connection  *conn,
        Operation   *op
 )
 {
-       return( 0 );
 }
index 5a26ff0fb61e6a401c5fb522ef8ca5d45815f1a7..5e9bf853a344eab4d8df8e075e687feabab61c27 100644 (file)
@@ -1,13 +1,16 @@
 /* config.c - passwd backend configuration file routine */
 
-#include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
 #include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
 #include "slap.h"
 
+void
 passwd_back_config(
     Backend    *be,
     char       *fname,
index 942b804a6c5daed42087f317cc69aa1a12a737c6..86fb55e6102f5822f6973e7b43f288071d5f6e24 100644 (file)
 
 #include "slap.h"
 
-extern time_t          currenttime;
-extern pthread_mutex_t currenttime_mutex;
-
-static Entry   *pw2entry();
+static Entry   *pw2entry(Backend *be, struct passwd *pw);
 
 int
 passwd_back_search(
index 89f054cc9c3d78d76f380d202f26613f595ab448..5d201fd586f8afbc555d102ce5a0a82a05206aca 100644 (file)
@@ -1,16 +1,16 @@
 /* add.c - shell backend add function */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
 #include "slap.h"
 #include "shell.h"
 
-extern pthread_mutex_t entry2str_mutex;
-extern char            *entry2str();
-
-void
+int
 shell_back_add(
     Backend    *be,
     Connection *conn,
@@ -25,18 +25,18 @@ shell_back_add(
        if ( si->si_add == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
                    "add not implemented" );
-               return;
+               return( -1 );
        }
 
        if ( (op->o_private = forkandexec( si->si_add, &rfp, &wfp )) == -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
                    "could not fork/exec" );
-               return;
+               return( -1 );
        }
 
        /* write out the request to the add process */
        fprintf( wfp, "ADD\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", op->o_msgid );
        print_suffixes( wfp, be );
        pthread_mutex_lock( &entry2str_mutex );
        fprintf( wfp, "%s", entry2str( e, &len, 0 ) );
@@ -47,4 +47,5 @@ shell_back_add(
        read_and_send_results( be, conn, op, rfp, NULL, 0 );
 
        fclose( rfp );
+       return( 0 );
 }
index dea149e4106fc4779706c3a065000fd7e976a1e5..ac1ab4e9828b403c90946e6ad5ea3fc75dc4cb73 100644 (file)
@@ -1,9 +1,12 @@
 /* bind.c - shell backend bind function */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include "slap.h"
 #include "shell.h"
 
@@ -24,23 +27,23 @@ shell_back_bind(
        if ( si->si_bind == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
                    "bind not implemented" );
-               return;
+               return( -1 );
        }
 
        if ( (op->o_private = forkandexec( si->si_bind, &rfp, &wfp ))
            == -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
                    "could not fork/exec" );
-               return;
+               return( -1 );
        }
 
        /* write out the request to the bind process */
        fprintf( wfp, "BIND\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", op->o_msgid );
        print_suffixes( wfp, be );
        fprintf( wfp, "dn: %s\n", dn );
        fprintf( wfp, "method: %d\n", method );
-       fprintf( wfp, "credlen: %d\n", cred->bv_len );
+       fprintf( wfp, "credlen: %lu\n", cred->bv_len );
        fprintf( wfp, "cred: %s\n", cred->bv_val ); /* XXX */
        fclose( wfp );
 
index 48dfbb553be6719c9b9c9e9d858a5f80e2996f3f..9fd4343a0a083aa5e77464ac055ed4fce00231dc 100644 (file)
@@ -1,13 +1,16 @@
 /* compare.c - shell backend compare function */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
 #include "slap.h"
 #include "shell.h"
 
-void
+int
 shell_back_compare(
     Backend    *be,
     Connection *conn,
@@ -22,19 +25,19 @@ shell_back_compare(
        if ( si->si_compare == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
                    "compare not implemented" );
-               return;
+               return( -1 );
        }
 
        if ( (op->o_private = forkandexec( si->si_compare, &rfp, &wfp ))
            == -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
                    "could not fork/exec" );
-               return;
+               return( -1 );
        }
 
        /* write out the request to the compare process */
        fprintf( wfp, "COMPARE\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", op->o_msgid );
        print_suffixes( wfp, be );
        fprintf( wfp, "dn: %s\n", dn );
        fprintf( wfp, "%s: %s\n", ava->ava_type, ava->ava_value.bv_val );
@@ -44,4 +47,5 @@ shell_back_compare(
        read_and_send_results( be, conn, op, rfp, NULL, 0 );
 
        fclose( rfp );
+       return( 0 );
 }
index 5d2fa1c19a4299a386eaa4703ddc16486a8b00d0..ac411d7563dbcf02de161cd729e20f561f307be9 100644 (file)
@@ -1,14 +1,16 @@
 /* config.c - shell backend configuration file routine */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
 #include "slap.h"
 #include "shell.h"
 
-extern char    **charray_dup();
-
+void
 shell_back_config(
     Backend    *be,
     char       *fname,
index 0dc3439c008ce53ea77a642f8cafa2313585a2f6..2d55fdc429fc8dbbd4c36cc673ce114c9b12fdcb 100644 (file)
@@ -1,13 +1,16 @@
 /* delete.c - shell backend delete function */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
 #include "slap.h"
 #include "shell.h"
 
-void
+int
 shell_back_delete(
     Backend    *be,
     Connection *conn,
@@ -21,19 +24,19 @@ shell_back_delete(
        if ( si->si_delete == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
                    "delete not implemented" );
-               return;
+               return( -1 );
        }
 
        if ( (op->o_private = forkandexec( si->si_delete, &rfp, &wfp ))
            == -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
                    "could not fork/exec" );
-               return;
+               return( -1 );
        }
 
        /* write out the request to the delete process */
        fprintf( wfp, "DELETE\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", op->o_msgid );
        print_suffixes( wfp, be );
        fprintf( wfp, "dn: %s\n", dn );
        fclose( wfp );
@@ -41,4 +44,5 @@ shell_back_delete(
        /* read in the results and send them along */
        read_and_send_results( be, conn, op, rfp, NULL, 0 );
        fclose( rfp );
+       return( 0 );
 }
index aff0e5bbe446778c06ec249e3312b0d435c077b5..13f099b3316b96abccac2487d7208bb976bf5d65 100644 (file)
@@ -1,11 +1,17 @@
 /* fork.c - fork and exec a process, connecting stdin/out w/pipes */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+
 #include "slap.h"
+#include "shell.h"
 
+int
 forkandexec(
     char       **args,
     FILE       **rfp,
index 1df9c4b265d8a6c49674cfc406a10d3e8c1635f9..6a841c154ba5903cc0123182fed21ac79995829f 100644 (file)
@@ -1,11 +1,15 @@
 /* init.c - initialize shell backend */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+
 #include "slap.h"
 #include "shell.h"
 
+void
 shell_back_init(
     Backend    *be
 )
index c3863bfd364c6c6bee1c7bdd19fbaabab5ca02c6..034830b649baadb0a66f982903a0246fa74ca021 100644 (file)
@@ -10,7 +10,7 @@
 #include "slap.h"
 #include "shell.h"
 
-void
+int
 shell_back_modify(
     Backend    *be,
     Connection *conn,
@@ -26,19 +26,19 @@ shell_back_modify(
        if ( si->si_modify == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
                    "modify not implemented" );
-               return;
+               return( -1 );
        }
 
        if ( (op->o_private = forkandexec( si->si_modify, &rfp, &wfp ))
            == -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
                    "could not fork/exec" );
-               return;
+               return( -1 );
        }
 
        /* write out the request to the modify process */
        fprintf( wfp, "MODIFY\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", op->o_msgid );
        print_suffixes( wfp, be );
        fprintf( wfp, "dn: %s\n", dn );
        for ( ; mods != NULL; mods = mods->mod_next ) {
@@ -67,4 +67,6 @@ shell_back_modify(
        /* read in the results and send them along */
        read_and_send_results( be, conn, op, rfp, NULL, 0 );
        fclose( rfp );
+       return( 0 );
+
 }
index 9fd793317d19e6de0f0cf1d64722c60f4047512e..ad7cc5ad4123b6c2001adb22cb9041996f180542 100644 (file)
@@ -1,13 +1,16 @@
 /* modrdn.c - shell backend modrdn function */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include "slap.h"
 #include "shell.h"
 
-void
+int
 shell_back_modrdn(
     Backend    *be,
     Connection *conn,
@@ -23,19 +26,19 @@ shell_back_modrdn(
        if ( si->si_modrdn == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
                    "modrdn not implemented" );
-               return;
+               return( -1 );
        }
 
        if ( (op->o_private = forkandexec( si->si_modrdn, &rfp, &wfp ))
            == -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
                    "could not fork/exec" );
-               return;
+               return( -1 );
        }
 
        /* write out the request to the modrdn process */
        fprintf( wfp, "MODRDN\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", op->o_msgid );
        print_suffixes( wfp, be );
        fprintf( wfp, "dn: %s\n", dn );
        fprintf( wfp, "newrdn: %s\n", newrdn );
@@ -45,4 +48,5 @@ shell_back_modrdn(
        /* read in the results and send them along */
        read_and_send_results( be, conn, op, rfp, NULL, 0 );
        fclose( rfp );
+       return( 0 );
 }
index 675aa1f144ced8a90503c7992ba1ab3c10d18605..daa826775d0055a6d0cf113d2e47e7162935d54d 100644 (file)
@@ -1,14 +1,16 @@
 /* result.c - shell backend result reading function */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+
 #include "slap.h"
 #include "shell.h"
 
-extern Entry   *str2entry();
-
 int
 read_and_send_results(
     Backend    *be,
index 749b112a9401238704bb7b9c4fc5606483ef1cc7..ded0b2f5fcc2851f73d5c8d503ddcbecfb2c015b 100644 (file)
@@ -1,15 +1,16 @@
 /* search.c - shell backend search function */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include "slap.h"
 #include "shell.h"
 
-extern Entry   *str2entry();
-
-void
+int
 shell_back_search(
     Backend    *be,
     Connection *conn,
@@ -34,19 +35,19 @@ shell_back_search(
        if ( si->si_search == NULL ) {
                send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
                    "search not implemented" );
-               return;
+               return( -1 );
        }
 
        if ( (op->o_private = forkandexec( si->si_search, &rfp, &wfp ))
            == -1 ) {
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
                    "could not fork/exec" );
-               return;
+               return( -1 );
        }
 
        /* write out the request to the search process */
        fprintf( wfp, "SEARCH\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", op->o_msgid );
        print_suffixes( wfp, be );
        fprintf( wfp, "base: %s\n", base );
        fprintf( wfp, "scope: %d\n", scope );
@@ -66,4 +67,5 @@ shell_back_search(
        read_and_send_results( be, conn, op, rfp, attrs, attrsonly );
 
        fclose( rfp );
+       return( 0 );
 }
index 5ef493c0458ac4e7b4c9304156ed74f629d79341..bb76f15fd95726ee86477f03396cfc4f21725930 100644 (file)
@@ -1,5 +1,12 @@
 /* shell.h - shell backend header file */
 
+#ifndef SLAPD_SHELL_H
+#define SLAPD_SHELL_H
+
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
+
 struct shellinfo {
        char    **si_bind;      /* cmd + args to exec for bind    */
        char    **si_unbind;    /* cmd + args to exec for unbind  */
@@ -11,3 +18,14 @@ struct shellinfo {
        char    **si_delete;    /* cmd + args to exec for delete  */
        char    **si_abandon;   /* cmd + args to exec for abandon */
 };
+
+struct backend;
+struct conn;
+struct op;
+extern int forkandexec LDAP_P((char **args, FILE **rfp, FILE **wfp));
+extern void print_suffixes LDAP_P((FILE *fp, struct backend *be));
+extern int read_and_send_results LDAP_P((struct backend *be, struct conn *conn, struct op *op, FILE *fp, char **attrs, int attrsonly));
+
+LDAP_END_DECL
+
+#endif
index 649fe96c137703e0759a2992aa6663f11622e19f..84bb05138ac789ee5a341f08e6a04806543ae561 100644 (file)
@@ -1,9 +1,12 @@
 /* unbind.c - shell backend unbind function */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include "slap.h"
 #include "shell.h"
 
@@ -11,10 +14,7 @@ void
 shell_back_unbind(
     Backend            *be,
     Connection         *conn,
-    Operation          *op,
-    char               *dn,
-    int                        method,
-    struct berval      *cred
+    Operation          *op
 )
 {
        struct shellinfo        *si = (struct shellinfo *) be->be_private;
@@ -35,9 +35,9 @@ shell_back_unbind(
 
        /* write out the request to the unbind process */
        fprintf( wfp, "UNBIND\n" );
-       fprintf( wfp, "msgid: %d\n", op->o_msgid );
+       fprintf( wfp, "msgid: %ld\n", op->o_msgid );
        print_suffixes( wfp, be );
-       fprintf( wfp, "dn: %s\n", dn );
+       fprintf( wfp, "dn: %s\n", (conn->c_dn ? conn->c_dn : "") );
        fclose( wfp );
 
        /* no response to unbind */
index 39fdd279d4363bcd6a4d74739254f708f1ab2ddf..61511ff7486c4f6468539a96b02f90b2972dbe27 100644 (file)
 
 #include "slap.h"
 
-#ifdef SLAPD_LDBM
-extern int     ldbm_back_bind();
-extern int     ldbm_back_unbind();
-extern int     ldbm_back_search();
-extern int     ldbm_back_compare();
-extern int     ldbm_back_modify();
-extern int     ldbm_back_modrdn();
-extern int     ldbm_back_add();
-extern int     ldbm_back_delete();
-extern int     ldbm_back_abandon();
-extern int     ldbm_back_config();
-extern int     ldbm_back_init();
-extern int     ldbm_back_close();
-extern int      ldbm_back_group();
-#endif
-
-#ifdef SLAPD_PASSWD
-extern int     passwd_back_search();
-extern int     passwd_back_config();
-#endif
-
-#ifdef SLAPD_SHELL
-extern int     shell_back_bind();
-extern int     shell_back_unbind();
-extern int     shell_back_search();
-extern int     shell_back_compare();
-extern int     shell_back_modify();
-extern int     shell_back_modrdn();
-extern int     shell_back_add();
-extern int     shell_back_delete();
-extern int     shell_back_abandon();
-extern int     shell_back_config();
-extern int     shell_back_init();
-#endif
-
-extern int     defsize;
-extern int     deftime;
 
 #define BACKEND_GRAB_SIZE      10
 
@@ -253,7 +216,7 @@ be_isroot_pw( Backend *be, char *dn, struct berval *cred )
 }
 
 void
-be_close()
+be_close( void )
 {
        int     i;
 
@@ -282,7 +245,13 @@ be_unbind(
 
 #ifdef SLAPD_ACLGROUPS
 int 
-be_group(Backend *be, char *bdn, char *edn, char *objectclassValue, char *groupattrName)
+be_group(
+       Backend *be,
+       char    *bdn,
+       char    *edn,
+       char    *objectclassValue,
+       char    *groupattrName
+)
 {
         if (be->be_group)
                 return(be->be_group(be, bdn, edn, objectclassValue, groupattrName));
index 8d3979992c57bca3e662fffebbc0c3de67f42878..7cb354ac1a75e7e6588d7f4d101d79062bc364cc 100644 (file)
 
 #include "slap.h"
 
-extern Backend *select_backend();
-extern char    *suffixAlias();
-
-extern char    *default_referral;
-
 void
 do_bind(
     Connection *conn,
index 519720e238862417b221b7fcb5b288f995e2ae0e..366e7bc1f17972b09ecefd3f648ce6a58c48bff5 100644 (file)
@@ -17,7 +17,7 @@ ch_malloc(
        void    *new;
 
        if ( (new = (void *) malloc( size )) == NULL ) {
-               Debug( LDAP_DEBUG_ANY, "malloc of %d bytes failed\n", size, 0, 0 );
+               Debug( LDAP_DEBUG_ANY, "malloc of %lu bytes failed\n", size, 0, 0 );
                exit( 1 );
        }
 
@@ -37,7 +37,7 @@ ch_realloc(
        }
 
        if ( (new = (void *) realloc( block, size )) == NULL ) {
-               Debug( LDAP_DEBUG_ANY, "realloc of %d bytes failed\n", size, 0, 0 );
+               Debug( LDAP_DEBUG_ANY, "realloc of %lu bytes failed\n", size, 0, 0 );
                exit( 1 );
        }
 
@@ -53,7 +53,7 @@ ch_calloc(
        void    *new;
 
        if ( (new = (void *) calloc( nelem, size )) == NULL ) {
-               Debug( LDAP_DEBUG_ANY, "calloc of %d elems of %d bytes failed\n",
+               Debug( LDAP_DEBUG_ANY, "calloc of %lu elems of %lu bytes failed\n",
                  nelem, size, 0 );
                exit( 1 );
        }
index 248c8b1ec7f9884cb49845af0d65abf065bf84a7..88a63e8b21b21f693a6f11e5aba988149b75592c 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
 
-extern Backend *select_backend();
+#include <ac/socket.h>
 
-extern char    *default_referral;
+#include "slap.h"
 
 void
 do_compare(
index 66050586ab794ac4f4e258306e58de0e293206ac..715dd8baee819d9ca587df288b4edce6787e9c92 100644 (file)
@@ -1,19 +1,18 @@
 /* config.c - configuration file handling routines */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
+
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/socket.h>
+
 #include "ldapconfig.h"
+#include "slap.h"
 
 #define MAXARGS        100
 
-extern Backend *new_backend();
-extern char    *default_referral;
-extern int     ldap_syslog;
-extern int     global_schemacheck;
-
 /*
  * defaults for various global variables
  */
@@ -25,11 +24,11 @@ char                *replogfile;
 int            global_lastmod;
 char           *ldap_srvtab = "";
 
-static char    *fp_getline();
-static void    fp_getline_init();
-static void    fp_parse_line();
+static char    *fp_getline(FILE *fp, int *lineno);
+static void    fp_getline_init(int *lineno);
+static void    fp_parse_line(char *line, int *argcp, char **argv);
 
-static char    *strtok_quote();
+static char    *strtok_quote(char *line, char *sep);
 
 void
 read_config( char *fname, Backend **bep, FILE *pfp )
@@ -81,6 +80,9 @@ read_config( char *fname, Backend **bep, FILE *pfp )
                        *bep = new_backend( cargv[1] );
                        be = *bep;
 
+               /* assign a default depth limit for alias deref */
+               be->be_maxDerefDepth = SLAPD_DEFAULT_MAXDEREFDEPTH; 
+
                /* set size limit */
                } else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
                        if ( cargc < 2 ) {
@@ -131,6 +133,54 @@ read_config( char *fname, Backend **bep, FILE *pfp )
                                charray_add( &be->be_suffix, dn );
                        }
 
+                /* set database suffixAlias */
+                } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
+                        if ( cargc < 2 ) {
+                                Debug( LDAP_DEBUG_ANY,
+                    "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
+                                    fname, lineno, 0 );
+                                exit( 1 );
+                        } else if ( cargc < 3 ) {
+                                Debug( LDAP_DEBUG_ANY,
+                    "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
+                                    fname, lineno, 0 );
+                                exit( 1 );
+                        } else if ( cargc > 3 ) {
+                                Debug( LDAP_DEBUG_ANY,
+    "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
+                                    fname, lineno, 0 );
+                        }
+                        if ( be == NULL ) {
+                                Debug( LDAP_DEBUG_ANY,
+"%s: line %d: suffixAlias line must appear inside a database definition (ignored)\n",
+                                    fname, lineno, 0 );
+                        } else {
+                                dn = strdup( cargv[1] );
+                                (void) dn_normalize( dn );
+                                charray_add( &be->be_suffixAlias, dn );
+
+                                dn = strdup( cargv[2] );
+                                (void) dn_normalize( dn );
+                                charray_add( &be->be_suffixAlias, dn );
+                        }
+
+               /* set max deref depth */
+               } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
+                       if ( cargc < 2 ) {
+                               Debug( LDAP_DEBUG_ANY,
+                   "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
+                                   fname, lineno, 0 );
+                               exit( 1 );
+                       }
+                       if ( be == NULL ) {
+                               Debug( LDAP_DEBUG_ANY,
+"%s: line %d: depth line must appear inside a database definition (ignored)\n",
+                                   fname, lineno, 0 );
+                       } else {
+                           be->be_maxDerefDepth = atoi (cargv[1]);
+                       }
+
+
                /* set magic "root" dn for this database */
                } else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
                        if ( cargc < 2 ) {
index 5599193006cdf4a53cdc6f32354036aaf5ad9d4c..9ad40ebedb63a8282037afcc054f3022049157e9 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
 #include "ldapconfig.h"
+#include "slap.h"
 
 #if defined( SLAPD_CONFIG_DN )
 
-extern int             nbackends;
-extern Backend         *backends;
-extern char            *default_referral;
-
 /*
  * no mutex protection in here - take our chances!
  */
@@ -40,6 +39,9 @@ config_info( Connection *conn, Operation *op )
        vals[1] = NULL;
 
        e = (Entry *) ch_calloc( 1, sizeof(Entry) );
+       /* initialize reader/writer lock */
+       entry_rdwr_init(e);
+
        e->e_attrs = NULL;
        e->e_dn = strdup( SLAPD_CONFIG_DN );
 
index abc10cdfced93e96c7e52a4da075c3b227683f16..36fca0b705356a6b268055176c6eb5dee9ad076e 100644 (file)
 
 #include "slap.h"
 
-extern Operation       *op_add();
-extern int             active_threads;
-extern pthread_mutex_t active_threads_mutex;
-extern pthread_mutex_t new_conn_mutex;
-extern long            ops_initiated;
-extern long            ops_completed;
-extern pthread_mutex_t ops_mutex;
-extern pthread_t       listener_tid;
-
 struct co_arg {
        Connection      *co_conn;
        Operation       *co_op;
@@ -30,9 +21,10 @@ struct co_arg {
  * calls the appropriate stub to handle it.
  */
 
-static void
-connection_operation( struct co_arg *arg )
+static void *
+connection_operation( void *arg_v )
 {
+       struct co_arg   *arg = arg_v;
        unsigned long   len;
 
        pthread_mutex_lock( &arg->co_conn->c_opsmutex );
@@ -90,7 +82,7 @@ connection_operation( struct co_arg *arg )
                break;
 
        default:
-               Debug( LDAP_DEBUG_ANY, "unknown request 0x%x\n",
+               Debug( LDAP_DEBUG_ANY, "unknown request 0x%lx\n",
                    arg->co_op->o_tag, 0, 0 );
                break;
        }
@@ -109,6 +101,7 @@ connection_operation( struct co_arg *arg )
        pthread_mutex_lock( &active_threads_mutex );
        active_threads--;
        pthread_mutex_unlock( &active_threads_mutex );
+       return NULL;
 }
 
 void
@@ -136,7 +129,7 @@ connection_activity(
                    "ber_get_next on fd %d failed errno %d (%s)\n",
                    conn->c_sb.sb_sd, errno, errno > -1 && errno < sys_nerr ?
                    sys_errlist[errno] : "unknown" );
-               Debug( LDAP_DEBUG_TRACE, "*** got %d of %d so far\n",
+               Debug( LDAP_DEBUG_TRACE, "*** got %d of %lu so far\n",
                    conn->c_currentber->ber_rwptr - conn->c_currentber->ber_buf,
                    conn->c_currentber->ber_len, 0 );
 
@@ -155,7 +148,7 @@ connection_activity(
 
        if ( (tag = ber_get_int( ber, &msgid )) != LDAP_TAG_MSGID ) {
                /* log, close and send error */
-               Debug( LDAP_DEBUG_ANY, "ber_get_int returns 0x%x\n", tag, 0,
+               Debug( LDAP_DEBUG_ANY, "ber_get_int returns 0x%lx\n", tag, 0,
                    0 );
                ber_free( ber, 1 );
 
@@ -165,7 +158,7 @@ connection_activity(
 
        if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) {
                /* log, close and send error */
-               Debug( LDAP_DEBUG_ANY, "ber_peek_tag returns 0x%x\n", tag, 0,
+               Debug( LDAP_DEBUG_ANY, "ber_peek_tag returns 0x%lx\n", tag, 0,
                    0 );
                ber_free( ber, 1 );
 
index 161fb79cf0e2bf6ce67b05be0ff4d7efba0a67ab..48eb7f13d3a5212a2bcab052772c4ad67a6912c0 100644 (file)
@@ -1,55 +1,47 @@
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <signal.h>
-#ifdef _AIX
-#include <sys/select.h>
-#endif
-#include "slap.h"
+
+/* Revision history
+ *
+ * 5-Jun-96    hodges
+ *     Added locking of new_conn_mutex when traversing the c[] array.
+ */
+
 #include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/ctype.h>
+#include <ac/errno.h>
+#include <ac/signal.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
 #include "ldapconfig.h"
-#ifdef NEED_FILIO
+#include "slap.h"
+
+#ifdef HAVE_SYS_FILIO_H
 #include <sys/filio.h>
-#else /* NEED_FILIO */
+#elif HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
-#endif /* NEED_FILIO */
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
+#endif
 
-extern Operation       *op_add();
+#ifdef HAVE_TCPD
+#include <tcpd.h>
 
-#ifndef SYSERRLIST_IN_STDIO
-extern int             sys_nerr;
-extern char            *sys_errlist[];
-#endif
-extern time_t          currenttime;
-extern pthread_mutex_t currenttime_mutex;
-extern int             active_threads;
-extern pthread_mutex_t active_threads_mutex;
-extern pthread_mutex_t new_conn_mutex;
-extern int             slapd_shutdown;
-extern pthread_t       listener_tid;
-extern int             num_conns;
-extern pthread_mutex_t ops_mutex;
-extern int             g_argc;
-extern char            **g_argv;
+int allow_severity = LOG_INFO;
+int deny_severity = LOG_NOTICE;
+#endif /* TCP Wrappers */
 
 int            dtblsize;
 Connection     *c;
 
-static void    set_shutdown();
-static void    do_nothing();
+static void    set_shutdown(int sig);
+static void    do_nothing  (int sig);
 
-void
-daemon(
-    int        port
+void *
+slapd_daemon(
+    void *port
 )
 {
        Operation               *o;
@@ -63,11 +55,19 @@ daemon(
        FILE                    *fp;
        int                     on = 1;
 
-#ifdef USE_SYSCONF
-        dtblsize = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
-        dtblsize = getdtablesize();
-#endif /* USE_SYSCONF */
+#ifdef HAVE_SYSCONF
+       dtblsize = sysconf( _SC_OPEN_MAX );
+#elif HAVE_GETDTABLESIZE
+       dtblsize = getdtablesize();
+#else
+       dtblsize = FD_SETSIZE
+#endif
+
+#ifdef FD_SETSIZE
+       if(dtblsize > FD_SETSIZE) {
+               dtblsize = FD_SETSIZE;
+       }
+#endif /* !FD_SETSIZE */
 
        c = (Connection *) ch_calloc( 1, dtblsize * sizeof(Connection) );
 
@@ -111,7 +111,7 @@ daemon(
        (void) memset( (void *) &addr, '\0', sizeof(addr) );
        addr.sin_family = AF_INET;
        addr.sin_addr.s_addr = INADDR_ANY;
-       addr.sin_port = htons( port );
+       addr.sin_port = htons( (int)port );
        if ( bind( tcps, (struct sockaddr *) &addr, sizeof(addr) ) == -1 ) {
                Debug( LDAP_DEBUG_ANY, "bind() failed errno %d (%s)\n",
                    errno, errno > -1 && errno < sys_nerr ? sys_errlist[errno] :
@@ -127,15 +127,25 @@ daemon(
        }
 
        (void) SIGNAL( SIGPIPE, SIG_IGN );
-       (void) SIGNAL( SIGUSR1, (void *) do_nothing );
-       (void) SIGNAL( SIGUSR2, (void *) set_shutdown );
-       (void) SIGNAL( SIGTERM, (void *) set_shutdown );
-       (void) SIGNAL( SIGHUP, (void *) set_shutdown );
+#ifdef HAVE_LINUX_THREADS
+       /*
+        * LinuxThreads are implemented using SIGUSR1/USR2,
+        * so we'll use SIGSTKFLT and SIGUNUSED
+        */
+       (void) SIGNAL( SIGSTKFLT, do_nothing );
+       (void) SIGNAL( SIGUNUSED, set_shutdown );
+#else  /* !linux */
+       (void) SIGNAL( SIGUSR1, do_nothing );
+       (void) SIGNAL( SIGUSR2, set_shutdown );
+#endif /* !linux */
+       (void) SIGNAL( SIGTERM, set_shutdown );
+       (void) SIGNAL( SIGINT, set_shutdown );
+       (void) SIGNAL( SIGHUP, set_shutdown );
 
        Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 );
 #ifdef SLAPD_PIDFILE
        if ( (fp = fopen( SLAPD_PIDFILE, "w" )) != NULL ) {
-               fprintf( fp, "%d\n", getpid() );
+               fprintf( fp, "%d\n", (int) getpid() );
                fclose( fp );
        }
 #endif
@@ -156,14 +166,22 @@ daemon(
                struct timeval          *tvp;
                int                     len, pid;
 
+               char    *client_name;
+               char    *client_addr;
+
                FD_ZERO( &writefds );
                FD_ZERO( &readfds );
                FD_SET( tcps, &readfds );
 
+               zero.tv_sec = 0;
+               zero.tv_usec = 0;
+
                pthread_mutex_lock( &active_threads_mutex );
                Debug( LDAP_DEBUG_CONNS,
                    "listening for connections on %d, activity on:",
                    tcps, 0, 0 );
+
+               pthread_mutex_lock( &new_conn_mutex );
                for ( i = 0; i < dtblsize; i++ ) {
                        if ( c[i].c_sb.sb_sd != -1 ) {
                                FD_SET( c[i].c_sb.sb_sd, &readfds );
@@ -176,19 +194,18 @@ daemon(
                        }
                }
                Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 );
+               pthread_mutex_unlock( &new_conn_mutex );
 
-               zero.tv_sec = 0;
-               zero.tv_usec = 0;
                Debug( LDAP_DEBUG_CONNS, "before select active_threads %d\n",
                    active_threads, 0, 0 );
-#ifdef PTHREAD_PREEMPTIVE
+#ifdef PREEMPTIVE_THREADS
                tvp = NULL;
 #else
                tvp = active_threads ? &zero : NULL;
 #endif
                pthread_mutex_unlock( &active_threads_mutex );
 
-               switch ( select( dtblsize, &readfds, &writefds, 0, tvp ) ) {
+               switch ( i = select( dtblsize, &readfds, &writefds, 0, tvp ) ) {
                case -1:        /* failure - try again */
                        Debug( LDAP_DEBUG_CONNS,
                            "select failed errno %d (%s)\n",
@@ -203,7 +220,7 @@ daemon(
                        continue;
 
                default:        /* something happened - deal with it */
-                       Debug( LDAP_DEBUG_CONNS, "select activity\n", 0, 0, 0 );
+                       Debug( LDAP_DEBUG_CONNS, "select activity on %d descriptors\n", i, 0, 0 );
                        ;       /* FALL */
                }
                pthread_mutex_lock( &currenttime_mutex );
@@ -225,8 +242,9 @@ daemon(
                        }
                        if ( ioctl( ns, FIONBIO, (caddr_t) &on ) == -1 ) {
                                Debug( LDAP_DEBUG_ANY,
-                                   "FIONBIO ioctl on %d faled\n", ns, 0, 0 );
+                                   "FIONBIO ioctl on %d failed\n", ns, 0, 0 );
                        }
+
                        c[ns].c_sb.sb_sd = ns;
                        Debug( LDAP_DEBUG_CONNS, "new connection on %d\n", ns,
                            0, 0 );
@@ -234,43 +252,76 @@ daemon(
                        pthread_mutex_lock( &ops_mutex );
                        c[ns].c_connid = num_conns++;
                        pthread_mutex_unlock( &ops_mutex );
+
                        len = sizeof(from);
+
                        if ( getpeername( ns, (struct sockaddr *) &from, &len )
                            == 0 ) {
-                               char    *s;
-#ifdef REVERSE_LOOKUP
+                               char *s;
+                               client_addr = inet_ntoa( from.sin_addr );
+
+#if defined(SLAPD_RLOOKUPS) || defined(HAVE_TCPD)
                                hp = gethostbyaddr( (char *)
                                    &(from.sin_addr.s_addr),
                                    sizeof(from.sin_addr.s_addr), AF_INET );
-#else
-                               hp = NULL;
-#endif
 
-                               Statslog( LDAP_DEBUG_STATS,
-                                   "conn=%d fd=%d connection from %s (%s)\n",
-                                   c[ns].c_connid, ns, hp == NULL ? "unknown"
-                                   : hp->h_name, inet_ntoa( from.sin_addr ),
-                                   0 );
+                               if(hp) {
+                                       client_name = hp->h_name;
 
-                               if ( c[ns].c_addr != NULL ) {
-                                       free( c[ns].c_addr );
-                               }
-                               c[ns].c_addr = strdup( inet_ntoa(
-                                   from.sin_addr ) );
-                               if ( c[ns].c_domain != NULL ) {
-                                       free( c[ns].c_domain );
-                               }
-                               c[ns].c_domain = strdup( hp == NULL ? "" :
-                                   hp->h_name );
-                               /* normalize the domain */
-                               for ( s = c[ns].c_domain; *s; s++ ) {
-                                       *s = TOLOWER( *s );
+                                       /* normalize the domain */
+                                       for ( s = client_name; *s; s++ ) {
+                                               *s = TOLOWER( *s );
+                                       }
+
+                               } else {
+                                       client_name = NULL;
                                }
+#else
+                               client_name = NULL;
+#endif
+
                        } else {
+                               client_name = NULL;;
+                               client_addr = NULL;
+                       }
+
+#ifdef HAVE_TCPD
+                       if(!hosts_ctl("slapd", client_name, client_addr,
+                               STRING_UNKNOWN))
+                       {
+                               /* DENY ACCESS */
                                Statslog( LDAP_DEBUG_STATS,
-                                   "conn=%d fd=%d connection from unknown\n",
-                                   c[ns].c_connid, ns, 0, 0, 0 );
+                                "conn=%d fd=%d connection from %s (%s) denied.\n",
+                                       c[ns].c_connid, ns,
+                                               client_name == NULL ? "unknown" : client_name,
+                                               client_addr == NULL ? "unknown" : client_addr,
+                                 0 );
+
+                               close(ns);
+                               pthread_mutex_unlock( &new_conn_mutex );
+                               continue;
+                       }
+#endif /* HAVE_TCPD */
+
+                       Statslog( LDAP_DEBUG_STATS,
+                           "conn=%d fd=%d connection from %s (%s) accepted.\n",
+                               c[ns].c_connid, ns,
+                                       client_name == NULL ? "unknown" : client_name,
+                                       client_addr == NULL ? "unknown" : client_addr,
+                            0 );
+
+                       if ( c[ns].c_addr != NULL ) {
+                               free( c[ns].c_addr );
+                       }
+                       c[ns].c_addr = strdup( client_addr );
+
+                       if ( c[ns].c_domain != NULL ) {
+                               free( c[ns].c_domain );
                        }
+
+                       c[ns].c_domain = strdup( client_name == NULL
+                               ? "" : client_name );
+
                        pthread_mutex_lock( &c[ns].c_dnmutex );
                        if ( c[ns].c_dn != NULL ) {
                                free( c[ns].c_dn );
@@ -342,22 +393,41 @@ daemon(
            0 );
        be_close();
        Debug( LDAP_DEBUG_ANY, "slapd stopping\n", 0, 0, 0 );
+       return NULL;
 }
 
 static void
-set_shutdown()
+set_shutdown( int sig )
 {
-       Debug( LDAP_DEBUG_ANY, "slapd got shutdown signal\n", 0, 0, 0 );
+       Debug( LDAP_DEBUG_ANY, "slapd got shutdown signal %d\n", sig, 0, 0 );
        slapd_shutdown = 1;
+#ifdef HAVE_LINUX_THREADS
+       /*
+        * LinuxThreads are implemented using SIGUSR1/USR2,
+        * so we'll use SIGSTKFLT and SIGUNUSED
+        */
+       pthread_kill( listener_tid, SIGSTKFLT );
+       (void) SIGNAL( SIGUNUSED, set_shutdown );
+#else /* !linux */
        pthread_kill( listener_tid, SIGUSR1 );
-       (void) SIGNAL( SIGUSR2, (void *) set_shutdown );
-       (void) SIGNAL( SIGTERM, (void *) set_shutdown );
-       (void) SIGNAL( SIGHUP, (void *) set_shutdown );
+       (void) SIGNAL( SIGUSR2, set_shutdown );
+#endif /* !linux */
+       (void) SIGNAL( SIGTERM, set_shutdown );
+       (void) SIGNAL( SIGINT, set_shutdown );
+       (void) SIGNAL( SIGHUP, set_shutdown );
 }
 
 static void
-do_nothing()
+do_nothing( int sig )
 {
-       Debug( LDAP_DEBUG_TRACE, "slapd got SIGUSR1\n", 0, 0, 0 );
-       (void) SIGNAL( SIGUSR1, (void *) do_nothing );
+       Debug( LDAP_DEBUG_TRACE, "slapd got do_nothing signal %d\n", sig, 0, 0 );
+#ifdef HAVE_LINUX_THREADS
+       /*
+        * LinuxThreads are implemented using SIGUSR1/USR2,
+        * so we'll use SIGSTKFLT and SIGUNUSED
+        */
+       (void) SIGNAL( SIGSTKFLT, do_nothing );
+#else /* !linux */
+       (void) SIGNAL( SIGUSR1, do_nothing );
+#endif /* !linux */
 }
index bbab47806c0d7d24d7181125d39cfc485bdc898f..a3df326eb376584cfdfd3cc70f5bd19ba03c615e 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
 
-extern Backend *select_backend();
+#include <ac/string.h>
+#include <ac/socket.h>
 
-extern char    *default_referral;
+#include "slap.h"
 
 void
 do_delete(
@@ -62,6 +61,9 @@ do_delete(
                return;
        }
 
+        /* alias suffix if approp */
+        dn = suffixAlias ( dn, op, be );
+
        /*
         * do the delete if 1 && (2 || 3)
         * 1) there is a delete function implemented in this backend;
diff --git a/servers/slapd/detach.c b/servers/slapd/detach.c
deleted file mode 100644 (file)
index 7b3fdab..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 1990, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#ifdef SVR4
-#include <sys/stat.h>
-#endif /* svr4 */
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <signal.h>
-#include "portable.h"
-
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
-
-
-detach()
-{
-       int             i, sd, nbits;
-#ifdef LDAP_DEBUG
-       extern int      ldap_debug;
-#endif
-
-#ifdef USE_SYSCONF
-       nbits = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
-       nbits = getdtablesize();
-#endif /* USE_SYSCONF */
-
-#ifdef LDAP_DEBUG
-       if ( ldap_debug == 0 ) {
-#endif
-               for ( i = 0; i < 5; i++ ) {
-#if defined( sunos5 ) && defined( THREAD_SUNOS5_LWP )
-                       switch ( fork1() ) {
-#else
-                       switch ( fork() ) {
-#endif
-                       case -1:
-                               sleep( 5 );
-                               continue;
-
-                       case 0:
-                               break;
-
-                       default:
-                               _exit( 0 );
-                       }
-                       break;
-               }
-
-/*
-               for ( i = 3; i < nbits; i++ )
-                       close( i );
-*/
-
-               (void) chdir( "/" );
-
-               if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
-                       perror( "/dev/null" );
-                       exit( 1 );
-               }
-               if ( isatty( 0 ) )
-                       (void) dup2( sd, 0 );
-               if ( isatty( 1 ) )
-                       (void) dup2( sd, 1 );
-               if ( isatty(2) )
-                       (void) dup2( sd, 2 );
-               close( sd );
-
-#ifdef USE_SETSID
-               setsid();
-#else /* USE_SETSID */
-               if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
-                       (void) ioctl( sd, TIOCNOTTY, NULL );
-                       (void) close( sd );
-               }
-#endif /* USE_SETSID */
-#ifdef LDAP_DEBUG
-       } 
-#endif
-
-       (void) SIGNAL( SIGPIPE, SIG_IGN );
-}
index 226937efa99f521a9c0cf0d6ef98deeb631f7fe7..bd51b3c13d9d7c8c7616517c0c2045da21f09ac1 100644 (file)
@@ -1,15 +1,15 @@
 /* dn.c - routines for dealing with distinguished names */
 
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
 #include "portable.h"
-#include "slap.h"
 
-static char    **dn_explode();
+#include <stdio.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "slap.h"
 
 #define DNSEPARATOR(c) (c == ',' || c == ';')
 #define SEPARATOR(c)   (c == ',' || c == ';' || c == '+')
@@ -206,7 +206,7 @@ dn_parent(
                }
        }
 
-       return( NULL );
+       return( strdup("") );
 }
 
 /*
index 80617959e04fa3a386b29982ecb5bb5aa0b0880e..f9f397546eeb09c4288e5e7e5109aadd619182f8 100644 (file)
@@ -10,9 +10,6 @@
 
 #include "slap.h"
 
-void   entry_free();
-char   *entry2str();
-
 static unsigned char   *ebuf;  /* buf returned by entry2str             */
 static unsigned char   *ecur;  /* pointer to end of currently used ebuf */
 static int             emaxsize;/* max size of ebuf                     */
@@ -90,7 +87,7 @@ str2entry( char       *s )
                if ( strcasecmp( type, "dn" ) == 0 ) {
                        if ( e->e_dn != NULL ) {
                                Debug( LDAP_DEBUG_ANY,
   "str2entry: entry %d has multiple dns \"%s\" and \"%s\" (second ignored)\n",
"str2entry: entry %lu has multiple dns \"%s\" and \"%s\" (second ignored)\n",
                                    e->e_id, e->e_dn, value );
                                continue;
                        }
@@ -111,13 +108,13 @@ str2entry( char   *s )
 
        /* check to make sure there was a dn: line */
        if ( e->e_dn == NULL ) {
-               Debug( LDAP_DEBUG_ANY, "str2entry: entry %d has no dn\n",
+               Debug( LDAP_DEBUG_ANY, "str2entry: entry %lu has no dn\n",
                    e->e_id, 0, 0 );
                entry_free( e );
                return( NULL );
        }
 
-       Debug( LDAP_DEBUG_TRACE, "<= str2entry 0x%x\n", e, 0, 0 );
+       Debug(LDAP_DEBUG_TRACE, "<= str2entry 0x%lx\n", (unsigned long)e, 0,0);
 
        return( e );
 }
@@ -261,4 +258,3 @@ entry_rdwr_init(Entry *e)
 {
        return pthread_rdwr_init_np(&e->e_rdwr, NULL);
 }
-
index 4f76fa55b9742bb3f8d5c31aa915edbed5439637..86d8dabcff7d5f0ca86f458279631a32ae04ea41 100644 (file)
@@ -9,10 +9,8 @@
 
 #include "slap.h"
 
-static int     get_filter_list();
-static int     get_substring_filter();
-
-extern int     get_ava();
+static int     get_filter_list(Connection *conn, BerElement *ber, Filter **f, char **fstr);
+static int     get_substring_filter(Connection *conn, BerElement *ber, Filter *f, char **fstr);
 
 int
 get_filter( Connection *conn, BerElement *ber, Filter **filt, char **fstr )
@@ -166,8 +164,8 @@ get_filter( Connection *conn, BerElement *ber, Filter **filt, char **fstr )
                break;
 
        default:
-               Debug( LDAP_DEBUG_ANY, "unknown filter type %d\n", f->f_choice,
-                   0, 0 );
+               Debug( LDAP_DEBUG_ANY, "unknown filter type %lu\n",
+                      f->f_choice, 0, 0 );
                err = LDAP_PROTOCOL_ERROR;
                break;
        }
@@ -373,8 +371,8 @@ filter_free( Filter *f )
                break;
 
        default:
-               Debug( LDAP_DEBUG_ANY, "unknown filter type %d\n", f->f_choice,
-                   0, 0 );
+               Debug( LDAP_DEBUG_ANY, "unknown filter type %lu\n",
+                      f->f_choice, 0, 0 );
                break;
        }
        free( f );
@@ -445,7 +443,7 @@ filter_print( Filter *f )
                break;
 
        default:
-               fprintf( stderr, "unknown type %d", f->f_choice );
+               fprintf( stderr, "unknown type %lu", f->f_choice );
                break;
        }
 }
index 5d1459ca94ead522b88bc3b0c7be431996264b62..7d429f27c58cab6567651aca4c05fdaca8552cdb 100644 (file)
 
 #include "slap.h"
 
-extern Attribute       *attr_find();
-extern char            *first_word();
-extern char            *next_word();
-extern char            *phonetic();
-
-static int     test_filter_list();
-static int     test_substring_filter();
-static int     test_ava_filter();
-static int     test_approx_filter();
-static int     test_presence_filter();
+static int     test_filter_list(Backend *be, Connection *conn, Operation *op, Entry *e, Filter *flist, int ftype);
+static int     test_substring_filter(Backend *be, Connection *conn, Operation *op, Entry *e, Filter *f);
+static int     test_ava_filter(Backend *be, Connection *conn, Operation *op, Entry *e, Ava *ava, int type);
+static int     test_approx_filter(Backend *be, Connection *conn, Operation *op, Entry *e, Ava *ava);
+static int     test_presence_filter(Backend *be, Connection *conn, Operation *op, Entry *e, char *type);
 
 /*
  * test_filter - test a filter against a single entry.
@@ -93,7 +88,7 @@ test_filter(
                break;
 
        default:
-               Debug( LDAP_DEBUG_ANY, "    unknown filter type %d\n",
+               Debug( LDAP_DEBUG_ANY, "    unknown filter type %lu\n",
                    f->f_choice, 0, 0 );
                rc = -1;
        }
index 03dd850f0e86c8e92e6fa4371741334114c32e9f..05c965f0787647d56ea16871e47a936c0de8da41 100644 (file)
@@ -1,28 +1,18 @@
 /* init.c - initialize various things */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
 #include "portable.h"
 #include "slap.h"
 
-extern pthread_mutex_t active_threads_mutex;
-extern pthread_mutex_t new_conn_mutex;
-extern pthread_mutex_t currenttime_mutex;
-extern pthread_mutex_t entry2str_mutex;
-extern pthread_mutex_t replog_mutex;
-extern pthread_mutex_t ops_mutex;
-extern pthread_mutex_t num_sent_mutex;
-#ifndef sunos5
-extern pthread_mutex_t regex_mutex;
-#endif
-
-init()
+void
+init( void )
 {
        pthread_mutex_init( &active_threads_mutex, pthread_mutexattr_default );
        pthread_mutex_init( &new_conn_mutex, pthread_mutexattr_default );
@@ -31,7 +21,4 @@ init()
        pthread_mutex_init( &replog_mutex, pthread_mutexattr_default );
        pthread_mutex_init( &ops_mutex, pthread_mutexattr_default );
        pthread_mutex_init( &num_sent_mutex, pthread_mutexattr_default );
-#ifndef sunos5
-       pthread_mutex_init( &regex_mutex, pthread_mutexattr_default );
-#endif
 }
index ad80443eb93755f78c803c416678309aeccc60b1..f634b220aa3026518a5e849b037b0a5c38df7dc8 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 
+#include <ac/string.h>
 #include <ac/socket.h>
 #include <ac/time.h>
 #include <ac/unistd.h>
index f38fea58e4c95d6963a46e7cbc39352d2b6785a1..322362febf0e9d0f1d5e8eb9db2e56ec676f526a 100644 (file)
@@ -5,16 +5,12 @@
 #include <ac/socket.h>
 #include <ac/string.h>
 #include <ac/time.h>
+#include <ac/unistd.h>
 
-#include "slap.h"
 #include "ldapconfig.h"
+#include "slap.h"
 #include "lutil.h"                     /* Get lutil_detach() */
 
-extern void    slapd_daemon();
-extern int     lber_debug;
-
-extern char Versionstr[];
-
 
 /*
  * read-only global variables or variables only written by the listener
@@ -58,16 +54,13 @@ pthread_mutex_t     entry2str_mutex;
 pthread_mutex_t        replog_mutex;
 
 static void
-usage( name )
-    char       *name;
+usage( char *name )
 {
        fprintf( stderr, "usage: %s [-d ?|debuglevel] [-f configfile] [-p portnumber] [-s sysloglevel]\n", name );
 }
 
 int
-main( argc, argv )
-    int                argc;
-    char       **argv;
+main( int argc, char **argv )
 {
        int             i;
        int             inetd = 0;
@@ -75,7 +68,6 @@ main( argc, argv )
        char            *myname;
        Backend         *be = NULL;
        FILE            *fp = NULL;
-       extern char     *optarg;
 
        configfile = SLAPD_DEFAULT_CONFIGFILE;
        port = LDAP_PORT;
@@ -268,7 +260,7 @@ main( argc, argv )
                            != LDAP_TAG_MSGID ) {
                                /* log and send error */
                                Debug( LDAP_DEBUG_ANY,
-                                   "ber_get_int returns 0x%x\n", tag, 0, 0 );
+                                  "ber_get_int returns 0x%lx\n", tag, 0, 0 );
                                return 1;
                        }
 
@@ -276,7 +268,7 @@ main( argc, argv )
                            == LBER_ERROR ) {
                                /* log, close and send error */
                                Debug( LDAP_DEBUG_ANY,
-                                   "ber_peek_tag returns 0x%x\n", tag, 0, 0 );
+                                  "ber_peek_tag returns 0x%lx\n", tag, 0, 0 );
                                ber_free( &ber, 1 );
                                close( c.c_sb.sb_sd );
                                c.c_sb.sb_sd = -1;
index 6575fe36adbd7a434c772d6ab328acd9fc51ad77..fa65acc2a8854a095c49b5335f85857483ddc05c 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
 
-extern Backend *select_backend();
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "slap.h"
 
-extern char            *default_referral;
-extern time_t          currenttime;
-extern pthread_mutex_t currenttime_mutex;
-extern int             global_lastmod;
+static void    modlist_free(LDAPMod *mods);
+static void    add_lastmods(Operation *op, LDAPMod **mods);
 
-static void    modlist_free();
-static void    add_lastmods();
 
 void
 do_modify(
@@ -147,6 +143,9 @@ do_modify(
                return;
        }
 
+        /* alias suffix if approp */
+        dn = suffixAlias ( dn, op, be );
+
        /*
         * do the modify if 1 && (2 || 3)
         * 1) there is a modify function implemented in this backend;
@@ -155,14 +154,14 @@ do_modify(
         */
        if ( be->be_modify != NULL ) {
                /* do the update here */
-               if ( be->be_updatedn == NULL || strcasecmp( be->be_updatedn,
-                   op->o_dn ) == 0 ) {
-                       if ( (be->be_lastmod == ON || be->be_lastmod == 0 &&
-                           global_lastmod == ON) && be->be_updatedn == NULL ) {
+               if ( be->be_updatedn == NULL ||
+                       strcasecmp( be->be_updatedn, op->o_dn ) == 0 ) {
+
+                       if ( (be->be_lastmod == ON || ( be->be_lastmod == UNDEFINED &&
+                               global_lastmod == ON ) ) && be->be_updatedn == NULL ) {
                                add_lastmods( op, &mods );
                        }
-                       if ( (*be->be_modify)( be, conn, op, odn, mods )
-                           == 0 ) {
+                       if ( (*be->be_modify)( be, conn, op, odn, mods ) == 0 ) {
                                replog( be, LDAP_REQ_MODIFY, dn, mods, 0 );
                        }
 
@@ -200,7 +199,7 @@ modlist_free(
 static void
 add_lastmods( Operation *op, LDAPMod **mods )
 {
-       char            buf[20];
+       char            buf[22];
        struct berval   bv;
        struct berval   *bvals[2];
        LDAPMod         **m;
@@ -214,17 +213,25 @@ add_lastmods( Operation *op, LDAPMod **mods )
 
        /* remove any attempts by the user to modify these attrs */
        for ( m = mods; *m != NULL; m = &(*m)->mod_next ) {
-               if ( strcasecmp( (*m)->mod_type, "modifytimestamp" ) == 0
-                   || strcasecmp( (*m)->mod_type, "modifiersname" ) == 0 ) {
-                       tmp = *m;
-                       *m = (*m)->mod_next;
-                       free( tmp->mod_type );
-                       if ( tmp->mod_bvalues != NULL ) {
-                               ber_bvecfree( tmp->mod_bvalues );
-                       }
-                       free( tmp );
-               }
-       }
+            if ( strcasecmp( (*m)->mod_type, "modifytimestamp" ) == 0 || 
+                               strcasecmp( (*m)->mod_type, "modifiersname" ) == 0 ||
+                               strcasecmp( (*m)->mod_type, "createtimestamp" ) == 0 || 
+                               strcasecmp( (*m)->mod_type, "creatorsname" ) == 0 ) {
+
+                Debug( LDAP_DEBUG_TRACE,
+                                       "add_lastmods: found lastmod attr: %s\n",
+                                       (*m)->mod_type, 0, 0 );
+                tmp = *m;
+                *m = (*m)->mod_next;
+                free( tmp->mod_type );
+                if ( tmp->mod_bvalues != NULL ) {
+                    ber_bvecfree( tmp->mod_bvalues );
+                }
+                free( tmp );
+                if (!*m)
+                    break;
+            }
+        }
 
        if ( op->o_dn == NULL || op->o_dn[0] == '\0' ) {
                bv.bv_val = "NULLDN";
@@ -243,16 +250,20 @@ add_lastmods( Operation *op, LDAPMod **mods )
        *mods = tmp;
 
        pthread_mutex_lock( &currenttime_mutex );
-        ltm = localtime( &currenttime );
-        strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
+#ifndef LDAP_LOCALTIME
+       ltm = gmtime( &currenttime );
+       strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
+#else
+       ltm = localtime( &currenttime );
+       strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
+#endif
        pthread_mutex_unlock( &currenttime_mutex );
        bv.bv_val = buf;
        bv.bv_len = strlen( bv.bv_val );
        tmp = (LDAPMod *) ch_calloc( 1, sizeof(LDAPMod) );
        tmp->mod_type = strdup( "modifytimestamp" );
        tmp->mod_op = LDAP_MOD_REPLACE;
-       tmp->mod_bvalues = (struct berval **) ch_calloc( 1,
-           2 * sizeof(struct berval *) );
+       tmp->mod_bvalues = (struct berval **) ch_calloc( 1, 2 * sizeof(struct berval *) );
        tmp->mod_bvalues[0] = ber_bvdup( &bv );
        tmp->mod_next = *mods;
        *mods = tmp;
index 802dda55acb4cf4f20fe02cde7a5b0ce69cd4d9e..25752ea85d7f968af9a51e9bba4f41b42d272d3f 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
 
-extern Backend *select_backend();
+#include <ac/socket.h>
+#include <ac/string.h>
 
-extern char    *default_referral;
+#include "slap.h"
 
 void
 do_modrdn(
index 73a78c8f70c46054f2aef52f0afc58f43a9c81fa..e7de185eed22545a78c64408430eafe44d3a6a9e 100644 (file)
 #include <ac/string.h>
 #include <ac/time.h>
 
-#include "slap.h"
 #include "ldapconfig.h"
+#include "slap.h"
 
 #if defined( SLAPD_MONITOR_DN )
 
-extern int             nbackends;
-extern Backend         *backends;
-extern int             active_threads;
-extern int             dtblsize;
-extern Connection      *c;
-extern long            ops_initiated;
-extern long            ops_completed;
-extern long            num_entries_sent;
-extern long            num_bytes_sent;
-extern time_t          currenttime;
-extern time_t          starttime;
-extern int             num_conns;
-
-extern pthread_mutex_t new_conn_mutex;
-extern pthread_mutex_t currenttime_mutex;
-
-extern char Versionstr[];
-
 void
 monitor_info( Connection *conn, Operation *op )
 {
@@ -106,7 +88,7 @@ monitor_info( Connection *conn, Operation *op )
                        pthread_mutex_unlock( &currenttime_mutex );
 
                        pthread_mutex_lock( &c[i].c_dnmutex );
-                       sprintf( buf, "%d : %s : %ld : %ld : %s : %s%s", i,
+                       sprintf( buf, "%d : %s : %d : %d : %s : %s%s", i,
                            buf2, c[i].c_opsinitiated, c[i].c_opscompleted,
                            c[i].c_dn ? c[i].c_dn : "NULLDN",
                            c[i].c_gettingber ? "r" : "",
index 0c62e219ece0041aede5f999440faa54f87664e2..9a06f97fbd3b543cbe4d367843a95f2425bbde32 100644 (file)
@@ -1,13 +1,14 @@
 /* operation.c - routines to deal with pending ldap operations */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
 #include "slap.h"
 
-extern time_t          currenttime;
-extern pthread_mutex_t currenttime_mutex;
 
 void
 op_free( Operation *op )
@@ -64,7 +65,7 @@ op_delete( Operation **olist, Operation *op )
                ;       /* NULL */
 
        if ( *tmp == NULL ) {
-               Debug( LDAP_DEBUG_ANY, "op_delete: can't find op %d\n",
+               Debug( LDAP_DEBUG_ANY, "op_delete: can't find op %ld\n",
                    op->o_msgid, 0, 0 );
                return; 
        }
index ef402878e030bb0f57207de6702ce7fd9847691b..200782010f56a595d94785ba2c72940108ccc490 100644 (file)
@@ -57,7 +57,7 @@ Backend * select_backend LDAP_P(( char * dn ));
 int be_issuffix LDAP_P(( Backend *be, char *suffix ));
 int be_isroot LDAP_P(( Backend *be, char *dn ));
 int be_isroot_pw LDAP_P(( Backend *be, char *dn, struct berval *cred ));
-void be_close LDAP_P(());
+void be_close LDAP_P(( void ));
 
 /*
  * ch_malloc.c
@@ -217,4 +217,100 @@ int value_find LDAP_P(( struct berval **vals, struct berval *v, int syntax,
  */
 char *suffixAlias LDAP_P(( char *dn, Operation *op, Backend *be ));
 
+/*
+ * Other...
+ */
+
+extern char            **g_argv;
+extern char            *default_referral;
+extern char            *replogfile;
+extern char            Versionstr[];
+extern int             active_threads;
+extern int             defsize;
+extern int             deftime;
+extern int             g_argc;
+extern int             global_default_access;
+extern int             global_lastmod;
+extern int             global_schemacheck;
+extern int             lber_debug;
+extern int             ldap_syslog;
+extern int             num_conns;
+extern int             slapd_shutdown;
+extern long            num_bytes_sent;
+extern long            num_entries_sent;
+extern long            ops_completed;
+extern long            ops_initiated;
+extern pthread_mutex_t active_threads_mutex;
+extern pthread_mutex_t currenttime_mutex;
+extern pthread_mutex_t entry2str_mutex;
+extern pthread_mutex_t new_conn_mutex;
+extern pthread_mutex_t num_sent_mutex;
+extern pthread_mutex_t ops_mutex;
+extern pthread_mutex_t replog_mutex;
+extern pthread_t       listener_tid;
+extern struct acl      *global_acl;
+extern struct objclass *global_oc;
+extern time_t          currenttime;
+
+extern int     be_group LDAP_P((Backend *be, char *bdn, char *edn, char *objectclassValue, char *groupattrName));
+extern void    init LDAP_P((void));
+extern void    be_unbind LDAP_P((Connection *conn, Operation *op));
+extern void    config_info LDAP_P((Connection *conn, Operation *op));
+extern void    do_abandon LDAP_P((Connection *conn, Operation *op));
+extern void    do_add LDAP_P((Connection *conn, Operation *op));
+extern void    do_bind LDAP_P((Connection *conn, Operation *op));
+extern void    do_compare LDAP_P((Connection *conn, Operation *op));
+extern void    do_delete LDAP_P((Connection *conn, Operation *op));
+extern void    do_modify LDAP_P((Connection *conn, Operation *op));
+extern void    do_modrdn LDAP_P((Connection *conn, Operation *op));
+extern void    do_search LDAP_P((Connection *conn, Operation *op));
+extern void    do_unbind LDAP_P((Connection *conn, Operation *op));
+extern void *  slapd_daemon LDAP_P((void *port));
+
+extern int             nbackends;
+extern Backend         *backends;
+extern int send_search_entry LDAP_P((Backend *be, Connection *conn, Operation *op, Entry *e, char **attrs, int attrsonly));
+extern int str2result LDAP_P(( char *s, int *code, char **matched, char **info ));
+
+#if defined( SLAPD_MONITOR_DN )
+extern Connection      *c;
+extern int             dtblsize;
+extern time_t          starttime;
+#endif
+
+#ifdef SLAPD_LDBM
+extern int  ldbm_back_bind   LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, int method, struct berval *cred ));
+extern void ldbm_back_unbind LDAP_P((Backend *be, Connection *c, Operation *o ));
+extern int  ldbm_back_search LDAP_P((Backend *be, Connection *c, Operation *o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, char *filterstr, char **attrs, int attrsonly));
+extern int  ldbm_back_compare LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, Ava *ava));
+extern int  ldbm_back_modify LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, LDAPMod *m));
+extern int  ldbm_back_modrdn LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, char *newrdn, int deleteoldrdn ));
+extern int  ldbm_back_add    LDAP_P((Backend *be, Connection *c, Operation *o, Entry *e));
+extern int  ldbm_back_delete LDAP_P((Backend *be, Connection *c, Operation *o, char *dn));
+extern void ldbm_back_abandon LDAP_P((Backend *be, Connection *c, Operation *o, int msgid));
+extern void ldbm_back_config LDAP_P((Backend *be, char *fname, int lineno, int argc, char **argv ));
+extern void ldbm_back_init   LDAP_P((Backend *be));
+extern void ldbm_back_close  LDAP_P((Backend *be));
+extern int  ldbm_back_group  LDAP_P((Backend *be, char *bdn, char *edn, char *objectclassValue, char *groupattrName ));
+#endif
+
+#ifdef SLAPD_PASSWD
+extern int  passwd_back_search LDAP_P((Backend *be, Connection *c, Operation *o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, char *filterstr, char **attrs, int attrsonly));
+extern void passwd_back_config LDAP_P((Backend *be, char *fname, int lineno, int argc, char **argv ));
+#endif
+
+#ifdef SLAPD_SHELL
+extern int  shell_back_bind   LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, int method, struct berval *cred ));
+extern void shell_back_unbind LDAP_P((Backend *be, Connection *c, Operation *o ));
+extern int  shell_back_search LDAP_P((Backend *be, Connection *c, Operation *o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, char *filterstr, char **attrs, int attrsonly));
+extern int  shell_back_compare LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, Ava *ava));
+extern int  shell_back_modify LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, LDAPMod *m));
+extern int  shell_back_modrdn LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, char *newrdn, int deleteoldrdn ));
+extern int  shell_back_add    LDAP_P((Backend *be, Connection *c, Operation *o, Entry *e));
+extern int  shell_back_delete LDAP_P((Backend *be, Connection *c, Operation *o, char *dn));
+extern void shell_back_abandon LDAP_P((Backend *be, Connection *c, Operation *o, int msgid));
+extern void shell_back_config LDAP_P((Backend *be, char *fname, int lineno, int argc, char **argv ));
+extern void shell_back_init   LDAP_P((Backend *be));
+#endif
+
 #endif /* _proto_slap */
index d47d754f576608e77fe2e0be532518cc138f3971..4f46ec114d317d20415957bcae3039d087254e51 100644 (file)
@@ -5,20 +5,13 @@
 #include <stdio.h>
 
 #include <ac/string.h>
+#include <ac/ctype.h>
 #include <ac/socket.h>
 
 #include <sys/file.h>
 
 #include "slap.h"
 
-extern pthread_mutex_t replog_mutex;
-extern pthread_mutex_t entry2str_mutex;
-extern time_t          currenttime;
-extern char            *replogfile;
-
-extern FILE    *lock_fopen();
-extern int     lock_fclose();
-extern char    *entry2str();
 
 void
 replog(
index 0ef82a7b3e36e03f85a4a71a91040153fe182064..a710e1910f98812e128d928e40764821b69da1a9 100644 (file)
@@ -1,30 +1,18 @@
 /* result.c - routines to send ldap results, errors, and referrals */
 
-#include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <errno.h>
-#include <signal.h>
 #include "portable.h"
-#include "slap.h"
 
-#ifndef SYSERRLIST_IN_STDIO
-extern int             sys_nerr;
-extern char            *sys_errlist[];
-#endif
-extern int             active_threads;
-extern pthread_mutex_t active_threads_mutex;
-extern pthread_mutex_t new_conn_mutex;
-extern pthread_t       listener_tid;
-extern struct acl      *acl_get_applicable();
-extern long            num_entries_sent;
-extern long            num_bytes_sent;
-extern pthread_mutex_t num_sent_mutex;
+#include <stdio.h>
+
+#include <ac/errno.h>
+#include <ac/signal.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h>         /* get close() */
+
+#include "slap.h"
 
-void   close_connection();
 
 static void
 send_ldap_result2(
@@ -40,6 +28,9 @@ send_ldap_result2(
        int             rc, sd;
        unsigned long   tag, bytes;
 
+       if ( err == LDAP_PARTIAL_RESULTS && (text == NULL || *text == '\0') )
+               err = LDAP_NO_SUCH_OBJECT;
+
        Debug( LDAP_DEBUG_TRACE, "send_ldap_result %d:%s:%s\n", err, matched ?
            matched : "", text ? text : "" );
 
@@ -61,7 +52,7 @@ send_ldap_result2(
                break;
        }
 
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
        if ( (ber = ber_alloc_t( conn->c_version == 30 ? 0 : LBER_USE_DER ))
            == NULLBER ) {
 #else
@@ -71,13 +62,13 @@ send_ldap_result2(
                return;
        }
 
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
        if ( op->o_cldap ) {
                rc = ber_printf( ber, "{is{t{ess}}}", op->o_msgid, "", tag,
                    err, matched ? matched : "", text ? text : "" );
        } else
 #endif
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
        if ( conn->c_version == 30 ) {
                rc = ber_printf( ber, "{it{{ess}}}", op->o_msgid, tag, err,
                    matched ? matched : "", text ? text : "" );
@@ -121,7 +112,13 @@ send_ldap_result2(
                pthread_mutex_lock( &active_threads_mutex );
                active_threads--;
                conn->c_writewaiter = 1;
+
+#ifdef HAVE_LINUX_THREADS
+               pthread_kill( listener_tid, SIGSTKFLT );
+#else /* !linux */
                pthread_kill( listener_tid, SIGUSR1 );
+#endif /* !linux */
+
                pthread_cond_wait( &conn->c_wcv, &active_threads_mutex );
                pthread_mutex_unlock( &active_threads_mutex );
 
@@ -151,7 +148,7 @@ send_ldap_result(
     char       *text
 )
 {
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
        if ( op->o_cldap ) {
                SAFEMEMCPY( (char *)conn->c_sb.sb_useaddr, &op->o_clientaddr,
                    sizeof( struct sockaddr ));
@@ -192,6 +189,7 @@ send_search_entry(
        Attribute       *a;
        int             i, rc, bytes, sd;
        struct acl      *acl;
+       char            *edn;
 
        Debug( LDAP_DEBUG_TRACE, "=> send_search_entry (%s)\n", e->e_dn, 0, 0 );
 
@@ -202,44 +200,64 @@ send_search_entry(
                return( 1 );
        }
 
-#ifdef COMPAT30
+       edn = dn_normalize_case( strdup( e->e_dn ) );
+
+#ifdef LDAP_COMPAT30
        if ( (ber = ber_alloc_t( conn->c_version == 30 ? 0 : LBER_USE_DER ))
-           == NULLBER ) {
+               == NULLBER )
 #else
-       if ( (ber = der_alloc()) == NULLBER ) {
+       if ( (ber = der_alloc()) == NULLBER )
 #endif
+       {
                Debug( LDAP_DEBUG_ANY, "ber_alloc failed\n", 0, 0, 0 );
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
-                   "ber_alloc" );
-               return( 1 );
+                       "ber_alloc" );
+               goto error_return;
        }
 
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
        if ( conn->c_version == 30 ) {
                rc = ber_printf( ber, "{it{{s{", op->o_msgid,
                    LDAP_RES_SEARCH_ENTRY, e->e_dn );
        } else
 #endif
+       {
                rc = ber_printf( ber, "{it{s{", op->o_msgid,
-                   LDAP_RES_SEARCH_ENTRY, e->e_dn );
+                       LDAP_RES_SEARCH_ENTRY, e->e_dn );
+       }
 
        if ( rc == -1 ) {
                Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
                ber_free( ber, 1 );
                send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
                    "ber_printf dn" );
-               return( 1 );
+               goto error_return;
        }
 
        for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
+               regmatch_t       matches[MAXREMATCHES];
+
                if ( attrs != NULL && ! charray_inlist( attrs, a->a_type ) ) {
                        continue;
                }
 
-               acl = acl_get_applicable( be, op, e, a->a_type );
+               /* the lastmod attributes are ignored by ACL checking */
+               if ( strcasecmp( a->a_type, "modifiersname" ) == 0 ||
+                       strcasecmp( a->a_type, "modifytimestamp" ) == 0 ||
+                       strcasecmp( a->a_type, "creatorsname" ) == 0 ||
+                       strcasecmp( a->a_type, "createtimestamp" ) == 0 ) 
+               {
+                       Debug( LDAP_DEBUG_ACL, "LASTMOD attribute: %s access DEFAULT\n",
+                               a->a_type, 0, 0 );
+                       acl = NULL;
+               } else {
+                       acl = acl_get_applicable( be, op, e, a->a_type, edn,
+                               MAXREMATCHES, matches );
+               }
 
-               if ( ! acl_access_allowed( acl, be, conn, e, NULL, op,
-                   ACL_READ ) ) {
+               if ( ! acl_access_allowed( acl, be, conn, e, NULL, op, ACL_READ,
+                       edn, matches ) ) 
+               {
                        continue;
                }
 
@@ -248,14 +266,14 @@ send_search_entry(
                        ber_free( ber, 1 );
                        send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
                            NULL, "ber_printf type" );
-                       return( 1 );
+                       goto error_return;
                }
 
                if ( ! attrsonly ) {
                        for ( i = 0; a->a_vals[i] != NULL; i++ ) {
-                               if ( a->a_syntax & SYNTAX_DN &&
-                                   ! acl_access_allowed( acl, be, conn, e,
-                                   a->a_vals[i], op, ACL_READ ) )
+                               if ( a->a_syntax & SYNTAX_DN && 
+                                       ! acl_access_allowed( acl, be, conn, e, a->a_vals[i], op,
+                                               ACL_READ, edn, matches) )
                                {
                                        continue;
                                }
@@ -270,7 +288,7 @@ send_search_entry(
                                        send_ldap_result( conn, op,
                                            LDAP_OPERATIONS_ERROR, NULL,
                                            "ber_printf value" );
-                                       return( 1 );
+                                       goto error_return;
                                }
                        }
                }
@@ -280,11 +298,13 @@ send_search_entry(
                        ber_free( ber, 1 );
                        send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
                            NULL, "ber_printf type end" );
-                       return( 1 );
+                       goto error_return;
                }
        }
 
-#ifdef COMPAT30
+       free(edn);
+
+#ifdef LDAP_COMPAT30
        if ( conn->c_version == 30 ) {
                rc = ber_printf( ber, "}}}}" );
        } else
@@ -356,6 +376,10 @@ send_search_entry(
        Debug( LDAP_DEBUG_TRACE, "<= send_search_entry\n", 0, 0, 0 );
 
        return( rc );
+
+error_return:;
+       free(edn);
+       return( 1 );
 }
 
 int
index ba16d9b0f13540041d9b221fcc4db4888f99a794..05dbd557776223c31098cd61c1172c32576a0653 100644 (file)
@@ -1,21 +1,17 @@
 /* schema.c - routines to enforce schema definitions */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
 
-extern Attribute       *attr_find();
-extern char            **str2charray();
-extern void            charray_merge();
+#include <ac/string.h>
+#include <ac/socket.h>
 
-extern struct objclass *global_oc;
-extern int             global_schemacheck;
+#include "slap.h"
 
-static struct objclass *oc_find();
-static int             oc_check_required();
-static int             oc_check_allowed();
+static struct objclass *oc_find(char *ocname);
+static int             oc_check_required(Entry *e, char *ocname);
+static int             oc_check_allowed(char *type, struct berval **ocl);
 
 /*
  * oc_check - check that entry e conforms to the schema required by
@@ -76,6 +72,11 @@ oc_check_required( Entry *e, char *ocname )
                return( 0 );
        }
 
+       /* check for empty oc_required */
+       if(oc->oc_required == NULL) {
+               return( 0 );
+       }
+
        /* for each required attribute */
        for ( i = 0; oc->oc_required[i] != NULL; i++ ) {
                /* see if it's in the entry */
@@ -111,14 +112,16 @@ oc_check_allowed( char *type, struct berval **ocl )
                /* if we know about the oc */
                if ( (oc = oc_find( ocl[i]->bv_val )) != NULL ) {
                        /* does it require the type? */
-                       for ( j = 0; oc->oc_required[j] != NULL; j++ ) {
+                       for ( j = 0; oc->oc_required != NULL && 
+                               oc->oc_required[j] != NULL; j++ ) {
                                if ( strcasecmp( oc->oc_required[j], type )
                                    == 0 ) {
                                        return( 0 );
                                }
                        }
                        /* does it allow the type? */
-                       for ( j = 0; oc->oc_allowed[j] != NULL; j++ ) {
+                       for ( j = 0; oc->oc_allowed != NULL && 
+                               oc->oc_allowed[j] != NULL; j++ ) {
                                if ( strcasecmp( oc->oc_allowed[j], type )
                                    == 0 || strcmp( oc->oc_allowed[j], "*" )
                                    == 0 )
@@ -154,7 +157,7 @@ oc_find( char *ocname )
 
 #ifdef LDAP_DEBUG
 
-static
+static void
 oc_print( struct objclass *oc )
 {
        int     i;
index 180ed71d005caeca8636e3c0336294756ef91b43..96e01f09b0afa5ea0e2d454b5b5925ee0e02b0fb 100644 (file)
@@ -1,18 +1,18 @@
 /* schemaparse.c - routines to parse config file objectclass definitions */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
 
-extern char            **str2charray();
-extern void            charray_merge();
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
 
 struct objclass                *global_oc;
 int                    global_schemacheck;
 
-static void            oc_usage();
+static void            oc_usage(void);
 
 void
 parse_oc(
@@ -69,7 +69,7 @@ parse_oc(
 }
 
 static void
-oc_usage()
+oc_usage( void )
 {
        fprintf( stderr, "<oc clause> ::= objectclass <ocname>\n" );
        fprintf( stderr, "                [ requires <attrlist> ]\n" );
index fc96d2fd021727bd9f14c04445f3ace096defa32..013075fdb183462f87e04d2e54ac2e7ed9179343 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
-#include "ldapconfig.h"
 
-extern int     get_filter();
-extern Backend *select_backend();
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "ldapconfig.h"
+#include "slap.h"
 
-extern char    *default_referral;
 
 void
-do_search( conn, op )
-    Connection *conn;  /* where to send results                       */
-    Operation  *op;    /* info about the op to which we're responding */
+do_search(
+    Connection *conn,  /* where to send results                       */
+    Operation  *op     /* info about the op to which we're responding */
+)
 {
        int             i, err;
        int             scope, deref, attrsonly;
@@ -161,6 +161,9 @@ do_search( conn, op )
                return;
        }
 
+        /* translate the base if it matches an aliased base part */
+        base = suffixAlias ( base, op, be );
+
        /* actually do the search and send the result(s) */
        if ( be->be_search != NULL ) {
                (*be->be_search)( be, conn, op, base, scope, deref, sizelimit,
index 2210651dbf1905fd1a95b58adb3dff8e9be35209..89d2fd73d66ad91f0a66a8b0fccb8aa209d5371b 100644 (file)
 */
 
 
-#include <sys/types.h>
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
+
+#include <ac/string.h>
+#include <ac/unistd.h>
+
 #include <pwd.h>
-#include <varargs.h>
+
 #include <lber.h>
 #include <ldap.h>
+
 #include "shellutil.h"
 #include "passwd-shell.h"
 
 
-#ifdef LDAP_DEBUG
-void debug_printf();
-#else /* LDAP_DEBUG */
-#define debug_printf()
-#endif /* LDAP_DEBUG */
-
-
-static void pwdfile_search( struct ldop *op, FILE *ofp );
-static struct ldentry *pw2entry( struct ldop *op, struct passwd *pw );
+static void pwdfile_search LDAP_P(( struct ldop *op, FILE *ofp ));
+static struct ldentry *pw2entry LDAP_P(( struct ldop *op, struct passwd *pw ));
 
 static char    tmpbuf[ MAXLINELEN * 2 ];
 
 
+int
 main( int argc, char **argv )
 {
     int                        c, errflg;
     struct ldop                op;
-    extern int         optind;
-    extern char                *optarg;
 
     if (( progname = strrchr( argv[ 0 ], '/' )) == NULL ) {
        progname = estrdup( argv[ 0 ] );
index 82eea1665b8d879664c61c833e4e9f89d088b5f1..59d43cb7073fe07c7d17ff9a17c421d4bd3780d9 100644 (file)
 */
 
 
-#include <sys/types.h>
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
+
 #include <stdlib.h>
+#include <ac/stdarg.h>
+
 #include <pwd.h>
-#include <varargs.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+
 #include <lber.h>
 #include <ldap.h>
 #include "shellutil.h"
@@ -314,19 +320,30 @@ ecalloc( unsigned nelem, unsigned elsize )
 
 /* VARARGS */
 void
-debug_printf( va_alist /* char *fmt, args... */ )
+debug_printf
+#ifdef STDC_HEADERS
+       ( char *fmt, ... )
+#else
+       ( va_alist )
     va_dcl
+#endif
 {
-    char       *fmt;
     va_list    ap;
-
-    if ( debugflg ) {
-       va_start( ap );
-       fmt = va_arg( ap, char * );
-       fprintf( stderr, "%s: ", progname );
-       vfprintf( stderr, fmt, ap );
-       va_end( ap );
-    }
+#ifndef STDC_HEADERS
+    char       *fmt;
+#endif
+
+       if ( debugflg ) {
+#ifdef STDC_HEADERS
+               va_start( ap, fmt );
+#else
+               va_start( ap );
+               fmt = va_arg( ap, char * );
+#endif
+               fprintf( stderr, "%s: ", progname );
+               vfprintf( stderr, fmt, ap );
+               va_end( ap );
+       }
 }
 
 
index 7ea0db057cbae98961b67a628fadf0ab8b7b4125..7f51500d35844ba2b28415dc60502a4d5e8ee05f 100644 (file)
  is provided ``as is'' without express or implied warranty.
 */
 
+#ifndef SHELLUTIL_H
+#define SHELLUTIL_H
+
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
 
 #define MAXLINELEN     512
 
@@ -69,7 +75,7 @@ struct ldentry {
 
 
 #ifdef LDAP_DEBUG
-void debug_printf();
+void debug_printf LDAP_P((char *, ...));
 #else /* LDAP_DEBUG */
 #define debug_printf()
 #endif /* LDAP_DEBUG */
@@ -88,9 +94,14 @@ void add_strval( char ***sp, char *val );
 char *ecalloc( unsigned nelem, unsigned elsize );
 void *erealloc( void *s, unsigned size );
 char *estrdup( char *s );
+extern void dump_ldop (struct ldop *op);
+
 
 /*
  * global variables
  */
 extern int     debugflg;
 extern char    *progname;
+
+LDAP_END_DECL
+#endif
index 49aaf52db53d0e5166871aa322afee25dd11d1cb..f860472101c461ee64397d8edf6acba62462e2e9 100644 (file)
@@ -33,6 +33,9 @@
 
 LDAP_BEGIN_DECL
 
+struct op;
+struct conn;
+
 /*
  * represents an attribute value assertion (i.e., attr=value)
  */
@@ -184,7 +187,8 @@ struct objclass {
  * represents a "database"
  */
 
-typedef struct backend {
+typedef struct backend Backend;
+struct backend {
        char    **be_suffix;    /* the DN suffixes of data in this backend */
         char    **be_suffixAlias;       /* the DN suffix aliases of data in this backend */
        char    *be_rootdn;     /* the magic "root" dn for this db         */
@@ -203,23 +207,25 @@ typedef struct backend {
 
        void    *be_private;    /* anything the backend needs              */
 
-       IFP     be_bind;        /* backend bind routine                    */
-       IFP     be_unbind;      /* backend unbind routine                  */
-       IFP     be_search;      /* backend search routine                  */
-       IFP     be_compare;     /* backend compare routine                 */
-       IFP     be_modify;      /* backend modify routine                  */
-       IFP     be_modrdn;      /* backend modrdn routine                  */
-       IFP     be_add;         /* backend add routine                     */
-       IFP     be_delete;      /* backend delete routine                  */
-       IFP     be_abandon;     /* backend abandon routine                 */
-       IFP     be_config;      /* backend config routine                  */
-       IFP     be_init;        /* backend init routine                    */
-       IFP     be_close;       /* backend close routine                   */
+       /* backend routines */
+       int     (*be_bind)   LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, int method, struct berval *cred ));
+       void    (*be_unbind) LDAP_P((Backend *be, struct conn *c, struct op *o ));
+       int     (*be_search) LDAP_P((Backend *be, struct conn *c, struct op *o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, char *filterstr, char **attrs, int attrsonly));
+       int     (*be_compare)LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, Ava *ava));
+       int     (*be_modify) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, LDAPMod *m));
+       int     (*be_modrdn) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, char *newrdn, int deleteoldrdn ));
+       int     (*be_add)    LDAP_P((Backend *be, struct conn *c, struct op *o, Entry *e));
+       int     (*be_delete) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn));
+       /* Bug: be_abandon in unused! */
+       void    (*be_abandon)LDAP_P((Backend *be, struct conn *c, struct op *o, int msgid));
+       void    (*be_config) LDAP_P((Backend *be, char *fname, int lineno, int argc, char **argv ));
+       void    (*be_init)   LDAP_P((Backend *be));
+       void    (*be_close)  LDAP_P((Backend *be));
 
 #ifdef SLAPD_ACLGROUPS
-       IFP     be_group;       /* backend group member test               */
+       int     (*be_group)  LDAP_P((Backend *be, char *bdn, char *edn, char *objectclassValue, char *groupattrName ));
 #endif
-} Backend;
+};
 
 /*
  * represents an operation pending from an ldap client
index aca9674fd846519207cd3e26d05a867f00419c45..71d4d1f56af7f46cfeb53da8ac8881dfeb312abf 100644 (file)
@@ -1,20 +1,24 @@
 /* str2filter.c - parse an rfc 1588 string filter */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/socket.h>
+
 #include "slap.h"
 
-static char    *find_matching_paren();
-static Filter  *str2list();
-static Filter  *str2simple();
-static int     str2subvals();
+static char    *find_matching_paren(char *s);
+static Filter  *str2list(char *str, long unsigned int ftype);
+static Filter  *str2simple(char *str);
+static int     str2subvals(char *val, Filter *f);
 
 Filter *
 str2filter( char *str )
 {
-       Filter  *f;
+       Filter  *f = NULL;
        char    *end;
 
        Debug( LDAP_DEBUG_FILTER, "str2filter \"%s\"\n", str, 0, 0 );
index c60530ef4867552297341e880dd0164f2feb01b8..26b990cd57972108ca9b8b4ba98d8701ac3a9763 100644 (file)
  * given a dn (or root part), return an aliased dn if any of the 
  * alias suffixes match
  */
-char *suffixAlias ( dn, op, be )
-       char *dn;
-       Operation *op;
-       Backend *be;
+char *suffixAlias (char *dn, Operation *op, Backend *be)
 {
        int     i, dnLength;
 
index 9f1e81f9773c3aa5ba78e9aad24b974d7d02512a..25cc1a0ef45fa75c2e3867942a0c6e3f879b478d 100644 (file)
@@ -8,6 +8,7 @@
 #include <ac/ctype.h>
 #include <ac/string.h>
 #include <ac/time.h>
+#include <ac/unistd.h>         /* get link(), unlink() */
 
 #include <lber.h>
 #include <ldap.h>
@@ -41,13 +42,13 @@ int         destldapauthmethod;
 int            verbose;
 int            not;
 
-static LDAP            *start_ldap_search();
-static LDAP            *bind_to_destination_ldap();
-static int             create_tmp_files();
-static int             generate_new_centroids();
-static LDAPMod **diff_centroids();
-static LDAPMod **full_centroid();
-static char            **charray_add_dup();
+static LDAP            *start_ldap_search(char *ldapsrcurl, char *ldapfilter, char **attrs);
+static LDAP            *bind_to_destination_ldap(char *ldapsrcurl, char *ldapdesturl);
+static int             create_tmp_files(char **attrs, char ***tmpfile, LDBM **ldbm);
+static int             generate_new_centroids(LDAP *ld, char **attrs, LDBM *ldbm);
+static LDAPMod **diff_centroids(char *attr, LDBM oldbm, LDBM nldbm, int nentries);
+static LDAPMod **full_centroid(char *attr, LDBM ldbm, int nentries);
+static char            **charray_add_dup(char ***a, int *cur, int *max, char *s);
 
 static void usage( char *name )
 {
@@ -72,6 +73,7 @@ static void usage( char *name )
        fprintf( stderr, "\t-c size\t\tldbm cache size\n" );
 }
 
+int
 main( int argc, char **argv )
 {
        char            *ldapfilter;
@@ -85,8 +87,6 @@ main( int argc, char **argv )
        char            buf[BUFSIZ];
        int                     i, j, k, count;
        char            *s;
-       extern int      optind;
-       extern char     *optarg;
 
        ldapsrcurl = NULL;
        ldapdesturl = NULL;
@@ -556,7 +556,6 @@ diff_centroids(
        Datum   olast, nlast;
        Datum   lastkey, key;
        Datum   data;
-       int             rc;
        LDAPMod **mods;
        char    **avals, **dvals;
        int             amax, acur, dmax, dcur;
@@ -620,7 +619,7 @@ diff_centroids(
              okey.dptr != NULL && nkey.dptr != NULL; )
 #endif
        {
-               rc = strcmp( okey.dptr, nkey.dptr );
+               int     rc = strcmp( okey.dptr, nkey.dptr );
 
                if ( rc == 0 ) {
                        /* value is in both places - leave it */
index f76884643b7ab8b8566fb92a06c55ce3c3a7461a..b9d171ba8e16bd2c5a8a6888e30d2f249826307c 100644 (file)
 
 #include <ac/ctype.h>
 #include <ac/string.h>
+#include <ac/unistd.h>
 
 #include <quipu/commonarg.h>
 #include <quipu/attrvalue.h>
 
 #include "ldif.h"
 
-static int dn2ldif();
-static void de_t61();
+static int dn2ldif(PS ps, DN dn);
+static void de_t61(char *s, int t61mark);
 
 extern FILE *lock_fopen( char *, char *, FILE ** );
 extern int lock_fclose( FILE *, FILE * );
@@ -228,9 +229,7 @@ dn2ldif( PS ps, DN dn )
 
 
 static void
-de_t61( s, t61mark )
-char   *s;
-int    t61mark;
+de_t61(char *s, int t61mark)
 {
        char    *next = s;
        int     c, hex;
@@ -295,9 +294,7 @@ int t61mark;
 
 
 char *
-getattr( buf, sep )
-char *buf;
-char sep;
+getattr(char *buf, char sep)
 {
     char *val;
 #define RBSIZE 255
@@ -314,24 +311,20 @@ char sep;
 
 
 char *
-getattr_ldif( buf )
-char *buf;
+getattr_ldif(char *buf)
 {
     return( getattr( buf, ':' ));
 }
 
 
 char *
-getattr_edb( buf )
-char *buf;
+getattr_edb(char *buf)
 {
     return( getattr( buf, '=' ));
 }
 
 char *
-getval( buf, sep )
-char *buf;
-char sep;
+getval(char *buf, char sep)
 {
     char *val;
 
@@ -343,16 +336,14 @@ char sep;
 }
 
 char *
-getval_ldif( buf )
-char *buf;
+getval_ldif(char *buf)
 {
     return( getval( buf, ':' ));
 }
 
 
 char *
-getval_edb( buf )
-char *buf;
+getval_edb(char *buf)
 {
     return( getval( buf, '=' ));
 }
@@ -361,10 +352,9 @@ char *buf;
 
 
 int
-isDNsyntax( attr )
-char *attr;
+isDNsyntax(char *attr)
 {
-    oid_table_attr *p, *name2attr();
+    oid_table_attr *p, *name2attr(char *);
 
     p = name2attr( attr );
     if ( p == ( oid_table_attr * ) 0 ) {
@@ -380,10 +370,7 @@ char *attr;
 
 
 void
-print_as( as, modtype, ofp )
-Attr_Sequence as;
-int modtype;
-FILE *ofp;
+print_as(Attr_Sequence as, int modtype, FILE *ofp)
 {
     Attr_Sequence p;
     AV_Sequence        av;
index d46be1edfd60d694c23ba5a2454fbb80b963fbd8..9aad796369a0c46b5f58f5f5395296c5877a19e1 100644 (file)
  * is provided ``as is'' without express or implied warranty.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <dirent.h>
 #include <stdlib.h>
-#include <ctype.h>
+
+#include <ac/ctype.h>
+#include <ac/errno.h>
+#include <ac/dirent.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -53,6 +59,7 @@ struct edbmap {
 static int edb2ldif( FILE *outfp, char *edbfile, char *basedn, int recurse );
 static int convert_entry( FILE *fp, char *edbname, FILE *outfp,
        char *basedn, char *loc_addvals, int loc_addlen, char *linebuf );
+static int add_rdn_values (Attr_Sequence entryas, RDN rdn);
 static int read_edbmap( char *mapfile, struct edbmap **edbmapp );
 static char *file2rdn( struct edbmap *edbmap, char *filename );
 static void free_edbmap( struct edbmap *edbmap );
@@ -77,15 +84,12 @@ int         ldap_syslog = 0;
 int            ldap_syslog_level = 0;
 
 
-main( argc, argv )
-    int                argc;
-    char       **argv;
+int
+main( int argc, char **argv )
 {
     char       *usage = "usage: %s [-d] [-o] [-r] [-v] [-b basedn] [-a addvalsfile] [-f fileattrdir] [-i ignoreattr...] [edbfile...]\n";
     char       edbfile[ MAXNAMLEN ], *basedn;
     int                c, rc, errflg, ignore_count, recurse;
-    extern int  optind;
-    extern char        *optarg;
     extern char        dsa_mode;
 #ifdef HAVE_FILE_ATTR_DIR
     extern char        *file_attr_directory;
@@ -243,11 +247,7 @@ main( argc, argv )
 
 
 static int
-edb2ldif( outfp, edbfile, basedn, recurse )
-    FILE       *outfp;
-    char       *edbfile;
-    char       *basedn;
-    int                recurse;
+edb2ldif( FILE *outfp, char *edbfile, char *basedn, int recurse )
 {
     FILE       *fp;
     char       *addvals, *p, *rdn, line[ MAX_LINE_SIZE + 1 ];
@@ -470,14 +470,15 @@ edb2ldif( outfp, edbfile, basedn, recurse )
  * return > 0 if entry converted, 0 if end of file, < 0 if error occurs
  */
 static int
-convert_entry( fp, edbname, outfp, basedn, loc_addvals, loc_addlen, linebuf )
-    FILE       *fp;
-    char       *edbname;
-    FILE       *outfp;
-    char       *basedn;
-    char       *loc_addvals;
-    int                loc_addlen;
-    char       *linebuf;
+convert_entry(
+    FILE       *fp,
+    char       *edbname,
+    FILE       *outfp,
+    char       *basedn,
+    char       *loc_addvals,
+    int                loc_addlen,
+    char       *linebuf
+)
 {
     Attr_Sequence      as, tmpas;
     AV_Sequence                av;
@@ -691,10 +692,8 @@ convert_entry( fp, edbname, outfp, basedn, loc_addvals, loc_addlen, linebuf )
 }
 
 
-int
-add_rdn_values( entryas, rdn )
-    Attr_Sequence      entryas;
-    RDN                        rdn;
+static int
+add_rdn_values( Attr_Sequence entryas, RDN rdn )
 {
 /*
  * this routine is based on code from the real_unravel_attribute() routine
@@ -730,9 +729,7 @@ add_rdn_values( entryas, rdn )
 
 /* read the EDB.map file and return a linked list of translations */
 static int
-read_edbmap( mapfile, edbmapp )
-    char               *mapfile;
-    struct edbmap      **edbmapp;
+read_edbmap( char *mapfile, struct edbmap **edbmapp )
 {
     FILE               *fp;
     char               *p, *filename, *rdn, line[ MAX_LINE_SIZE + 1 ];
@@ -815,9 +812,7 @@ read_edbmap( mapfile, edbmapp )
 
 
 static char *
-file2rdn( edbmap, filename )
-    struct edbmap      *edbmap;
-    char               *filename;
+file2rdn( struct edbmap *edbmap, char *filename )
 {
 #ifdef LDAP_DEBUG
     if ( debugflg ) {
@@ -838,8 +833,7 @@ file2rdn( edbmap, filename )
 
 /* free the edbmap list */
 static void
-free_edbmap( edbmap )
-    struct edbmap      *edbmap;
+free_edbmap( struct edbmap *edbmap )
 {
     struct edbmap      *tmp;
 
@@ -860,13 +854,8 @@ free_edbmap( edbmap )
 
 
 static void
-print_err( msg )
-    char       *msg;
+print_err( char *msg )
 {
-    extern int sys_nerr;
-    extern char        *sys_errlist[];
-    extern int errno;
-
 #ifdef LDAP_DEBUG
     if ( debugflg ) {
        fprintf( stderr, "print_err( \"%s\" )\n", msg );
index 79465df072ef442648214c7c973a2e1d3d0f87bb..ad058114476d8d35211d3947ba1f1e275bb8f2e5 100644 (file)
@@ -1,21 +1,23 @@
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+
 #include "ldbm.h"
 #include "../slap.h"
 
-usage( name )
-char   *name;
+static void
+usage( char *name )
 {
        fprintf( stderr, "usage: %s [-n] <filename>\n", name );
        exit( 1 );
 }
 
-main( argc, argv )
-    int                argc;
-    char       **argv;
+int
+main( int argc, char **argv )
 {
        Datum           key, last, data;
        LDBM            dbp;
@@ -24,6 +26,10 @@ main( argc, argv )
        char            *file, *s;
        int             printid = 1;
 
+#ifdef HAVE_BERKELEY_DB2
+       DBC     *cursorp;
+#endif
+
        if ( argc < 2 || argc > 3 || ( argc == 3 && strcmp( argv[1], "-n" )
            != 0 )) {
                usage( argv[0] );
@@ -41,8 +47,15 @@ main( argc, argv )
        }
 
         last.dptr = NULL;
+
+#ifdef HAVE_BERKELEY_DB2
+        for ( key = ldbm_firstkey( dbp, &cursorp ); key.dptr != NULL;
+            key = ldbm_nextkey( dbp, last, cursorp ) )
+#else
         for ( key = ldbm_firstkey( dbp ); key.dptr != NULL;
-            key = ldbm_nextkey( dbp, last ) ) {
+            key = ldbm_nextkey( dbp, last ) )
+#endif
+       {
                 if ( last.dptr != NULL )
                         ldbm_datum_free( dbp, last );
                 data = ldbm_fetch( dbp, key );
index 56513ab5b84a11a7922ac31b82601349b0e88456..99fdee67c80bce435d58485e4e2cb45631a72d43 100644 (file)
@@ -1,31 +1,35 @@
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
+#include <limits.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+#include <ac/wait.h>
+
 #include <sys/resource.h>
-#include <sys/wait.h>
 #include <sys/param.h>
 #include <sys/stat.h>
-#include <limits.h>
-#include "portable.h"
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
 #include "ldapconfig.h"
 #include "../slap.h"
 #include "../back-ldbm/back-ldbm.h"
 
 #define EDITOR "/usr/ucb/vi"
 
-extern IDList          *idl_fetch();
-extern Backend         *select_backend();
-extern struct dbcache  *ldbm_cache_open();
-
-static struct dbcache  *openchoice();
-static void            print_entry();
-static void            free_and_close();
-static void            edit_entry();
-static void            get_keydata();
+static struct dbcache  *openchoice(char c, int mode, int verbose, char **fname);
+static void            print_entry(FILE *fp, char c, Datum *key, char *klabel, Datum *data, char *dlabel);
+static void            free_and_close(struct dbcache *dbc, Datum key, Datum data);
+static void            edit_entry(char c, Datum *data);
+static void            get_keydata(FILE *fp, char c, Datum *key, Datum *data);
 
 struct dbcache *dbc;
 LDBM           dbp;
@@ -35,8 +39,8 @@ int           ldap_debug;
 int            ldap_syslog;
 int            ldap_syslog_level;
 int            global_schemacheck;
-int            num_entries_sent;
-int            num_bytes_sent;
+long           num_entries_sent;
+long           num_bytes_sent;
 int            active_threads;
 char           *default_referral;
 struct objclass        *global_oc;
@@ -51,9 +55,8 @@ pthread_mutex_t       replog_mutex;
 pthread_mutex_t        ops_mutex;
 pthread_mutex_t        regex_mutex;
 
-main( argc, argv )
-    int                argc;
-    char       **argv;
+int
+main( int argc, char **argv )
 {
        char            buf[256];
        Datum           savekey, key, data, last;
@@ -62,7 +65,10 @@ main( argc, argv )
        IDList          *idl;
        Backend         *tbe;
        int             i;
-       extern char     *optarg;
+
+#ifdef HAVE_BERKELEY_DB2
+       DBC     *cursorp;
+#endif
 
        tailorfile = SLAPD_DEFAULT_CONFIGFILE;
        while ( (i = getopt( argc, argv, "d:f:" )) != EOF ) {
@@ -151,9 +157,16 @@ main( argc, argv )
                        }
 
                        savekey.dptr = NULL;
+#ifdef HAVE_BERKELEY_DB2
+                       for ( key = ldbm_firstkey( dbc->dbc_db, &cursorp );
+                           key.dptr != NULL;
+                           key = ldbm_nextkey( dbc->dbc_db, key, cursorp ) )
+#else
                        for ( key = ldbm_firstkey( dbc->dbc_db );
                            key.dptr != NULL;
-                           key = ldbm_nextkey( dbc->dbc_db, key ) ) {
+                           key = ldbm_nextkey( dbc->dbc_db, key ) )
+#endif
+                       {
                                if ( savekey.dptr != NULL )
                                        ldbm_datum_free( dbc->dbc_db, savekey );
                                savekey = key;
@@ -271,7 +284,7 @@ main( argc, argv )
                                if ( idl_insert_key( be, dbc, key, id )
                                    != 0 ) {
                                        fprintf( stderr,
-                                           "idl_insert_key (%s) %d failed\n",
+                                           "idl_insert_key (%s) %ld failed\n",
                                            key.dptr, id );
                                        continue;
                                }
@@ -313,8 +326,16 @@ main( argc, argv )
                        }
 
                        last.dptr = NULL;
+
+#ifdef HAVE_BERKELEY_DB2
+                       for ( key = ldbm_firstkey( dbp, &cursorp );
+                               key.dptr != NULL;
+                               key = ldbm_nextkey( dbp, last, cursorp ) )
+#else
                        for ( key = ldbm_firstkey( dbp ); key.dptr != NULL;
-                           key = ldbm_nextkey( dbp, last ) ) {
+                           key = ldbm_nextkey( dbp, last ) )
+#endif
+                       {
                                if ( last.dptr != NULL ) {
                                        ldbm_datum_free( dbp, last );
                                }
@@ -352,10 +373,7 @@ main( argc, argv )
 }
 
 static void
-free_and_close( dbc, key, data )
-    struct dbcache     *dbc;
-    Datum              key;
-    Datum              data;
+free_and_close( struct dbcache *dbc, Datum key, Datum data )
 {
        ldbm_cache_really_close( be, dbc );
        if ( key.dptr != NULL )
@@ -365,17 +383,13 @@ free_and_close( dbc, key, data )
 }
 
 static int
-dnid_cmp( a, b )
-    long       *a;
-    long       *b;
+dnid_cmp( const void *a, const void *b )
 {
-       return( *a - *b );
+       return( *(const long int *)a - *(const long int *)b );
 }
 
 static char *
-myrealloc( p, size )
-    char       *p;
-    int                size;
+myrealloc( char *p, int size )
 {
        if ( p == NULL )
                return( (char *) malloc( size ) );
@@ -384,9 +398,7 @@ myrealloc( p, size )
 }
 
 static void
-get_idlist( fp, data )
-    FILE       *fp;
-    Datum      *data;
+get_idlist( FILE *fp, Datum *data )
 {
        char    buf[20];
        int     i, j, fd, tty;
@@ -448,7 +460,7 @@ get_idlist( fp, data )
                        p->b_nids = i;
                }
 
-               qsort( (void *) p->b_ids, i, sizeof(ID), (void *) dnid_cmp );
+               qsort( (void *) p->b_ids, i, sizeof(ID), dnid_cmp );
        }
 
        data->dptr = (char *) p;
@@ -456,9 +468,7 @@ get_idlist( fp, data )
 }
 
 static void
-get_entry( fp, data )
-    FILE       *fp;
-    Datum      *data;
+get_entry( FILE *fp, Datum *data )
 {
        char    buf[BUFSIZ];
        char    *p;
@@ -492,17 +502,17 @@ get_entry( fp, data )
 }
 
 static void
-edit_entry( c, data )
-    char       c;
-    Datum      *data;
+edit_entry( char c, Datum *data )
 {
        int             fd, pid;
        char            tmpname[20];
        FILE            *fp;
+#ifndef HAVE_WAITPID
        WAITSTATUSTYPE  status;
+#endif
 
        strcpy( tmpname, "/tmp/dbtestXXXXXX" );
-#ifdef ultrix
+#ifndef HAVE_MKSTEMP
        if ( (fd = open( mktemp( tmpname ), O_RDWR, 0600 )) == -1 ) {
                perror( tmpname );
                return;
@@ -536,8 +546,8 @@ edit_entry( c, data )
 
        fclose( fp );
  
-#ifdef USE_WAITPID
-       if ( waitpid( (pid_t) -1, 0, WAIT_FLAGS ) < 0 ) {
+#ifdef HAVE_WAITPID
+       if ( waitpid( (pid_t) -1, NULL, WAIT_FLAGS ) < 0 ) {
 #else
        if ( wait3( &status, WAIT_FLAGS, 0 ) < 0 ) {
 #endif
@@ -556,12 +566,7 @@ edit_entry( c, data )
 }
 
 static struct dbcache *
-openfile( name, namesiz, mode, verbose, c )
-    char       *name;
-    int                namesiz;
-    int                mode;
-    int                verbose;
-    char       c;
+openfile( char *name, int namesiz, int mode, int verbose, char c )
 {
        struct dbcache  *dbc;
 
@@ -590,11 +595,7 @@ openfile( name, namesiz, mode, verbose, c )
 }
 
 static struct dbcache *
-openchoice( c, mode, verbose, fname )
-    char       c;
-    int                mode;
-    int                verbose;
-    char       **fname;
+openchoice( char c, int mode, int verbose, char **fname )
 {
        static char     name[MAXPATHLEN];
 
@@ -629,13 +630,14 @@ openchoice( c, mode, verbose, fname )
 }
 
 static void
-print_entry( fp, c, key, klabel, data, dlabel )
-    FILE       *fp;
-    char       c;
-    Datum      *key;
-    char       *klabel;
-    Datum      *data;
-    char       *dlabel;
+print_entry(
+       FILE    *fp,
+       char    c,
+       Datum   *key,
+       char    *klabel,
+       Datum   *data,
+       char    *dlabel
+)
 {
        ID      id;
        IDList  *idl;
@@ -661,14 +663,14 @@ print_entry( fp, c, key, klabel, data, dlabel )
                            key->dsize );
                if ( data != NULL ) {
                        SAFEMEMCPY( (char *) &id, data->dptr, sizeof(ID) );
-                       fprintf( fp, "%s%d\n", dlabel ? dlabel : "", id );
+                       fprintf( fp, "%s%ld\n", dlabel ? dlabel : "", id );
                }
                break;
 
        case 'e':       /* id2entry - key is dnid, data is entry */
                if ( key != NULL ) {
                        SAFEMEMCPY( (char *) &id, key->dptr, sizeof(ID) );
-                       fprintf( fp, "%s %d\n", klabel, id );
+                       fprintf( fp, "%s %lu\n", klabel, id );
                }
                if ( data != NULL ) {
                        if ( dlabel ) {
@@ -688,19 +690,19 @@ print_entry( fp, c, key, klabel, data, dlabel )
                        idl = (IDList *) data->dptr;
 
                        if ( dlabel )
-                               fprintf( fp, "%s\tnmax=%d\n\tncur=%d\n", dlabel,
+                               fprintf( fp, "%s\tnmax=%ld\n\tncur=%ld\n", dlabel,
                                    idl->b_nmax, idl->b_nids );
 
                        if ( INDIRECT_BLOCK( idl ) ) {
                                for ( i = 0; idl->b_ids[i] != NOID; i++ ) {
-                                       fprintf( fp, "\t%d\n", idl->b_ids[i] );
+                                       fprintf( fp, "\t%ld\n", idl->b_ids[i] );
                                }
                        } else if ( ALLIDS( idl ) ) {
-                               fprintf( fp, "\tALLIDS (1..%d)\n",
+                               fprintf( fp, "\tALLIDS (1..%ld)\n",
                                    idl->b_nids - 1 );
                        } else {
                                for ( i = 0; i < idl->b_nids; i++ ) {
-                                       fprintf( fp, "\t%d\n", idl->b_ids[i] );
+                                       fprintf( fp, "\t%ld\n", idl->b_ids[i] );
                                }
                        }
                }
@@ -722,11 +724,7 @@ print_entry( fp, c, key, klabel, data, dlabel )
 }
 
 static void
-get_keydata( fp, c, key, data )
-    FILE       *fp;
-    char       c;
-    Datum      *key;
-    Datum      *data;
+get_keydata( FILE *fp, char c, Datum *key, Datum *data )
 {
        static char     kbuf[BUFSIZ], dbuf[BUFSIZ];
        long            n;
index 0668eddbcd0e80ebced57c4e1f2028bde9aa5b9d..0f4b2ebb67ae5b3e50c9b5b90278471661acaac3 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <ac/string.h>
 #include <ac/socket.h>
+#include <ac/unistd.h>                 /* Get read() */
 
 #include "lber.h"
 #include "ldap.h"
@@ -14,16 +15,15 @@ int ldap_syslog;
 int    ldap_syslog_level;
 
 
-usage( name )
-char   *name;
+static void
+usage( char *name )
 {
        fprintf( stderr, "usage: %s [-b] <attrtype>\n", name );
        exit( 1 );
 }
 
-main( argc, argv )
-    int                argc;
-    char       **argv;
+int
+main( int argc, char **argv )
 {
        char    buf[BUFSIZ];
        char    *type, *out;
index ee128855a86baa9274c5e06b65dcb70eaca693ee..4c802e1f4412684a2ccb19c323479fecb5103b6e 100644 (file)
@@ -4,30 +4,23 @@
 
 #include <ac/string.h>
 #include <ac/socket.h>
+#include <ac/unistd.h>
 
+#include "ldapconfig.h"
 #include "../slap.h"
 #include "../back-ldbm/back-ldbm.h"
 
-#include "ldapconfig.h"
 #include "ldif.h"
 
 #define MAXARGS                100
 
-extern struct dbcache  *ldbm_cache_open();
-extern void            attr_index_config();
-extern char            *dn_parent();
-extern char            *dn_normalize_case();
-extern int             nbackends;
-extern Backend         *backends;
-extern int             ldap_debug;
-
 int            lineno;
 int            ldap_debug;
 int            ldap_syslog;
 int            ldap_syslog_level;
 int            global_schemacheck;
-int            num_entries_sent;
-int            num_bytes_sent;
+long           num_entries_sent;
+long           num_bytes_sent;
 int            active_threads;
 char           *default_referral;
 struct objclass        *global_oc;
@@ -52,6 +45,7 @@ usage( char *name )
        exit( 1 );
 }
 
+int
 main( int argc, char **argv )
 {
        int             i, cargc, indb, stop, status;
@@ -68,7 +62,6 @@ main( int argc, char **argv )
        struct berval   bv;
        struct berval   *vals[2];
        Avlnode         *avltypes = NULL;
-       extern char     *optarg;
 
        tailorfile = SLAPD_DEFAULT_CONFIGFILE;
        dbnum = -1;
@@ -188,7 +181,7 @@ main( int argc, char **argv )
                                }
 
                                if ( linep == NULL ) {
-                                       fprintf( stderr, "entry %d has no dn\n",
+                                       fprintf( stderr, "entry %lu has no dn\n",
                                            id );
                                } else {
                                        key.dptr = dn_normalize_case( val );
@@ -264,7 +257,7 @@ main( int argc, char **argv )
                                }
 
                                if ( linep == NULL ) {
-                                       fprintf( stderr, "entry %d has no dn\n",
+                                       fprintf( stderr, "entry %lu has no dn\n",
                                            id );
                                } else {
                                        if ( (dn = dn_parent( be, val ))
@@ -292,7 +285,7 @@ main( int argc, char **argv )
                                                    data.dptr, sizeof(ID) );
                                        }
 
-                                       sprintf( buf2, "%c%d", EQ_PREFIX, pid );
+                                       sprintf( buf2, "%c%ld", EQ_PREFIX, pid );
                                        key.dptr = buf2;
                                        key.dsize = strlen( buf2 ) + 1;
                                        if ( idl_insert_key( be, db2, key, id )
index 5c8874c513206ed06f65ddd22d54107b59f8a18c..226d8232db6dc4eb7a3621c4449876fce29a3bc7 100644 (file)
@@ -1,26 +1,23 @@
+#include "portable.h"
+
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+
+#include "ldapconfig.h"
 #include "../slap.h"
 #include "../back-ldbm/back-ldbm.h"
 
-#define DEFAULT_CONFIGFILE     "/usr/local/etc/slapd.conf"
 #define MAXARGS                100
 
-extern struct dbcache  *ldbm_cache_open();
-extern void            attr_index_config();
-extern int             strcasecmp();
-extern int             nbackends;
-extern Backend         *backends;
-extern int             ldap_debug;
-
 int            ldap_debug;
 int            ldap_syslog;
 int            ldap_syslog_level;
 int            global_schemacheck;
-int            num_entries_sent;
-int            num_bytes_sent;
+long           num_entries_sent;
+long           num_bytes_sent;
 int            active_threads;
 char           *default_referral;
 struct objclass        *global_oc;
@@ -35,8 +32,6 @@ pthread_mutex_t       replog_mutex;
 pthread_mutex_t        ops_mutex;
 pthread_mutex_t        regex_mutex;
 
-static int     make_index();
-
 static char    *tailorfile;
 static char    *inputfile;
  
@@ -47,6 +42,7 @@ usage( char *name )
        exit( 1 );
 }
 
+int
 main( int argc, char **argv )
 {
        int             i, cargc, indb, stop, status;
@@ -63,9 +59,8 @@ main( int argc, char **argv )
        struct berval   *vals[2];
        Avlnode         *avltypes = NULL;
        FILE            *fp;
-       extern char     *optarg;
 
-       tailorfile = DEFAULT_CONFIGFILE;
+       tailorfile = SLAPD_DEFAULT_CONFIGFILE;
        dbnum = -1;
        while ( (i = getopt( argc, argv, "d:f:i:n:" )) != EOF ) {
                switch ( i ) {
@@ -117,7 +112,7 @@ main( int argc, char **argv )
                        fprintf( stderr, "No ldbm database found in config file\n" );
                        exit( 1 );
                }
-       } else if ( dbnum < 1 || dbnum > nbackends ) {
+       } else if ( dbnum < 0 || dbnum > (nbackends-1) ) {
                fprintf( stderr, "Database number selected via -n is out of range\n" );
                fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
                exit( 1 );
@@ -149,7 +144,7 @@ main( int argc, char **argv )
 
                        len = strlen( line );
                        if ( buf == NULL || *buf == '\0' ) {
-                               sprintf( idbuf, "%d\n", id + 1 );
+                               sprintf( idbuf, "%lu\n", id + 1 );
                                idlen = strlen( idbuf );
                        } else {
                                idlen = 0;
index 9995dea664fa3b5f88fd40e3a9e553cf0014f00d..1287f502d08f40eddce01fb70debe7a453c0a99a 100644 (file)
@@ -4,26 +4,22 @@
 
 #include <ac/string.h>
 #include <ac/socket.h>
+#include <ac/unistd.h>
 
 #include "../slap.h"
+#include "../back-ldbm/back-ldbm.h"
 
 #include "ldapconfig.h"
 #include "ldif.h"
 
 #define MAXARGS                100
 
-extern void    attr_index_config();
-extern char    *attr_normalize();
-extern int     nbackends;
-extern Backend *backends;
-extern int     ldap_debug;
-
 int            ldap_debug;
 int            ldap_syslog;
 int            ldap_syslog_level;
 int            global_schemacheck;
-int            num_entries_sent;
-int            num_bytes_sent;
+long           num_entries_sent;
+long           num_bytes_sent;
 int            active_threads;
 char           *default_referral;
 struct objclass        *global_oc;
@@ -38,6 +34,7 @@ pthread_mutex_t       replog_mutex;
 pthread_mutex_t        ops_mutex;
 pthread_mutex_t        regex_mutex;
 
+
 static void
 usage( char *name )
 {
@@ -45,6 +42,7 @@ usage( char *name )
        exit( 1 );
 }
 
+int
 main( int argc, char **argv )
 {
        int             i, cargc, indb, stop;
@@ -60,7 +58,6 @@ main( int argc, char **argv )
        Backend         *be = NULL;
        struct berval   bv;
        struct berval   *vals[2];
-       extern char     *optarg;
 
        inputfile = NULL;
        tailorfile = SLAPD_DEFAULT_CONFIGFILE;
index 01ae4fbd2165730d7311ea5872efe224231a8e99..53c8fa008c9e14875aab5fcc848f29522648bb07 100644 (file)
@@ -3,13 +3,16 @@
 #include <stdio.h>
 
 #include <ac/string.h>
+#include <ac/ctype.h>
 #include <ac/socket.h>
+#include <ac/unistd.h>
+#include <ac/wait.h>
 
 #include <sys/param.h>
 
+#include "ldapconfig.h"
 #include "../slap.h"
 #include "../back-ldbm/back-ldbm.h"
-#include "ldapconfig.h"
 #include "ldif.h"
 
 #define INDEXCMD               "ldif2index"
 #define ID2CHILDRENCMD         "ldif2id2children"
 #define MAXARGS                100
 
-extern int             nbackends;
-extern Backend *backends;
-extern int             ldap_debug;
-
 int            ldap_debug;
 int            ldap_syslog;
 int            ldap_syslog_level;
 int            global_schemacheck;
-int            num_entries_sent;
-int            num_bytes_sent;
+long           num_entries_sent;
+long           num_bytes_sent;
 int            active_threads;
 char           *default_referral;
 struct objclass        *global_oc;
@@ -49,7 +48,7 @@ static char   *tailorfile;
 static char    *inputfile;
 static int      maxkids = 1;
 static int      nkids;
+
 static void
 usage( char *name )
 {
@@ -57,6 +56,7 @@ usage( char *name )
        exit( 1 );
 }
 
+int
 main( int argc, char **argv )
 {
        int             i, stop, status;
@@ -73,7 +73,6 @@ main( int argc, char **argv )
        struct berval   bv;
        struct berval   *vals[2];
        Avlnode         *avltypes = NULL;
-       extern char     *optarg;
 
        sbindir = DEFAULT_SBINDIR;
        tailorfile = SLAPD_DEFAULT_CONFIGFILE;
index 45d82301007b6866f9aedf8e2379b24f53f852b9..b21ddbce64a6f53c6c8104eab1e5df12662733c0 100644 (file)
@@ -1,4 +1,10 @@
+#include "portable.h"
+
 #include <stdio.h>
+#include <stdlib.h>
+#include <ac/string.h>
+#include <unistd.h>                    /* get unlink() */
+
 #include <ldbm.h>
 #include <lber.h>
 #include <ldap.h>
 #define DB_FLAGS       (LDBM_WRCREAT|LDBM_NEWDB)
 #define SUBLEN         3
 
-extern char    *first_word();
-extern char    *next_word();
-extern char    *word_dup();
-extern char    *phonetic();
+extern char    *first_word(char *);
+extern char    *next_word(char *);
+extern char    *word_dup(char *);
+extern char    *phonetic(char *);
 
 extern int ldap_debug;
 extern int lber_debug;
@@ -20,11 +26,10 @@ extern int lber_debug;
 int    ldap_syslog;
 int    ldap_syslog_level;
 
-static void    add();
+static void    add(LDBM ldbm, char *s, int *count, int *size, int freeit);
 
-main( argc, argv )
-    int                argc;
-    char       **argv;
+int
+main( int argc, char **argv )
 {
        LDAP                    *ld;
        LDAPMessage             *res, *e;
index 500006c34f0a76218346a570a99fb6d992198863..a4a85468124237064672c122c0153230020709d9 100644 (file)
  *
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
 
-extern Backend *select_backend();
-extern void      be_unbind();
+#include <ac/socket.h>
+
+#include "slap.h"
 
-extern char            *default_referral;
-extern pthread_mutex_t new_conn_mutex;
 
 void
 do_unbind(
index 6a58b40c4c34f044f7072fc9dea3faf174b47469..b5aecdca0f93e7cdc65f95d2c759ee6238384873 100644 (file)
  * reconfiguration of slurpd.
  */
 
+#include "portable.h"
 
 #include <stdio.h>
-#include <signal.h>
+
+#include <ac/signal.h>
 
 #include "slurp.h"
 #include "globals.h"
@@ -33,9 +35,9 @@
  * slurpd receives a USR2 signal, it will dump its replication 
  * queue to the disk file given by SLURPD_DUMPFILE.
  */
-void
-do_admin()
+RETSIGTYPE
+do_admin( int sig )
 {
     sglob->rq->rq_dump( sglob->rq );
-    (void) SIGNAL( SIGUSR2, (void *) do_admin );
+    (void) SIGNAL( SIGUSR2, do_admin );
 }
index d598cce645428d1b9bc4fcce5c2e4c4c6c4316f5..c3b202065c67ed09a08fb16a134a301ff030665f 100644 (file)
 #include "portable.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <ac/string.h>
 #include <ac/time.h>
+#include <ac/unistd.h>
 
 #include <lber.h>
 #include <ldap.h>
@@ -53,7 +55,6 @@ doargs(
 )
 {
     int                i;
-    extern char        *optarg;
     int                rflag = 0;
 
     if ( (g->myname = strrchr( argv[0], '/' )) == NULL ) {
index cf3b79c0b93b10ad4859f8a9f087a8c3818524c2..d6ad464e41e7a3e1ce24edf89c92e4fc8ceabf58 100644 (file)
@@ -17,6 +17,7 @@
 #include "portable.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <ac/socket.h>
 
index ffd25ed0290493bc286769e7968cef253d225125..8fa21f67524ae4c06b3c485b2d08052c0f5157a3 100644 (file)
@@ -18,6 +18,7 @@
 #include "portable.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <ac/string.h>
 #include <ac/socket.h>
diff --git a/servers/slurpd/detach.c b/servers/slurpd/detach.c
deleted file mode 100644 (file)
index 7b3fdab..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 1990, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#ifdef SVR4
-#include <sys/stat.h>
-#endif /* svr4 */
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <signal.h>
-#include "portable.h"
-
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
-
-
-detach()
-{
-       int             i, sd, nbits;
-#ifdef LDAP_DEBUG
-       extern int      ldap_debug;
-#endif
-
-#ifdef USE_SYSCONF
-       nbits = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
-       nbits = getdtablesize();
-#endif /* USE_SYSCONF */
-
-#ifdef LDAP_DEBUG
-       if ( ldap_debug == 0 ) {
-#endif
-               for ( i = 0; i < 5; i++ ) {
-#if defined( sunos5 ) && defined( THREAD_SUNOS5_LWP )
-                       switch ( fork1() ) {
-#else
-                       switch ( fork() ) {
-#endif
-                       case -1:
-                               sleep( 5 );
-                               continue;
-
-                       case 0:
-                               break;
-
-                       default:
-                               _exit( 0 );
-                       }
-                       break;
-               }
-
-/*
-               for ( i = 3; i < nbits; i++ )
-                       close( i );
-*/
-
-               (void) chdir( "/" );
-
-               if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
-                       perror( "/dev/null" );
-                       exit( 1 );
-               }
-               if ( isatty( 0 ) )
-                       (void) dup2( sd, 0 );
-               if ( isatty( 1 ) )
-                       (void) dup2( sd, 1 );
-               if ( isatty(2) )
-                       (void) dup2( sd, 2 );
-               close( sd );
-
-#ifdef USE_SETSID
-               setsid();
-#else /* USE_SETSID */
-               if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
-                       (void) ioctl( sd, TIOCNOTTY, NULL );
-                       (void) close( sd );
-               }
-#endif /* USE_SETSID */
-#ifdef LDAP_DEBUG
-       } 
-#endif
-
-       (void) SIGNAL( SIGPIPE, SIG_IGN );
-}
index 602f8cd8a6547b4a89d82903fc27d0fbb2872d87..be02d2b6f910c5d101fcdd817342e41b7bbbfcc7 100644 (file)
@@ -17,6 +17,7 @@
 #include "portable.h"
 
 #include <stdio.h>
+#include <stdlib.h>                    /* get free() */
 
 #include <ac/string.h>
 #include <ac/signal.h>
 #include "globals.h"
 
 
-/*
- * Externs
- */
-extern RETSIGTYPE do_admin LDAP_P((int));
-extern int file_nonempty LDAP_P(( char * ));
-extern int acquire_lock LDAP_P((char *, FILE **, FILE ** ));
-extern int relinquish_lock LDAP_P((char *, FILE *, FILE * ));
-
 /*
  * Forward references
  */
 static char *get_record LDAP_P(( FILE * ));
 static void populate_queue LDAP_P(( char *f ));
 static RETSIGTYPE set_shutdown LDAP_P((int));
-RETSIGTYPE do_nothing LDAP_P((int));
 
 
 /*
@@ -50,7 +42,7 @@ RETSIGTYPE do_nothing LDAP_P((int));
  *  - adds items to the internal queue of replication work to do
  *  - signals the replication threads to let them know new work has arrived.
  */
-void
+void *
 fm(
     void *arg
 )
@@ -83,7 +75,7 @@ fm(
                sglob->rq->rq_getcount( sglob->rq, RQ_COUNT_ALL ));
        printf( "%d replication records to process.\n",
                sglob->rq->rq_getcount( sglob->rq, RQ_COUNT_NZRC ));
-       return;
+       return NULL;
     }
     /*
      * There may be some leftover replication records in our own
@@ -133,6 +125,7 @@ fm(
        }
     }
     Debug( LDAP_DEBUG_ARGS, "fm: exiting\n", 0, 0, 0 );
+    return NULL;
 }
 
 
@@ -260,4 +253,3 @@ get_record(
     }
     return( buf );
 }
-
index ba13dd20004554f775899b9911e1d81771cf5157..91b7e3086fcc6b90f3364dea62b1b4238b526e0d 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <ac/string.h>
 
 #include "slurp.h"
 #include "globals.h"
@@ -32,7 +33,8 @@ int ldap_debug = 0;
 /*
  * Initialize the globals
  */
-Globals *init_globals()
+Globals *
+init_globals( void )
 {
     Globals *g;
 
index 6107bcbdac9426cafcb599e43cb36f16cde59869..8563edee63398c5a498d08cb838a233d19c4c4df 100644 (file)
 #include "portable.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <ac/errno.h>
 #include <ac/string.h>
 #include <ac/ctype.h>
 #include <ac/time.h>
+#include <ac/unistd.h>         /* Get_t getpid() */
 
 #include <ac/krb.h>
 
@@ -36,7 +38,7 @@ static int op_ldap_add LDAP_P(( Ri *, Re *, char ** ));
 static int op_ldap_modify LDAP_P(( Ri *, Re *, char ** ));
 static int op_ldap_delete LDAP_P(( Ri *, Re *, char ** ));
 static int op_ldap_modrdn LDAP_P(( Ri *, Re *, char ** ));
-static LDAPMod *alloc_ldapmod LDAP_P(());
+static LDAPMod *alloc_ldapmod LDAP_P(( void ));
 static void free_ldapmod LDAP_P(( LDAPMod * ));
 static void free_ldmarr LDAP_P(( LDAPMod ** ));
 static int getmodtype LDAP_P(( char * ));
@@ -434,7 +436,7 @@ op_ldap_modrdn(
  * Allocate and initialize an ldapmod struct.
  */
 static LDAPMod *
-alloc_ldapmod()
+alloc_ldapmod( void )
 {
     LDAPMod    *ldm;
 
@@ -549,7 +551,7 @@ do_unbind(
        if ( rc != LDAP_SUCCESS ) {
            Debug( LDAP_DEBUG_ANY,
                    "Error: do_unbind: ldap_unbind failed for %s:%d: %s\n",
-                   ldap_err2string( rc ), ri->ri_hostname, ri->ri_port );
+                   ri->ri_hostname, ri->ri_port, ldap_err2string( rc ) );
        }
        ri->ri_ldp = NULL;
     }
@@ -750,7 +752,8 @@ kexit:      if ( krbnames != NULL ) {
  */
 static void
 dump_ldm_array(
-LDAPMod **ldmarr )
+    LDAPMod **ldmarr
+)
 {
     int                         i, j;
     LDAPMod            *ldm;
@@ -760,21 +763,21 @@ LDAPMod **ldmarr )
     for ( i = 0; ldmarr[ i ] != NULL; i++ ) {
        ldm = ldmarr[ i ];
        Debug( LDAP_DEBUG_TRACE,
-               "Trace (%d): *** ldmarr[ %d ] contents:\n",
-               getpid(), i, 0 );
+               "Trace (%ld): *** ldmarr[ %d ] contents:\n",
+               (long) getpid(), i, 0 );
        Debug( LDAP_DEBUG_TRACE,
-               "Trace (%d): *** ldm->mod_op: %d\n",
-               getpid(), ldm->mod_op, 0 );
+               "Trace (%ld): *** ldm->mod_op: %d\n",
+               (long) getpid(), ldm->mod_op, 0 );
        Debug( LDAP_DEBUG_TRACE,
-               "Trace (%d): *** ldm->mod_type: %s\n",
-               getpid(), ldm->mod_type, 0 );
+               "Trace (%ld): *** ldm->mod_type: %s\n",
+               (long) getpid(), ldm->mod_type, 0 );
        if ( ldm->mod_bvalues != NULL ) {
            for ( j = 0; ( b = ldm->mod_bvalues[ j ] ) != NULL; j++ ) {
                msgbuf = ch_malloc( b->bv_len + 512 );
                sprintf( msgbuf, "***** bv[ %d ] len = %ld, val = <%s>",
                        j, b->bv_len, b->bv_val );
                Debug( LDAP_DEBUG_TRACE,
-                       "Trace (%d):%s\n", getpid(), msgbuf, 0 );
+                       "Trace (%ld):%s\n", (long) getpid(), msgbuf, 0 );
                free( msgbuf );
            }
        }
@@ -846,7 +849,8 @@ read_krbnames(
  */
 static void
 upcase(
-char *s )
+    char *s
+)
 {
     char *p;
 
index 3e41854eb0dadaae5b5a4965d99b7ea2df0fe582..692c9c3f88878dc48a41acc41fcd085bc09fb2a8 100644 (file)
@@ -26,8 +26,7 @@
 #include <sys/file.h>
 #include <sys/param.h>
 
-#include "../slapd/slap.h"
-
+#include "slurp.h"
 
 
 FILE *
@@ -109,8 +108,8 @@ acquire_lock(
 {
     if (( *rfp = lock_fopen( file, "r+", lfp )) == NULL ) {
        Debug( LDAP_DEBUG_ANY,
-               "Error: acquire_lock(%d): Could not acquire lock on \"%s\"\n",
-               getpid(), file, 0);
+               "Error: acquire_lock(%ld): Could not acquire lock on \"%s\"\n",
+               (long) getpid(), file, 0);
        return( -1 );
     }
     return( 0 );
@@ -131,8 +130,8 @@ relinquish_lock(
 {
     if ( lock_fclose( rfp, lfp ) == EOF ) {
        Debug( LDAP_DEBUG_ANY,
-               "Error: relinquish_lock (%d): Error closing \"%s\"\n",
-               getpid(), file, 0 );
+               "Error: relinquish_lock (%ld): Error closing \"%s\"\n",
+               (long) getpid(), file, 0 );
        return( -1 );
     }
     return( 0 );
index 385633b4acae6448ef19fdced04051f1e2108ec6..28a27fc2ffa577edd35f58c3a8b4650bf36557fe 100644 (file)
 #include "lutil.h"
 
 
-extern int             doargs( int, char **, Globals * );
-extern void            fm();
-extern int             start_replica_thread( Ri * );
-extern Globals         *init_globals();
-extern int             sanity();
-
-#if defined( HAVE_LWP )
-extern void            start_lwp_scheduler();
-#endif /* HAVE_LWP */
-
 int
 main(
     int                argc,
diff --git a/servers/slurpd/proto-slurp.h b/servers/slurpd/proto-slurp.h
new file mode 100644 (file)
index 0000000..c697344
--- /dev/null
@@ -0,0 +1,68 @@
+#ifndef _PROTO_SLURP
+#define _PROTO_SLURP
+
+#include <ldap_cdefs.h>
+
+struct globals;
+
+/* admin.c */
+RETSIGTYPE do_admin    LDAP_P((int sig));
+
+/* args.c */
+int doargs     LDAP_P((int argc, char **argv, struct globals *g));
+
+/* ch_malloc.c */
+void *ch_malloc        LDAP_P((unsigned long size));
+void *ch_realloc       LDAP_P((void *block, unsigned long size));
+void *ch_calloc        LDAP_P((unsigned long nelem, unsigned long size));
+void ch_free   LDAP_P((void *p));
+
+/* config.c */
+int slurpd_read_config LDAP_P((char *fname));
+
+/* ch_malloc.c */
+void ch_free LDAP_P(( void *p ));
+
+/* fm.c */
+void *fm       LDAP_P((void *arg));
+RETSIGTYPE do_nothing  LDAP_P((int i));
+
+/* globals.c */
+extern struct globals *sglob;
+extern int ldap_syslog;
+extern int ldap_syslog_level;
+extern int ldap_debug;
+extern struct globals *init_globals    LDAP_P((void));
+
+/* ldap_op.c */
+int do_ldap    LDAP_P((Ri *ri, Re *re, char **errmsg));
+
+/* lock.c */
+FILE *lock_fopen       LDAP_P((char *fname, char *type, FILE **lfp));
+int lock_fclose        LDAP_P((FILE *fp, FILE *lfp));
+int acquire_lock       LDAP_P((char *file, FILE **rfp, FILE **lfp));
+int relinquish_lock    LDAP_P((char *file, FILE *rfp, FILE *lfp));
+
+/* reject.c */
+void write_reject      LDAP_P((Ri *ri, Re *re, int lderr, char *errmsg));
+
+/* replica.c */
+int start_replica_thread       LDAP_P((Ri *ri));
+
+/* replog.c */
+int copy_replog        LDAP_P((char *src, char *dst));
+int file_nonempty      LDAP_P((char *filename));
+
+/* sanity.c */
+int sanity     LDAP_P((void));
+
+/* st.c */
+int St_init    LDAP_P((St **st));
+
+/* tsleep.c */
+void tsleep    LDAP_P((time_t interval));
+#if defined( HAVE_LWP )
+void start_lwp_scheduler LDAP_P(( void ));
+#endif
+
+#endif /* _PROTO_SLURP */
index f568f07df4b8d0cb26255bde40f87131df42998a..c7358fddc1a0814298ca7fac02f85f88a7dbe244 100644 (file)
@@ -31,9 +31,6 @@
 #include "slurp.h"
 #include "globals.h"
 
-/* externs */
-extern char *str_getline LDAP_P(( char **next ));
-
 /* Forward references */
 static Rh      *get_repl_hosts LDAP_P(( char *, int *, char ** ));
 static int     gettype LDAP_P(( char * ));
@@ -63,6 +60,7 @@ Re_getnext(
 
 /*
  * Free an Re
+ * ??? Something should apparently return nonzero here, but I dont know what.
  */
 static int
 Re_free(
@@ -101,6 +99,7 @@ Re_free(
        free( mi );
     }
     free( re );
+    return 0;
 }
 
 
index 98521033b23e4df4e98c9dad3c24327aea994a68..41861617a0827d59227b1c6b27171cc3d24915fb 100644 (file)
  * Just invoke the Ri's process() member function, and log the start and
  * finish.
  */
-void
+static void *
 replicate(
-    Ri *ri
+    void       *ri_arg
 )
 {
+    Ri         *ri = (Ri *) ri_arg;
+
     Debug( LDAP_DEBUG_ARGS, "begin replication thread for %s:%d\n",
-           ri->ri_hostname, ri->ri_port, 0 );
+           ((Ri *)ri)->ri_hostname, ((Ri *)ri)->ri_port, 0 );
 
     ri->ri_process( ri );
 
     Debug( LDAP_DEBUG_ARGS, "end replication thread for %s:%d\n",
            ri->ri_hostname, ri->ri_port, 0 );
-    return;
+    return NULL;
 }
 
 
index b6b6004960a75e682efb791412c27df689f7cdd7..aa15411a13dc3875c8450dba8e983731956d9618 100644 (file)
 #include "slurp.h"
 #include "globals.h"
 
-/*
- * Externs
- */
-extern FILE *lock_fopen LDAP_P(( char *, char *, FILE ** ));
-
-/*
- * Forward declarations
- */
-int file_nonempty LDAP_P(( char * ));
-
-
-/*
- * Forward declarations
- */
-static int duplicate_replog( char *, char * );
-
-
 /*
  * Copy the replication log.  Returns 0 on success, 1 if a temporary
  * error occurs, and -1 if a fatal error occurs.
@@ -84,8 +67,8 @@ copy_replog(
     }
     if ( access( buf, W_OK ) < 0 ) {
        Debug( LDAP_DEBUG_ANY,
-               "Error: copy_replog (%d): Directory %s is not writable\n",
-               getpid(), buf, 0 );
+               "Error: copy_replog (%ld): Directory %s is not writable\n",
+               (long) getpid(), buf, 0 );
        return( -1 );
     }
     strcpy( buf, dst );
@@ -96,8 +79,8 @@ copy_replog(
     }
     if ( access( buf, W_OK ) < 0 ) {
        Debug( LDAP_DEBUG_ANY,
-               "Error: copy_replog (%d): Directory %s is not writable\n",
-               getpid(), buf, 0 );
+               "Error: copy_replog (%ld): Directory %s is not writable\n",
+               (long) getpid(), buf, 0 );
        return( -1 );
     }
 
index e3af2d05f483ffb2bfb5250a388f3ca75f2b0f9f..d96482d13c04e10aa01da78b0d247aa708a9ff7f 100644 (file)
 #include "globals.h"
 
 
-/* External references */
-extern void write_reject LDAP_P(( Ri *, Re *, int, char * ));
-extern void do_nothing LDAP_P(());
-
 /* Forward references */
 static int ismine LDAP_P(( Ri  *, Re  * ));
 static int isnew LDAP_P(( Ri  *, Re  * ));
-void tsleep LDAP_P(( time_t ));
 
 
 /*
@@ -263,5 +258,3 @@ isnew(
     sglob->st->st_unlock( sglob->st );
     return ret;
 }
-
-
index 783b15ba2d7536a2a58635cb72d44667b96210c0..3fe7285275e1dd5862b661314c61fddc8ef349ee 100644 (file)
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <ac/unistd.h>         /* get ftruncate() */
 
 #include "slurp.h"
 #include "globals.h"
 
 
-/* externs */
-extern void Re_dump LDAP_P(( Re *re ));
-
 /*
  * Lock the replication queue.
  */
@@ -409,4 +407,3 @@ Rq_init(
 
     return 0;
 }
-
index 04be7db86af87d728e9f03c83735cd62d3587613..d666f65da0802bd69a6a834b2ccf9488e0141ac0 100644 (file)
  * feedback to the users.
  */
 
+#include "portable.h"
+
 #include <stdio.h>
-#include <unistd.h>
-#include <string.h>
+
+#include <ac/unistd.h>
+#include <ac/string.h>
 
 #include "slurp.h"
 #include "globals.h"
-#include "portable.h"
 
 #define FC_DIRBAD      1
 #define FC_DIRUNREAD   2
 /*
  * Forward declarations
  */
-#ifdef NEEDPROTOS
-static unsigned int filecheck( char * );
-#else /* NEEDPROTOS */
-static unsigned int filecheck();
-#endif /* NEEDPROTOS */
+static unsigned int filecheck LDAP_P(( char * ));
 
 
 
@@ -58,7 +56,7 @@ static unsigned int filecheck();
  */
 
 int
-sanity()
+sanity( void )
 {
     int        err = 0;
     int rc;
@@ -201,4 +199,3 @@ filecheck(
 
     return ret;
 }
-
index 6041f6fe290e2d58ad8f86b2790d6f9d07754caf..9ec47d2f75e422323846f2c979ad2c41f82e6d95 100644 (file)
@@ -161,7 +161,8 @@ typedef struct rh {
  * Notes:
  *  - Private data should not be manipulated expect by Ri member functions.
  */
-typedef struct ri {
+typedef struct ri Ri;
+struct ri {
 
     /* Private data */
     char       *ri_hostname;           /* canonical hostname of replica */
@@ -179,9 +180,9 @@ typedef struct ri {
     pthread_t  ri_tid;                 /* ID of thread for this replica */
 
     /* Member functions */
-    int                (*ri_process)();        /* process the next repl entry */
-    void       (*ri_wake)();           /* wake up a sleeping thread */
-} Ri;
+    int (*ri_process) LDAP_P(( Ri * ));        /* process the next repl entry */
+    void (*ri_wake)   LDAP_P(( Ri * ));        /* wake up a sleeping thread */
+};
     
 
 
@@ -201,13 +202,13 @@ typedef struct mi {
 
 
 
-
 /* 
  * Information about one particular replication entry.  Only routines in
  * re.c  and rq.c should touch the private data.  Other routines should
  * only use member functions.
  */
-typedef struct re {
+typedef struct re Re;
+struct re {
 
     /* Private data */
     pthread_mutex_t
@@ -222,16 +223,16 @@ typedef struct re {
     struct re  *re_next;               /* pointer to next element */
 
     /* Public functions */
-    int        (*re_free)();           /* free an re struct */
-    struct re  *(*re_getnext)();       /* return next Re in linked list */
-    int                (*re_parse)();          /* parse a replication log entry */
-    int                (*re_write)();          /* write a replication log entry */
-    void       (*re_dump)();           /* debugging  - print contents */
-    int                (*re_lock)();           /* lock this re */
-    int                (*re_unlock)();         /* unlock this re */
-    int                (*re_decrefcnt)();      /* decrement the refcnt */
-    int                (*re_getrefcnt)();      /* get the refcnt */
-} Re;
+    int        (*re_free)    LDAP_P(( Re * )); /* free an re struct */
+    Re *(*re_getnext) LDAP_P(( Re * ));        /* return next Re in linked list */
+    int (*re_parse) LDAP_P(( Re *, char * )); /* parse replication log entry */
+    int (*re_write) LDAP_P(( Ri *, Re *, FILE * )); /* write repl. log entry */
+    void (*re_dump)  LDAP_P(( Re *, FILE * )); /* debugging - print contents */
+    int (*re_lock)   LDAP_P(( Re * ));   /* lock this re */
+    int (*re_unlock) LDAP_P(( Re * ));   /* unlock this re */
+    int (*re_decrefcnt) LDAP_P(( Re * )); /* decrement the refcnt */
+    int (*re_getrefcnt) LDAP_P(( Re * )); /* get the refcnt */
+};
 
 
 
@@ -244,7 +245,8 @@ typedef struct re {
  * variable so routines in ri.c can use it as a mutex for the
  * rq_more condition variable.
  */
-typedef struct rq {
+typedef struct rq Rq;
+struct rq {
 
     /* Private data */
     Re         *rq_head;               /* pointer to head */
@@ -260,18 +262,18 @@ typedef struct rq {
                rq_more;                /* condition var - more work added */
 
     /* Member functions */
-    Re         *(*rq_gethead)();       /* get the element at head */
-    Re         *(*rq_getnext)();       /* get the next element */
-    int                (*rq_delhead)();        /* delete the element at head */
-    int                (*rq_add)();            /* add at tail */
-    void       (*rq_gc)();             /* garbage-collect queue */
-    int                (*rq_lock)();           /* lock the queue */
-    int                (*rq_unlock)();         /* unlock the queue */
-    int                (*rq_needtrim)();       /* see if queue needs trimming */
-    int                (*rq_write)();          /* write Rq contents to a file */
-    int                (*rq_getcount)();       /* return queue counts */
-    void       (*rq_dump)();           /* debugging  - print contents */
-} Rq;
+    Re * (*rq_gethead) LDAP_P(( Rq * )); /* get the element at head */
+    Re * (*rq_getnext) LDAP_P(( Re * )); /* get the next element */
+    int         (*rq_delhead)  LDAP_P(( Rq * )); /* delete the element at head */
+    int         (*rq_add)      LDAP_P(( Rq *, char * )); /* add at tail */
+    void (*rq_gc)      LDAP_P(( Rq * )); /* garbage-collect queue */
+    int         (*rq_lock)     LDAP_P(( Rq * )); /* lock the queue */
+    int         (*rq_unlock)   LDAP_P(( Rq * )); /* unlock the queue */
+    int         (*rq_needtrim) LDAP_P(( Rq * )); /* see if queue needs trimming */
+    int         (*rq_write)    LDAP_P(( Rq *, FILE * )); /*write Rq contents to file*/
+    int         (*rq_getcount) LDAP_P(( Rq *, int )); /* return queue counts */
+    void (*rq_dump)    LDAP_P(( Rq * )); /* debugging - print contents */
+};
 
 
 
@@ -298,8 +300,8 @@ typedef struct stel {
  * if present, uses the timestamps to avoid "replaying" replications
  * which have already been sent to a given replica.
  */
-typedef struct st {
-
+typedef struct st St;
+struct st {
     /* Private data */
     pthread_mutex_t
                st_mutex;               /* mutex to serialize access */
@@ -310,13 +312,13 @@ typedef struct st {
     FILE       *st_lfp;                /* lockfile fp */
 
     /* Public member functions */
-    int                (*st_update)();         /* update the entry for a host */
-    Stel       *(*st_add)();           /* add a new repl host */
-    int                (*st_write)();          /* write status to disk */
-    int                (*st_read)();           /* read status info from disk */
-    int                (*st_lock)();           /* read status info from disk */
-    int                (*st_unlock)();         /* read status info from disk */
-} St;
+    int  (*st_update) LDAP_P(( St *, Stel*, Re* ));/*update entry for a host*/
+    Stel*(*st_add)    LDAP_P(( St *, Ri * ));     /*add a new repl host*/
+    int  (*st_write)  LDAP_P(( St * ));        /* write status to disk */
+    int  (*st_read)   LDAP_P(( St * ));        /* read status info from disk */
+    int  (*st_lock)   LDAP_P(( St * ));        /* read status info from disk */
+    int  (*st_unlock) LDAP_P(( St * ));        /* read status info from disk */
+};
 
 #if defined( HAVE_LWP )
 typedef struct tl {
@@ -331,15 +333,6 @@ typedef struct tsl {
 } tsl_t;
 #endif /* HAVE_LWP */
 
-/* Public functions */
-
-/* In ch_malloc.c */
-void * ch_malloc       LDAP_P(( unsigned long size ));
-void * ch_realloc      LDAP_P(( void *block, unsigned long size ));
-void * ch_calloc       LDAP_P(( unsigned long nelem, unsigned long size ));
-void   ch_free         LDAP_P(( void *p ));
-    
-
 /* 
  * Public functions used to instantiate and initialize queue objects.
  */
@@ -347,6 +340,8 @@ extern int Ri_init LDAP_P(( Ri **ri ));
 extern int Rq_init LDAP_P(( Rq **rq ));
 extern int Re_init LDAP_P(( Re **re ));
 
+#include "proto-slurp.h"
+
 LDAP_END_DECL
 
 #endif /* _SLURPD_H_ */
index 5dc3ba3deabfbae444527663c6d8c4daa3ab9669..abe606d02a04094b2c9d936172fd86899fe7c102 100644 (file)
  * is so much simpler...
  */
 
+#include "portable.h"
+
 #include <stdio.h>
+#include <stdlib.h>
+#include <ac/unistd.h>         /* get sleep() */
 
 #include "slurp.h"
 #include "globals.h"
 
 
-#if defined( THREAD_SUNOS4_LWP )
-
-extern stkalign_t *get_stack( int * );
-extern void free_stack( int );
+#if defined( HAVE_LWP )
 
 int
 tsleep(
-    int        interval
+    time_t     interval
 )
 {
     thread_t   mylwp;
@@ -55,7 +56,7 @@ tsleep(
        for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) {
            if ( SAMETHREAD( t->tl_tid, mylwp )) {
                /* We're already sleeping? */
-               t->tl_wake = now + (time_t) interval;
+               t->tl_wake = now + interval;
                mon_exit( &sglob->tsl_mon );
                lwp_suspend( mylwp );
                return 0;
@@ -65,7 +66,7 @@ tsleep(
     nt = (tl_t *) malloc( sizeof( tl_t ));
 
     nt->tl_next = sglob->tsl_list;
-    nt->tl_wake = now + (time_t) interval;
+    nt->tl_wake = now + interval;
     nt->tl_tid = mylwp;
     sglob->tsl_list = nt;
     mon_exit( &sglob->tsl_mon );
@@ -126,7 +127,7 @@ lwp_scheduler(
  * Create the lwp_scheduler thread.
  */
 void
-start_lwp_scheduler()
+start_lwp_scheduler( void )
 {
     thread_t   tid;
     stkalign_t *stack;
@@ -140,7 +141,7 @@ start_lwp_scheduler()
 }
 
 
-#else /* THREAD_SUNOS4_LWP */
+#else /* !HAVE_LWP */
 
 /*
  * Here we assume we have fully preemptive threads, and that sleep()
@@ -153,7 +154,4 @@ tsleep(
 {
     sleep( interval );
 }
-#endif /* THREAD_SUNOS4_LWP */
-
-
-
+#endif /* !HAVE_LWP */