From 7e6ad5100c2702b1d56a285bdfb341ddf38c0d76 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Sun, 15 Nov 1998 22:40:11 +0000 Subject: [PATCH] Protoized, moved extern definitions to .h files, fixed related bugs. Most function and variable definitions are now preceded by its extern definition, for error checking. Retyped a number of functions, usually to return void. Fixed a number of printf format errors. API changes (in ldap/include): Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h. A number of `extern' declarations are left (some added by protoize), to be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind, optarg, errno. --- clients/fax500/fax500.h | 10 + clients/fax500/faxtotpc.c | 31 +- clients/fax500/main.c | 278 ++++++++--------- clients/fax500/rp500.c | 26 +- clients/finger/main.c | 38 ++- clients/gopher/go500.c | 60 ++-- clients/gopher/go500gw.c | 117 ++++--- clients/mail500/main.c | 318 +++++++++----------- clients/rcpt500/help.c | 7 +- clients/rcpt500/main.c | 44 ++- clients/rcpt500/query.c | 62 ++-- clients/rcpt500/rcpt500.h | 25 +- clients/tools/ldapdelete.c | 9 +- clients/tools/ldapmodify.c | 5 +- clients/tools/ldapmodrdn.c | 9 +- clients/tools/ldapsearch.c | 18 +- clients/ud/auth.c | 50 ++- clients/ud/edit.c | 58 ++-- clients/ud/find.c | 50 +-- clients/ud/globals.c | 30 +- clients/ud/group.c | 72 ++--- clients/ud/help.c | 7 +- clients/ud/main.c | 46 ++- clients/ud/mod.c | 87 ++---- clients/ud/print.c | 69 ++--- clients/ud/string_to_key.c | 43 +-- clients/ud/ud.h | 143 ++++++++- clients/ud/util.c | 115 +++---- contrib/whois++/command.c | 45 +-- contrib/whois++/config.c | 16 +- contrib/whois++/help.c | 4 +- contrib/whois++/template.c | 25 +- contrib/whois++/util.c | 25 +- contrib/whois++/version.c | 3 +- contrib/whois++/whois++.h | 11 +- include/avl.h | 7 + include/lber.h | 1 - include/ldap.h | 10 +- include/lutil.h | 17 +- libraries/libavl/avl.c | 125 +++----- libraries/libavl/testavl.c | 6 +- libraries/liblber/bprint.c | 2 +- libraries/liblber/decode.c | 3 - libraries/liblber/io.c | 10 +- libraries/libldap/cldap.c | 7 +- libraries/libldap/disptmpl.c | 1 + libraries/libldap/dsparse.c | 1 + libraries/libldap/friendly.c | 1 + libraries/libldap/getdn.c | 2 + libraries/libldap/init.c | 6 +- libraries/libldap/ldap-int.h | 8 +- libraries/libldap/options.c | 1 + libraries/libldap/os-ip.c | 2 +- libraries/libldap/request.c | 1 + libraries/libldap/search.c | 1 + libraries/libldap/sort.c | 12 +- libraries/libldap/test.c | 12 +- libraries/libldap/tmplout.c | 1 + libraries/libldap/tmpltest.c | 4 +- libraries/libldap/ufn.c | 3 +- libraries/libldap/url.c | 2 + libraries/libldbm/ldbm.c | 3 +- libraries/liblthread/thread.c | 8 +- libraries/liblutil/md5.c | 29 +- libraries/liblutil/passwd.c | 1 + libraries/liblutil/setproctitle.c | 1 + libraries/liblutil/sha1.c | 41 ++- libraries/liblutil/strdup.c | 4 +- libraries/liblutil/tempnam.c | 10 +- servers/ldapd/add.c | 4 +- servers/ldapd/association.c | 30 +- servers/ldapd/bind.c | 9 +- servers/ldapd/certificate.c | 15 +- servers/ldapd/common.h | 60 ++++ servers/ldapd/compare.c | 2 - servers/ldapd/delete.c | 2 - servers/ldapd/error.c | 1 + servers/ldapd/kerberos.c | 4 - servers/ldapd/main.c | 35 +-- servers/ldapd/modify.c | 20 +- servers/ldapd/modrdn.c | 3 - servers/ldapd/proto-ldapd.h | 37 ++- servers/ldapd/request.c | 9 +- servers/ldapd/result.c | 9 - servers/ldapd/search.c | 10 +- servers/ldapd/syntax.c | 22 +- servers/ldapd/util.c | 9 +- servers/slapd/abandon.c | 4 - servers/slapd/acl.c | 20 +- servers/slapd/aclparse.c | 23 +- servers/slapd/add.c | 14 +- servers/slapd/attr.c | 9 +- servers/slapd/back-ldbm/abandon.c | 3 +- servers/slapd/back-ldbm/add.c | 4 - servers/slapd/back-ldbm/attr.c | 2 - servers/slapd/back-ldbm/bind.c | 3 +- servers/slapd/back-ldbm/cache.c | 13 +- servers/slapd/back-ldbm/close.c | 1 + servers/slapd/back-ldbm/compare.c | 2 - servers/slapd/back-ldbm/config.c | 1 + servers/slapd/back-ldbm/dbcache.c | 12 +- servers/slapd/back-ldbm/delete.c | 2 - servers/slapd/back-ldbm/dn2id.c | 8 +- servers/slapd/back-ldbm/filterindex.c | 35 +-- servers/slapd/back-ldbm/group.c | 6 +- servers/slapd/back-ldbm/id2children.c | 14 +- servers/slapd/back-ldbm/id2entry.c | 19 +- servers/slapd/back-ldbm/idl.c | 15 +- servers/slapd/back-ldbm/index.c | 19 +- servers/slapd/back-ldbm/init.c | 1 + servers/slapd/back-ldbm/modify.c | 9 +- servers/slapd/back-ldbm/modrdn.c | 2 - servers/slapd/back-ldbm/nextid.c | 20 +- servers/slapd/back-ldbm/proto-back-ldbm.h | 3 + servers/slapd/back-ldbm/search.c | 17 +- servers/slapd/back-ldbm/unbind.c | 4 +- servers/slapd/back-passwd/config.c | 1 + servers/slapd/back-passwd/search.c | 5 +- servers/slapd/back-shell/add.c | 12 +- servers/slapd/back-shell/bind.c | 8 +- servers/slapd/back-shell/compare.c | 9 +- servers/slapd/back-shell/config.c | 3 +- servers/slapd/back-shell/delete.c | 9 +- servers/slapd/back-shell/fork.c | 3 + servers/slapd/back-shell/init.c | 1 + servers/slapd/back-shell/modify.c | 10 +- servers/slapd/back-shell/modrdn.c | 9 +- servers/slapd/back-shell/result.c | 3 +- servers/slapd/back-shell/search.c | 11 +- servers/slapd/back-shell/shell.h | 7 + servers/slapd/back-shell/unbind.c | 9 +- servers/slapd/backend.c | 47 +-- servers/slapd/bind.c | 5 - servers/slapd/ch_malloc.c | 6 +- servers/slapd/compare.c | 4 - servers/slapd/config.c | 16 +- servers/slapd/configinfo.c | 6 +- servers/slapd/connection.c | 23 +- servers/slapd/daemon.c | 37 +-- servers/slapd/delete.c | 5 - servers/slapd/dn.c | 2 - servers/slapd/entry.c | 10 +- servers/slapd/filter.c | 16 +- servers/slapd/filterentry.c | 17 +- servers/slapd/init.c | 11 +- servers/slapd/lock.c | 2 + servers/slapd/main.c | 19 +- servers/slapd/modify.c | 12 +- servers/slapd/modrdn.c | 4 - servers/slapd/monitor.c | 22 +- servers/slapd/operation.c | 4 +- servers/slapd/proto-slap.h | 98 +++++- servers/slapd/repl.c | 9 +- servers/slapd/result.c | 11 +- servers/slapd/schema.c | 15 +- servers/slapd/schemaparse.c | 7 +- servers/slapd/search.c | 14 +- servers/slapd/shell-backends/passwd-shell.c | 1 + servers/slapd/shell-backends/shellutil.c | 2 + servers/slapd/shell-backends/shellutil.h | 2 + servers/slapd/slap.h | 36 ++- servers/slapd/str2filter.c | 9 +- servers/slapd/suffixalias.c | 5 +- servers/slapd/tools/centipede.c | 22 +- servers/slapd/tools/chlog2replog.c | 39 +-- servers/slapd/tools/edb2ldif.c | 49 ++- servers/slapd/tools/ldbmcat.c | 9 +- servers/slapd/tools/ldbmtest.c | 100 +++--- servers/slapd/tools/ldif.c | 10 +- servers/slapd/tools/ldif2id2children.c | 21 +- servers/slapd/tools/ldif2id2entry.c | 20 +- servers/slapd/tools/ldif2index.c | 13 +- servers/slapd/tools/ldif2ldbm.c | 16 +- servers/slapd/tools/sizecount.c | 19 +- servers/slapd/unbind.c | 5 - servers/slurpd/admin.c | 2 +- servers/slurpd/args.c | 1 + servers/slurpd/ch_malloc.c | 1 + servers/slurpd/config.c | 1 + servers/slurpd/fm.c | 16 +- servers/slurpd/globals.c | 4 +- servers/slurpd/ldap_op.c | 28 +- servers/slurpd/lock.c | 12 +- servers/slurpd/main.c | 10 - servers/slurpd/proto-slurp.h | 68 +++++ servers/slurpd/re.c | 5 +- servers/slurpd/replica.c | 10 +- servers/slurpd/replog.c | 25 +- servers/slurpd/ri.c | 7 - servers/slurpd/rq.c | 5 +- servers/slurpd/sanity.c | 3 +- servers/slurpd/slurp.h | 90 +++--- servers/slurpd/tsleep.c | 13 +- 193 files changed, 1898 insertions(+), 2168 deletions(-) create mode 100644 clients/fax500/fax500.h create mode 100644 servers/slurpd/proto-slurp.h diff --git a/clients/fax500/fax500.h b/clients/fax500/fax500.h new file mode 100644 index 0000000000..41d08495ec --- /dev/null +++ b/clients/fax500/fax500.h @@ -0,0 +1,10 @@ +#include +#include +#include +extern char *strdup (const char *); + +/* 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 ); diff --git a/clients/fax500/faxtotpc.c b/clients/fax500/faxtotpc.c index 727020f85f..73cadf2f16 100644 --- a/clients/fax500/faxtotpc.c +++ b/clients/fax500/faxtotpc.c @@ -19,20 +19,16 @@ */ #include "portable.h" - -#include -#include - +#include "fax500.h" #include -#include #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 +54,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 +124,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 +167,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 +229,4 @@ char *userinfo; strcat(obuf, TPCDOMAIN); /* tack on domain name */ p = strdup(obuf); return(p); - } diff --git a/clients/fax500/main.c b/clients/fax500/main.c index 7288e941a8..bc6d6a869e 100644 --- a/clients/fax500/main.c +++ b/clients/fax500/main.c @@ -11,16 +11,18 @@ */ #include "portable.h" +#include "fax500.h" -#include #include -#include #include -#include #include #include #include +#include +#include +extern int optind, errno; +extern char *optarg; #ifdef HAVE_SYS_PARAM_H #include @@ -48,7 +50,6 @@ char *errorsfrom = NULL; char *mailfrom = NULL; char *host = NULL; int hostlen = 0; -char *faxtotpc(); int identity; #define MAIL500 1 @@ -104,27 +105,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; @@ -132,9 +139,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 ) { @@ -256,7 +260,7 @@ char **argv; */ if ( numerr > 0 && numto > nargs || ngroups > 0 ) { - int fd; + FILE *fp; char buf[BUFSIZ]; umask( 077 ); @@ -304,7 +308,8 @@ char **argv; return( EX_OK ); } -connect_to_x500() +static int +connect_to_x500( void ) { int sizelimit = FAX_MAXAMBIGUOUS; int deref = LDAP_DEREF_ALWAYS; @@ -326,16 +331,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; @@ -577,16 +583,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 @@ -615,16 +622,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; @@ -796,15 +804,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; @@ -887,13 +897,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; @@ -905,17 +917,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; @@ -927,13 +939,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 @@ -942,7 +951,7 @@ send_message( to ) /* parent */ - if ( pid = fork() ) { + if ( (pid = fork()) != 0 ) { #ifdef HAVE_WAITPID waitpid( pid, (int *) NULL, 0 ); #else @@ -959,10 +968,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; @@ -990,7 +997,7 @@ send_group( group, ngroup ) /* parent */ - if ( pid = fork() ) { + if ( (pid = fork()) != 0 ) { #ifdef HAVE_WAITPID waitpid( pid, (int *) NULL, 0 ); #else @@ -1009,10 +1016,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; @@ -1108,12 +1113,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; @@ -1202,11 +1203,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; @@ -1257,9 +1255,8 @@ do_ambiguous( fp, err, namelen ) } } -static -count_values( list ) - char **list; +static int +count_values( char **list ) { int i; @@ -1269,11 +1266,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; @@ -1297,9 +1291,8 @@ add_to( list, nlist, new ) return; } -static -isgroup( e ) - LDAPMessage *e; +static int +isgroup( LDAPMessage *e ) { int i; char **oclist; @@ -1317,13 +1310,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) ); @@ -1339,11 +1327,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; @@ -1390,9 +1375,8 @@ add_group( dn, list, nlist ) return; } -static -unbind_and_exit( rc ) - int rc; +static void +unbind_and_exit( int rc ) { int i; @@ -1403,8 +1387,7 @@ unbind_and_exit( rc ) } static char * -canonical( s ) - char *s; +canonical( char *s ) { char *saves = s; @@ -1416,9 +1399,8 @@ canonical( s ) return( saves ); } -static -group_loop( dn ) - char *dn; +static int +group_loop( char *dn ) { int i; static char **groups; @@ -1440,11 +1422,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; @@ -1462,10 +1441,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; diff --git a/clients/fax500/rp500.c b/clients/fax500/rp500.c index bea1f4b495..eb54335dc4 100644 --- a/clients/fax500/rp500.c +++ b/clients/fax500/rp500.c @@ -11,12 +11,12 @@ */ #include "portable.h" +#include "fax500.h" -#include +#include #include #include -#include #include #include #include @@ -38,23 +38,20 @@ int deref = LDAP_DEREF_ALWAYS; int sizelimit = DEFAULT_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; @@ -177,7 +174,6 @@ main (argc, argv) rdn++; if ( strcasecmp( rdn, buf ) == 0 ) { char **cn; - char *s; int i, last; cn = ldap_get_values( ld, e, "cn" ); @@ -238,16 +234,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 ); diff --git a/clients/finger/main.c b/clients/finger/main.c index e2c3fbe25d..a617ae9b56 100644 --- a/clients/finger/main.c +++ b/clients/finger/main.c @@ -13,6 +13,7 @@ #include "portable.h" #include +#include #include #include @@ -22,6 +23,8 @@ #include #include #include +extern char *strdup (const char *); +extern int strcasecmp(const char *, const char *); #include @@ -42,21 +45,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; @@ -133,7 +134,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 ); @@ -147,7 +148,8 @@ char **argv; return( 0 ); } -static do_query() +static void +do_query( void ) { char buf[256]; int len, rc, tblsize; @@ -239,8 +241,7 @@ static do_query() } static void -spaces2dots( s ) - char *s; +spaces2dots( char *s ) { for ( ; *s; s++ ) { if ( *s == ' ' ) { @@ -249,9 +250,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; @@ -265,7 +265,6 @@ char *buf; FINGER_SORT_ATTR, #endif 0 }; - extern int strcasecmp(); ufn = 0; #ifdef FINGER_UFN @@ -417,9 +416,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/go500.c b/clients/gopher/go500.c index 984b38ab46..3f21c9cbbc 100644 --- a/clients/gopher/go500.c +++ b/clients/gopher/go500.c @@ -13,6 +13,7 @@ #include "portable.h" #include +#include #include #include @@ -22,6 +23,9 @@ #include #include #include +extern char *strdup (const char *); +extern int strcasecmp(const char *, const char *); +extern int gethostname (char *, int); #include @@ -53,24 +57,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; @@ -80,7 +83,6 @@ char **argv; struct hostent *hp; struct sockaddr_in from; int fromlen; - RETSIGTYPE wait4child(); extern char *optarg; #if defined( LDAP_PROCTITLE ) && !defined( HAVE_SETPROCTITLE ) @@ -261,9 +263,8 @@ char **argv; /* NOT REACHED */ } -static -set_socket( port ) -int port; +static int +set_socket( int port ) { int s, one; struct sockaddr_in addr; @@ -306,7 +307,7 @@ int port; } static RETSIGTYPE -wait4child() +wait4child( int sig ) { #ifndef HAVE_WAITPID WAITSTATUSTYPE status; @@ -325,9 +326,8 @@ wait4child() (void) SIGNAL( SIGCHLD, wait4child ); } -static -do_queries( s ) -int s; +static void +do_queries( int s ) { char buf[1024], *query; int len; @@ -435,10 +435,8 @@ int s; /* NOT REACHED */ } -static -do_error( fp, s ) -FILE *fp; -char *s; +static void +do_error( FILE *fp, char *s ) { int code; @@ -450,11 +448,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; @@ -567,11 +562,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; diff --git a/clients/gopher/go500gw.c b/clients/gopher/go500gw.c index 464361ff80..5e903beb65 100644 --- a/clients/gopher/go500gw.c +++ b/clients/gopher/go500gw.c @@ -13,6 +13,7 @@ #include "portable.h" #include +#include #include #include @@ -22,6 +23,7 @@ #include #include #include +extern int strcasecmp(const char *, const char *); #include @@ -54,31 +56,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; @@ -88,7 +94,6 @@ char **argv; struct hostent *hp; struct sockaddr_in from; int fromlen; - RETSIGTYPE wait4child(); extern char *optarg; #if defined( LDAP_PROCTITLE ) && !defined( HAVE_SETPROCTITLE ) @@ -285,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; @@ -330,7 +335,7 @@ int port; } static RETSIGTYPE -wait4child() +wait4child( int sig ) { #ifndef HAVE_WAITPID WAITSTATUSTYPE status; @@ -349,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; @@ -456,7 +461,7 @@ int s; break; case 'S': /* search */ - do_search( ld, fp, query, 1 ); + do_search( ld, fp, query ); break; case 'M': /* X.500 menu */ @@ -475,8 +480,8 @@ int s; /* NOT REACHED */ } -static char *pick_oc( oclist ) -char **oclist; +static char * +pick_oc( char **oclist ) { int i; @@ -493,10 +498,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; @@ -547,10 +550,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; @@ -580,10 +581,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; @@ -658,9 +657,8 @@ char *dn; } } -static isoc( ocl, oc ) -char **ocl; -char *oc; +static int +isoc( char **ocl, char *oc ) { int i; @@ -672,9 +670,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; @@ -705,10 +702,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 deref; int scope; @@ -778,7 +773,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; @@ -791,7 +786,7 @@ char *query; #endif if ( count == 0 ) { - return( 0 ); + return; } if ( count == 1 ) { @@ -803,10 +798,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 ); @@ -851,10 +846,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; @@ -876,8 +869,8 @@ char *dn; } } -static do_help( op ) -FILE *op; +static void +do_help( FILE *op ) { FILE *fp; char line[BUFSIZ]; @@ -896,9 +889,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" ); @@ -914,9 +906,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/mail500/main.c b/clients/mail500/main.c index ef0e90006a..4efa295f4c 100644 --- a/clients/mail500/main.c +++ b/clients/mail500/main.c @@ -20,6 +20,10 @@ #include #include #include +#include +extern char *strdup (const char *); +extern int optind, errno; +extern char *optarg; #ifdef HAVE_SYS_PARAM_H #include @@ -122,27 +126,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 ); + +void do_group_errors( LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr ); +void do_group_request( LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr ); +void do_group_owner( LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr ); +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; @@ -150,9 +159,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] ); @@ -286,7 +292,7 @@ char **argv; */ if ( numerr > 0 && numto > nargs || ngroups > 0 ) { - int fd; + FILE *fp; char buf[BUFSIZ]; umask( 077 ); @@ -343,7 +349,8 @@ char **argv; return( EX_OK ); } -connect_to_x500() +static int +connect_to_x500( void ) { int opt; @@ -365,10 +372,8 @@ connect_to_x500() return( 0 ); } -static -mailcmp( a, b ) - char *a; - char *b; +static int +mailcmp( char *a, char *b ) { int i; @@ -391,16 +396,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; @@ -692,20 +698,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; @@ -763,16 +768,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; @@ -907,20 +913,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; +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; @@ -977,17 +983,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; +void +do_group_request( + LDAPMessage *e, + char *dn, + char ***to, + int *nto, + Error **err, + int *nerr +) { char **requeststo; @@ -999,17 +1005,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; +void +do_group_errors( + LDAPMessage *e, + char *dn, + char ***to, + int *nto, + Error **err, + int *nerr +) { char **errorsto; @@ -1021,17 +1027,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; +void +do_group_owner( + LDAPMessage *e, + char *dn, + char ***to, + int *nto, + Error **err, + int *nerr +) { char **owner; @@ -1041,12 +1047,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 @@ -1067,7 +1071,7 @@ send_message( to ) } /* parent */ - if ( pid = fork() ) { + if ( (pid = fork()) != 0 ) { #ifdef HAVE_WAITPID waitpid( pid, (int *) NULL, 0 ); #else @@ -1084,10 +1088,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; @@ -1127,7 +1129,7 @@ send_group( group, ngroup ) } /* parent */ - if ( pid = fork() ) { + if ( (pid = fork()) != 0 ) { #ifdef HAVE_WAITPID waitpid( pid, (int *) NULL, 0 ); #else @@ -1142,14 +1144,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; @@ -1190,7 +1188,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 ); @@ -1293,15 +1291,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; @@ -1385,11 +1378,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; @@ -1440,9 +1430,8 @@ do_ambiguous( fp, err, namelen ) } } -static -count_values( list ) - char **list; +static int +count_values( char **list ) { int i; @@ -1452,11 +1441,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; @@ -1475,13 +1461,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; @@ -1499,13 +1482,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) ); @@ -1517,15 +1495,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; @@ -1568,13 +1541,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; @@ -1585,8 +1555,7 @@ unbind_and_exit( rc ) } static char * -canonical( s ) - char *s; +canonical( char *s ) { char *saves = s; @@ -1598,9 +1567,8 @@ canonical( s ) return( saves ); } -static -group_loop( dn ) - char *dn; +static int +group_loop( char *dn ) { int i; static char **groups; @@ -1622,11 +1590,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; @@ -1644,10 +1609,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; diff --git a/clients/rcpt500/help.c b/clients/rcpt500/help.c index b789da2343..9485f7dd9f 100644 --- a/clients/rcpt500/help.c +++ b/clients/rcpt500/help.c @@ -12,6 +12,7 @@ #include #include +#include #ifdef HAVE_FCNTL_H #include @@ -20,13 +21,9 @@ #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; diff --git a/clients/rcpt500/main.c b/clients/rcpt500/main.c index 4a73a2f53d..4a1b637a41 100644 --- a/clients/rcpt500/main.c +++ b/clients/rcpt500/main.c @@ -14,6 +14,8 @@ #include #include #include +extern char *strdup (const char *); +extern char *strstr (const char *, const char *); #include "ldapconfig.h" #include "rcpt500.h" @@ -32,24 +34,23 @@ char *searchbase = NULL; char *dapuser = NULL; 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; @@ -168,10 +169,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 +230,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 +266,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 +345,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; diff --git a/clients/rcpt500/query.c b/clients/rcpt500/query.c index fe9c7e88e8..f1dc4a25af 100644 --- a/clients/rcpt500/query.c +++ b/clients/rcpt500/query.c @@ -9,11 +9,13 @@ #include "portable.h" #include +#include #include #include #include #include +extern int strcasecmp(const char *, const char *); #include "lber.h" #include "ldap.h" @@ -23,30 +25,19 @@ #include "rcpt500.h" #include "ldapconfig.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; - static char buf[ MAXSIZE ]; static char *errpreface = "Your query failed: "; -extern int strcasecmp(); - -void close_ldap(); +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); int -query_cmd( msgp, reply ) - struct msginfo *msgp; - char *reply; +query_cmd( struct msginfo *msgp, char *reply ) { LDAP *ldp; LDAPMessage *ldmsgp, *entry; @@ -224,7 +215,7 @@ query_cmd( msgp, reply ) } -void +static void close_ldap( LDAP *ld ) { #ifdef LDAP_CONNECTIONLESS @@ -236,11 +227,8 @@ close_ldap( LDAP *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; @@ -301,23 +289,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 }; @@ -333,9 +314,8 @@ do_read( ldp, dn, reply, tmpll ) } -report_ldap_err( ldp, reply ) - LDAP *ldp; - char *reply; +static void +report_ldap_err( LDAP *ldp, char *reply ) { int ld_errno = 0; ldap_get_option(ldp, LDAP_OPT_ERROR_NUMBER, &ld_errno); @@ -346,8 +326,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; diff --git a/clients/rcpt500/rcpt500.h b/clients/rcpt500/rcpt500.h index 8b3a5ea17d..c8d4da822d 100644 --- a/clients/rcpt500/rcpt500.h +++ b/clients/rcpt500/rcpt500.h @@ -20,8 +20,9 @@ struct msginfo { }; struct command { - char *cmd_text; /* text for command, e.g. "HELP" */ - int (*cmd_handler)LDAP_P(()); /* 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)); }; @@ -31,12 +32,28 @@ struct command { /* * functions */ -int help_cmd LDAP_P(()); -int query_cmd LDAP_P(()); +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 diff --git a/clients/tools/ldapdelete.c b/clients/tools/ldapdelete.c index 5ff04f187a..3a24aff5a3 100644 --- a/clients/tools/ldapdelete.c +++ b/clients/tools/ldapdelete.c @@ -8,6 +8,7 @@ #include #include +extern char *strdup (const char *); #include #include @@ -20,10 +21,6 @@ static int ldapport = 0; 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 )) @@ -32,9 +29,7 @@ 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 ]; diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 3d4d9e9d4c..821a8120d3 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -8,6 +8,7 @@ #include #include #include +extern char *strdup (const char *); #include @@ -30,10 +31,6 @@ static int ldapport = 0; 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 )) diff --git a/clients/tools/ldapmodrdn.c b/clients/tools/ldapmodrdn.c index e293fc530e..436d8c9978 100644 --- a/clients/tools/ldapmodrdn.c +++ b/clients/tools/ldapmodrdn.c @@ -8,6 +8,7 @@ #include #include #include +extern char *strdup (const char *); #include #include @@ -20,10 +21,6 @@ static int ldapport = 0; 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 )) @@ -34,9 +31,7 @@ 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 ]; diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index 18ea706c0b..bc6f1f6d67 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -6,6 +6,9 @@ #include #include #include +extern char *strdup (const char *); +extern int strcasecmp(const char *, const char *); +extern char *mktemp(char *); #include #include @@ -13,13 +16,9 @@ #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" ); @@ -85,9 +84,7 @@ 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; @@ -373,8 +370,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; @@ -410,7 +405,6 @@ void print_entry( BerElement *ber; struct berval **bvals; FILE *tmpfp; - extern char *mktemp(); dn = ldap_get_dn( ld, entry ); if ( ldif ) { diff --git a/clients/ud/auth.c b/clients/ud/auth.c index 193829e56a..ccb44282e0 100644 --- a/clients/ud/auth.c +++ b/clients/ud/auth.c @@ -19,6 +19,8 @@ #include #include #include +#include +extern char *strdup (const char *); #ifdef HAVE_PWD_H #include @@ -30,25 +32,17 @@ #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 +65,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) @@ -308,8 +295,8 @@ int implicit; #define FIVEMINS ( 5 * 60 ) #define TGT "krbtgt" -static void str2upper( s ) - char *s; +static void +str2upper( char *s ) { char *p; @@ -319,8 +306,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 ]; @@ -360,9 +347,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; @@ -392,8 +377,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 ]; @@ -432,7 +417,8 @@ static kinit( kname ) return( 0 ); } -void destroy_tickets(void) +void +destroy_tickets( void ) { if ( *tktpath != '\0' ) { unlink( tktpath ); @@ -440,11 +426,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); diff --git a/clients/ud/edit.c b/clients/ud/edit.c index d780c5ab9e..cce199024f 100644 --- a/clients/ud/edit.c +++ b/clients/ud/edit.c @@ -17,8 +17,12 @@ #include #include +#include #include #include +#include +extern char *strdup (const char *); +extern char * mktemp(char *); #ifdef HAVE_SYS_RESOURCE_H #include @@ -31,33 +35,22 @@ #include #include #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 +104,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 +200,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 +221,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 +237,8 @@ short flag; return(FALSE); } -static write_entry() +static void +write_entry( void ) { int i = 0, j, number_of_values = -1; @@ -259,9 +248,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 +441,8 @@ static write_entry() return; } -static ovalues(attr) -char *attr; +static int +ovalues( char *attr ) { struct attribute *ap; diff --git a/clients/ud/find.c b/clients/ud/find.c index caa8f8ef69..3a8b72efde 100644 --- a/clients/ud/find.c +++ b/clients/ud/find.c @@ -13,28 +13,23 @@ #include "portable.h" #include +#include #include #include #include +extern char *strdup (const char *); #include #include #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 }; @@ -61,11 +56,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; @@ -74,7 +66,6 @@ char *who; char *name = NULL; /* DN to lookup */ LDAPMessage *mp; int ld_errno = 0; - extern void Free(); #ifdef DEBUG if (debug & D_TRACE) @@ -161,9 +152,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() */ @@ -177,9 +167,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) @@ -342,8 +329,8 @@ int quiet; return(NULL); } -pick_one(i) -int i; +int +pick_one( int i ) { int n; char user_pick[SMALL_BUF_SIZE]; @@ -368,13 +355,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; @@ -418,9 +402,8 @@ again: return; } -find_all_subscribers(sub, group) -char *sub[]; -char *group; +int +find_all_subscribers( char **sub, char *group ) { int count; LDAPMessage *result; @@ -465,9 +448,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 */ diff --git a/clients/ud/globals.c b/clients/ud/globals.c index 6c6f74f979..9e76d94a24 100644 --- a/clients/ud/globals.c +++ b/clients/ud/globals.c @@ -13,15 +13,11 @@ #include "portable.h" #include +#include /* portable.h+ldap.h needs time_t */ +#include +#include #include "ud.h" -extern void set_boolean(), - change_field(), -#ifdef UOFM - set_updates(), -#endif - mod_addrDN(); - struct attribute attrlist[] = { /* @@ -30,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 }, @@ -40,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 HAVE_KERBEROS - { "krbName", "Kerberos name", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_READ }, + { "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 @@ -67,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 } }; diff --git a/clients/ud/group.c b/clients/ud/group.c index a573d19e5b..5ce609bb96 100644 --- a/clients/ud/group.c +++ b/clients/ud/group.c @@ -16,31 +16,21 @@ #include #include +#include #include +#include +extern char *strdup (const char *); #include #include - #include #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; - -extern void Free(); +static char * bind_and_fetch(char *name); -static char * bind_and_fetch(); -void add_group(name) -char *name; +void +add_group( char *name ) { register int i, idx = 0, prompt = 0; char tmp[BUFSIZ], dn[BUFSIZ]; @@ -50,8 +40,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) { @@ -168,7 +156,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); @@ -207,8 +194,8 @@ char *name; return; } -void remove_group(name) -char *name; +void +remove_group( char *name ) { char *dn, tmp[BUFSIZ]; @@ -255,9 +242,8 @@ 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; @@ -354,8 +340,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; @@ -510,15 +496,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) { @@ -664,7 +648,8 @@ ask: return; } -void tidy_up() +void +tidy_up( void ) { register int i = 0; int found_one = 0; @@ -739,11 +724,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; @@ -1012,10 +995,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; @@ -1034,8 +1015,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]; @@ -1113,12 +1094,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) { @@ -1168,8 +1148,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]; diff --git a/clients/ud/help.c b/clients/ud/help.c index 5905c74157..b851d49d37 100644 --- a/clients/ud/help.c +++ b/clients/ud/help.c @@ -23,12 +23,9 @@ #include "ud.h" -#ifdef DEBUG -extern int debug; -#endif -print_help(s) -char *s; +void +print_help( char *s ) { int len; /* command length */ diff --git a/clients/ud/main.c b/clients/ud/main.c index 93f5e1ae15..d1d61964e5 100644 --- a/clients/ud/main.c +++ b/clients/ud/main.c @@ -21,6 +21,8 @@ #include #include #include +extern char *strdup (const char *); +extern char *getenv(const char *); #ifdef HAVE_PWD_H #include @@ -28,6 +30,7 @@ #include #include +#include #include #include #include @@ -81,14 +84,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 */ @@ -164,7 +163,8 @@ char *argv[]; /* NOTREACHED */ } -do_commands() +void +do_commands( void ) { LDAPMessage *mp; /* returned by find() */ register char *cp; /* misc char pointer */ @@ -172,10 +172,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) @@ -286,9 +282,9 @@ do_commands() /* NOTREACHED */ } -status() +void +status( void ) { - void printbase(); register char **rdns; char *host; @@ -325,9 +321,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 */ @@ -341,13 +336,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) @@ -544,7 +535,8 @@ char **base, *s; } } -void initialize_client() +void +initialize_client( void ) { FILE *fp; /* for config file */ static char buffer[MED_BUF_SIZE]; /* for input */ @@ -553,9 +545,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) @@ -693,7 +682,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; @@ -721,7 +709,8 @@ void initialize_client() #endif } -RETSIGTYPE attn() +RETSIGTYPE +attn( int sig ) { fflush(stderr); fflush(stdout); @@ -732,8 +721,9 @@ RETSIGTYPE attn() longjmp(env, 1); } -#ifndef NO_TERMCAP -RETSIGTYPE chwinsz() +#if !defined(NO_TERMCAP) && defined(TIOCGWINSZ) +RETSIGTYPE +chwinsz( int sig ) { struct winsize win; diff --git a/clients/ud/mod.c b/clients/ud/mod.c index 6b26ccd3c7..063c04ac6b 100644 --- a/clients/ud/mod.c +++ b/clients/ud/mod.c @@ -13,6 +13,7 @@ #include "portable.h" #include +#include #include #include @@ -21,28 +22,14 @@ #include #include #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,12 +39,9 @@ char *who; #ifdef UOFM static char printed_warning = 0; /* for use with the */ struct attribute no_batch_update_attr; - extern char * fetch_boolean_value(); int ld_errno; #endif int is_a_group; /* TRUE if it is; FALSE otherwise */ - extern void Free(); - extern int bind_status; #ifdef DEBUG if (debug & D_TRACE) @@ -169,14 +153,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; @@ -184,7 +170,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) @@ -382,8 +367,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 */ @@ -545,12 +530,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]; @@ -604,11 +592,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 }; @@ -674,11 +661,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++) { @@ -703,15 +689,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) { @@ -747,18 +729,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]; @@ -788,8 +764,8 @@ static char * get_URL() return((char *) rvalue); } -static check_URL(url) -char *url; +static int +check_URL( char *url ) { register char *cp; @@ -803,6 +779,7 @@ char *url; } +void mod_perror( LDAP *ld ) { int ld_errno = 0; diff --git a/clients/ud/print.c b/clients/ud/print.c index 5ff0f6b2d9..ce09772091 100644 --- a/clients/ud/print.c +++ b/clients/ud/print.c @@ -17,25 +17,17 @@ #include #include #include +extern char *strdup (const char *); #include #include #include "ud.h" -#ifdef DEBUG -extern int debug; -#endif - struct entry Entry; -extern LDAP *ld; -extern void * Malloc(); -extern void Free(); -extern char * my_ldap_dn2ufn(); - -static char *time2text(); -static long gtime(); +static char *time2text(char *ldtimestr, int dateonly); +static long gtime(struct tm *tm); /* * When displaying entries, display only these attributes, and in this @@ -85,15 +77,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) @@ -142,10 +134,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; @@ -190,12 +180,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(); #ifdef DEBUG if (debug & D_TRACE) @@ -281,8 +271,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; @@ -374,13 +364,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) @@ -411,10 +400,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) @@ -460,11 +449,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)) @@ -472,11 +460,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; @@ -485,8 +472,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; @@ -520,16 +507,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++) ; @@ -615,7 +597,8 @@ int dmsize[] = { /* */ -static long gtime ( struct tm *tm ) +static long +gtime( struct tm *tm ) { register int i, sec, diff --git a/clients/ud/string_to_key.c b/clients/ud/string_to_key.c index d886969e5e..65f2ede485 100644 --- a/clients/ud/string_to_key.c +++ b/clients/ud/string_to_key.c @@ -43,9 +43,7 @@ extern void des_fixup_key_parity(); * 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; @@ -145,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; @@ -184,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]; @@ -213,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 @@ -237,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); diff --git a/clients/ud/ud.h b/clients/ud/ud.h index 56ed57f6c6..aeea56ae64 100644 --- a/clients/ud/ud.h +++ b/clients/ud/ud.h @@ -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 diff --git a/clients/ud/util.c b/clients/ud/util.c index 64dc8bf552..caca219e63 100644 --- a/clients/ud/util.c +++ b/clients/ud/util.c @@ -29,12 +29,8 @@ #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; diff --git a/contrib/whois++/command.c b/contrib/whois++/command.c index 2a59e32d8b..1b109ae65c 100644 --- a/contrib/whois++/command.c +++ b/contrib/whois++/command.c @@ -29,8 +29,8 @@ static char copyright[] = "Copyright 1992 The University of Adelaide"; */ #include "whois++.h" - -extern char *index(), *rindex(); +#include +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; @@ -208,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; @@ -341,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]; @@ -367,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++; @@ -375,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++; @@ -389,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 ); @@ -402,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))))", @@ -529,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 diff --git a/contrib/whois++/config.c b/contrib/whois++/config.c index 3c1387d8ef..a6d0e5c84c 100644 --- a/contrib/whois++/config.c +++ b/contrib/whois++/config.c @@ -29,6 +29,7 @@ static char copyright[] = "Copyright 1992 The University of Adelaide"; */ #include "whois++.h" +#include 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; diff --git a/contrib/whois++/help.c b/contrib/whois++/help.c index d18f4b05b3..499ad3a411 100644 --- a/contrib/whois++/help.c +++ b/contrib/whois++/help.c @@ -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]; diff --git a/contrib/whois++/template.c b/contrib/whois++/template.c index 771fe989b1..cafbc63957 100644 --- a/contrib/whois++/template.c +++ b/contrib/whois++/template.c @@ -29,10 +29,11 @@ static char copyright[] = "Copyright 1992 The University of Adelaide"; */ #include "whois++.h" +#include -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; diff --git a/contrib/whois++/util.c b/contrib/whois++/util.c index 8431878e0b..5d7b8ebec4 100644 --- a/contrib/whois++/util.c +++ b/contrib/whois++/util.c @@ -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 #include #include @@ -41,12 +43,12 @@ static char copyright[] = "Copyright 1992 The University of Adelaide"; #include #include #endif +#include -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; } diff --git a/contrib/whois++/version.c b/contrib/whois++/version.c index 4c747631fc..e15157a144 100644 --- a/contrib/whois++/version.c +++ b/contrib/whois++/version.c @@ -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"; } diff --git a/contrib/whois++/whois++.h b/contrib/whois++/whois++.h index fe22ee19bb..6d148526e9 100644 --- a/contrib/whois++/whois++.h +++ b/contrib/whois++/whois++.h @@ -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/avl.h b/include/avl.h index c9dc9b2a25..651b9026d8 100644 --- a/include/avl.h +++ b/include/avl.h @@ -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 diff --git a/include/lber.h b/include/lber.h index a2e006fab3..1696fe8c9a 100644 --- a/include/lber.h +++ b/include/lber.h @@ -147,7 +147,6 @@ LDAP_F int ber_start_set LDAP_P(( BerElement *ber, unsigned long tag )); LDAP_F int ber_put_seq LDAP_P(( BerElement *ber )); LDAP_F int ber_put_set LDAP_P(( BerElement *ber )); LDAP_F int ber_printf LDAP_P(( BerElement *ber, char *fmt, ... )); -LDAP_F int ber_fatten LDAP_P(( BerElement *ber, struct berval **bvPtr)); /* * in io.c: */ diff --git a/include/ldap.h b/include/ldap.h index 0dc8a50abc..5a53ef2c1d 100644 --- a/include/ldap.h +++ b/include/ldap.h @@ -470,9 +470,13 @@ typedef struct ldap_url_desc { /* avoid pulling in headers */ struct timeval; +/* + * in options.c: + */ LDAP_F int ldap_get_option LDAP_P((LDAP *ld, int option, void *outvalue)); LDAP_F int ldap_set_option LDAP_P((LDAP *ld, int option, void *invalue)); +/* Not yet */ LDAP_F void ldap_control_free LDAP_P(( LDAPControl *ctrl )); LDAP_F void ldap_controls_free LDAP_P(( LDAPControl **ctrls )); @@ -693,10 +697,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 )); /* diff --git a/include/lutil.h b/include/lutil.h index 0d0208a903..3f3a09d392 100644 --- a/include/lutil.h +++ b/include/lutil.h @@ -6,14 +6,27 @@ * 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)); + +/* strdup.c */ +#ifndef HAVE_STRDUP +char *strdup (); /* No prototype, might conflict with someone else''s */ +#endif + +/* tempnam.c */ +#ifndef HAVE_TEMPNAM +LDAP_F char *tempnam (); /* No prototype, might conflict with someone else''s */ +#endif + LDAP_END_DECL #endif /* _LUTIL_H */ diff --git a/libraries/libavl/avl.c b/libraries/libavl/avl.c index 30938263d1..7de1e1cbb7 100644 --- a/libraries/libavl/avl.c +++ b/libraries/libavl/avl.c @@ -50,14 +50,15 @@ static char avl_version[] = "AVL library version 1.0\n"; * and balance of an avl tree. */ -static -int 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; @@ -204,11 +205,8 @@ int ravl_insert( iroot, data, taller, fcmp, fdup, depth ) * NOTE: this routine may malloc memory */ -int 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; @@ -221,8 +219,7 @@ int avl_insert( root, data, fcmp, fdup ) */ static int -right_balance( root ) - Avlnode **root; +right_balance( Avlnode **root ) { int shorter = -1; Avlnode *r, *l; @@ -285,9 +282,8 @@ right_balance( root ) * been shortened because of a deletion. */ -static -int left_balance( root ) - Avlnode **root; +static int +left_balance( Avlnode **root ) { int shorter = -1; Avlnode *r, *l; @@ -353,11 +349,7 @@ int 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; @@ -446,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 -int 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 ); @@ -480,12 +465,8 @@ int avl_inapply( root, fn, arg, stopflag ) return( avl_inapply( root->avl_right, fn, arg, stopflag ) ); } -static -int 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 ); @@ -503,12 +484,8 @@ int avl_postapply( root, fn, arg, stopflag ) return( (*fn)( root->avl_data, arg ) ); } -static -int 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 ); @@ -535,12 +512,8 @@ int avl_preapply( root, fn, arg, stopflag ) * of nodes. */ -int 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: @@ -568,14 +541,16 @@ int avl_apply( root, fn, arg, stopflag, type ) * AVL_NOMORE is returned. */ -int 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; @@ -617,9 +592,8 @@ int avl_prefixapply( root, data, fmatch, marg, fcmp, carg, stopflag ) * number of items actually freed is returned. */ -int avl_free( root, dfree ) - Avlnode *root; - IFP dfree; +int +avl_free( Avlnode *root, IFP dfree ) { int nleft, nright; @@ -647,10 +621,7 @@ int 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; @@ -672,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; @@ -703,10 +671,8 @@ static int avl_nextlist; #define AVL_GRABSIZE 100 /* ARGSUSED */ -static -int avl_buildlist( data, arg ) - caddr_t data; - int arg; +static int +avl_buildlist( caddr_t data, int arg ) { static int slots; @@ -738,8 +704,7 @@ int avl_buildlist( data, arg ) */ caddr_t -avl_getfirst( root ) - Avlnode *root; +avl_getfirst( Avlnode *root ) { if ( avl_list ) { free( (char *) avl_list); @@ -757,7 +722,7 @@ avl_getfirst( root ) } caddr_t -avl_getnext() +avl_getnext( void ) { if ( avl_list == 0 ) return( 0 ); @@ -771,12 +736,14 @@ avl_getnext() return( avl_list[ avl_nextlist++ ] ); } -int avl_dup_error() +int +avl_dup_error( void ) { return( -1 ); } -int avl_dup_ok() +int +avl_dup_ok( void ) { return( 0 ); } diff --git a/libraries/libavl/testavl.c b/libraries/libavl/testavl.c index 5e69e6f3f6..56e3121ce2 100644 --- a/libraries/libavl/testavl.c +++ b/libraries/libavl/testavl.c @@ -7,15 +7,15 @@ #include #include +extern char *strdup (const char *); #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 ]; diff --git a/libraries/liblber/bprint.c b/libraries/liblber/bprint.c index 0b380e62ca..099c61bbe8 100644 --- a/libraries/liblber/bprint.c +++ b/libraries/liblber/bprint.c @@ -5,8 +5,8 @@ #if defined( LDAP_DEBUG ) && defined( LDAP_LIBUI ) #include -#include #endif /* LDAP_DEBUG && LDAP_LIBUI */ +#include #include "lber-int.h" diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c index 838653ef1d..c36ab991be 100644 --- a/libraries/liblber/decode.c +++ b/libraries/liblber/decode.c @@ -14,10 +14,7 @@ #include "portable.h" #include - -#ifdef STDC_HEADERS #include -#endif #include diff --git a/libraries/liblber/io.c b/libraries/liblber/io.c index 884c63ebd2..0a6954996c 100644 --- a/libraries/liblber/io.c +++ b/libraries/liblber/io.c @@ -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 ) ); } @@ -473,7 +473,7 @@ ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ) unsigned long tag = 0, netlen, toread; unsigned char lc; long rc; - int noctets, diff; + unsigned int noctets, diff; #ifdef LDAP_DEBUG if ( lber_debug ) diff --git a/libraries/libldap/cldap.c b/libraries/libldap/cldap.c index 9403c090c0..8af9627307 100644 --- a/libraries/libldap/cldap.c +++ b/libraries/libldap/cldap.c @@ -20,6 +20,7 @@ static char copyright[] = "@(#) Copyright (c) 1990, 1994 Regents of the Universi #include #include #include +#include #include "ldap-int.h" @@ -291,8 +292,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_w_nullc( &ber, 0 ); ldap_set_ber_options( ld, &ber ); @@ -464,7 +465,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 */ diff --git a/libraries/libldap/disptmpl.c b/libraries/libldap/disptmpl.c index 54b493e7c7..426681eb96 100644 --- a/libraries/libldap/disptmpl.c +++ b/libraries/libldap/disptmpl.c @@ -22,6 +22,7 @@ #include #include #include +extern char *strdup (const char *); #ifdef HAVE_SYS_FILE_H #include diff --git a/libraries/libldap/dsparse.c b/libraries/libldap/dsparse.c index 394e61ec34..e0a40daa1d 100644 --- a/libraries/libldap/dsparse.c +++ b/libraries/libldap/dsparse.c @@ -23,6 +23,7 @@ #include #include #include +extern char *strdup (const char *); #ifdef HAVE_SYS_FILE_H #include diff --git a/libraries/libldap/friendly.c b/libraries/libldap/friendly.c index 12896aad83..a18a2456d2 100644 --- a/libraries/libldap/friendly.c +++ b/libraries/libldap/friendly.c @@ -19,6 +19,7 @@ static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of #include #include #include +extern char *strdup (const char *); #include "ldap-int.h" diff --git a/libraries/libldap/getdn.c b/libraries/libldap/getdn.c index 70c09c7933..1abe7668d8 100644 --- a/libraries/libldap/getdn.c +++ b/libraries/libldap/getdn.c @@ -18,6 +18,8 @@ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of #include #include #include +extern char *strdup (const char *); +extern char *strtok (char *, const char *); #include "ldap-int.h" diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c index 9d88d4a613..9836277748 100644 --- a/libraries/libldap/init.c +++ b/libraries/libldap/init.c @@ -5,7 +5,9 @@ #include #include +#include #include +extern char *strdup (const char *); #include "ldap-int.h" #include "ldapconfig.h" @@ -28,7 +30,7 @@ struct ol_keyvalue { int value; }; -struct ol_keyvalue deref_kv[] = { +static struct ol_keyvalue deref_kv[] = { {"never", LDAP_DEREF_NEVER}, {"searching", LDAP_DEREF_SEARCHING}, {"finding", LDAP_DEREF_FINDING}, @@ -36,7 +38,7 @@ struct ol_keyvalue deref_kv[] = { {NULL, 0} }; -struct ol_attribute { +static struct ol_attribute { int type; char* name; void* data; diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index adb8b347df..bd3335c153 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -156,7 +156,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 )); @@ -227,6 +227,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_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ +/* + * in result.c: + */ +#ifdef LDAP_CONNECTIONLESS +LDAP_F int cldap_getmsg ( LDAP *ld, struct timeval *timeout, BerElement *ber ); +#endif /* * in search.c diff --git a/libraries/libldap/options.c b/libraries/libldap/options.c index 182e7df67d..5c5580cb27 100644 --- a/libraries/libldap/options.c +++ b/libraries/libldap/options.c @@ -5,6 +5,7 @@ #include #include +extern char *strdup (const char *); #include "ldap-int.h" diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index 56aa3deecf..e1ebac2661 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -259,7 +259,7 @@ ldap_is_read_ready( LDAP *ld, Sockbuf *sb ) void * -ldap_new_select_info() +ldap_new_select_info( void ) { struct selectinfo *sip; diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 8c33f20d7c..846d1989b1 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -19,6 +19,7 @@ static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of #include #include #include +extern char *strdup (const char *); #include "ldap-int.h" diff --git a/libraries/libldap/search.c b/libraries/libldap/search.c index 2a45f1ce6d..3ac8de7489 100644 --- a/libraries/libldap/search.c +++ b/libraries/libldap/search.c @@ -18,6 +18,7 @@ static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of #include #include #include +extern char *strdup (const char *); #include "ldap-int.h" diff --git a/libraries/libldap/sort.c b/libraries/libldap/sort.c index 7771b4b7c0..831947019d 100644 --- a/libraries/libldap/sort.c +++ b/libraries/libldap/sort.c @@ -29,17 +29,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 @@ -78,7 +78,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; @@ -131,7 +131,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; diff --git a/libraries/libldap/test.c b/libraries/libldap/test.c index 1d840e4b0f..d37556a5cf 100644 --- a/libraries/libldap/test.c +++ b/libraries/libldap/test.c @@ -8,6 +8,7 @@ #include #include #include +extern char *strdup (const char *); #include @@ -26,6 +27,13 @@ */ #include "ldap-int.h" +/* 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 )); @@ -33,7 +41,7 @@ static void free_list LDAP_P(( char **list )); #define NOCACHEERRMSG "don't compile with -DLDAP_NOCACHE if you desire local caching" -char *dnsuffix; +static char *dnsuffix; #ifndef HAVE_GETLINE static char * @@ -215,7 +223,7 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 ) #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS -int +static int bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp, int freeit ) { diff --git a/libraries/libldap/tmplout.c b/libraries/libldap/tmplout.c index 08e3326217..372f427f25 100644 --- a/libraries/libldap/tmplout.c +++ b/libraries/libldap/tmplout.c @@ -25,6 +25,7 @@ #include "ldap-int.h" #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, diff --git a/libraries/libldap/tmpltest.c b/libraries/libldap/tmpltest.c index 5bd25241b4..9855317b56 100644 --- a/libraries/libldap/tmpltest.c +++ b/libraries/libldap/tmpltest.c @@ -15,8 +15,8 @@ #include "disptmpl.h" #include "srchpref.h" -void dump_tmpl LDAP_P(( struct ldap_disptmpl *tmpl )); -void dump_srchpref LDAP_P(( struct ldap_searchobj *sp )); +static void dump_tmpl ( struct ldap_disptmpl *tmpl ); +static void dump_srchpref( struct ldap_searchobj *sp ); #define NULLSTRINGIFNULL( s ) ( s == NULL ? "(null)" : s ) diff --git a/libraries/libldap/ufn.c b/libraries/libldap/ufn.c index a5a279b42f..546481b2e4 100644 --- a/libraries/libldap/ufn.c +++ b/libraries/libldap/ufn.c @@ -18,12 +18,14 @@ static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of #include #include +extern char *strdup (const char *); #include "ldap-int.h" #include "ldapconfig.h" 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, @@ -71,7 +73,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 }; /* diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c index 92cc34ef64..39826e117e 100644 --- a/libraries/libldap/url.c +++ b/libraries/libldap/url.c @@ -30,10 +30,12 @@ static char copyright[] = "@(#) Copyright (c) 1996 Regents of the University of #include #include #include +extern char *strdup (const char *); #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 ); diff --git a/libraries/libldbm/ldbm.c b/libraries/libldbm/ldbm.c index 23e6f842f9..7a49e6b31c 100644 --- a/libraries/libldbm/ldbm.c +++ b/libraries/libldbm/ldbm.c @@ -12,6 +12,7 @@ #include #include +#include #include #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 ); diff --git a/libraries/liblthread/thread.c b/libraries/liblthread/thread.c index 8604b37f49..6c7cff5415 100644 --- a/libraries/liblthread/thread.c +++ b/libraries/liblthread/thread.c @@ -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(); } @@ -372,7 +372,7 @@ pthread_create( } void -pthread_yield() +pthread_yield( void ) { lwp_yield( SELF ); } @@ -525,7 +525,7 @@ pthread_create( } void -pthread_yield() +pthread_yield( void ) { return; } diff --git a/libraries/liblutil/md5.c b/libraries/liblutil/md5.c index 122495cf3e..956b9e5a4c 100644 --- a/libraries/liblutil/md5.c +++ b/libraries/liblutil/md5.c @@ -45,17 +45,14 @@ surprised if they were a performance bottleneck for MD5. */ static uint32 -getu32 (addr) - const unsigned char *addr; +getu32( const unsigned char *addr ) { return (((((unsigned long)addr[3] << 8) | addr[2]) << 8) | addr[1]) << 8 | addr[0]; } static void -putu32 (data, addr) - uint32 data; - unsigned char *addr; +putu32( uint32 data, unsigned char *addr ) { addr[0] = (unsigned char)data; addr[1] = (unsigned char)(data >> 8); @@ -68,8 +65,7 @@ putu32 (data, addr) * initialization constants. */ void -ldap_MD5Init(ctx) - struct ldap_MD5Context *ctx; +ldap_MD5Init( struct ldap_MD5Context *ctx ) { ctx->buf[0] = 0x67452301; ctx->buf[1] = 0xefcdab89; @@ -85,10 +81,11 @@ ldap_MD5Init(ctx) * of bytes. */ void -ldap_MD5Update(ctx, buf, len) - struct ldap_MD5Context *ctx; - unsigned char const *buf; - unsigned len; +ldap_MD5Update( + struct ldap_MD5Context *ctx, + const unsigned char *buf, + unsigned int len +) { uint32 t; @@ -136,9 +133,7 @@ ldap_MD5Update(ctx, buf, len) * 1 0* (64-bit count of bits processed, MSB-first) */ void -ldap_MD5Final(digest, ctx) - unsigned char digest[16]; - struct ldap_MD5Context *ctx; +ldap_MD5Final( unsigned char *digest, struct ldap_MD5Context *ctx ) { unsigned count; unsigned char *p; @@ -199,9 +194,7 @@ ldap_MD5Final(digest, ctx) * the data and converts bytes into longwords for this routine. */ void -ldap_MD5Transform(buf, inraw) - uint32 buf[4]; - const unsigned char inraw[64]; +ldap_MD5Transform( uint32 *buf, const unsigned char *inraw ) { register uint32 a, b, c, d; uint32 in[16]; @@ -296,7 +289,7 @@ ldap_MD5Transform(buf, inraw) #include int -main (int argc, char **argv) +main (int argc, char **argv ) { struct ldap_MD5Context context; unsigned char checksum[16]; diff --git a/libraries/liblutil/passwd.c b/libraries/liblutil/passwd.c index 89b45b92c3..3abbc3041b 100644 --- a/libraries/liblutil/passwd.c +++ b/libraries/liblutil/passwd.c @@ -16,6 +16,7 @@ #include "lutil_md5.h" #include "lutil_sha1.h" #include "lutil.h" +extern char *crypt (const char *, const char *); /* */ diff --git a/libraries/liblutil/setproctitle.c b/libraries/liblutil/setproctitle.c index d0da848040..0d7f04f881 100644 --- a/libraries/liblutil/setproctitle.c +++ b/libraries/liblutil/setproctitle.c @@ -2,6 +2,7 @@ #ifndef HAVE_SETPROCTITLE +#include #include #include diff --git a/libraries/liblutil/sha1.c b/libraries/liblutil/sha1.c index a6153f1f8a..d254b3fcda 100644 --- a/libraries/liblutil/sha1.c +++ b/libraries/liblutil/sha1.c @@ -57,9 +57,8 @@ /* * Hash a single 512-bit block. This is the core of the algorithm. */ -void ldap_SHA1Transform(state, buffer) - uint32 state[5]; - const unsigned char buffer[64]; +void +ldap_SHA1Transform( uint32 *state, const unsigned char *buffer ) { uint32 a, b, c, d, e; typedef union { @@ -69,8 +68,8 @@ void ldap_SHA1Transform(state, buffer) CHAR64LONG16 *block; #ifdef SHA1HANDSOFF - static unsigned char workspace[64]; - block = (CHAR64LONG16 *)workspace; + CHAR64LONG16 workspace; + block = &workspace; (void)memcpy(block, buffer, 64); #else block = (CHAR64LONG16 *)buffer; @@ -120,8 +119,8 @@ void ldap_SHA1Transform(state, buffer) /* * ldap_SHA1Init - Initialize new context */ -void ldap_SHA1Init(context) - ldap_SHA1_CTX *context; +void +ldap_SHA1Init( ldap_SHA1_CTX *context ) { /* SHA1 initialization constants */ @@ -137,10 +136,12 @@ void ldap_SHA1Init(context) /* * Run your data through this. */ -void ldap_SHA1Update(context, data, len) - ldap_SHA1_CTX *context; - const unsigned char *data; - u_int len; +void +ldap_SHA1Update( + ldap_SHA1_CTX *context, + const unsigned char *data, + u_int len +) { u_int i, j; @@ -164,9 +165,8 @@ void ldap_SHA1Update(context, data, len) /* * Add padding and return the message digest. */ -void ldap_SHA1Final(digest, context) - unsigned char digest[20]; - ldap_SHA1_CTX* context; +void +ldap_SHA1Final( unsigned char *digest, ldap_SHA1_CTX *context ) { u_int i; unsigned char finalcount[8]; @@ -225,9 +225,7 @@ static char rcsid[] = "$OpenBSD: sha1hl.c,v 1.1 1997/07/12 20:06:03 millert Exp /* ARGSUSED */ char * -ldap_SHA1End(ctx, buf) - ldap_SHA1_CTX *ctx; - char *buf; +ldap_SHA1End( ldap_SHA1_CTX *ctx, char *buf ) { int i; char *p = buf; @@ -247,9 +245,7 @@ ldap_SHA1End(ctx, buf) } char * -ldap_SHA1File (filename, buf) - char *filename; - char *buf; +ldap_SHA1File( char *filename, char *buf ) { unsigned char buffer[BUFSIZ]; ldap_SHA1_CTX ctx; @@ -270,10 +266,7 @@ ldap_SHA1File (filename, buf) } char * -ldap_SHA1Data (data, len, buf) - const unsigned char *data; - size_t len; - char *buf; +ldap_SHA1Data( const unsigned char *data, size_t len, char *buf ) { ldap_SHA1_CTX ctx; diff --git a/libraries/liblutil/strdup.c b/libraries/liblutil/strdup.c index a7140dbd86..31baa12b30 100644 --- a/libraries/liblutil/strdup.c +++ b/libraries/liblutil/strdup.c @@ -2,14 +2,16 @@ #ifndef HAVE_STRDUP +#include #include +#include "lutil.h" char *strdup( const char *s ) { char *p; if ( (p = (char *) malloc( strlen( s ) + 1 )) == NULL ) - return( NULL ); + return( (char *)0 ); strcpy( p, s ); diff --git a/libraries/liblutil/tempnam.c b/libraries/liblutil/tempnam.c index 9aa21870b8..cdd5385a2e 100644 --- a/libraries/liblutil/tempnam.c +++ b/libraries/liblutil/tempnam.c @@ -1,10 +1,16 @@ #include "portable.h" -#ifndef HAVE_TEMPNAME +#ifndef HAVE_TEMPNAM +#include +#include #include +extern char *mktemp (char *); -char *tempnam( char *dir, char *pfx ) +#include "lutil.h" + +char * +tempnam( char *dir, char *pfx ) { char *s; diff --git a/servers/ldapd/add.c b/servers/ldapd/add.c index 08bf49404b..4b1b6806b1 100644 --- a/servers/ldapd/add.c +++ b/servers/ldapd/add.c @@ -27,7 +27,6 @@ #include "common.h" #ifdef LDAP_COMPAT20 -extern int ldap_compat; #define ADDTAG (ldap_compat == 20 ? OLD_LDAP_RES_ADD : LDAP_RES_ADD) #else #define ADDTAG LDAP_RES_ADD @@ -47,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 ); @@ -90,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; diff --git a/servers/ldapd/association.c b/servers/ldapd/association.c index 1af91e2588..a1c77ac14a 100644 --- a/servers/ldapd/association.c +++ b/servers/ldapd/association.c @@ -18,17 +18,19 @@ #include #include #include +extern int errno; #include #include -#include "lber.h" -#include "ldap.h" - +#include /* get dap_unbind() */ #if ISODEPACKAGE == IC #include #else #include #endif + +#include "lber.h" +#include "ldap.h" #include "common.h" #ifdef HAVE_SYS_IOCTL_H @@ -44,11 +46,10 @@ 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 +71,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 +104,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 +172,7 @@ conn_setfds( fd_set *fds ) } void -conn_badfds() +conn_badfds( void ) { struct conn *tmp; @@ -186,7 +185,8 @@ conn_badfds() } } -struct conn *conn_getfd( fd_set *fds ) +struct conn * +conn_getfd( fd_set *fds ) { struct conn *tmp; @@ -226,7 +226,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 +264,7 @@ struct conn *conn_find( struct conn *c ) } void -conn_close() +conn_close( void ) { struct conn *tmp; @@ -277,7 +278,6 @@ int isclosed( int ad ) { int o; - extern int errno; if ( ioctl( ad, FIOGETOWN, &o ) < 0 ) return( errno == EBADF ? 1 : 0 ); diff --git a/servers/ldapd/bind.c b/servers/ldapd/bind.c index 20f97de576..1d83e1c060 100644 --- a/servers/ldapd/bind.c +++ b/servers/ldapd/bind.c @@ -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; diff --git a/servers/ldapd/certificate.c b/servers/ldapd/certificate.c index 01a57d21e2..be12fed134 100644 --- a/servers/ldapd/certificate.c +++ b/servers/ldapd/certificate.c @@ -17,12 +17,15 @@ #include #include #include +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; diff --git a/servers/ldapd/common.h b/servers/ldapd/common.h index 3193b8b452..b5ea74af0e 100644 --- a/servers/ldapd/common.h +++ b/servers/ldapd/common.h @@ -58,4 +58,64 @@ struct msg { #include "proto-ldapd.h" #include "ldap_log.h" +/* 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[]; + #endif diff --git a/servers/ldapd/compare.c b/servers/ldapd/compare.c index 7cf0833d10..b0b8d339b8 100644 --- a/servers/ldapd/compare.c +++ b/servers/ldapd/compare.c @@ -28,7 +28,6 @@ #include "common.h" #ifdef HAVE_COMPAT20 -extern int ldap_compat; #define COMPTAG (ldap_compat == 20 ? OLD_LDAP_RES_COMPARE : LDAP_RES_COMPARE) #else #define COMPTAG LDAP_RES_COMPARE @@ -46,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 ); diff --git a/servers/ldapd/delete.c b/servers/ldapd/delete.c index 7c7b6ebfe8..fbc6ac0737 100644 --- a/servers/ldapd/delete.c +++ b/servers/ldapd/delete.c @@ -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/error.c b/servers/ldapd/error.c index 2a92880065..a93590fc3e 100644 --- a/servers/ldapd/error.c +++ b/servers/ldapd/error.c @@ -25,6 +25,7 @@ #include "lber.h" #include "ldap.h" #include "ldap_log.h" +#include "common.h" /* get ldap_dn_print() */ void print_error( struct DSError *e ) diff --git a/servers/ldapd/kerberos.c b/servers/ldapd/kerberos.c index 5f7d9767a1..e0de204479 100644 --- a/servers/ldapd/kerberos.c +++ b/servers/ldapd/kerberos.c @@ -38,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 ); @@ -72,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 ); diff --git a/servers/ldapd/main.c b/servers/ldapd/main.c index 9ef964106c..f4e179a5ff 100644 --- a/servers/ldapd/main.c +++ b/servers/ldapd/main.c @@ -49,12 +49,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 @@ -83,8 +82,6 @@ char *kerberos_keyfile; int dtblsize; int RunFromInetd = 0; -extern char Versionstr[]; - static void usage( char *name ) { @@ -102,9 +99,7 @@ usage( char *name ) } int -main (argc, argv) -int argc; -char **argv; +main( int argc, char **argv ) { int tcps, ns; #ifdef LDAP_CONNECTIONLESS @@ -119,7 +114,6 @@ char **argv; int len; int dsapargc; char **dsapargv; - RETSIGTYPE wait4child(); #ifdef LDAP_PROCTITLE char title[80]; #endif @@ -275,8 +269,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 ); } /* @@ -450,7 +444,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 */ @@ -466,7 +460,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; @@ -539,7 +533,6 @@ do_queries( timeout.tv_usec = 0; for ( ;; ) { struct conn *dsaconn; - extern struct conn *conns; FD_ZERO( &readfds ); FD_SET( clientsock, &readfds ); @@ -652,7 +645,8 @@ set_socket( return( s ); } -static RETSIGTYPE wait4child() +static RETSIGTYPE +wait4child( int sig ) { #ifndef HAVE_WAITPID WAITSTATUSTYPE status; @@ -668,11 +662,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; @@ -700,9 +694,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 ); diff --git a/servers/ldapd/modify.c b/servers/ldapd/modify.c index dd4538c034..11a22a1028 100644 --- a/servers/ldapd/modify.c +++ b/servers/ldapd/modify.c @@ -24,6 +24,7 @@ #include #include #include +extern IFP merge_acl; #include "lber.h" #include "ldap.h" @@ -31,22 +32,9 @@ 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 || diff --git a/servers/ldapd/modrdn.c b/servers/ldapd/modrdn.c index 33ae4f8406..1dfa005b7a 100644 --- a/servers/ldapd/modrdn.c +++ b/servers/ldapd/modrdn.c @@ -28,7 +28,6 @@ #include "common.h" #ifdef LDAP_COMPAT20 -extern int ldap_compat; #define MODRDNTAG (ldap_compat == 20 ? OLD_LDAP_RES_MODRDN : LDAP_RES_MODRDN) #else #define MODRDNTAG LDAP_RES_MODRDN @@ -45,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 ); diff --git a/servers/ldapd/proto-ldapd.h b/servers/ldapd/proto-ldapd.h index a317c1ccfd..57ac601696 100644 --- a/servers/ldapd/proto-ldapd.h +++ b/servers/ldapd/proto-ldapd.h @@ -14,21 +14,22 @@ int do_abandon LDAP_P(( struct conn *dsaconn, BerElement *ber, int msgid )); */ 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 LDAP_P(( struct conn *cn )); -int conn_init LDAP_P(()); +int conn_init LDAP_P(( void )); void conn_free LDAP_P(( struct conn *conn )); void conn_del LDAP_P(( struct conn *conn )); -void conn_badfds LDAP_P(()); +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_add LDAP_P(( struct conn *new )); -void conn_close LDAP_P(()); +void conn_close LDAP_P(( void )); int isclosed LDAP_P(( int ad )); /* @@ -46,19 +47,23 @@ 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 certif_init LDAP_P(( void )); /* * compare.c */ +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 LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber )); +void delete_result LDAP_P(( Sockbuf *sb, struct msg *m )); /* * error.c @@ -71,13 +76,17 @@ int x500err2ldaperr LDAP_P(( struct DSError *e, char **matched )); * kerberos.c */ +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 LDAP_P(( int exitcode )); +RETSIGTYPE log_and_exit LDAP_P(( int exitcode )); /* * message.c @@ -94,9 +103,12 @@ struct msg * get_cldap_msg LDAP_P(( int msgid, int msgtype, struct sockaddr *fro * modify.c */ +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 )); + char *type, struct berval **bvals )); +void modify_result LDAP_P(( Sockbuf *sb, struct msg *m )); void modlist_free LDAP_P(( LDAPMod *mods )); /* @@ -104,6 +116,7 @@ void modlist_free LDAP_P(( LDAPMod *mods )); */ int do_modrdn LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber )); +void modrdn_result LDAP_P((Sockbuf *sb, struct msg *m)); /* * request.c @@ -113,6 +126,10 @@ 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 @@ -128,13 +145,17 @@ int send_ldap_result LDAP_P(( Sockbuf *sb, unsigned long tag, int msgid, int err * search.c */ +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 LDAP_P(()); +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)); diff --git a/servers/ldapd/request.c b/servers/ldapd/request.c index fd33fc2545..28dae68661 100644 --- a/servers/ldapd/request.c +++ b/servers/ldapd/request.c @@ -31,8 +31,6 @@ #include "ldap.h" #include "common.h" -extern int dosyslog; - #ifdef PEPSY_DUMP #ifndef DEBUG #define DEBUG @@ -70,11 +68,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 ); @@ -203,7 +196,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 ); diff --git a/servers/ldapd/result.c b/servers/ldapd/result.c index beaef17cd4..498ef4a701 100644 --- a/servers/ldapd/result.c +++ b/servers/ldapd/result.c @@ -27,11 +27,6 @@ #include "ldap.h" #include "common.h" -extern int dosyslog; -#ifdef LDAP_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 @@ -310,10 +305,6 @@ send_ldap_result( int rc; #ifdef LDAP_CONNECTIONLESS int cldap; -#endif - extern int version; - -#ifdef LDAP_CONNECTIONLESS cldap = ( sb->sb_naddr > 0 ); #endif diff --git a/servers/ldapd/search.c b/servers/ldapd/search.c index 30d9141e28..cd413856c4 100644 --- a/servers/ldapd/search.c +++ b/servers/ldapd/search.c @@ -29,13 +29,11 @@ #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 @@ -55,7 +53,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 ); @@ -426,7 +423,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/syntax.c b/servers/ldapd/syntax.c index 806968c236..955ce71734 100644 --- a/servers/ldapd/syntax.c +++ b/servers/ldapd/syntax.c @@ -24,6 +24,8 @@ #include #include #include +extern oid_table_attr *name2attr( char * ); +/*extern AttributeValue str_at2AttrV( char *, IF_AttributeType * );*/ #include "lber.h" #include "../../libraries/liblber/lber-int.h" /* get struct berelement */ @@ -60,7 +62,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 ); @@ -75,10 +77,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 ); @@ -135,7 +135,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 */ ) @@ -182,7 +183,6 @@ dn_print_real( int firstrdn; char *value; PS rps; - void ldap_dn_print(); char key[512]; if ( dn == NULLDN ) @@ -554,9 +554,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 ); @@ -623,7 +620,8 @@ trim_trailing_spaces( char *s ) } } -DN ldap_str2dn( char *str ) +DN +ldap_str2dn( char *str ) { DN dn, save; RDN rdn, newrdn, tmprdn; @@ -786,7 +784,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; @@ -966,7 +965,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 ); diff --git a/servers/ldapd/util.c b/servers/ldapd/util.c index 965d1cd78c..4baccd6a04 100644 --- a/servers/ldapd/util.c +++ b/servers/ldapd/util.c @@ -53,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--; @@ -70,7 +70,8 @@ bprint( char *data, int len ) } } -void charlist_free( char **cl ) +void +charlist_free( char **cl ) { int i; @@ -86,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 ); @@ -132,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 ); diff --git a/servers/slapd/abandon.c b/servers/slapd/abandon.c index fb9d1be4b2..d3f3cd4896 100644 --- a/servers/slapd/abandon.c +++ b/servers/slapd/abandon.c @@ -19,10 +19,6 @@ #include "slap.h" -extern Backend *select_backend(); - -extern char *default_referral; - void do_abandon( Connection *conn, diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index a9fcc6a120..5bb093fea9 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -10,20 +10,9 @@ #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, diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index e47a00380a..637471cb91 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -12,27 +12,22 @@ #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 to [ by ]+ \n" ); fprintf( stderr, " ::= * | [dn=] [filter=] [attrs=]\n" ); diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 110e3d365d..5393e3afe9 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -20,20 +20,10 @@ #include "slap.h" -extern Backend *select_backend(); -extern char *dn_normalize(); - -extern char *default_referral; -extern time_t currenttime; -extern pthread_mutex_t currenttime_mutex; -extern int global_lastmod; - -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; diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index e4fa388fa9..99cd92b2ca 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -21,7 +21,6 @@ #include "slap.h" -extern char **charray_dup(); extern int errno; void @@ -294,7 +293,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 +324,7 @@ attr_syntax_config( #ifdef LDAP_DEBUG -static +static int attr_syntax_printnode( struct asyntaxinfo *a ) { int i; @@ -337,8 +336,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 ); diff --git a/servers/slapd/back-ldbm/abandon.c b/servers/slapd/back-ldbm/abandon.c index 11280148a8..ef7409ce62 100644 --- a/servers/slapd/back-ldbm/abandon.c +++ b/servers/slapd/back-ldbm/abandon.c @@ -2,7 +2,8 @@ #include "portable.h" -int +/*ARGSUSED*/ +void ldbm_back_abandon() { } diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index eebcf4a257..75dd12b1b2 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -11,10 +11,6 @@ #include "back-ldbm.h" #include "proto-back-ldbm.h" -extern int global_schemacheck; -extern char *dn_parent(); -extern char *dn_normalize(); - int ldbm_back_add( Backend *be, diff --git a/servers/slapd/back-ldbm/attr.c b/servers/slapd/back-ldbm/attr.c index ea9694857f..1ef4bbd07f 100644 --- a/servers/slapd/back-ldbm/attr.c +++ b/servers/slapd/back-ldbm/attr.c @@ -10,8 +10,6 @@ #include "slap.h" #include "back-ldbm.h" -extern char **str2charray(); - static int ainfo_type_cmp( char *type, diff --git a/servers/slapd/back-ldbm/bind.c b/servers/slapd/back-ldbm/bind.c index d1224a2dfd..dce574b95e 100644 --- a/servers/slapd/back-ldbm/bind.c +++ b/servers/slapd/back-ldbm/bind.c @@ -8,6 +8,7 @@ #include #include #include +extern char *crypt (); #include "slap.h" #include "back-ldbm.h" @@ -23,8 +24,6 @@ #include -extern Attribute *attr_find(); - #ifdef HAVE_KERBEROS extern int krbv4_ldap_auth(); #endif diff --git a/servers/slapd/back-ldbm/cache.c b/servers/slapd/back-ldbm/cache.c index 4f2fa10107..1674432d69 100644 --- a/servers/slapd/back-ldbm/cache.c +++ b/servers/slapd/back-ldbm/cache.c @@ -3,15 +3,16 @@ #include "portable.h" #include +int strcasecmp( const char *, const char *); #include #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 ); } } diff --git a/servers/slapd/back-ldbm/close.c b/servers/slapd/back-ldbm/close.c index f300d9f92d..4539163b2f 100644 --- a/servers/slapd/back-ldbm/close.c +++ b/servers/slapd/back-ldbm/close.c @@ -9,6 +9,7 @@ #include "slap.h" #include "back-ldbm.h" +void ldbm_back_close( Backend *be ) { Debug( LDAP_DEBUG_TRACE, "ldbm backend syncing\n", 0, 0, 0 ); diff --git a/servers/slapd/back-ldbm/compare.c b/servers/slapd/back-ldbm/compare.c index d3a4a4d90b..d17c5da88a 100644 --- a/servers/slapd/back-ldbm/compare.c +++ b/servers/slapd/back-ldbm/compare.c @@ -11,8 +11,6 @@ #include "back-ldbm.h" #include "proto-back-ldbm.h" -extern Attribute *attr_find(); - int ldbm_back_compare( Backend *be, diff --git a/servers/slapd/back-ldbm/config.c b/servers/slapd/back-ldbm/config.c index a47d7a14a1..dab1dec432 100644 --- a/servers/slapd/back-ldbm/config.c +++ b/servers/slapd/back-ldbm/config.c @@ -10,6 +10,7 @@ #include "slap.h" #include "back-ldbm.h" +void ldbm_back_config( Backend *be, char *fname, diff --git a/servers/slapd/back-ldbm/dbcache.c b/servers/slapd/back-ldbm/dbcache.c index ff09593f93..3da34b0126 100644 --- a/servers/slapd/back-ldbm/dbcache.c +++ b/servers/slapd/back-ldbm/dbcache.c @@ -15,17 +15,9 @@ #include #endif +#include "ldapconfig.h" #include "slap.h" #include "back-ldbm.h" -#include "ldapconfig.h" - -#ifdef DECL_SYS_ERRLIST -extern int sys_nerr; -extern char *sys_errlist[]; -#endif - -extern time_t currenttime; -extern pthread_mutex_t currenttime_mutex; struct dbcache * ldbm_cache_open( @@ -122,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 ); diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index 412566d809..32317c922f 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -11,8 +11,6 @@ #include "back-ldbm.h" #include "proto-back-ldbm.h" -extern Attribute *attr_find(); - int ldbm_back_delete( Backend *be, diff --git a/servers/slapd/back-ldbm/dn2id.c b/servers/slapd/back-ldbm/dn2id.c index 4a7da28731..593107cc2c 100644 --- a/servers/slapd/back-ldbm/dn2id.c +++ b/servers/slapd/back-ldbm/dn2id.c @@ -11,10 +11,6 @@ #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 ); } diff --git a/servers/slapd/back-ldbm/filterindex.c b/servers/slapd/back-ldbm/filterindex.c index ffb9292b42..31d9551e17 100644 --- a/servers/slapd/back-ldbm/filterindex.c +++ b/servers/slapd/back-ldbm/filterindex.c @@ -10,21 +10,12 @@ #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. @@ -92,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 ); } @@ -123,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 ); } @@ -140,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 ); } @@ -177,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 ); } @@ -218,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 ); } @@ -285,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 ); } @@ -353,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 ); } diff --git a/servers/slapd/back-ldbm/group.c b/servers/slapd/back-ldbm/group.c index 42a16e4e42..7def923a4d 100644 --- a/servers/slapd/back-ldbm/group.c +++ b/servers/slapd/back-ldbm/group.c @@ -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 */ diff --git a/servers/slapd/back-ldbm/id2children.c b/servers/slapd/back-ldbm/id2children.c index 7c555bfecb..cd0cc7a6df 100644 --- a/servers/slapd/back-ldbm/id2children.c +++ b/servers/slapd/back-ldbm/id2children.c @@ -10,10 +10,6 @@ #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 ) { diff --git a/servers/slapd/back-ldbm/id2entry.c b/servers/slapd/back-ldbm/id2entry.c index edc8f4c7b2..ab8ff238f1 100644 --- a/servers/slapd/back-ldbm/id2entry.c +++ b/servers/slapd/back-ldbm/id2entry.c @@ -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 ) ); } diff --git a/servers/slapd/back-ldbm/idl.c b/servers/slapd/back-ldbm/idl.c index d1e38aa197..4e47e78ada 100644 --- a/servers/slapd/back-ldbm/idl.c +++ b/servers/slapd/back-ldbm/idl.c @@ -7,12 +7,10 @@ #include #include -#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; diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index dbe549b924..c00bd2509c 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -10,17 +10,8 @@ #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]; diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index 9193f7213c..407e3c74ee 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -10,6 +10,7 @@ #include "slap.h" #include "back-ldbm.h" +void ldbm_back_init( Backend *be ) diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 3c16b925d4..7b0d141d0f 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -11,12 +11,9 @@ #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( diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index 1555383045..4ea74e9533 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -11,8 +11,6 @@ #include "back-ldbm.h" #include "proto-back-ldbm.h" -extern char *dn_parent(); - int ldbm_back_modrdn( Backend *be, diff --git a/servers/slapd/back-ldbm/nextid.c b/servers/slapd/back-ldbm/nextid.c index b16100a3f0..9bb2d605be 100644 --- a/servers/slapd/back-ldbm/nextid.c +++ b/servers/slapd/back-ldbm/nextid.c @@ -29,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 { @@ -37,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; } @@ -47,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 ); } } @@ -83,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 ); } } @@ -116,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 { @@ -124,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; } diff --git a/servers/slapd/back-ldbm/proto-back-ldbm.h b/servers/slapd/back-ldbm/proto-back-ldbm.h index 96eabe5850..b51691eb4c 100644 --- a/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -47,6 +47,7 @@ int cache_delete_entry LDAP_P(( struct cache *cache, Entry *e )); 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 )); @@ -73,6 +74,7 @@ IDList * filter_candidates LDAP_P(( Backend *be, Filter *f )); */ 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 )); /* @@ -95,6 +97,7 @@ 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 )); diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index 6b73e802b7..4b25fe66cd 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -11,17 +11,9 @@ #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; } diff --git a/servers/slapd/back-ldbm/unbind.c b/servers/slapd/back-ldbm/unbind.c index 6330b4db20..0241a00b35 100644 --- a/servers/slapd/back-ldbm/unbind.c +++ b/servers/slapd/back-ldbm/unbind.c @@ -3,17 +3,15 @@ #include "portable.h" #include - #include #include "slap.h" -int +void ldbm_back_unbind( Backend *be, Connection *conn, Operation *op ) { - return( 0 ); } diff --git a/servers/slapd/back-passwd/config.c b/servers/slapd/back-passwd/config.c index 839af28cab..5e9bf853a3 100644 --- a/servers/slapd/back-passwd/config.c +++ b/servers/slapd/back-passwd/config.c @@ -10,6 +10,7 @@ #include "slap.h" +void passwd_back_config( Backend *be, char *fname, diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index 942b804a6c..86fb55e610 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -12,10 +12,7 @@ #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( diff --git a/servers/slapd/back-shell/add.c b/servers/slapd/back-shell/add.c index c798e8c6c1..5d201fd586 100644 --- a/servers/slapd/back-shell/add.c +++ b/servers/slapd/back-shell/add.c @@ -10,10 +10,7 @@ #include "slap.h" #include "shell.h" -extern pthread_mutex_t entry2str_mutex; -extern char *entry2str(); - -void +int shell_back_add( Backend *be, Connection *conn, @@ -28,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 ) ); @@ -50,4 +47,5 @@ shell_back_add( read_and_send_results( be, conn, op, rfp, NULL, 0 ); fclose( rfp ); + return( 0 ); } diff --git a/servers/slapd/back-shell/bind.c b/servers/slapd/back-shell/bind.c index 33bcd9df97..ac1ab4e982 100644 --- a/servers/slapd/back-shell/bind.c +++ b/servers/slapd/back-shell/bind.c @@ -27,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 ); diff --git a/servers/slapd/back-shell/compare.c b/servers/slapd/back-shell/compare.c index ed93c411d9..9fd4343a0a 100644 --- a/servers/slapd/back-shell/compare.c +++ b/servers/slapd/back-shell/compare.c @@ -10,7 +10,7 @@ #include "slap.h" #include "shell.h" -void +int shell_back_compare( Backend *be, Connection *conn, @@ -25,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 ); @@ -47,4 +47,5 @@ shell_back_compare( read_and_send_results( be, conn, op, rfp, NULL, 0 ); fclose( rfp ); + return( 0 ); } diff --git a/servers/slapd/back-shell/config.c b/servers/slapd/back-shell/config.c index 10aee26a2c..ac411d7563 100644 --- a/servers/slapd/back-shell/config.c +++ b/servers/slapd/back-shell/config.c @@ -10,8 +10,7 @@ #include "slap.h" #include "shell.h" -extern char **charray_dup(); - +void shell_back_config( Backend *be, char *fname, diff --git a/servers/slapd/back-shell/delete.c b/servers/slapd/back-shell/delete.c index 75760ed271..2d55fdc429 100644 --- a/servers/slapd/back-shell/delete.c +++ b/servers/slapd/back-shell/delete.c @@ -10,7 +10,7 @@ #include "slap.h" #include "shell.h" -void +int shell_back_delete( Backend *be, Connection *conn, @@ -24,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 ); @@ -44,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 ); } diff --git a/servers/slapd/back-shell/fork.c b/servers/slapd/back-shell/fork.c index 14eaca4349..13f099b331 100644 --- a/servers/slapd/back-shell/fork.c +++ b/servers/slapd/back-shell/fork.c @@ -6,9 +6,12 @@ #include #include +#include #include "slap.h" +#include "shell.h" +int forkandexec( char **args, FILE **rfp, diff --git a/servers/slapd/back-shell/init.c b/servers/slapd/back-shell/init.c index 0865887123..6a841c154b 100644 --- a/servers/slapd/back-shell/init.c +++ b/servers/slapd/back-shell/init.c @@ -9,6 +9,7 @@ #include "slap.h" #include "shell.h" +void shell_back_init( Backend *be ) diff --git a/servers/slapd/back-shell/modify.c b/servers/slapd/back-shell/modify.c index c3863bfd36..034830b649 100644 --- a/servers/slapd/back-shell/modify.c +++ b/servers/slapd/back-shell/modify.c @@ -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 ); + } diff --git a/servers/slapd/back-shell/modrdn.c b/servers/slapd/back-shell/modrdn.c index f3f00217ad..ad7cc5ad41 100644 --- a/servers/slapd/back-shell/modrdn.c +++ b/servers/slapd/back-shell/modrdn.c @@ -10,7 +10,7 @@ #include "slap.h" #include "shell.h" -void +int shell_back_modrdn( Backend *be, Connection *conn, @@ -26,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 ); @@ -48,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 ); } diff --git a/servers/slapd/back-shell/result.c b/servers/slapd/back-shell/result.c index 3d18e23baa..daa826775d 100644 --- a/servers/slapd/back-shell/result.c +++ b/servers/slapd/back-shell/result.c @@ -6,12 +6,11 @@ #include #include +#include #include "slap.h" #include "shell.h" -extern Entry *str2entry(); - int read_and_send_results( Backend *be, diff --git a/servers/slapd/back-shell/search.c b/servers/slapd/back-shell/search.c index 969215883b..ded0b2f5fc 100644 --- a/servers/slapd/back-shell/search.c +++ b/servers/slapd/back-shell/search.c @@ -10,9 +10,7 @@ #include "slap.h" #include "shell.h" -extern Entry *str2entry(); - -void +int shell_back_search( Backend *be, Connection *conn, @@ -37,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 ); @@ -69,4 +67,5 @@ shell_back_search( read_and_send_results( be, conn, op, rfp, attrs, attrsonly ); fclose( rfp ); + return( 0 ); } diff --git a/servers/slapd/back-shell/shell.h b/servers/slapd/back-shell/shell.h index 6228b6408e..bb76f15fd9 100644 --- a/servers/slapd/back-shell/shell.h +++ b/servers/slapd/back-shell/shell.h @@ -19,6 +19,13 @@ struct shellinfo { 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 diff --git a/servers/slapd/back-shell/unbind.c b/servers/slapd/back-shell/unbind.c index 93c6889468..84bb05138a 100644 --- a/servers/slapd/back-shell/unbind.c +++ b/servers/slapd/back-shell/unbind.c @@ -14,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; @@ -38,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 */ diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 39fdd279d4..61511ff748 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -12,43 +12,6 @@ #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)); diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index 8d3979992c..7cb354ac1a 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -21,11 +21,6 @@ #include "slap.h" -extern Backend *select_backend(); -extern char *suffixAlias(); - -extern char *default_referral; - void do_bind( Connection *conn, diff --git a/servers/slapd/ch_malloc.c b/servers/slapd/ch_malloc.c index 519720e238..366e7bc1f1 100644 --- a/servers/slapd/ch_malloc.c +++ b/servers/slapd/ch_malloc.c @@ -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 ); } diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index d31f2655a4..88a63e8b21 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -18,10 +18,6 @@ #include "slap.h" -extern Backend *select_backend(); - -extern char *default_referral; - void do_compare( Connection *conn, diff --git a/servers/slapd/config.c b/servers/slapd/config.c index f7aa3b688c..715dd8baee 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -5,18 +5,14 @@ #include #include +#include #include -#include "slap.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 */ @@ -28,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 ) diff --git a/servers/slapd/configinfo.c b/servers/slapd/configinfo.c index 744d611ad8..9ad40ebedb 100644 --- a/servers/slapd/configinfo.c +++ b/servers/slapd/configinfo.c @@ -17,15 +17,11 @@ #include #include -#include "slap.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! */ diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index abc10cdfce..36fca0b705 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -10,15 +10,6 @@ #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 ); diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index b9a11efb70..48eb7f13d3 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -17,8 +17,8 @@ #include #include -#include "slap.h" #include "ldapconfig.h" +#include "slap.h" #ifdef HAVE_SYS_FILIO_H #include @@ -33,29 +33,15 @@ int allow_severity = LOG_INFO; int deny_severity = LOG_NOTICE; #endif /* TCP Wrappers */ -extern Operation *op_add(); - -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 dtblsize; Connection *c; -static void set_shutdown(); -static void do_nothing(); +static void set_shutdown(int sig); +static void do_nothing (int sig); -void +void * slapd_daemon( - int port + void *port ) { Operation *o; @@ -125,7 +111,7 @@ slapd_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] : @@ -159,7 +145,7 @@ slapd_daemon( 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 @@ -407,12 +393,13 @@ slapd_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 /* @@ -431,9 +418,9 @@ set_shutdown() } static void -do_nothing() +do_nothing( int sig ) { - Debug( LDAP_DEBUG_TRACE, "slapd got do_nothing signal\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "slapd got do_nothing signal %d\n", sig, 0, 0 ); #ifdef HAVE_LINUX_THREADS /* * LinuxThreads are implemented using SIGUSR1/USR2, diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index 477e6f35f1..a3df326eb3 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -19,11 +19,6 @@ #include "slap.h" -extern Backend *select_backend(); -extern char *suffixAlias(); - -extern char *default_referral; - void do_delete( Connection *conn, diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index d67aca70ac..bd51b3c13d 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -11,8 +11,6 @@ #include "slap.h" -static char **dn_explode(); - #define DNSEPARATOR(c) (c == ',' || c == ';') #define SEPARATOR(c) (c == ',' || c == ';' || c == '+') #define SPACE(c) (c == ' ' || c == '\n') diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 80617959e0..f9f397546e 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -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); } - diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index 4f76fa55b9..86d8dabcff 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -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; } } diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index 5d1459ca94..7d429f27c5 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -10,16 +10,11 @@ #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; } diff --git a/servers/slapd/init.c b/servers/slapd/init.c index 81384199e3..05c965f078 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -11,15 +11,8 @@ #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; - -init() +void +init( void ) { pthread_mutex_init( &active_threads_mutex, pthread_mutexattr_default ); pthread_mutex_init( &new_conn_mutex, pthread_mutexattr_default ); diff --git a/servers/slapd/lock.c b/servers/slapd/lock.c index ad80443eb9..8d5d7f2ec5 100644 --- a/servers/slapd/lock.c +++ b/servers/slapd/lock.c @@ -4,9 +4,11 @@ #include +#include #include #include #include +extern int flock (); #include #include diff --git a/servers/slapd/main.c b/servers/slapd/main.c index dc600f0d89..733fb10e7f 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -5,16 +5,12 @@ #include #include #include +#include -#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; @@ -269,7 +262,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; } @@ -277,7 +270,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; diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 235acc536b..fa65acc2a8 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -20,16 +20,8 @@ #include "slap.h" -extern Backend *select_backend(); - -extern char *default_referral; -extern time_t currenttime; -extern pthread_mutex_t currenttime_mutex; -extern int global_lastmod; - -static void modlist_free(); -static void add_lastmods(); -extern char *suffixAlias(); +static void modlist_free(LDAPMod *mods); +static void add_lastmods(Operation *op, LDAPMod **mods); void diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 4928727817..25752ea85d 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -19,10 +19,6 @@ #include "slap.h" -extern Backend *select_backend(); - -extern char *default_referral; - void do_modrdn( Connection *conn, diff --git a/servers/slapd/monitor.c b/servers/slapd/monitor.c index 73a78c8f70..e7de185eed 100644 --- a/servers/slapd/monitor.c +++ b/servers/slapd/monitor.c @@ -25,29 +25,11 @@ #include #include -#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( ¤ttime_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" : "", diff --git a/servers/slapd/operation.c b/servers/slapd/operation.c index b08d679298..9a06f97fbd 100644 --- a/servers/slapd/operation.c +++ b/servers/slapd/operation.c @@ -9,8 +9,6 @@ #include "slap.h" -extern time_t currenttime; -extern pthread_mutex_t currenttime_mutex; void op_free( Operation *op ) @@ -67,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; } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index ef402878e0..200782010f 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -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 */ diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index d47d754f57..4f46ec114d 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -5,20 +5,13 @@ #include #include +#include #include #include #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( diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 06df02159d..a710e1910f 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -9,19 +9,10 @@ #include #include #include +#include /* get close() */ #include "slap.h" -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; - -void close_connection(); static void send_ldap_result2( diff --git a/servers/slapd/schema.c b/servers/slapd/schema.c index a324a60d1d..05dbd55777 100644 --- a/servers/slapd/schema.c +++ b/servers/slapd/schema.c @@ -9,16 +9,9 @@ #include "slap.h" -extern Attribute *attr_find(); -extern char **str2charray(); -extern void charray_merge(); - -extern struct objclass *global_oc; -extern int global_schemacheck; - -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 @@ -164,7 +157,7 @@ oc_find( char *ocname ) #ifdef LDAP_DEBUG -static +static void oc_print( struct objclass *oc ) { int i; diff --git a/servers/slapd/schemaparse.c b/servers/slapd/schemaparse.c index 8f72136abb..96e01f09b0 100644 --- a/servers/slapd/schemaparse.c +++ b/servers/slapd/schemaparse.c @@ -9,13 +9,10 @@ #include "slap.h" -extern char **str2charray(); -extern void charray_merge(); - struct objclass *global_oc; int global_schemacheck; -static void oc_usage(); +static void oc_usage(void); void parse_oc( @@ -72,7 +69,7 @@ parse_oc( } static void -oc_usage() +oc_usage( void ) { fprintf( stderr, " ::= objectclass \n" ); fprintf( stderr, " [ requires ]\n" ); diff --git a/servers/slapd/search.c b/servers/slapd/search.c index 004678e82d..013075fdb1 100644 --- a/servers/slapd/search.c +++ b/servers/slapd/search.c @@ -17,19 +17,15 @@ #include #include -#include "slap.h" #include "ldapconfig.h" +#include "slap.h" -extern int get_filter(); -extern Backend *select_backend(); -extern char *suffixAlias(); - -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; diff --git a/servers/slapd/shell-backends/passwd-shell.c b/servers/slapd/shell-backends/passwd-shell.c index 2d7df71c74..1f035ca11e 100644 --- a/servers/slapd/shell-backends/passwd-shell.c +++ b/servers/slapd/shell-backends/passwd-shell.c @@ -34,6 +34,7 @@ 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; diff --git a/servers/slapd/shell-backends/shellutil.c b/servers/slapd/shell-backends/shellutil.c index 4f7b469043..68266efd37 100644 --- a/servers/slapd/shell-backends/shellutil.c +++ b/servers/slapd/shell-backends/shellutil.c @@ -28,6 +28,8 @@ #include #include +#include +extern long int random (void); #include #include diff --git a/servers/slapd/shell-backends/shellutil.h b/servers/slapd/shell-backends/shellutil.h index 58775b2f99..7f51500d35 100644 --- a/servers/slapd/shell-backends/shellutil.h +++ b/servers/slapd/shell-backends/shellutil.h @@ -94,6 +94,8 @@ 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 diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index a17eed4a4d..6a4ee58d18 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -35,6 +35,9 @@ LDAP_BEGIN_DECL +struct op; +struct conn; + /* * represents an attribute value assertion (i.e., attr=value) */ @@ -186,7 +189,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 */ @@ -205,23 +209,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 diff --git a/servers/slapd/str2filter.c b/servers/slapd/str2filter.c index 60ced1aee2..71d4d1f56a 100644 --- a/servers/slapd/str2filter.c +++ b/servers/slapd/str2filter.c @@ -5,14 +5,15 @@ #include #include +#include #include #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 ) diff --git a/servers/slapd/suffixalias.c b/servers/slapd/suffixalias.c index c60530ef48..26b990cd57 100644 --- a/servers/slapd/suffixalias.c +++ b/servers/slapd/suffixalias.c @@ -21,10 +21,7 @@ * 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; diff --git a/servers/slapd/tools/centipede.c b/servers/slapd/tools/centipede.c index 487dd70778..1ce5765405 100644 --- a/servers/slapd/tools/centipede.c +++ b/servers/slapd/tools/centipede.c @@ -8,6 +8,10 @@ #include #include #include +#include /* get link(), unlink() */ +extern char *strdup (const char *); +extern char *strtok (char *, const char *); +extern char *strpbrk (const char *, const char *); #include #include @@ -40,13 +44,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 ) { @@ -71,6 +75,7 @@ static void usage( char *name ) fprintf( stderr, "\t-c size\t\tldbm cache size\n" ); } +int main( int argc, char **argv ) { char *ldapfilter; @@ -555,7 +560,6 @@ diff_centroids( Datum olast, nlast; Datum lastkey, key; Datum data; - int rc; LDAPMod **mods; char **avals, **dvals; int amax, acur, dmax, dcur; @@ -619,7 +623,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 */ diff --git a/servers/slapd/tools/chlog2replog.c b/servers/slapd/tools/chlog2replog.c index f76884643b..b9d171ba8e 100644 --- a/servers/slapd/tools/chlog2replog.c +++ b/servers/slapd/tools/chlog2replog.c @@ -23,14 +23,15 @@ #include #include +#include #include #include #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; diff --git a/servers/slapd/tools/edb2ldif.c b/servers/slapd/tools/edb2ldif.c index 5e2b3d9a30..5be7cba614 100644 --- a/servers/slapd/tools/edb2ldif.c +++ b/servers/slapd/tools/edb2ldif.c @@ -57,6 +57,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 ); @@ -81,9 +82,8 @@ 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; @@ -247,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 ]; @@ -474,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; @@ -695,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 @@ -734,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 ]; @@ -819,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 ) { @@ -842,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; @@ -864,8 +854,7 @@ free_edbmap( edbmap ) static void -print_err( msg ) - char *msg; +print_err( char *msg ) { extern int sys_nerr; extern char *sys_errlist[]; diff --git a/servers/slapd/tools/ldbmcat.c b/servers/slapd/tools/ldbmcat.c index 59cd4d1179..ad05811447 100644 --- a/servers/slapd/tools/ldbmcat.c +++ b/servers/slapd/tools/ldbmcat.c @@ -9,16 +9,15 @@ #include "ldbm.h" #include "../slap.h" -usage( name ) -char *name; +static void +usage( char *name ) { fprintf( stderr, "usage: %s [-n] \n", name ); exit( 1 ); } -main( argc, argv ) - int argc; - char **argv; +int +main( int argc, char **argv ) { Datum key, last, data; LDBM dbp; diff --git a/servers/slapd/tools/ldbmtest.c b/servers/slapd/tools/ldbmtest.c index 9649eff22b..beee4046cf 100644 --- a/servers/slapd/tools/ldbmtest.c +++ b/servers/slapd/tools/ldbmtest.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -13,6 +14,7 @@ #include #include #include +extern int mkstemp (char *); #ifdef HAVE_FCNTL_H #include @@ -24,15 +26,11 @@ #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; @@ -42,8 +40,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; @@ -58,9 +56,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; @@ -289,7 +286,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; } @@ -378,10 +375,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 ) @@ -391,17 +385,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 ) ); @@ -410,9 +400,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; @@ -482,9 +470,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; @@ -518,9 +504,7 @@ 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]; @@ -584,12 +568,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; @@ -618,11 +597,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]; @@ -657,13 +632,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; @@ -689,14 +665,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 ) { @@ -716,19 +692,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] ); } } } @@ -750,11 +726,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; diff --git a/servers/slapd/tools/ldif.c b/servers/slapd/tools/ldif.c index 0668eddbcd..0f4b2ebb67 100644 --- a/servers/slapd/tools/ldif.c +++ b/servers/slapd/tools/ldif.c @@ -5,6 +5,7 @@ #include #include +#include /* 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] \n", name ); exit( 1 ); } -main( argc, argv ) - int argc; - char **argv; +int +main( int argc, char **argv ) { char buf[BUFSIZ]; char *type, *out; diff --git a/servers/slapd/tools/ldif2id2children.c b/servers/slapd/tools/ldif2id2children.c index ee128855a8..7af679e068 100644 --- a/servers/slapd/tools/ldif2id2children.c +++ b/servers/slapd/tools/ldif2id2children.c @@ -5,29 +5,21 @@ #include #include +#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 +44,7 @@ usage( char *name ) exit( 1 ); } +int main( int argc, char **argv ) { int i, cargc, indb, stop, status; @@ -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 ) diff --git a/servers/slapd/tools/ldif2id2entry.c b/servers/slapd/tools/ldif2id2entry.c index de32fc9d53..e043e6ce25 100644 --- a/servers/slapd/tools/ldif2id2entry.c +++ b/servers/slapd/tools/ldif2id2entry.c @@ -4,27 +4,20 @@ #include #include +extern int strcasecmp(const char *, const char *); +#include "ldapconfig.h" #include "../slap.h" #include "../back-ldbm/back-ldbm.h" -#include "ldapconfig.h" - #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; @@ -39,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; @@ -51,6 +42,7 @@ usage( char *name ) exit( 1 ); } +int main( int argc, char **argv ) { int i, cargc, indb, stop, status; @@ -153,7 +145,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; diff --git a/servers/slapd/tools/ldif2index.c b/servers/slapd/tools/ldif2index.c index 9995dea664..6bcc3c9caa 100644 --- a/servers/slapd/tools/ldif2index.c +++ b/servers/slapd/tools/ldif2index.c @@ -6,24 +6,19 @@ #include #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 +33,7 @@ pthread_mutex_t replog_mutex; pthread_mutex_t ops_mutex; pthread_mutex_t regex_mutex; + static void usage( char *name ) { @@ -45,6 +41,7 @@ usage( char *name ) exit( 1 ); } +int main( int argc, char **argv ) { int i, cargc, indb, stop; diff --git a/servers/slapd/tools/ldif2ldbm.c b/servers/slapd/tools/ldif2ldbm.c index 01ae4fbd21..38f0dea765 100644 --- a/servers/slapd/tools/ldif2ldbm.c +++ b/servers/slapd/tools/ldif2ldbm.c @@ -3,13 +3,16 @@ #include #include +#include #include +#include +#include #include +#include "ldapconfig.h" #include "../slap.h" #include "../back-ldbm/back-ldbm.h" -#include "ldapconfig.h" #include "ldif.h" #define INDEXCMD "ldif2index" @@ -17,16 +20,12 @@ #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; diff --git a/servers/slapd/tools/sizecount.c b/servers/slapd/tools/sizecount.c index a653796ba5..b21ddbce64 100644 --- a/servers/slapd/tools/sizecount.c +++ b/servers/slapd/tools/sizecount.c @@ -1,6 +1,10 @@ #include "portable.h" #include +#include +#include +#include /* get unlink() */ + #include #include #include @@ -11,10 +15,10 @@ #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; @@ -22,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; diff --git a/servers/slapd/unbind.c b/servers/slapd/unbind.c index 1b0d820e68..a4a8546812 100644 --- a/servers/slapd/unbind.c +++ b/servers/slapd/unbind.c @@ -21,11 +21,6 @@ #include "slap.h" -extern Backend *select_backend(); -extern void be_unbind(); - -extern char *default_referral; -extern pthread_mutex_t new_conn_mutex; void do_unbind( diff --git a/servers/slurpd/admin.c b/servers/slurpd/admin.c index 5af8d53cce..b5aecdca0f 100644 --- a/servers/slurpd/admin.c +++ b/servers/slurpd/admin.c @@ -36,7 +36,7 @@ * queue to the disk file given by SLURPD_DUMPFILE. */ RETSIGTYPE -do_admin() +do_admin( int sig ) { sglob->rq->rq_dump( sglob->rq ); (void) SIGNAL( SIGUSR2, do_admin ); diff --git a/servers/slurpd/args.c b/servers/slurpd/args.c index d598cce645..3a51d53c95 100644 --- a/servers/slurpd/args.c +++ b/servers/slurpd/args.c @@ -17,6 +17,7 @@ #include "portable.h" #include +#include #include #include diff --git a/servers/slurpd/ch_malloc.c b/servers/slurpd/ch_malloc.c index cf3b79c0b9..d6ad464e41 100644 --- a/servers/slurpd/ch_malloc.c +++ b/servers/slurpd/ch_malloc.c @@ -17,6 +17,7 @@ #include "portable.h" #include +#include #include diff --git a/servers/slurpd/config.c b/servers/slurpd/config.c index ffd25ed029..8fa21f6752 100644 --- a/servers/slurpd/config.c +++ b/servers/slurpd/config.c @@ -18,6 +18,7 @@ #include "portable.h" #include +#include #include #include diff --git a/servers/slurpd/fm.c b/servers/slurpd/fm.c index 602f8cd8a6..be02d2b6f9 100644 --- a/servers/slurpd/fm.c +++ b/servers/slurpd/fm.c @@ -17,6 +17,7 @@ #include "portable.h" #include +#include /* get free() */ #include #include @@ -25,21 +26,12 @@ #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 ); } - diff --git a/servers/slurpd/globals.c b/servers/slurpd/globals.c index ba13dd2000..91b7e3086f 100644 --- a/servers/slurpd/globals.c +++ b/servers/slurpd/globals.c @@ -18,6 +18,7 @@ #include #include +#include #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; diff --git a/servers/slurpd/ldap_op.c b/servers/slurpd/ldap_op.c index 36ee80be89..d7582a6837 100644 --- a/servers/slurpd/ldap_op.c +++ b/servers/slurpd/ldap_op.c @@ -17,11 +17,13 @@ #include "portable.h" #include +#include #include #include #include #include +#include /* Get_t getpid() */ #include @@ -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 * )); @@ -438,7 +440,7 @@ op_ldap_modrdn( * Allocate and initialize an ldapmod struct. */ static LDAPMod * -alloc_ldapmod() +alloc_ldapmod( void ) { LDAPMod *ldm; @@ -553,7 +555,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; } @@ -752,7 +754,8 @@ kexit: if ( krbnames != NULL ) { */ static void dump_ldm_array( -LDAPMod **ldmarr ) + LDAPMod **ldmarr +) { int i, j; LDAPMod *ldm; @@ -762,21 +765,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 ); } } @@ -848,7 +851,8 @@ read_krbnames( */ static void upcase( -char *s ) + char *s +) { char *p; diff --git a/servers/slurpd/lock.c b/servers/slurpd/lock.c index 3e41854eb0..6fbd4bbf9c 100644 --- a/servers/slurpd/lock.c +++ b/servers/slurpd/lock.c @@ -22,12 +22,12 @@ #include #include #include +extern int flock (); #include #include -#include "../slapd/slap.h" - +#include "slurp.h" /* Was ../slapd/slap.h */ FILE * @@ -109,8 +109,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 +131,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 ); diff --git a/servers/slurpd/main.c b/servers/slurpd/main.c index 385633b4ac..28a27fc2ff 100644 --- a/servers/slurpd/main.c +++ b/servers/slurpd/main.c @@ -24,16 +24,6 @@ #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 index 0000000000..c697344028 --- /dev/null +++ b/servers/slurpd/proto-slurp.h @@ -0,0 +1,68 @@ +#ifndef _PROTO_SLURP +#define _PROTO_SLURP + +#include + +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 */ diff --git a/servers/slurpd/re.c b/servers/slurpd/re.c index f568f07df4..c7358fddc1 100644 --- a/servers/slurpd/re.c +++ b/servers/slurpd/re.c @@ -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; } diff --git a/servers/slurpd/replica.c b/servers/slurpd/replica.c index 98521033b2..41861617a0 100644 --- a/servers/slurpd/replica.c +++ b/servers/slurpd/replica.c @@ -27,19 +27,21 @@ * 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; } diff --git a/servers/slurpd/replog.c b/servers/slurpd/replog.c index b6b6004960..aa15411a13 100644 --- a/servers/slurpd/replog.c +++ b/servers/slurpd/replog.c @@ -32,23 +32,6 @@ #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 ); } diff --git a/servers/slurpd/ri.c b/servers/slurpd/ri.c index 40aa0f9045..5f27e121ac 100644 --- a/servers/slurpd/ri.c +++ b/servers/slurpd/ri.c @@ -27,14 +27,9 @@ #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 )); /* @@ -265,5 +260,3 @@ isnew( sglob->st->st_unlock( sglob->st ); return ret; } - - diff --git a/servers/slurpd/rq.c b/servers/slurpd/rq.c index 783b15ba2d..3fe7285275 100644 --- a/servers/slurpd/rq.c +++ b/servers/slurpd/rq.c @@ -35,14 +35,12 @@ #include #include +#include /* 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; } - diff --git a/servers/slurpd/sanity.c b/servers/slurpd/sanity.c index db0d2ed045..d666f65da0 100644 --- a/servers/slurpd/sanity.c +++ b/servers/slurpd/sanity.c @@ -56,7 +56,7 @@ static unsigned int filecheck LDAP_P(( char * )); */ int -sanity() +sanity( void ) { int err = 0; int rc; @@ -199,4 +199,3 @@ filecheck( return ret; } - diff --git a/servers/slurpd/slurp.h b/servers/slurpd/slurp.h index 971fd485af..e32246b0ea 100644 --- a/servers/slurpd/slurp.h +++ b/servers/slurpd/slurp.h @@ -163,7 +163,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 */ @@ -181,9 +182,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 */ +}; @@ -203,13 +204,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 @@ -224,16 +225,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 */ +}; @@ -246,7 +247,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 */ @@ -262,19 +264,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 */ +}; /* @@ -300,8 +301,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 */ @@ -312,13 +313,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 { @@ -333,15 +334,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. */ @@ -349,6 +341,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_ */ diff --git a/servers/slurpd/tsleep.c b/servers/slurpd/tsleep.c index 548a71544d..abe606d02a 100644 --- a/servers/slurpd/tsleep.c +++ b/servers/slurpd/tsleep.c @@ -27,6 +27,8 @@ #include "portable.h" #include +#include +#include /* get sleep() */ #include "slurp.h" #include "globals.h" @@ -36,7 +38,7 @@ int tsleep( - int interval + time_t interval ) { thread_t mylwp; @@ -54,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; @@ -64,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 ); @@ -125,7 +127,7 @@ lwp_scheduler( * Create the lwp_scheduler thread. */ void -start_lwp_scheduler() +start_lwp_scheduler( void ) { thread_t tid; stkalign_t *stack; @@ -153,6 +155,3 @@ tsleep( sleep( interval ); } #endif /* !HAVE_LWP */ - - - -- 2.39.5