X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=clients%2Frcpt500%2Fquery.c;h=e70a224ec085252614b37d16ce331bd64adfcca0;hb=40ba9bc80bb28e0f99cc1d24d668e86971401484;hp=aac3e2253224aefff8d8b80ddf538e14f360c92f;hpb=43f29c3cb85f252b3c6aaf39e85a5d02bffb51e0;p=openldap diff --git a/clients/rcpt500/query.c b/clients/rcpt500/query.c index aac3e22532..e70a224ec0 100644 --- a/clients/rcpt500/query.c +++ b/clients/rcpt500/query.c @@ -9,8 +9,9 @@ #include "portable.h" #include -#include +#include +#include #include #include #include @@ -18,45 +19,29 @@ #include "lber.h" #include "ldap.h" -#if LDAP_VERSION < LDAP_VERSION3 -/* quick fix until we have ldap_set_options */ -#include "../libraries/libldap/ldap-int.h" -#endif - #include "disptmpl.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; char *s, *dn; - int matches, rc, ufn; + int matches, rc, ld_errno, ufn; LDAPFiltDesc *lfdp; LDAPFiltInfo *lfi; struct ldap_disptmpl *tmpllist = NULL; @@ -113,8 +98,8 @@ query_cmd( msgp, reply ) /* * set options for search and build filter */ - ldp->ld_deref = derefaliases; - ldp->ld_sizelimit = sizelimit; + ldap_set_option(ldp, LDAP_OPT_DEREF, &derefaliases); + ldap_set_option(ldp, LDAP_OPT_SIZELIMIT, &sizelimit); matches = 0; @@ -179,8 +164,11 @@ query_cmd( msgp, reply ) return( 0 ); } - if ( ldp->ld_errno == LDAP_TIMELIMIT_EXCEEDED - || ldp->ld_errno == LDAP_SIZELIMIT_EXCEEDED ) { + ld_errno = 0; + ldap_get_option(ldp, LDAP_OPT_ERROR_NUMBER, &ld_errno); + + if ( ld_errno == LDAP_TIMELIMIT_EXCEEDED + || ld_errno == LDAP_SIZELIMIT_EXCEEDED ) { strcat( reply, "(Partial results only - a limit was exceeded)\n" ); } @@ -226,7 +214,7 @@ query_cmd( msgp, reply ) } -void +static void close_ldap( LDAP *ld ) { #ifdef LDAP_CONNECTIONLESS @@ -238,11 +226,8 @@ close_ldap( LDAP *ld ) } -append_entry_list( reply, query, ldp, ldmsgp ) - char *reply; - char *query; - LDAP *ldp; - LDAPMessage *ldmsgp; +static void +append_entry_list( char *reply, char *query, LDAP *ldp, LDAPMessage *ldmsgp ) { LDAPMessage *e; char *dn, *rdn, *s, **title; @@ -303,23 +288,16 @@ append_entry_list( reply, query, ldp, ldmsgp ) } -int -append_text( reply, text, len ) - char *reply; - char *text; - int len; +static int +append_text( void *reply, char *text, int len ) { - strcat( reply, text ); + strcat( (char *) reply, text ); return( len ); } -int -do_read( ldp, dn, reply, tmpll ) - LDAP *ldp; - char *dn; - char *reply; - struct ldap_disptmpl *tmpll; +static int +do_read( LDAP *ldp, char *dn, char *reply, struct ldap_disptmpl *tmpll ) { int rc; static char *maildefvals[] = { "None registered in this service", NULL }; @@ -335,18 +313,20 @@ do_read( ldp, dn, reply, tmpll ) } -report_ldap_err( ldp, reply ) - LDAP *ldp; - char *reply; +static void +report_ldap_err( LDAP *ldp, char *reply ) { + int ld_errno = 0; + ldap_get_option(ldp, LDAP_OPT_ERROR_NUMBER, &ld_errno); + strcat( reply, errpreface ); - strcat( reply, ldap_err2string( ldp->ld_errno )); + strcat( reply, ldap_err2string( ld_errno )); strcat( reply, "\n" ); } -remove_trailing_space( s ) - char *s; +static void +remove_trailing_space( char *s ) { char *p = s + strlen( s ) - 1;