--- /dev/null
+#include <stdio.h>
+#include <ac/ctype.h>
+#include <ac/string.h>
+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 );
*/
#include "portable.h"
-
-#include <stdio.h>
-#include <ctype.h>
-
+#include "fax500.h"
#include <sys/types.h>
-#include <ac/string.h>
#define TPCDOMAIN "tpc.int"
/*
* Remove everything from 'str' which is not a digit
*/
-void strip_nonnum(str)
-char *str;
+void
+strip_nonnum( char *str )
{
char *p, *q;
p = q = str;
* 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;
* 6 93
* 8 99
*/
-char *munge_phone(ibuf, obuf)
-char *ibuf;
-char *obuf;
+char *
+munge_phone( char *ibuf, char *obuf )
{
#define UMAREACODE "1313"
-
-
-
-
-
/*
* 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;
strcat(obuf, TPCDOMAIN); /* tack on domain name */
p = strdup(obuf);
return(p);
-
}
*/
#include "portable.h"
+#include "fax500.h"
-#include <stdio.h>
#include <stdlib.h>
-#include <ctype.h>
#include <ac/socket.h>
-#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/time.h>
#include <ac/wait.h>
+#include <ac/unistd.h>
+#include <ac/errno.h>
+extern int optind, errno;
+extern char *optarg;
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
char *mailfrom = NULL;
char *host = NULL;
int hostlen = 0;
-char *faxtotpc();
int identity;
#define MAIL500 1
"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;
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 ) {
*/
if ( numerr > 0 && numto > nargs || ngroups > 0 ) {
- int fd;
+ FILE *fp;
char buf[BUFSIZ];
umask( 077 );
return( EX_OK );
}
-connect_to_x500()
+static int
+connect_to_x500( void )
{
int sizelimit = FAX_MAXAMBIGUOUS;
int deref = LDAP_DEREF_ALWAYS;
}
-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;
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
}
/* 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;
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;
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;
} 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;
} 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
/* parent */
- if ( pid = fork() ) {
+ if ( (pid = fork()) != 0 ) {
#ifdef HAVE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
}
}
-static
-send_group( group, ngroup )
- Group *group;
- int ngroup;
+static void
+send_group( Group *group, int ngroup )
{
int i, pid;
char **argv;
/* parent */
- if ( pid = fork() ) {
+ if ( (pid = fork()) != 0 ) {
#ifdef HAVE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
return;
}
-static
-send_errors( err, nerr )
- Error *err;
- int nerr;
+static void
+send_errors( Error *err, int nerr )
{
int i, namelen;
FILE *fp;
}
-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;
}
/* 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;
}
}
-static
-count_values( list )
- char **list;
+static int
+count_values( char **list )
{
int i;
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;
return;
}
-static
-isgroup( e )
- LDAPMessage *e;
+static int
+isgroup( LDAPMessage *e )
{
int i;
char **oclist;
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) );
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;
return;
}
-static
-unbind_and_exit( rc )
- int rc;
+static void
+unbind_and_exit( int rc )
{
int i;
}
static char *
-canonical( s )
- char *s;
+canonical( char *s )
{
char *saves = s;
return( saves );
}
-static
-group_loop( dn )
- char *dn;
+static int
+group_loop( char *dn )
{
int i;
static char **groups;
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;
}
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;
*/
#include "portable.h"
+#include "fax500.h"
-#include <stdio.h>
+#include <stdlib.h>
#include <signal.h>
#include <ac/socket.h>
-#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/time.h>
#include <ac/wait.h>
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;
rdn++;
if ( strcasecmp( rdn, buf ) == 0 ) {
char **cn;
- char *s;
int i, last;
cn = ldap_get_values( ld, e, "cn" );
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 );
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ctype.h>
#include <signal.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <ac/wait.h>
+extern char *strdup (const char *);
+extern int strcasecmp(const char *, const char *);
#include <sys/resource.h>
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;
#endif
}
- if ( dosyslog && mypeer != -1 ) {
+ if ( dosyslog && mypeer != (unsigned long) -1 ) {
struct in_addr addr;
hp = gethostbyaddr( (char *) &mypeer, sizeof(mypeer), AF_INET );
return( 0 );
}
-static do_query()
+static void
+do_query( void )
{
char buf[256];
int len, rc, tblsize;
}
static void
-spaces2dots( s )
- char *s;
+spaces2dots( char *s )
{
for ( ; *s; s++ ) {
if ( *s == ' ' ) {
}
}
-static do_search( ld, buf )
-LDAP *ld;
-char *buf;
+static void
+do_search( LDAP *ld, char *buf )
{
char *dn, *rdn;
char **title;
FINGER_SORT_ATTR,
#endif
0 };
- extern int strcasecmp();
ufn = 0;
#ifdef FINGER_UFN
}
-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 };
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/signal.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <ac/wait.h>
+extern char *strdup (const char *);
+extern int strcasecmp(const char *, const char *);
+extern int gethostname (char *, int);
#include <ac/setproctitle.h>
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;
struct hostent *hp;
struct sockaddr_in from;
int fromlen;
- RETSIGTYPE wait4child();
extern char *optarg;
#if defined( LDAP_PROCTITLE ) && !defined( HAVE_SETPROCTITLE )
/* NOT REACHED */
}
-static
-set_socket( port )
-int port;
+static int
+set_socket( int port )
{
int s, one;
struct sockaddr_in addr;
}
static RETSIGTYPE
-wait4child()
+wait4child( int sig )
{
#ifndef HAVE_WAITPID
WAITSTATUSTYPE status;
(void) SIGNAL( SIGCHLD, wait4child );
}
-static
-do_queries( s )
-int s;
+static void
+do_queries( int s )
{
char buf[1024], *query;
int len;
/* NOT REACHED */
}
-static
-do_error( fp, s )
-FILE *fp;
-char *s;
+static void
+do_error( FILE *fp, char *s )
{
int code;
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;
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;
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/signal.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <ac/wait.h>
+extern int strcasecmp(const char *, const char *);
#include <ac/setproctitle.h>
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;
struct hostent *hp;
struct sockaddr_in from;
int fromlen;
- RETSIGTYPE wait4child();
extern char *optarg;
#if defined( LDAP_PROCTITLE ) && !defined( HAVE_SETPROCTITLE )
/* NOT REACHED */
}
-static set_socket( port )
-int port;
+static int
+set_socket( int port )
{
int s, one;
struct sockaddr_in addr;
}
static RETSIGTYPE
-wait4child()
+wait4child( int sig )
{
#ifndef HAVE_WAITPID
WAITSTATUSTYPE status;
(void) SIGNAL( SIGCHLD, wait4child );
}
-static do_queries( s )
-int s;
+static void
+do_queries( int s )
{
char buf[1024], *query;
int len;
break;
case 'S': /* search */
- do_search( ld, fp, query, 1 );
+ do_search( ld, fp, query );
break;
case 'M': /* X.500 menu */
/* NOT REACHED */
}
-static char *pick_oc( oclist )
-char **oclist;
+static char *
+pick_oc( char **oclist )
{
int i;
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;
#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;
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;
}
}
-static isoc( ocl, oc )
-char **ocl;
-char *oc;
+static int
+isoc( char **ocl, char *oc )
{
int i;
return( 0 );
}
-static int make_scope( ld, dn )
-LDAP *ld;
-char *dn;
+static int
+make_scope( LDAP *ld, char *dn )
{
int scope;
char **oc;
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;
!= 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;
#endif
if ( count == 0 ) {
- return( 0 );
+ return;
}
if ( count == 1 ) {
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 );
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;
}
}
-static do_help( op )
-FILE *op;
+static void
+do_help( FILE *op )
{
FILE *fp;
char line[BUFSIZ];
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" );
fprintf( fp, ".\r\n" );
}
-static do_error( fp, s )
-FILE *fp;
-char *s;
+static void
+do_error( FILE *fp, char *s )
{
int code;
#include <ac/syslog.h>
#include <ac/time.h>
#include <ac/wait.h>
+#include <ac/unistd.h>
+extern char *strdup (const char *);
+extern int optind, errno;
+extern char *optarg;
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
"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;
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] );
*/
if ( numerr > 0 && numto > nargs || ngroups > 0 ) {
- int fd;
+ FILE *fp;
char buf[BUFSIZ];
umask( 077 );
return( EX_OK );
}
-connect_to_x500()
+static int
+connect_to_x500( void )
{
int opt;
return( 0 );
}
-static
-mailcmp( a, b )
- char *a;
- char *b;
+static int
+mailcmp( char *a, char *b )
{
int i;
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;
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;
}
/* 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;
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;
}
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;
} 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;
} 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;
} 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
}
/* parent */
- if ( pid = fork() ) {
+ if ( (pid = fork()) != 0 ) {
#ifdef HAVE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
}
}
-static
-send_group( group, ngroup )
- Group *group;
- int ngroup;
+static void
+send_group( Group *group, int ngroup )
{
int i, pid;
char **argv;
}
/* parent */
- if ( pid = fork() ) {
+ if ( (pid = fork()) != 0 ) {
#ifdef HAVE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
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;
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 );
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;
}
/* 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;
}
}
-static
-count_values( list )
- char **list;
+static int
+count_values( char **list )
{
int i;
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;
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;
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) );
(*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;
(*nlist)++;
ldap_value_free( ufn );
-
- return;
}
-static
-unbind_and_exit( rc )
- int rc;
+static void
+unbind_and_exit( int rc )
{
int i;
}
static char *
-canonical( s )
- char *s;
+canonical( char *s )
{
char *saves = s;
return( saves );
}
-static
-group_loop( dn )
- char *dn;
+static int
+group_loop( char *dn )
{
int i;
static char **groups;
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;
}
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;
#include <ac/syslog.h>
#include <ac/string.h>
+#include <ac/unistd.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#include "ldapconfig.h"
#include "rcpt500.h"
-extern int dosyslog;
-
int
-help_cmd( msgp, reply )
- struct msginfo *msgp;
- char *reply;
+help_cmd(struct msginfo *msgp, char *reply)
{
int fd, len;
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/syslog.h>
+extern char *strdup (const char *);
+extern char *strstr (const char *, const char *);
#include "ldapconfig.h"
#include "rcpt500.h"
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;
}
-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;
}
-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;
}
-int
-send_reply( msgp, body )
- struct msginfo *msgp;
- char *body;
+static int
+send_reply( struct msginfo *msgp, char *body )
{
char buf[ MAXSIZE ];
FILE *cmdpipe;
}
-int
-find_command( text, argp )
- char *text;
- char **argp;
+static int
+find_command( char *text, char **argp )
{
int i;
char *s, *p;
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ctype.h>
#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/time.h>
+extern int strcasecmp(const char *, const char *);
#include "lber.h"
#include "ldap.h"
#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;
}
-void
+static void
close_ldap( LDAP *ld )
{
#ifdef LDAP_CONNECTIONLESS
}
-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;
}
-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 };
}
-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);
}
-remove_trailing_space( s )
- char *s;
+static void
+remove_trailing_space( char *s )
{
char *p = s + strlen( s ) - 1;
};
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));
};
/*
* 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
#include <ac/string.h>
#include <ac/unistd.h>
+extern char *strdup (const char *);
#include <lber.h>
#include <ldap.h>
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 ))
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 ];
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/unistd.h>
+extern char *strdup (const char *);
#include <sys/stat.h>
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 ))
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/unistd.h>
+extern char *strdup (const char *);
#include <lber.h>
#include <ldap.h>
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 ))
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 ];
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/unistd.h>
+extern char *strdup (const char *);
+extern int strcasecmp(const char *, const char *);
+extern char *mktemp(char *);
#include <lber.h>
#include <ldap.h>
#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" );
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;
ldap_perror( ld, "ldap_search" );
}
if ( sortattr != NULL ) {
- extern int strcasecmp();
-
(void) ldap_sort_entries( ld, &res,
( *sortattr == '\0' ) ? NULL : sortattr, strcasecmp );
matches = 0;
BerElement *ber;
struct berval **bvals;
FILE *tmpfp;
- extern char *mktemp();
dn = ldap_get_dn( ld, entry );
if ( ldif ) {
#include <ac/krb.h>
#include <ac/string.h>
#include <ac/time.h>
+#include <ac/unistd.h>
+extern char *strdup (const char *);
#ifdef HAVE_PWD_H
#include <pwd.h>
#include "ud.h"
-extern LDAP *ld; /* our LDAP descriptor */
-extern int verbose; /* verbosity indicator */
-extern char *mygetpass(); /* getpass() passwds are too short */
-
-#ifdef DEBUG
-extern int debug; /* debug flag */
-#endif
-
#ifdef HAVE_KERBEROS
static char tktpath[20]; /* ticket file path */
static int kinit();
static int valid_tgt();
#endif
-static void set_bound_dn();
+static void set_bound_dn(char *s);
-auth(who, implicit)
-char *who;
-int implicit;
+
+int
+auth( char *who, int implicit )
{
int rc; /* return code from ldap_bind() */
char *passwd = NULL; /* returned by mygetpass() */
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)
#define FIVEMINS ( 5 * 60 )
#define TGT "krbtgt"
-static void str2upper( s )
- char *s;
+static void
+str2upper( char *s )
{
char *p;
}
-static valid_tgt( names )
- char **names;
+static int
+valid_tgt( char **names )
{
int i;
char name[ ANAME_SZ ], inst[ INST_SZ ], realm[ REALM_SZ ];
/*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;
return( 0 );
}
-static kinit( kname )
- char *kname;
+static int
+kinit( char *kname )
{
int rc;
char name[ ANAME_SZ ], inst[ INST_SZ ], realm[ REALM_SZ ];
return( 0 );
}
-void destroy_tickets(void)
+void
+destroy_tickets( void )
{
if ( *tktpath != '\0' ) {
unlink( tktpath );
}
#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);
#include <ac/signal.h>
#include <ac/string.h>
+#include <ac/ctype.h>
#include <ac/time.h>
#include <ac/wait.h>
+#include <ac/unistd.h>
+extern char *strdup (const char *);
+extern char * mktemp(char *);
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#include <ldap.h>
#include <ldapconfig.h>
#include "ud.h"
-extern void *Malloc();
-extern struct entry Entry;
-extern int verbose;
-extern LDAP *ld;
-
-extern LDAPMessage *find();
-
-static int load_editor();
-static int modifiable();
-static int print_attrs_and_values();
-static int ovalues();
-static int write_entry();
+static int load_editor( void );
+static int modifiable( char *s, short flag );
+static int print_attrs_and_values( FILE *fp, struct attribute *attrs, short flag );
+static int ovalues( char *attr );
+static void write_entry( void );
static char *entry_temp_file;
-#ifdef DEBUG
-extern int debug;
-#endif
-edit(who)
-char *who;
+void
+edit( char *who )
{
LDAPMessage *mp; /* returned from find() */
char *dn, **rdns; /* distinguished name */
char name[MED_BUF_SIZE]; /* entry to modify */
- extern int bind_status;
#ifdef DEBUG
if (debug & D_TRACE)
(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;
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;
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))
return(FALSE);
}
-static write_entry()
+static void
+write_entry( void )
{
int i = 0, j, number_of_values = -1;
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");
return;
}
-static ovalues(attr)
-char *attr;
+static int
+ovalues( char *attr )
{
struct attribute *ap;
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/time.h>
+extern char *strdup (const char *);
#include <lber.h>
#include <ldap.h>
#include "ud.h"
-extern char *search_base; /* search base */
-extern int verbose; /* verbose mode flag */
-extern LDAP *ld; /* our ldap descriptor */
-
static int num_picked = 0; /* used when user picks entry at More prompt */
-#ifdef DEBUG
-extern int debug; /* debug flag */
-#endif
-vrfy(dn)
-char *dn;
+int
+vrfy( char *dn )
{
LDAPMessage *results;
static char *attrs[2] = { "objectClass", NULL };
}
-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;
char *name = NULL; /* DN to lookup */
LDAPMessage *mp;
int ld_errno = 0;
- extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
}
}
-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() */
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)
return(NULL);
}
-pick_one(i)
-int i;
+int
+pick_one( int i )
{
int n;
char user_pick[SMALL_BUF_SIZE];
/* 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;
return;
}
-find_all_subscribers(sub, group)
-char *sub[];
-char *group;
+int
+find_all_subscribers( char **sub, char *group )
{
int count;
LDAPMessage *result;
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 */
#include "portable.h"
#include <stdio.h>
+#include <ac/time.h> /* portable.h+ldap.h needs time_t */
+#include <lber.h>
+#include <ldap.h>
#include "ud.h"
-extern void set_boolean(),
- change_field(),
-#ifdef UOFM
- set_updates(),
-#endif
- mod_addrDN();
-
struct attribute attrlist[] = {
/*
* 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 },
{ "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
{ "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 }
};
#include <stdio.h>
#include <ac/string.h>
+#include <ac/ctype.h>
#include <ac/time.h>
+#include <ac/unistd.h>
+extern char *strdup (const char *);
#include <lber.h>
#include <ldap.h>
-
#include <ldapconfig.h>
#include "ud.h"
-extern LDAPMessage * find();
-
-#ifdef DEBUG
-extern int debug;
-#endif
-
-extern char *bound_dn, *group_base;
-extern int verbose, bind_status;
-extern struct entry Entry;
-extern LDAP *ld;
-
-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];
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) {
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);
return;
}
-void remove_group(name)
-char *name;
+void
+remove_group( char *name )
{
char *dn, tmp[BUFSIZ];
return;
}
-void x_group(action, name)
-int action;
-char *name;
+void
+x_group( int action, char *name )
{
char **vp;
char *values[2], *group_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;
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) {
return;
}
-void tidy_up()
+void
+tidy_up( void )
{
register int i = 0;
int found_one = 0;
* 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;
}
}
-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;
return(rc);
}
-void list_groups(who)
-char *who;
+void
+list_groups( char *who )
{
LDAPMessage *mp;
char name[BUFSIZ], filter[BUFSIZ], *search_attrs[2];
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) {
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];
#include "ud.h"
-#ifdef DEBUG
-extern int debug;
-#endif
-print_help(s)
-char *s;
+void
+print_help( char *s )
{
int len; /* command length */
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
+extern char *strdup (const char *);
+extern char *getenv(const char *);
#ifdef HAVE_PWD_H
#include <pwd.h>
#include <ac/signal.h>
#include <ac/string.h>
+#include <ac/ctype.h>
#include <ac/termios.h>
#include <ac/time.h>
#include <ac/unistd.h>
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 */
/* NOTREACHED */
}
-do_commands()
+void
+do_commands( void )
{
LDAPMessage *mp; /* returned by find() */
register char *cp; /* misc char pointer */
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)
/* NOTREACHED */
}
-status()
+void
+status( void )
{
- void printbase();
register char **rdns;
char *host;
}
}
-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 */
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)
}
}
-void initialize_client()
+void
+initialize_client( void )
{
FILE *fp; /* for config file */
static char buffer[MED_BUF_SIZE]; /* for input */
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)
#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;
#endif
}
-RETSIGTYPE attn()
+RETSIGTYPE
+attn( int sig )
{
fflush(stderr);
fflush(stdout);
longjmp(env, 1);
}
-#ifndef NO_TERMCAP
-RETSIGTYPE chwinsz()
+#if !defined(NO_TERMCAP) && defined(TIOCGWINSZ)
+RETSIGTYPE
+chwinsz( int sig )
{
struct winsize win;
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <lber.h>
#include <ldap.h>
#include "ud.h"
-extern void Free();
-extern struct entry Entry;
-extern int verbose;
-extern LDAP *ld;
+static char *get_URL( void );
+static int check_URL( char *url );
-extern LDAPMessage *find();
-extern void * Malloc();
-static char * get_URL();
-static int check_URL();
-
-#ifdef DEBUG
-extern int debug;
-#endif
-
-modify(who)
-char *who;
+void
+modify( char *who )
{
-#ifdef UOFM
- void set_updates(); /* routine to modify noBatchUpdates */
-#endif
LDAPMessage *mp; /* returned from find() */
char *dn; /* distinguished name */
char **rdns; /* for fiddling with the DN */
#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)
}
/* generic routine for changing any field */
-void change_field(who, attr)
-char *who; /* DN of entry we are changing */
-struct attribute attr; /* attribute to change */
+void
+change_field(
+ char *who, /* DN of entry we are changing */
+ int attr_idx /* attribute to change */
+)
{
+ struct attribute attr = Entry.attrs[attr_to_index(attrlist[attr_idx].quipu_name)];
#define IS_MOD(x) (!strncasecmp(resp, (x), strlen(resp)))
- char *get_value(); /* routine to extract values */
static char buf[MED_BUF_SIZE]; /* for printing things */
static char resp[SMALL_BUF_SIZE]; /* for user input */
char *prompt, *prompt2, *more;
static LDAPMod mod;
static LDAPMod *mods[2] = { &mod }; /* passed to ldap_modify */
static char *values[MAX_VALUES]; /* passed to ldap_modify */
- extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
#define MAX_DESC_LINES 24
#define INTL_ADDR_LIMIT 30
-char *get_value(id, prompt)
-char *id, *prompt;
+char *
+get_value( char *id, char *prompt )
{
char *cp; /* for the Malloc() */
int count; /* line # of new value -- if multiline */
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];
#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 };
#endif
-print_mod_list(group)
-int group;
+void
+print_mod_list( int group )
{
register int i, j = 1;
- extern struct attribute attrlist[];
if (group == TRUE) {
for (i = 0; attrlist[i].quipu_name != NULL; i++) {
#endif
}
-perform_action(choice, dn, group)
-char choice[];
-char *dn;
-int group;
+int
+perform_action( char *choice, char *dn, int group )
{
int selection;
register int i, j = 1;
- extern struct attribute attrlist[];
- extern void mod_addrDN(), change_field(), set_boolean();
selection = atoi(choice);
if (selection < 1) {
return(1);
/* NOTREACHED */
}
- if (attrlist[i].mod_func == change_field)
- (*attrlist[i].mod_func)(dn, Entry.attrs[attr_to_index(attrlist[i].quipu_name)]);
- else if (attrlist[i].mod_func == mod_addrDN)
- (*attrlist[i].mod_func)(dn, i);
- else if (attrlist[i].mod_func == set_boolean)
- (*attrlist[i].mod_func)(dn, Entry.attrs[attr_to_index(attrlist[i].quipu_name)]);
- else
- (*attrlist[i].mod_func)(dn);
+ (*attrlist[i].mod_func)(dn, i);
return(0);
}
-static char * get_URL()
+static char *
+get_URL( void )
{
char *rvalue, label[MED_BUF_SIZE], url[MED_BUF_SIZE];
return((char *) rvalue);
}
-static check_URL(url)
-char *url;
+static int
+check_URL( char *url )
{
register char *cp;
}
+void
mod_perror( LDAP *ld )
{
int ld_errno = 0;
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/time.h>
+extern char *strdup (const char *);
#include <lber.h>
#include <ldap.h>
#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
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)
#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;
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)
#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;
}
/* 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)
return;
}
-void clear_entry()
+void
+clear_entry( void )
{
register int i;
- extern struct attribute attrlist[];
#ifdef DEBUG
if (debug & D_TRACE)
}
}
-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))
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;
}
/* 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;
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++)
;
/* \f */
-static long gtime ( struct tm *tm )
+static long
+gtime( struct tm *tm )
{
register int i,
sec,
* 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;
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;
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];
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
* 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);
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;
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
#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];
register char *p;
register int c;
FILE *fi;
- RETSIGTYPE (*sig)();
+ RETSIGTYPE (*sig)( int sig );
#ifdef DEBUG
if (debug & D_TRACE)
#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)
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;
}
-fatal(s)
-char *s;
+void
+fatal( char *s )
{
if (errno != 0)
perror(s);
exit(-1);
}
-isgroup()
+int
+isgroup( void )
{
- extern struct entry Entry;
char **vp;
register int i;
int group = FALSE;
* 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)
* 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 = "";
#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)
return(tmp);
}
-char * code_to_str(int i)
+char *
+code_to_str( int i )
{
switch(i) {
case LDAP_MOD_ADD : return("ADD");
}
}
-char * friendly_name(s)
-char *s;
+char *
+friendly_name( char *s )
{
static FriendlyMap *map = NULL;
static char *cp;
#ifdef UOFM
/* return TRUE if s has the syntax of a uniqname */
-isauniqname(s)
-char *s;
+int
+isauniqname( char *s )
{
int i = strlen(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))
return(FALSE);
}
-char * my_ldap_dn2ufn(s)
-char *s;
+char *
+my_ldap_dn2ufn( char *s )
{
register char **cpp;
static char short_DN[BUFSIZ];
}
/* 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))
}
/* 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))
return(FALSE);
}
-void * Malloc(size)
-unsigned int size;
+void *
+Malloc( unsigned int size )
{
void *void_ptr;
return(void_ptr);
}
-void Free(ptr)
-char *ptr;
+void
+Free( void *ptr )
{
#ifndef STDC_HEADERS
if (free(ptr) < 0) {
return;
}
-char * nextstr(s)
-char *s;
+char *
+nextstr( char *s )
{
while (isspace(*s) && (*s != '\0'))
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)
}
-confirm_action( msg )
- char *msg;
+int
+confirm_action( char *msg )
{
char tmp[SMALL_BUF_SIZE];
int i;
*/
#include "whois++.h"
-
-extern char *index(), *rindex();
+#include <stdlib.h>
+extern int getdtablesize (void);
#define isspecial(c) ( (c) == ',' || (c) == ';' || (c) == ':' || (c) == '=' )
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;
}
}
-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;
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];
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++;
(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++;
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 );
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))))",
return SEARCH;
}
-int parseCommand( query )
-char *query;
+int
+parseCommand( char *query )
{
/*
* This procedure reads the string sent by the user and breaks it
*/
#include "whois++.h"
+#include <stdlib.h>
static struct {
char *str;
NULL, NULL
};
-static nextLine(fp)
-FILE *fp;
+static void
+nextLine( FILE *fp )
{
/*
* We probably should check that the user hasn't put anything else
/*
* 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;
return (cp != buffer);
}
-void readConfiguration( config )
-FILE *config;
-
+void
+readConfiguration( FILE *config )
{
char buffer[BUFSIZ];
char *s;
#include "whois++.h"
-void needHelp( reason )
-char *reason;
+void
+needHelp( char *reason )
{
char filename[MAXPATHLEN];
char buffer[BUFSIZ];
*/
#include "whois++.h"
+#include <stdlib.h>
-void showTemplate( template )
-char *template;
+void
+showTemplate( char *template )
{
char filename[MAXPATHLEN], buffer[BUFSIZ];
FILE *description;
}
}
-void listTemplates( query )
-char *query;
-
+void
+listTemplates( char *query )
{
char filename[MAXPATHLEN];
DIR *dir;
}
}
-char **specifyAttributes( objectClass )
-char *objectClass;
-
+char **
+specifyAttributes( char *objectClass )
{
FILE *description;
char filename[MAXPATHLEN], buffer[BUFSIZ];
return attributes;
}
-char *templateToObjectClass( template )
-char *template;
-
+char *
+templateToObjectClass( char *template )
{
int i;
return template;
}
-char *objectClassToTemplate( objectClass )
-char *objectClass;
-
+char *
+objectClassToTemplate( char *objectClass )
{
int i;
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
#include <langinfo.h>
#include <locale.h>
#endif
+#include <ac/unistd.h>
-static void handler();
-
-char *lowerCase( string )
-char *string;
+static void handler(int sig);
+char *
+lowerCase( char *string )
{
char *s;
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
static long interrupt;
-char *getPassword( prompt )
-char *prompt;
-
+char *
+getPassword( char *prompt )
{
#if defined(SYS5) || defined(XOS_2)
struct termios ttyb;
#endif
FILE *input;
struct sigvec ovec, vec;
- void handler();
unsigned long flags;
int c, idx;
static char buffer[BUFSIZ + 1];
return buffer;
}
-static void handler()
-
+static void
+handler( int sig )
{
++interrupt;
}
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-char *version()
-
+char *version( void )
{
return "1.7";
}
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);
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
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
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:
*/
/* 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 ));
*/
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 ));
/*
* 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 */
* 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;
* 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;
*/
static int
-right_balance( root )
- Avlnode **root;
+right_balance( Avlnode **root )
{
int shorter = -1;
Avlnode *r, *l;
* 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;
*/
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;
*/
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 );
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 );
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 );
* 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:
* 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;
* 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;
*/
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;
*/
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;
#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;
*/
caddr_t
-avl_getfirst( root )
- Avlnode *root;
+avl_getfirst( Avlnode *root )
{
if ( avl_list ) {
free( (char *) avl_list);
}
caddr_t
-avl_getnext()
+avl_getnext( void )
{
if ( avl_list == 0 )
return( 0 );
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 );
}
#include <ac/string.h>
#include <sys/types.h>
+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 ];
#if defined( LDAP_DEBUG ) && defined( LDAP_LIBUI )
#include <ac/ctype.h>
-#include <ac/string.h>
#endif /* LDAP_DEBUG && LDAP_LIBUI */
+#include <ac/string.h>
#include "lber-int.h"
#include "portable.h"
#include <stdio.h>
-
-#ifdef STDC_HEADERS
#include <stdlib.h>
-#endif
#include <ac/stdarg.h>
#define EXBUFSIZ 1024
-int
+static int
ber_filbuf( Sockbuf *sb, long len )
{
short rc;
}
-long
+static long
BerRead( Sockbuf *sb, char *buf, long len )
{
int c;
}
BerElement *
-ber_alloc()
+ber_alloc( void )
{
return( ber_alloc_t( 0 ) );
}
BerElement *
-der_alloc()
+der_alloc( void )
{
return( ber_alloc_t( LBER_USE_DER ) );
}
unsigned long tag = 0, netlen, toread;
unsigned char lc;
long rc;
- int noctets, diff;
+ unsigned int noctets, diff;
#ifdef LDAP_DEBUG
if ( lber_debug )
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
+#include <ac/unistd.h>
#include "ldap-int.h"
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 );
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 */
#include <ac/string.h>
#include <ac/time.h>
#include <ac/unistd.h>
+extern char *strdup (const char *);
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/time.h>
+extern char *strdup (const char *);
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
+extern char *strdup (const char *);
#include "ldap-int.h"
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
+extern char *strdup (const char *);
+extern char *strtok (char *, const char *);
#include "ldap-int.h"
#include <ac/socket.h>
#include <ac/string.h>
+#include <ac/ctype.h>
#include <ac/time.h>
+extern char *strdup (const char *);
#include "ldap-int.h"
#include "ldapconfig.h"
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},
{NULL, 0}
};
-struct ol_attribute {
+static struct ol_attribute {
int type;
char* name;
void* data;
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 ));
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
#include <ac/socket.h>
#include <ac/string.h>
+extern char *strdup (const char *);
#include "ldap-int.h"
void *
-ldap_new_select_info()
+ldap_new_select_info( void )
{
struct selectinfo *sip;
#include <ac/string.h>
#include <ac/time.h>
#include <ac/unistd.h>
+extern char *strdup (const char *);
#include "ldap-int.h"
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
+extern char *strdup (const char *);
#include "ldap-int.h"
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
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;
ldap_sort_values(
LDAP *ld,
char **vals,
- int (*cmp) LDAP_P((const void *, const void *))
+ int (*cmp) (const void *, const void *)
)
{
int nel;
#include <ac/string.h>
#include <ac/time.h>
#include <ac/unistd.h>
+extern char *strdup (const char *);
#include <sys/stat.h>
*/
#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 ));
#define NOCACHEERRMSG "don't compile with -DLDAP_NOCACHE if you desire local caching"
-char *dnsuffix;
+static char *dnsuffix;
#ifndef HAVE_GETLINE
static char *
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
-int
+static int
bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
int freeit )
{
#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,
#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 )
#include <ac/socket.h>
#include <ac/time.h>
+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,
LDAPFiltInfo *fi;
LDAPMessage *tmpcand;
LDAPMessage *candidates;
- LDAPMessage *ldap_msg_merge(), *ldap_ufn_expand();
static char *objattrs[] = { "objectClass", NULL };
/*
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
+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 );
#include <stdio.h>
#include <stdlib.h>
+#include <ac/string.h>
#include <ac/errno.h>
#include "ldbm.h"
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 );
}
void
-pthread_yield()
+pthread_yield( void )
{
cthread_yield();
}
#endif /* ! sunos56 */
void
-pthread_yield()
+pthread_yield( void )
{
thr_yield();
}
}
void
-pthread_yield()
+pthread_yield( void )
{
lwp_yield( SELF );
}
}
void
-pthread_yield()
+pthread_yield( void )
{
return;
}
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);
* initialization constants.
*/
void
-ldap_MD5Init(ctx)
- struct ldap_MD5Context *ctx;
+ldap_MD5Init( struct ldap_MD5Context *ctx )
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
* 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;
* 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;
* 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];
#include <stdio.h>
int
-main (int argc, char **argv)
+main (int argc, char **argv )
{
struct ldap_MD5Context context;
unsigned char checksum[16];
#include "lutil_md5.h"
#include "lutil_sha1.h"
#include "lutil.h"
+extern char *crypt (const char *, const char *);
/*
*/
#ifndef HAVE_SETPROCTITLE
+#include <stdio.h>
#include <stdlib.h>
#include <ac/string.h>
/*
* 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 {
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;
/*
* ldap_SHA1Init - Initialize new context
*/
-void ldap_SHA1Init(context)
- ldap_SHA1_CTX *context;
+void
+ldap_SHA1Init( ldap_SHA1_CTX *context )
{
/* SHA1 initialization constants */
/*
* 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;
/*
* 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];
/* 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;
}
char *
-ldap_SHA1File (filename, buf)
- char *filename;
- char *buf;
+ldap_SHA1File( char *filename, char *buf )
{
unsigned char buffer[BUFSIZ];
ldap_SHA1_CTX ctx;
}
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;
#ifndef HAVE_STRDUP
+#include <stdlib.h>
#include <ac/string.h>
+#include "lutil.h"
char *strdup( const char *s )
{
char *p;
if ( (p = (char *) malloc( strlen( s ) + 1 )) == NULL )
- return( NULL );
+ return( (char *)0 );
strcpy( p, s );
#include "portable.h"
-#ifndef HAVE_TEMPNAME
+#ifndef HAVE_TEMPNAM
+#include <stdlib.h>
+#include <stdlib.h>
#include <ac/string.h>
+extern char *mktemp (char *);
-char *tempnam( char *dir, char *pfx )
+#include "lutil.h"
+
+char *
+tempnam( char *dir, char *pfx )
{
char *s;
#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
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 );
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;
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
+extern int errno;
#include <quipu/commonarg.h>
#include <quipu/ds_error.h>
-#include "lber.h"
-#include "ldap.h"
-
+#include <quipu/dap.h> /* get dap_unbind() */
#if ISODEPACKAGE == IC
#include <ll/isoaddrs.h>
#else
#include <isoaddrs.h>
#endif
+
+#include "lber.h"
+#include "ldap.h"
#include "common.h"
#ifdef HAVE_SYS_IOCTL_H
struct conn *conns;
-struct conn *conn_dup( struct conn *cn )
+struct conn *
+conn_dup( struct conn *cn )
{
struct conn *new;
- struct PSAPaddr *psap_cpy();
-
if ( (new = (struct conn *) malloc( sizeof(struct conn) )) == NULL )
return( NULL );
}
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 );
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 );
}
void
-conn_badfds()
+conn_badfds( void )
{
struct conn *tmp;
}
}
-struct conn *conn_getfd( fd_set *fds )
+struct conn *
+conn_getfd( fd_set *fds )
{
struct conn *tmp;
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;
}
void
-conn_close()
+conn_close( void )
{
struct conn *tmp;
isclosed( int ad )
{
int o;
- extern int errno;
if ( ioctl( ad, FIOGETOWN, &o ) < 0 )
return( errno == EBADF ? 1 : 0 );
#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
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 );
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 ) {
#ifdef HAVE_KERBEROS
u_long nonce;
#endif
- extern DN ldap_str2dn();
-
Debug( LDAP_DEBUG_TRACE, "do_bind_real\n", 0, 0, 0 );
*matched = NULL;
#include <quipu/ds_search.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
+extern sntx_table *get_syntax_table( short int sntx );
+extern PE asn2pe( char * );
#include "lber.h"
#include "ldap.h"
#include "common.h"
-int ldap_certif_print( PS ps, struct certificate *parm, int format )
+int
+ldap_certif_print( PS ps, struct certificate *parm, int format )
{
Debug( LDAP_DEBUG_TRACE, "ldap_certif_print()\n", 0, 0, 0 );
}
}
-struct certificate *ldap_str2cert( char *str )
+struct certificate *
+ldap_str2cert( char *str )
{
struct certificate *result;
char *ptr;
void
ldap_str2alg( char *str, struct alg_id *alg )
{
-PE asn2pe();
-
if ((str == NULLCP) || (*str == '\0'))
{
alg->asn = NULLPE;
}
}
-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;
#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
#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
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 );
#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
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 );
#include "lber.h"
#include "ldap.h"
#include "ldap_log.h"
+#include "common.h" /* get ldap_dn_print() */
void
print_error( struct DSError *e )
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 );
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 );
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
int dtblsize;
int RunFromInetd = 0;
-extern char Versionstr[];
-
static void
usage( char *name )
{
}
int
-main (argc, argv)
-int argc;
-char **argv;
+main( int argc, char **argv )
{
int tcps, ns;
#ifdef LDAP_CONNECTIONLESS
int len;
int dsapargc;
char **dsapargv;
- RETSIGTYPE wait4child();
#ifdef LDAP_PROCTITLE
char title[80];
#endif
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 );
}
/*
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 */
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;
timeout.tv_usec = 0;
for ( ;; ) {
struct conn *dsaconn;
- extern struct conn *conns;
FD_ZERO( &readfds );
FD_SET( clientsock, &readfds );
return( s );
}
-static RETSIGTYPE wait4child()
+static RETSIGTYPE
+wait4child( int sig )
{
#ifndef HAVE_WAITPID
WAITSTATUSTYPE status;
; /* NULL */
#endif
- (void) SIGNAL( SIGCHLD, (void *) wait4child );
+ (void) SIGNAL( SIGCHLD, wait4child );
}
-void
+RETSIGTYPE
log_and_exit( int exitcode )
{
struct timeval tv;
{
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 );
#include <quipu/modify.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
+extern IFP merge_acl;
#include "lber.h"
#include "ldap.h"
static CommonArgs common = default_common_args;
-extern short ldap_photo_syntax;
-extern short ldap_jpeg_syntax;
-extern short ldap_jpeg_nonfile_syntax;
-extern short ldap_audio_syntax;
-extern short ldap_dn_syntax;
-extern short ldap_postaladdress_syntax;
-extern short ldap_acl_syntax;
-extern short ldap_mtai_syntax;
-extern short ldap_rts_cred_syntax;
-extern short ldap_rtl_syntax;
-extern short ldap_octetstring_syntax;
-
static int replace_mod( struct entrymod *, Attr_Sequence, Attr_Sequence );
#ifdef LDAP_COMPAT20
-extern int ldap_compat;
#define MODTAG (ldap_compat == 20 ? OLD_LDAP_RES_MODIFY : LDAP_RES_MODIFY)
#else
#define MODTAG LDAP_RES_MODIFY
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 );
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 ) {
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 ||
#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
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 );
*/
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 ));
/*
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
* 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
* 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 ));
/*
*/
int do_modrdn LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
+void modrdn_result LDAP_P((Sockbuf *sb, struct msg *m));
/*
* request.c
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
* 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));
#include "ldap.h"
#include "common.h"
-extern int dosyslog;
-
#ifdef PEPSY_DUMP
#ifndef DEBUG
#define DEBUG
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 );
* 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 );
#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
int rc;
#ifdef LDAP_CONNECTIONLESS
int cldap;
-#endif
- extern int version;
-
-#ifdef LDAP_CONNECTIONLESS
cldap = ( sb->sb_naddr > 0 );
#endif
#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
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 );
AttributeType type;
char *valstr, *last;
AttributeValue value;
- extern short ldap_dn_syntax;
Debug( LDAP_DEBUG_TRACE, "get_substring_filter\n", 0, 0, 0 );
#include <quipu/ds_search.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
+extern oid_table_attr *name2attr( char * );
+/*extern AttributeValue str_at2AttrV( char *, IF_AttributeType * );*/
#include "lber.h"
#include "../../libraries/liblber/lber-int.h" /* get struct berelement */
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 );
}
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 );
* 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 */
)
int firstrdn;
char *value;
PS rps;
- void ldap_dn_print();
char key[512];
if ( dn == NULLDN )
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 );
}
}
-DN ldap_str2dn( char *str )
+DN
+ldap_str2dn( char *str )
{
DN dn, save;
RDN rdn, newrdn, tmprdn;
#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;
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 );
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--;
}
}
-void charlist_free( char **cl )
+void
+charlist_free( char **cl )
{
int i;
get_ava( BerElement *ber, AVA *tava )
{
char *type, *value;
- extern short ldap_dn_syntax;
Debug( LDAP_DEBUG_TRACE, "get_ava\n", 0, 0, 0 );
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 );
#include "slap.h"
-extern Backend *select_backend();
-
-extern char *default_referral;
-
void
do_abandon(
Connection *conn,
#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);
/*
return( LDAP_SUCCESS );
}
-static string_expand(
+static void
+string_expand(
char *newbuf,
int bufsiz,
char *pat,
#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;
}
static void
-acl_usage()
+acl_usage( void )
{
fprintf( stderr, "\n<access clause> ::= access to <what> [ by <who> <access> ]+ \n" );
fprintf( stderr, "<what> ::= * | [dn=<regex>] [filter=<ldapfilter>] [attrs=<attrlist>]\n" );
#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;
#include "slap.h"
-extern char **charray_dup();
extern int errno;
void
} 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 );
#ifdef LDAP_DEBUG
-static
+static int
attr_syntax_printnode( struct asyntaxinfo *a )
{
int i;
return( 0 );
}
-static
-attr_syntax_print()
+static void
+attr_syntax_print( void )
{
(void) avl_apply( attr_syntaxes, attr_syntax_printnode, 0, -1,
AVL_INORDER );
#include "portable.h"
-int
+/*ARGSUSED*/
+void
ldbm_back_abandon()
{
}
#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,
#include "slap.h"
#include "back-ldbm.h"
-extern char **str2charray();
-
static int
ainfo_type_cmp(
char *type,
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/unistd.h>
+extern char *crypt ();
#include "slap.h"
#include "back-ldbm.h"
#include <lutil.h>
-extern Attribute *attr_find();
-
#ifdef HAVE_KERBEROS
extern int krbv4_ldap_auth();
#endif
#include "portable.h"
#include <stdio.h>
+int strcasecmp( const char *, const char *);
#include <ac/socket.h>
#include "slap.h"
#include "back-ldbm.h"
-static int cache_delete_entry_internal();
+static int cache_delete_entry_internal(struct cache *cache, Entry *e);
#ifdef LDAP_DEBUG
-static void lru_print();
+static void lru_print(struct cache *cache);
#endif
/*
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 */
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 */
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 );
}
}
#include "slap.h"
#include "back-ldbm.h"
+void
ldbm_back_close( Backend *be )
{
Debug( LDAP_DEBUG_TRACE, "ldbm backend syncing\n", 0, 0, 0 );
#include "back-ldbm.h"
#include "proto-back-ldbm.h"
-extern Attribute *attr_find();
-
int
ldbm_back_compare(
Backend *be,
#include "slap.h"
#include "back-ldbm.h"
+void
ldbm_back_config(
Backend *be,
char *fname,
#include <sys/param.h>
#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(
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 );
#include "back-ldbm.h"
#include "proto-back-ldbm.h"
-extern Attribute *attr_find();
-
int
ldbm_back_delete(
Backend *be,
#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,
/* 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 );
}
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 );
}
#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.
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 );
}
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 );
}
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 );
}
}
}
- 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 );
}
}
}
- 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 );
}
}
}
- 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 );
}
}
}
- 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 );
}
#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
/* 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 */
#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,
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 ) {
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,
}
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;
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 ) {
#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 )
{
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 ))
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 */
}
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 );
}
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 );
}
}
Entry *
-id2entry_2( Backend *be, ID id )
+id2entry_w( Backend *be, ID id )
{
return( id2entry( be, id, 1 ) );
}
#include <ac/string.h>
#include <ac/socket.h>
-#include "slap.h"
#include "ldapconfig.h"
+#include "slap.h"
#include "back-ldbm.h"
-extern Datum ldbm_cache_fetch();
-
IDList *
idl_alloc( int nids )
{
}
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 );
}
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 );
{
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 )
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;
#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(
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 );
}
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 );
}
)
{
char *val, *p, *code, *w;
- int i, j, len;
+ unsigned i, j, len;
int indexmask, syntax;
char buf[SUBLEN + 1];
char vbuf[BUFSIZ];
#include "slap.h"
#include "back-ldbm.h"
+void
ldbm_back_init(
Backend *be
)
#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(
#include "back-ldbm.h"
#include "proto-back-ldbm.h"
-extern char *dn_parent();
-
int
ldbm_back_modrdn(
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 {
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;
}
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 );
}
}
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 );
}
}
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 {
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;
}
struct dbcache * ldbm_cache_open LDAP_P(( Backend *be, char *name, char *suffix,
int flags ));
void ldbm_cache_close LDAP_P(( Backend *be, struct dbcache *db ));
+void ldbm_cache_really_close LDAP_P(( Backend *be, struct dbcache *db ));
void ldbm_cache_flush_all LDAP_P(( Backend *be ));
Datum ldbm_cache_fetch LDAP_P(( struct dbcache *db, Datum key ));
int ldbm_cache_store LDAP_P(( struct dbcache *db, Datum key, Datum data, int flags ));
*/
int 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 ));
/*
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 ));
#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
/* 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;
}
#include "portable.h"
#include <stdio.h>
-
#include <ac/socket.h>
#include "slap.h"
-int
+void
ldbm_back_unbind(
Backend *be,
Connection *conn,
Operation *op
)
{
- return( 0 );
}
#include "slap.h"
+void
passwd_back_config(
Backend *be,
char *fname,
#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(
#include "slap.h"
#include "shell.h"
-extern pthread_mutex_t entry2str_mutex;
-extern char *entry2str();
-
-void
+int
shell_back_add(
Backend *be,
Connection *conn,
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 ) );
read_and_send_results( be, conn, op, rfp, NULL, 0 );
fclose( rfp );
+ return( 0 );
}
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 );
#include "slap.h"
#include "shell.h"
-void
+int
shell_back_compare(
Backend *be,
Connection *conn,
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 );
read_and_send_results( be, conn, op, rfp, NULL, 0 );
fclose( rfp );
+ return( 0 );
}
#include "slap.h"
#include "shell.h"
-extern char **charray_dup();
-
+void
shell_back_config(
Backend *be,
char *fname,
#include "slap.h"
#include "shell.h"
-void
+int
shell_back_delete(
Backend *be,
Connection *conn,
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 );
/* read in the results and send them along */
read_and_send_results( be, conn, op, rfp, NULL, 0 );
fclose( rfp );
+ return( 0 );
}
#include <ac/string.h>
#include <ac/socket.h>
+#include <ac/unistd.h>
#include "slap.h"
+#include "shell.h"
+int
forkandexec(
char **args,
FILE **rfp,
#include "slap.h"
#include "shell.h"
+void
shell_back_init(
Backend *be
)
#include "slap.h"
#include "shell.h"
-void
+int
shell_back_modify(
Backend *be,
Connection *conn,
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 ) {
/* read in the results and send them along */
read_and_send_results( be, conn, op, rfp, NULL, 0 );
fclose( rfp );
+ return( 0 );
+
}
#include "slap.h"
#include "shell.h"
-void
+int
shell_back_modrdn(
Backend *be,
Connection *conn,
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 );
/* read in the results and send them along */
read_and_send_results( be, conn, op, rfp, NULL, 0 );
fclose( rfp );
+ return( 0 );
}
#include <ac/string.h>
#include <ac/socket.h>
+#include <ac/unistd.h>
#include "slap.h"
#include "shell.h"
-extern Entry *str2entry();
-
int
read_and_send_results(
Backend *be,
#include "slap.h"
#include "shell.h"
-extern Entry *str2entry();
-
-void
+int
shell_back_search(
Backend *be,
Connection *conn,
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 );
read_and_send_results( be, conn, op, rfp, attrs, attrsonly );
fclose( rfp );
+ return( 0 );
}
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
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;
/* 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 */
#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
}
void
-be_close()
+be_close( void )
{
int i;
#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));
#include "slap.h"
-extern Backend *select_backend();
-extern char *suffixAlias();
-
-extern char *default_referral;
-
void
do_bind(
Connection *conn,
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 );
}
}
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 );
}
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 );
}
#include "slap.h"
-extern Backend *select_backend();
-
-extern char *default_referral;
-
void
do_compare(
Connection *conn,
#include <stdio.h>
#include <ac/string.h>
+#include <ac/ctype.h>
#include <ac/socket.h>
-#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
*/
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 )
#include <ac/string.h>
#include <ac/socket.h>
-#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!
*/
#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;
* 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 );
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;
}
pthread_mutex_lock( &active_threads_mutex );
active_threads--;
pthread_mutex_unlock( &active_threads_mutex );
+ return NULL;
}
void
"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 );
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 );
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 );
#include <ac/time.h>
#include <ac/unistd.h>
-#include "slap.h"
#include "ldapconfig.h"
+#include "slap.h"
#ifdef HAVE_SYS_FILIO_H
#include <sys/filio.h>
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;
(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] :
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
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
/*
}
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,
#include "slap.h"
-extern Backend *select_backend();
-extern char *suffixAlias();
-
-extern char *default_referral;
-
void
do_delete(
Connection *conn,
#include "slap.h"
-static char **dn_explode();
-
#define DNSEPARATOR(c) (c == ',' || c == ';')
#define SEPARATOR(c) (c == ',' || c == ';' || c == '+')
#define SPACE(c) (c == ' ' || c == '\n')
#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 */
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;
}
/* 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 );
}
{
return pthread_rdwr_init_np(&e->e_rdwr, NULL);
}
-
#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 )
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;
}
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 );
break;
default:
- fprintf( stderr, "unknown type %d", f->f_choice );
+ fprintf( stderr, "unknown type %lu", f->f_choice );
break;
}
}
#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.
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;
}
#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 );
#include <stdio.h>
+#include <ac/string.h>
#include <ac/socket.h>
#include <ac/time.h>
#include <ac/unistd.h>
+extern int flock ();
#include <sys/file.h>
#include <sys/param.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
+#include <ac/unistd.h>
-#include "slap.h"
#include "ldapconfig.h"
+#include "slap.h"
#include "lutil.h" /* Get lutil_detach() */
-extern void slapd_daemon();
-extern int lber_debug;
-
-extern char Versionstr[];
-
/*
* read-only global variables or variables only written by the listener
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;
!= 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;
}
== 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;
#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
#include "slap.h"
-extern Backend *select_backend();
-
-extern char *default_referral;
-
void
do_modrdn(
Connection *conn,
#include <ac/string.h>
#include <ac/time.h>
-#include "slap.h"
#include "ldapconfig.h"
+#include "slap.h"
#if defined( SLAPD_MONITOR_DN )
-extern int nbackends;
-extern Backend *backends;
-extern int active_threads;
-extern int dtblsize;
-extern Connection *c;
-extern long ops_initiated;
-extern long ops_completed;
-extern long num_entries_sent;
-extern long num_bytes_sent;
-extern time_t currenttime;
-extern time_t starttime;
-extern int num_conns;
-
-extern pthread_mutex_t new_conn_mutex;
-extern pthread_mutex_t currenttime_mutex;
-
-extern char Versionstr[];
-
void
monitor_info( Connection *conn, Operation *op )
{
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" : "",
#include "slap.h"
-extern time_t currenttime;
-extern pthread_mutex_t currenttime_mutex;
void
op_free( 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;
}
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
*/
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 */
#include <stdio.h>
#include <ac/string.h>
+#include <ac/ctype.h>
#include <ac/socket.h>
#include <sys/file.h>
#include "slap.h"
-extern pthread_mutex_t replog_mutex;
-extern pthread_mutex_t entry2str_mutex;
-extern time_t currenttime;
-extern char *replogfile;
-
-extern FILE *lock_fopen();
-extern int lock_fclose();
-extern char *entry2str();
void
replog(
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
+#include <ac/unistd.h> /* 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(
#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
#ifdef LDAP_DEBUG
-static
+static void
oc_print( struct objclass *oc )
{
int i;
#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(
}
static void
-oc_usage()
+oc_usage( void )
{
fprintf( stderr, "<oc clause> ::= objectclass <ocname>\n" );
fprintf( stderr, " [ requires <attrlist> ]\n" );
#include <ac/string.h>
#include <ac/socket.h>
-#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;
static char tmpbuf[ MAXLINELEN * 2 ];
+int
main( int argc, char **argv )
{
int c, errflg;
#include <pwd.h>
#include <ac/string.h>
+#include <ac/ctype.h>
+extern long int random (void);
#include <lber.h>
#include <ldap.h>
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
LDAP_BEGIN_DECL
+struct op;
+struct conn;
+
/*
* represents an attribute value assertion (i.e., attr=value)
*/
* 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 */
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
#include <stdio.h>
#include <ac/string.h>
+#include <ac/ctype.h>
#include <ac/socket.h>
#include "slap.h"
-static char *find_matching_paren();
-static Filter *str2list();
-static Filter *str2simple();
-static int str2subvals();
+static char *find_matching_paren(char *s);
+static Filter *str2list(char *str, long unsigned int ftype);
+static Filter *str2simple(char *str);
+static int str2subvals(char *val, Filter *f);
Filter *
str2filter( char *str )
* 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;
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/time.h>
+#include <ac/unistd.h> /* get link(), unlink() */
+extern char *strdup (const char *);
+extern char *strtok (char *, const char *);
+extern char *strpbrk (const char *, const char *);
#include <lber.h>
#include <ldap.h>
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 )
{
fprintf( stderr, "\t-c size\t\tldbm cache size\n" );
}
+int
main( int argc, char **argv )
{
char *ldapfilter;
Datum olast, nlast;
Datum lastkey, key;
Datum data;
- int rc;
LDAPMod **mods;
char **avals, **dvals;
int amax, acur, dmax, dcur;
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 */
#include <ac/ctype.h>
#include <ac/string.h>
+#include <ac/unistd.h>
#include <quipu/commonarg.h>
#include <quipu/attrvalue.h>
#include "ldif.h"
-static int dn2ldif();
-static void de_t61();
+static int dn2ldif(PS ps, DN dn);
+static void de_t61(char *s, int t61mark);
extern FILE *lock_fopen( char *, char *, FILE ** );
extern int lock_fclose( FILE *, FILE * );
static void
-de_t61( s, t61mark )
-char *s;
-int t61mark;
+de_t61(char *s, int t61mark)
{
char *next = s;
int c, hex;
char *
-getattr( buf, sep )
-char *buf;
-char sep;
+getattr(char *buf, char sep)
{
char *val;
#define RBSIZE 255
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;
}
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, '=' ));
}
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 ) {
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;
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 );
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;
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 ];
* 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;
}
-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
/* 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 ];
static char *
-file2rdn( edbmap, filename )
- struct edbmap *edbmap;
- char *filename;
+file2rdn( struct edbmap *edbmap, char *filename )
{
#ifdef LDAP_DEBUG
if ( debugflg ) {
/* free the edbmap list */
static void
-free_edbmap( edbmap )
- struct edbmap *edbmap;
+free_edbmap( struct edbmap *edbmap )
{
struct edbmap *tmp;
static void
-print_err( msg )
- char *msg;
+print_err( char *msg )
{
extern int sys_nerr;
extern char *sys_errlist[];
#include "ldbm.h"
#include "../slap.h"
-usage( name )
-char *name;
+static void
+usage( char *name )
{
fprintf( stderr, "usage: %s [-n] <filename>\n", name );
exit( 1 );
}
-main( argc, argv )
- int argc;
- char **argv;
+int
+main( int argc, char **argv )
{
Datum key, last, data;
LDBM dbp;
#include <ac/socket.h>
#include <ac/string.h>
+#include <ac/ctype.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <ac/wait.h>
#include <sys/resource.h>
#include <sys/param.h>
#include <sys/stat.h>
+extern int mkstemp (char *);
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#define EDITOR "/usr/ucb/vi"
-extern IDList *idl_fetch();
-extern Backend *select_backend();
-extern struct dbcache *ldbm_cache_open();
-
-static struct dbcache *openchoice();
-static void print_entry();
-static void free_and_close();
-static void edit_entry();
-static void get_keydata();
+static struct dbcache *openchoice(char c, int mode, int verbose, char **fname);
+static void print_entry(FILE *fp, char c, Datum *key, char *klabel, Datum *data, char *dlabel);
+static void free_and_close(struct dbcache *dbc, Datum key, Datum data);
+static void edit_entry(char c, Datum *data);
+static void get_keydata(FILE *fp, char c, Datum *key, Datum *data);
struct dbcache *dbc;
LDBM dbp;
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;
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;
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;
}
}
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 )
}
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 ) );
}
static void
-get_idlist( fp, data )
- FILE *fp;
- Datum *data;
+get_idlist( FILE *fp, Datum *data )
{
char buf[20];
int i, j, fd, tty;
}
static void
-get_entry( fp, data )
- FILE *fp;
- Datum *data;
+get_entry( FILE *fp, Datum *data )
{
char buf[BUFSIZ];
char *p;
}
static void
-edit_entry( c, data )
- char c;
- Datum *data;
+edit_entry( char c, Datum *data )
{
int fd, pid;
char tmpname[20];
}
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;
}
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];
}
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;
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 ) {
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] );
}
}
}
}
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;
#include <ac/string.h>
#include <ac/socket.h>
+#include <ac/unistd.h> /* Get read() */
#include "lber.h"
#include "ldap.h"
int ldap_syslog_level;
-usage( name )
-char *name;
+static void
+usage( char *name )
{
fprintf( stderr, "usage: %s [-b] <attrtype>\n", name );
exit( 1 );
}
-main( argc, argv )
- int argc;
- char **argv;
+int
+main( int argc, char **argv )
{
char buf[BUFSIZ];
char *type, *out;
#include <ac/string.h>
#include <ac/socket.h>
+#include "ldapconfig.h"
#include "../slap.h"
#include "../back-ldbm/back-ldbm.h"
-#include "ldapconfig.h"
#include "ldif.h"
#define MAXARGS 100
-extern struct dbcache *ldbm_cache_open();
-extern void attr_index_config();
-extern char *dn_parent();
-extern char *dn_normalize_case();
-extern int nbackends;
-extern Backend *backends;
-extern int ldap_debug;
-
int lineno;
int ldap_debug;
int ldap_syslog;
int ldap_syslog_level;
int global_schemacheck;
-int num_entries_sent;
-int num_bytes_sent;
+long num_entries_sent;
+long num_bytes_sent;
int active_threads;
char *default_referral;
struct objclass *global_oc;
exit( 1 );
}
+int
main( int argc, char **argv )
{
int i, cargc, indb, stop, status;
}
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 );
}
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 ))
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 )
#include <ac/string.h>
#include <ac/socket.h>
+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;
pthread_mutex_t ops_mutex;
pthread_mutex_t regex_mutex;
-static int make_index();
-
static char *tailorfile;
static char *inputfile;
exit( 1 );
}
+int
main( int argc, char **argv )
{
int i, cargc, indb, stop, status;
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;
#include <ac/socket.h>
#include "../slap.h"
+#include "../back-ldbm/back-ldbm.h"
#include "ldapconfig.h"
#include "ldif.h"
#define MAXARGS 100
-extern void attr_index_config();
-extern char *attr_normalize();
-extern int nbackends;
-extern Backend *backends;
-extern int ldap_debug;
-
int ldap_debug;
int ldap_syslog;
int ldap_syslog_level;
int global_schemacheck;
-int num_entries_sent;
-int num_bytes_sent;
+long num_entries_sent;
+long num_bytes_sent;
int active_threads;
char *default_referral;
struct objclass *global_oc;
pthread_mutex_t ops_mutex;
pthread_mutex_t regex_mutex;
+
static void
usage( char *name )
{
exit( 1 );
}
+int
main( int argc, char **argv )
{
int i, cargc, indb, stop;
#include <stdio.h>
#include <ac/string.h>
+#include <ac/ctype.h>
#include <ac/socket.h>
+#include <ac/unistd.h>
+#include <ac/wait.h>
#include <sys/param.h>
+#include "ldapconfig.h"
#include "../slap.h"
#include "../back-ldbm/back-ldbm.h"
-#include "ldapconfig.h"
#include "ldif.h"
#define INDEXCMD "ldif2index"
#define ID2CHILDRENCMD "ldif2id2children"
#define MAXARGS 100
-extern int nbackends;
-extern Backend *backends;
-extern int ldap_debug;
-
int ldap_debug;
int ldap_syslog;
int ldap_syslog_level;
int global_schemacheck;
-int num_entries_sent;
-int num_bytes_sent;
+long num_entries_sent;
+long num_bytes_sent;
int active_threads;
char *default_referral;
struct objclass *global_oc;
static char *inputfile;
static int maxkids = 1;
static int nkids;
-
+
static void
usage( char *name )
{
exit( 1 );
}
+int
main( int argc, char **argv )
{
int i, stop, status;
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
+#include <ac/string.h>
+#include <unistd.h> /* get unlink() */
+
#include <ldbm.h>
#include <lber.h>
#include <ldap.h>
#define DB_FLAGS (LDBM_WRCREAT|LDBM_NEWDB)
#define SUBLEN 3
-extern char *first_word();
-extern char *next_word();
-extern char *word_dup();
-extern char *phonetic();
+extern char *first_word(char *);
+extern char *next_word(char *);
+extern char *word_dup(char *);
+extern char *phonetic(char *);
extern int ldap_debug;
extern int lber_debug;
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;
#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(
* 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 );
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/string.h>
#include <ac/time.h>
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/socket.h>
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/string.h>
#include <ac/socket.h>
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h> /* get free() */
#include <ac/string.h>
#include <ac/signal.h>
#include "globals.h"
-/*
- * Externs
- */
-extern RETSIGTYPE do_admin LDAP_P((int));
-extern int file_nonempty LDAP_P(( char * ));
-extern int acquire_lock LDAP_P((char *, FILE **, FILE ** ));
-extern int relinquish_lock LDAP_P((char *, FILE *, FILE * ));
-
/*
* Forward references
*/
static char *get_record LDAP_P(( FILE * ));
static void populate_queue LDAP_P(( char *f ));
static RETSIGTYPE set_shutdown LDAP_P((int));
-RETSIGTYPE do_nothing LDAP_P((int));
/*
* - 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
)
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
}
}
Debug( LDAP_DEBUG_ARGS, "fm: exiting\n", 0, 0, 0 );
+ return NULL;
}
}
return( buf );
}
-
#include <stdio.h>
#include <stdlib.h>
+#include <ac/string.h>
#include "slurp.h"
#include "globals.h"
/*
* Initialize the globals
*/
-Globals *init_globals()
+Globals *
+init_globals( void )
{
Globals *g;
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/errno.h>
#include <ac/string.h>
#include <ac/ctype.h>
#include <ac/time.h>
+#include <ac/unistd.h> /* Get_t getpid() */
#include <ac/krb.h>
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 * ));
* Allocate and initialize an ldapmod struct.
*/
static LDAPMod *
-alloc_ldapmod()
+alloc_ldapmod( void )
{
LDAPMod *ldm;
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;
}
*/
static void
dump_ldm_array(
-LDAPMod **ldmarr )
+ LDAPMod **ldmarr
+)
{
int i, j;
LDAPMod *ldm;
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 );
}
}
*/
static void
upcase(
-char *s )
+ char *s
+)
{
char *p;
#include <ac/socket.h>
#include <ac/time.h>
#include <ac/unistd.h>
+extern int flock ();
#include <sys/file.h>
#include <sys/param.h>
-#include "../slapd/slap.h"
-
+#include "slurp.h" /* Was ../slapd/slap.h */
FILE *
{
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 );
{
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 );
#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,
--- /dev/null
+#ifndef _PROTO_SLURP
+#define _PROTO_SLURP
+
+#include <ldap_cdefs.h>
+
+struct globals;
+
+/* admin.c */
+RETSIGTYPE do_admin LDAP_P((int sig));
+
+/* args.c */
+int doargs LDAP_P((int argc, char **argv, struct globals *g));
+
+/* ch_malloc.c */
+void *ch_malloc LDAP_P((unsigned long size));
+void *ch_realloc LDAP_P((void *block, unsigned long size));
+void *ch_calloc LDAP_P((unsigned long nelem, unsigned long size));
+void ch_free LDAP_P((void *p));
+
+/* config.c */
+int slurpd_read_config LDAP_P((char *fname));
+
+/* ch_malloc.c */
+void ch_free LDAP_P(( void *p ));
+
+/* fm.c */
+void *fm LDAP_P((void *arg));
+RETSIGTYPE do_nothing LDAP_P((int i));
+
+/* globals.c */
+extern struct globals *sglob;
+extern int ldap_syslog;
+extern int ldap_syslog_level;
+extern int ldap_debug;
+extern struct globals *init_globals LDAP_P((void));
+
+/* ldap_op.c */
+int do_ldap LDAP_P((Ri *ri, Re *re, char **errmsg));
+
+/* lock.c */
+FILE *lock_fopen LDAP_P((char *fname, char *type, FILE **lfp));
+int lock_fclose LDAP_P((FILE *fp, FILE *lfp));
+int acquire_lock LDAP_P((char *file, FILE **rfp, FILE **lfp));
+int relinquish_lock LDAP_P((char *file, FILE *rfp, FILE *lfp));
+
+/* reject.c */
+void write_reject LDAP_P((Ri *ri, Re *re, int lderr, char *errmsg));
+
+/* replica.c */
+int start_replica_thread LDAP_P((Ri *ri));
+
+/* replog.c */
+int copy_replog LDAP_P((char *src, char *dst));
+int file_nonempty LDAP_P((char *filename));
+
+/* sanity.c */
+int sanity LDAP_P((void));
+
+/* st.c */
+int St_init LDAP_P((St **st));
+
+/* tsleep.c */
+void tsleep LDAP_P((time_t interval));
+#if defined( HAVE_LWP )
+void start_lwp_scheduler LDAP_P(( void ));
+#endif
+
+#endif /* _PROTO_SLURP */
#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 * ));
/*
* Free an Re
+ * ??? Something should apparently return nonzero here, but I dont know what.
*/
static int
Re_free(
free( mi );
}
free( re );
+ return 0;
}
* 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;
}
#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.
}
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 );
}
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 );
}
#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 ));
/*
sglob->st->st_unlock( sglob->st );
return ret;
}
-
-
#include <stdio.h>
#include <stdlib.h>
+#include <ac/unistd.h> /* get ftruncate() */
#include "slurp.h"
#include "globals.h"
-/* externs */
-extern void Re_dump LDAP_P(( Re *re ));
-
/*
* Lock the replication queue.
*/
return 0;
}
-
*/
int
-sanity()
+sanity( void )
{
int err = 0;
int rc;
return ret;
}
-
* 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 */
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 */
+};
-
/*
* 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
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 */
+};
* 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 */
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 */
+};
/*
* 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 */
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 {
} 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.
*/
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_ */
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
+#include <ac/unistd.h> /* get sleep() */
#include "slurp.h"
#include "globals.h"
int
tsleep(
- int interval
+ time_t interval
)
{
thread_t mylwp;
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;
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 );
* Create the lwp_scheduler thread.
*/
void
-start_lwp_scheduler()
+start_lwp_scheduler( void )
{
thread_t tid;
stkalign_t *stack;
sleep( interval );
}
#endif /* !HAVE_LWP */
-
-
-