From b3b17ca4e7cfb8035c2b91cb98f27952ba1026a8 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 19 Dec 2001 21:46:34 +0000 Subject: [PATCH] Remove srchpref and disptmpl stuff. --- include/Makefile.in | 3 +- include/disptmpl.h | 320 ----------- include/srchpref.h | 105 ---- libraries/liblber/lber-int.h | 2 +- libraries/libldap/Makefile.in | 8 +- libraries/libldap/disptmpl.c | 715 ------------------------- libraries/libldap/dsparse.c | 195 ------- libraries/libldap/ldap-int.h | 8 +- libraries/libldap/ldapsearchprefs.conf | 154 ------ libraries/libldap/ldaptemplates.conf | 678 ----------------------- libraries/libldap/srchpref.c | 419 --------------- libraries/libldap/tmpltest.c | 280 ---------- libraries/libldap_r/Makefile.in | 6 +- 13 files changed, 8 insertions(+), 2885 deletions(-) delete mode 100644 include/disptmpl.h delete mode 100644 include/srchpref.h delete mode 100644 libraries/libldap/disptmpl.c delete mode 100644 libraries/libldap/dsparse.c delete mode 100644 libraries/libldap/ldapsearchprefs.conf delete mode 100644 libraries/libldap/ldaptemplates.conf delete mode 100644 libraries/libldap/srchpref.c delete mode 100644 libraries/libldap/tmpltest.c diff --git a/include/Makefile.in b/include/Makefile.in index f93ba38f44..8d44c10375 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -11,8 +11,7 @@ install-local: FORCE for header in $(srcdir)/lber.h lber_types.h \ $(srcdir)/ldap.h $(srcdir)/ldap_cdefs.h \ $(srcdir)/ldap_schema.h $(srcdir)/ldap_utf8.h \ - ldap_features.h \ - $(srcdir)/disptmpl.h $(srcdir)/srchpref.h; \ + ldap_features.h; \ do \ $(INSTALL) $(INSTALLFLAGS) -m 644 $$header $(DESTDIR)$(includedir); \ done diff --git a/include/disptmpl.h b/include/disptmpl.h deleted file mode 100644 index c5a858c727..0000000000 --- a/include/disptmpl.h +++ /dev/null @@ -1,320 +0,0 @@ -/* $OpenLDAP$ */ -/* - * Copyright 1998-2001 The OpenLDAP Foundation, Redwood City, California, USA - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted only as authorized by the OpenLDAP - * Public License. A copy of this license is available at - * http://www.OpenLDAP.org/license.html or in file LICENSE in the - * top-level directory of the distribution. - */ -/* Portions - * Copyright (c) 1993, 1994 Regents of the University of Michigan. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that this notice is preserved and that due credit is given - * to the University of Michigan at Ann Arbor. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific prior written permission. This software - * is provided ``as is'' without express or implied warranty. - * - * disptmpl.h: display template library defines - * 7 March 1994 by Mark C Smith - */ - -/* DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED */ - -#ifndef _DISPTMPL_H -#define _DISPTMPL_H - -#include - -LDAP_BEGIN_DECL - -#define LDAP_TEMPLATE_VERSION 1 - -/* - * general types of items (confined to most significant byte) - */ -#define LDAP_SYN_TYPE_TEXT 0x01000000L -#define LDAP_SYN_TYPE_IMAGE 0x02000000L -#define LDAP_SYN_TYPE_BOOLEAN 0x04000000L -#define LDAP_SYN_TYPE_BUTTON 0x08000000L -#define LDAP_SYN_TYPE_ACTION 0x10000000L - - -/* - * syntax options (confined to second most significant byte) - */ -#define LDAP_SYN_OPT_DEFER 0x00010000L - - -/* - * display template item syntax ids (defined by common agreement) - * these are the valid values for the ti_syntaxid of the tmplitem - * struct (defined below). A general type is encoded in the - * most-significant 8 bits, and some options are encoded in the next - * 8 bits. The lower 16 bits are reserved for the distinct types. - */ -#define LDAP_SYN_CASEIGNORESTR ( 1 | LDAP_SYN_TYPE_TEXT ) -#define LDAP_SYN_MULTILINESTR ( 2 | LDAP_SYN_TYPE_TEXT ) -#define LDAP_SYN_DN ( 3 | LDAP_SYN_TYPE_TEXT ) -#define LDAP_SYN_BOOLEAN ( 4 | LDAP_SYN_TYPE_BOOLEAN ) -#define LDAP_SYN_JPEGIMAGE ( 5 | LDAP_SYN_TYPE_IMAGE ) -#define LDAP_SYN_JPEGBUTTON ( 6 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER ) -#define LDAP_SYN_FAXIMAGE ( 7 | LDAP_SYN_TYPE_IMAGE ) -#define LDAP_SYN_FAXBUTTON ( 8 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER ) -#define LDAP_SYN_AUDIOBUTTON ( 9 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER ) -#define LDAP_SYN_TIME ( 10 | LDAP_SYN_TYPE_TEXT ) -#define LDAP_SYN_DATE ( 11 | LDAP_SYN_TYPE_TEXT ) -#define LDAP_SYN_LABELEDURL ( 12 | LDAP_SYN_TYPE_TEXT ) -#define LDAP_SYN_SEARCHACTION ( 13 | LDAP_SYN_TYPE_ACTION ) -#define LDAP_SYN_LINKACTION ( 14 | LDAP_SYN_TYPE_ACTION ) -#define LDAP_SYN_ADDDNACTION ( 15 | LDAP_SYN_TYPE_ACTION ) -#define LDAP_SYN_VERIFYDNACTION ( 16 | LDAP_SYN_TYPE_ACTION ) -#define LDAP_SYN_RFC822ADDR ( 17 | LDAP_SYN_TYPE_TEXT ) - - -/* - * handy macros - */ -#define LDAP_GET_SYN_TYPE( syid ) ((syid) & 0xFF000000L ) -#define LDAP_GET_SYN_OPTIONS( syid ) ((syid) & 0x00FF0000L ) - - -/* - * display options for output routines (used by entry2text and friends) - */ -/* - * use calculated label width (based on length of longest label in - * template) instead of contant width - */ -#define LDAP_DISP_OPT_AUTOLABELWIDTH 0x00000001L -#define LDAP_DISP_OPT_HTMLBODYONLY 0x00000002L - -/* - * perform search actions (applies to ldap_entry2text_search only) - */ -#define LDAP_DISP_OPT_DOSEARCHACTIONS 0x00000002L - -/* - * include additional info. relevant to "non leaf" entries only - * used by ldap_entry2html and ldap_entry2html_search to include "Browse" - * and "Move Up" HREFs - */ -#define LDAP_DISP_OPT_NONLEAF 0x00000004L - - -/* - * display template item options (may not apply to all types) - * if this bit is set in ti_options, it applies. - */ -#define LDAP_DITEM_OPT_READONLY 0x00000001L -#define LDAP_DITEM_OPT_SORTVALUES 0x00000002L -#define LDAP_DITEM_OPT_SINGLEVALUED 0x00000004L -#define LDAP_DITEM_OPT_HIDEIFEMPTY 0x00000008L -#define LDAP_DITEM_OPT_VALUEREQUIRED 0x00000010L -#define LDAP_DITEM_OPT_HIDEIFFALSE 0x00000020L /* booleans only */ - - - -/* - * display template item structure - */ -struct ldap_tmplitem { - unsigned long ti_syntaxid; - unsigned long ti_options; - char *ti_attrname; - char *ti_label; - char **ti_args; - struct ldap_tmplitem *ti_next_in_row; - struct ldap_tmplitem *ti_next_in_col; - void *ti_appdata; -}; - - -#define LDAP_SET_TMPLITEM_APPDATA( ti, datap ) \ - ( (ti)->ti_appdata = (void *)(datap) ) - -#define LDAP_GET_TMPLITEM_APPDATA( ti, type ) \ - ( (type)((ti)->ti_appdata) ) - -#define LDAP_IS_TMPLITEM_OPTION_SET( ti, option ) \ - ( ((ti)->ti_options & (option) ) != 0 ) - - -/* - * object class array structure - */ -struct ldap_oclist { - char **oc_objclasses; - struct ldap_oclist *oc_next; -}; - - -/* - * add defaults list - */ -struct ldap_adddeflist { - int ad_source; -#define LDAP_ADSRC_CONSTANTVALUE 1 -#define LDAP_ADSRC_ADDERSDN 2 - char *ad_attrname; - char *ad_value; - struct ldap_adddeflist *ad_next; -}; - - -/* - * display template global options - * if this bit is set in dt_options, it applies. - */ -/* - * users should be allowed to try to add objects of these entries - */ -#define LDAP_DTMPL_OPT_ADDABLE 0x00000001L - -/* - * users should be allowed to do "modify RDN" operation of these entries - */ -#define LDAP_DTMPL_OPT_ALLOWMODRDN 0x00000002L - -/* - * this template is an alternate view, not a primary view - */ -#define LDAP_DTMPL_OPT_ALTVIEW 0x00000004L - - -/* - * display template structure - */ -struct ldap_disptmpl { - char *dt_name; - char *dt_pluralname; - char *dt_iconname; - unsigned long dt_options; - char *dt_authattrname; - char *dt_defrdnattrname; - char *dt_defaddlocation; - struct ldap_oclist *dt_oclist; - struct ldap_adddeflist *dt_adddeflist; - struct ldap_tmplitem *dt_items; - void *dt_appdata; - struct ldap_disptmpl *dt_next; -}; - -#define LDAP_SET_DISPTMPL_APPDATA( dt, datap ) \ - ( (dt)->dt_appdata = (void *)(datap) ) - -#define LDAP_GET_DISPTMPL_APPDATA( dt, type ) \ - ( (type)((dt)->dt_appdata) ) - -#define LDAP_IS_DISPTMPL_OPTION_SET( dt, option ) \ - ( ((dt)->dt_options & (option) ) != 0 ) - -#define LDAP_TMPL_ERR_VERSION 1 -#define LDAP_TMPL_ERR_MEM 2 -#define LDAP_TMPL_ERR_SYNTAX 3 -#define LDAP_TMPL_ERR_FILE 4 - -/* - * buffer size needed for entry2text and vals2text - */ -#define LDAP_DTMPL_BUFSIZ 8192 - - -typedef int (*ldap_writeptype) LDAP_P(( - void *writeparm, char *p, ber_len_t len )); - -LDAP_F( int ) -ldap_init_templates LDAP_P(( char *file, struct ldap_disptmpl **tmpllistp )); - -LDAP_F( int ) -ldap_init_templates_buf LDAP_P(( char *buf, - ber_len_t buflen, - struct ldap_disptmpl **tmpllistp )); - -LDAP_F( void ) -ldap_free_templates LDAP_P(( struct ldap_disptmpl *tmpllist )); - -LDAP_F( struct ldap_disptmpl * ) -ldap_first_disptmpl LDAP_P(( struct ldap_disptmpl *tmpllist )); - -LDAP_F( struct ldap_disptmpl * ) -ldap_next_disptmpl LDAP_P(( struct ldap_disptmpl *tmpllist, - struct ldap_disptmpl *tmpl )); - -LDAP_F( struct ldap_disptmpl * ) -ldap_name2template LDAP_P(( char *name, - struct ldap_disptmpl *tmpllist )); - -LDAP_F( struct ldap_disptmpl * ) -ldap_oc2template LDAP_P(( char **oclist, - struct ldap_disptmpl *tmpllist )); - -LDAP_F( char ** ) -ldap_tmplattrs LDAP_P(( struct ldap_disptmpl *tmpl, - char **includeattrs, - int exclude, - unsigned long syntaxmask )); - -LDAP_F( struct ldap_tmplitem * ) -ldap_first_tmplrow LDAP_P(( struct ldap_disptmpl *tmpl )); - -LDAP_F( struct ldap_tmplitem * ) -ldap_next_tmplrow LDAP_P(( struct ldap_disptmpl *tmpl, - struct ldap_tmplitem *row )); - -LDAP_F( struct ldap_tmplitem * ) -ldap_first_tmplcol LDAP_P(( struct ldap_disptmpl *tmpl, - struct ldap_tmplitem *row )); - -LDAP_F( struct ldap_tmplitem * ) -ldap_next_tmplcol LDAP_P(( struct ldap_disptmpl *tmpl, - struct ldap_tmplitem *row, - struct ldap_tmplitem *col )); - -LDAP_F( int ) -ldap_entry2text LDAP_P(( LDAP *ld, - char *buf, LDAPMessage *entry, - struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, - ldap_writeptype writeproc, void *writeparm, char *eol, int rdncount, - unsigned long opts )); - -LDAP_F( int ) -ldap_vals2text LDAP_P(( LDAP *ld, - char *buf, char **vals, char *label, int labelwidth, - unsigned long syntaxid, ldap_writeptype writeproc, void *writeparm, - char *eol, int rdncount )); - -LDAP_F( int ) -ldap_entry2text_search LDAP_P(( LDAP *ld, - char *dn, char *base, LDAPMessage *entry, - struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, - ldap_writeptype writeproc, void *writeparm, char *eol, int rdncount, - unsigned long opts )); - -LDAP_F( int ) -ldap_entry2html LDAP_P(( LDAP *ld, - char *buf, LDAPMessage *entry, - struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, - ldap_writeptype writeproc, void *writeparm, char *eol, int rdncount, - unsigned long opts, char *urlprefix, char *base )); - -LDAP_F( int ) -ldap_vals2html LDAP_P(( LDAP *ld, - char *buf, char **vals, char *label, int labelwidth, - unsigned long syntaxid, ldap_writeptype writeproc, void *writeparm, - char *eol, int rdncount, char *urlprefix )); - -LDAP_F( int ) -ldap_entry2html_search LDAP_P(( LDAP - *ld, char *dn, char *base, LDAPMessage *entry, - struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, - ldap_writeptype writeproc, void *writeparm, char *eol, int rdncount, - unsigned long opts, char *urlprefix )); - -LDAP_END_DECL -#endif /* _DISPTMPL_H */ diff --git a/include/srchpref.h b/include/srchpref.h deleted file mode 100644 index f711bb4dc3..0000000000 --- a/include/srchpref.h +++ /dev/null @@ -1,105 +0,0 @@ -/* $OpenLDAP$ */ -/* - * Copyright 1998-2001 The OpenLDAP Foundation, Redwood City, California, USA - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted only as authorized by the OpenLDAP - * Public License. A copy of this license is available at - * http://www.OpenLDAP.org/license.html or in file LICENSE in the - * top-level directory of the distribution. - */ -/* Portions - * Copyright (c) 1993, 1994 Regents of the University of Michigan. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that this notice is preserved and that due credit is given - * to the University of Michigan at Ann Arbor. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific prior written permission. This software - * is provided ``as is'' without express or implied warranty. - * - * searchpref.h: display template library defines - * 16 May 1994 by Gordon Good - */ - -/* DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED */ - -#ifndef _SRCHPREF_H -#define _SRCHPREF_H - -#include - -LDAP_BEGIN_DECL - -struct ldap_searchattr { - char *sa_attrlabel; - char *sa_attr; - /* max 32 matchtypes for now */ - unsigned long sa_matchtypebitmap; - char *sa_selectattr; - char *sa_selecttext; - struct ldap_searchattr *sa_next; -}; - -struct ldap_searchmatch { - char *sm_matchprompt; - char *sm_filter; - struct ldap_searchmatch *sm_next; -}; - -struct ldap_searchobj { - char *so_objtypeprompt; - unsigned long so_options; - char *so_prompt; - short so_defaultscope; - char *so_filterprefix; - char *so_filtertag; - char *so_defaultselectattr; - char *so_defaultselecttext; - struct ldap_searchattr *so_salist; - struct ldap_searchmatch *so_smlist; - struct ldap_searchobj *so_next; -}; - -/* - * global search object options - */ -#define LDAP_SEARCHOBJ_OPT_INTERNAL 0x00000001 - -#define LDAP_IS_SEARCHOBJ_OPTION_SET( so, option ) \ - (((so)->so_options & (option) ) != 0 ) - -#define LDAP_SEARCHPREF_VERSION_ZERO 0 -#define LDAP_SEARCHPREF_VERSION 1 - -#define LDAP_SEARCHPREF_ERR_VERSION 1 -#define LDAP_SEARCHPREF_ERR_MEM 2 -#define LDAP_SEARCHPREF_ERR_SYNTAX 3 -#define LDAP_SEARCHPREF_ERR_FILE 4 - - -LDAP_F( int ) -ldap_init_searchprefs LDAP_P(( char *file, - struct ldap_searchobj **solistp )); - -LDAP_F( int ) -ldap_init_searchprefs_buf LDAP_P(( char *buf, - ber_len_t buflen, - struct ldap_searchobj **solistp )); - -LDAP_F( void ) -ldap_free_searchprefs LDAP_P(( struct ldap_searchobj *solist )); - -LDAP_F( struct ldap_searchobj * ) -ldap_first_searchobj LDAP_P(( struct ldap_searchobj *solist )); - -LDAP_F( struct ldap_searchobj * ) -ldap_next_searchobj LDAP_P(( struct ldap_searchobj *sollist, - struct ldap_searchobj *so )); - - -LDAP_END_DECL - -#endif /* _SRCHPREF_H */ diff --git a/libraries/liblber/lber-int.h b/libraries/liblber/lber-int.h index 37bd015c67..e0004ba755 100644 --- a/libraries/liblber/lber-int.h +++ b/libraries/liblber/lber-int.h @@ -25,7 +25,7 @@ LDAP_BEGIN_DECL typedef void (*BER_LOG_FN)(FILE *file, - const char *subsys, int level, const char *fmt, va_list vl ); + const char *subsys, int level, const char *fmt, ... ); LBER_V (BER_ERRNO_FN) ber_int_errno_fn; diff --git a/libraries/libldap/Makefile.in b/libraries/libldap/Makefile.in index 484b8f6591..051b1ceb3a 100644 --- a/libraries/libldap/Makefile.in +++ b/libraries/libldap/Makefile.in @@ -13,7 +13,7 @@ SRCS = bind.c open.c result.c error.c compare.c search.c \ controls.c messages.c references.c extended.c cyrus.c \ modify.c add.c modrdn.c delete.c abandon.c cache.c \ getfilter.c sasl.c sbind.c kbind.c unbind.c \ - free.c disptmpl.c srchpref.c dsparse.c tmplout.c sort.c \ + free.c tmplout.c sort.c \ getdn.c getentry.c getattr.c getvalues.c addentry.c \ request.c os-ip.c url.c sortctrl.c vlvctrl.c \ init.c options.c print.c string.c util-int.c schema.c \ @@ -23,7 +23,7 @@ OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \ controls.lo messages.lo references.lo extended.lo cyrus.lo \ modify.lo add.lo modrdn.lo delete.lo abandon.lo cache.lo \ getfilter.lo sasl.lo sbind.lo kbind.lo unbind.lo \ - free.lo disptmpl.lo srchpref.lo dsparse.lo tmplout.lo sort.lo \ + free.lo tmplout.lo sort.lo \ getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \ request.lo os-ip.lo url.lo sortctrl.lo vlvctrl.lo \ init.lo options.lo print.lo string.lo util-int.lo schema.lo \ @@ -43,12 +43,10 @@ apitest: $(LIBRARY) apitest.o $(LDAP_LIBLBER_DEPEND) $(LTLINK) -o $@ apitest.o $(LIBS) ltest: $(LIBRARY) test.o $(LDAP_LIBLBER_DEPEND) $(LTLINK) -o $@ test.o $(LIBS) -ttest: $(LIBRARY) tmpltest.o $(LDAP_LIBLBER_DEPEND) - $(LTLINK) -o $@ tmpltest.o $(LIBS) dntest: $(LIBRARY) dntest.o $(LDAP_LIBLBER_DEPEND) $(LTLINK) -o $@ dntest.o $(LIBS) -CFFILES=ldap.conf ldapfilter.conf ldaptemplates.conf ldapsearchprefs.conf +CFFILES=ldap.conf ldapfilter.conf install-local: $(CFFILES) FORCE -$(MKDIR) $(DESTDIR)$(libdir) diff --git a/libraries/libldap/disptmpl.c b/libraries/libldap/disptmpl.c deleted file mode 100644 index f1cf4117ce..0000000000 --- a/libraries/libldap/disptmpl.c +++ /dev/null @@ -1,715 +0,0 @@ -/* $OpenLDAP$ */ -/* - * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file - */ -/* Portions - * Copyright (c) 1993, 1994 Regents of the University of Michigan. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that this notice is preserved and that due credit is given - * to the University of Michigan at Ann Arbor. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific prior written permission. This software - * is provided ``as is'' without express or implied warranty. - * - * disptmpl.c: display template library routines for LDAP clients - * 7 March 1994 by Mark C Smith - */ - -#include "portable.h" - -#include - -#include - -#include -#include -#include - -#ifdef HAVE_SYS_FILE_H -#include -#endif - -#include "ldap-int.h" -#include "disptmpl.h" - -static void free_disptmpl LDAP_P(( struct ldap_disptmpl *tmpl )); -static int read_next_tmpl LDAP_P(( char **bufp, ber_len_t *blenp, - struct ldap_disptmpl **tmplp, int dtversion )); - -static const char *const tmploptions[] = { - "addable", "modrdn", - "altview", - NULL -}; - - -static const unsigned long tmploptvals[] = { - LDAP_DTMPL_OPT_ADDABLE, LDAP_DTMPL_OPT_ALLOWMODRDN, - LDAP_DTMPL_OPT_ALTVIEW, -}; - - -static const char *const itemtypes[] = { - "cis", "mls", "dn", - "bool", "jpeg", "jpegbtn", - "fax", "faxbtn", "audiobtn", - "time", "date", "url", - "searchact", "linkact", "adddnact", - "addact", "verifyact", "mail", - NULL -}; - -static const unsigned long itemsynids[] = { - LDAP_SYN_CASEIGNORESTR, LDAP_SYN_MULTILINESTR, LDAP_SYN_DN, - LDAP_SYN_BOOLEAN, LDAP_SYN_JPEGIMAGE, LDAP_SYN_JPEGBUTTON, - LDAP_SYN_FAXIMAGE, LDAP_SYN_FAXBUTTON, LDAP_SYN_AUDIOBUTTON, - LDAP_SYN_TIME, LDAP_SYN_DATE, LDAP_SYN_LABELEDURL, - LDAP_SYN_SEARCHACTION, LDAP_SYN_LINKACTION, LDAP_SYN_ADDDNACTION, - LDAP_SYN_ADDDNACTION, LDAP_SYN_VERIFYDNACTION,LDAP_SYN_RFC822ADDR, -}; - - -static const char *const itemoptions[] = { - "ro", "sort", - "1val", "hide", - "required", "hideiffalse", - NULL -}; - - -static const unsigned long itemoptvals[] = { - LDAP_DITEM_OPT_READONLY, LDAP_DITEM_OPT_SORTVALUES, - LDAP_DITEM_OPT_SINGLEVALUED, LDAP_DITEM_OPT_HIDEIFEMPTY, - LDAP_DITEM_OPT_VALUEREQUIRED, LDAP_DITEM_OPT_HIDEIFFALSE, -}; - - -#define ADDEF_CONSTANT "constant" -#define ADDEF_ADDERSDN "addersdn" - - -int -ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp ) -{ - FILE *fp; - char *buf; - long rlen, len; - int rc, eof; - - *tmpllistp = NULL; - - if (( fp = fopen( file, "r" )) == NULL ) { - return( LDAP_TMPL_ERR_FILE ); - } - - if ( fseek( fp, 0L, SEEK_END ) != 0 ) { /* move to end to get len */ - fclose( fp ); - return( LDAP_TMPL_ERR_FILE ); - } - - len = ftell( fp ); - - if ( fseek( fp, 0L, SEEK_SET ) != 0 ) { /* back to start of file */ - fclose( fp ); - return( LDAP_TMPL_ERR_FILE ); - } - - if (( buf = LDAP_MALLOC( (size_t)len )) == NULL ) { - fclose( fp ); - return( LDAP_TMPL_ERR_MEM ); - } - - rlen = fread( buf, 1, (size_t)len, fp ); - eof = feof( fp ); - fclose( fp ); - - if ( rlen != len && !eof ) { /* error: didn't get the whole file */ - LDAP_FREE( buf ); - return( LDAP_TMPL_ERR_FILE ); - } - - rc = ldap_init_templates_buf( buf, rlen, tmpllistp ); - LDAP_FREE( buf ); - - return( rc ); -} - - -int -ldap_init_templates_buf( char *buf, ber_len_t buflen, - struct ldap_disptmpl **tmpllistp ) -{ - int rc=-1, version; - char **toks; - struct ldap_disptmpl *prevtmpl, *tmpl; - - *tmpllistp = prevtmpl = NULL; - - if ( ldap_int_next_line_tokens( &buf, &buflen, &toks ) != 2 || - strcasecmp( toks[ 0 ], "version" ) != 0 ) { - LDAP_VFREE( toks ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - version = atoi( toks[ 1 ] ); - LDAP_VFREE( toks ); - if ( version != LDAP_TEMPLATE_VERSION ) { - return( LDAP_TMPL_ERR_VERSION ); - } - - while ( buflen > 0 && ( rc = read_next_tmpl( &buf, &buflen, &tmpl, - version )) == 0 && tmpl != NULL ) { - if ( prevtmpl == NULL ) { - *tmpllistp = tmpl; - } else { - prevtmpl->dt_next = tmpl; - } - prevtmpl = tmpl; - } - - if ( rc != 0 ) { - ldap_free_templates( *tmpllistp ); - } - - return( rc ); -} - - - -void -ldap_free_templates( struct ldap_disptmpl *tmpllist ) -{ - struct ldap_disptmpl *tp, *nexttp; - - if ( tmpllist != NULL ) { - for ( tp = tmpllist; tp != NULL; tp = nexttp ) { - nexttp = tp->dt_next; - free_disptmpl( tp ); - } - } -} - - -static void -free_disptmpl( struct ldap_disptmpl *tmpl ) -{ - if ( tmpl != NULL ) { - if ( tmpl->dt_name != NULL ) { - LDAP_FREE( tmpl->dt_name ); - } - - if ( tmpl->dt_pluralname != NULL ) { - LDAP_FREE( tmpl->dt_pluralname ); - } - - if ( tmpl->dt_iconname != NULL ) { - LDAP_FREE( tmpl->dt_iconname ); - } - - if ( tmpl->dt_authattrname != NULL ) { - LDAP_FREE( tmpl->dt_authattrname ); - } - - if ( tmpl->dt_defrdnattrname != NULL ) { - LDAP_FREE( tmpl->dt_defrdnattrname ); - } - - if ( tmpl->dt_defaddlocation != NULL ) { - LDAP_FREE( tmpl->dt_defaddlocation ); - } - - if ( tmpl->dt_oclist != NULL ) { - struct ldap_oclist *ocp, *nextocp; - - for ( ocp = tmpl->dt_oclist; ocp != NULL; ocp = nextocp ) { - nextocp = ocp->oc_next; - LDAP_VFREE( ocp->oc_objclasses ); - LDAP_FREE( ocp ); - } - } - - if ( tmpl->dt_adddeflist != NULL ) { - struct ldap_adddeflist *adp, *nextadp; - - for ( adp = tmpl->dt_adddeflist; adp != NULL; adp = nextadp ) { - nextadp = adp->ad_next; - if( adp->ad_attrname != NULL ) { - LDAP_FREE( adp->ad_attrname ); - } - if( adp->ad_value != NULL ) { - LDAP_FREE( adp->ad_value ); - } - LDAP_FREE( adp ); - } - } - - if ( tmpl->dt_items != NULL ) { - struct ldap_tmplitem *rowp, *nextrowp, *colp, *nextcolp; - - for ( rowp = tmpl->dt_items; rowp != NULL; rowp = nextrowp ) { - nextrowp = rowp->ti_next_in_col; - for ( colp = rowp; colp != NULL; colp = nextcolp ) { - nextcolp = colp->ti_next_in_row; - if ( colp->ti_attrname != NULL ) { - LDAP_FREE( colp->ti_attrname ); - } - if ( colp->ti_label != NULL ) { - LDAP_FREE( colp->ti_label ); - } - if ( colp->ti_args != NULL ) { - LDAP_VFREE( colp->ti_args ); - } - LDAP_FREE( colp ); - } - } - } - - LDAP_FREE( tmpl ); - } -} - - -struct ldap_disptmpl * -ldap_first_disptmpl( struct ldap_disptmpl *tmpllist ) -{ - return( tmpllist ); -} - - -struct ldap_disptmpl * -ldap_next_disptmpl( struct ldap_disptmpl *tmpllist, - struct ldap_disptmpl *tmpl ) -{ - return( tmpl == NULL ? tmpl : tmpl->dt_next ); -} - - -struct ldap_disptmpl * -ldap_name2template( char *name, struct ldap_disptmpl *tmpllist ) -{ - struct ldap_disptmpl *dtp; - - for ( dtp = ldap_first_disptmpl( tmpllist ); dtp != NULL; - dtp = ldap_next_disptmpl( tmpllist, dtp )) { - if ( strcasecmp( name, dtp->dt_name ) == 0 ) { - return( dtp ); - } - } - - return( NULL ); -} - - -struct ldap_disptmpl * -ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist ) -{ - struct ldap_disptmpl *dtp; - struct ldap_oclist *oclp; - int i, j, needcnt, matchcnt; - - if ( tmpllist == NULL || oclist == NULL || oclist[ 0 ] == NULL ) { - return( NULL ); - } - - for ( dtp = ldap_first_disptmpl( tmpllist ); dtp != NULL; - dtp = ldap_next_disptmpl( tmpllist, dtp )) { - for ( oclp = dtp->dt_oclist; oclp != NULL; - oclp = oclp->oc_next ) { - needcnt = matchcnt = 0; - for ( i = 0; oclp->oc_objclasses[ i ] != NULL; ++i ) { - for ( j = 0; oclist[ j ] != NULL; ++j ) { - if ( strcasecmp( oclist[ j ], oclp->oc_objclasses[ i ] ) - == 0 ) { - ++matchcnt; - } - } - ++needcnt; - } - - if ( matchcnt == needcnt ) { - return( dtp ); - } - } - } - - return( NULL ); -} - - -struct ldap_tmplitem * -ldap_first_tmplrow( struct ldap_disptmpl *tmpl ) -{ - return( tmpl->dt_items ); -} - - -struct ldap_tmplitem * -ldap_next_tmplrow( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row ) -{ - return( row == NULL ? row : row->ti_next_in_col ); -} - - -struct ldap_tmplitem * -ldap_first_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row ) -{ - return( row ); -} - - -struct ldap_tmplitem * -ldap_next_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row, - struct ldap_tmplitem *col ) -{ - return( col == NULL ? col : col->ti_next_in_row ); -} - - -char ** -ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, - int exclude, unsigned long syntaxmask ) -{ -/* - * this routine should filter out duplicate attributes... - */ - struct ldap_tmplitem *tirowp, *ticolp; - int i, attrcnt, memerr; - char **attrs; - - attrcnt = 0; - memerr = 0; - - if (( attrs = (char **)LDAP_MALLOC( sizeof( char * ))) == NULL ) { - return( NULL ); - } - - if ( includeattrs != NULL ) { - for ( i = 0; !memerr && includeattrs[ i ] != NULL; ++i ) { - if (( attrs = (char **)LDAP_REALLOC( attrs, ( attrcnt + 2 ) * - sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] = - LDAP_STRDUP( includeattrs[ i ] )) == NULL ) { - memerr = 1; - } else { - attrs[ attrcnt ] = NULL; - } - } - } - - for ( tirowp = ldap_first_tmplrow( tmpl ); - !memerr && tirowp != NULL; - tirowp = ldap_next_tmplrow( tmpl, tirowp )) { - for ( ticolp = ldap_first_tmplcol( tmpl, tirowp ); - ticolp != NULL; - ticolp = ldap_next_tmplcol( tmpl, tirowp, ticolp )) { - - if ( syntaxmask != 0 ) { - if (( exclude && - ( syntaxmask & ticolp->ti_syntaxid ) != 0 ) || - ( !exclude && - ( syntaxmask & ticolp->ti_syntaxid ) == 0 )) { - continue; - } - } - - if ( ticolp->ti_attrname != NULL ) { - if (( attrs = (char **)LDAP_REALLOC( attrs, ( attrcnt + 2 ) * - sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] = - LDAP_STRDUP( ticolp->ti_attrname )) == NULL ) { - memerr = 1; - } else { - attrs[ attrcnt ] = NULL; - } - } - } - } - - if ( memerr || attrcnt == 0 ) { - for ( i = 0; i < attrcnt; ++i ) { - if ( attrs[ i ] != NULL ) { - LDAP_FREE( attrs[ i ] ); - } - } - - LDAP_FREE( (char *)attrs ); - return( NULL ); - } - - return( attrs ); -} - - -static int -read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp, - int dtversion ) -{ - int i, j, tokcnt, samerow, adsource; - char **toks, *itemopts; - struct ldap_disptmpl *tmpl; - struct ldap_oclist *ocp, *prevocp = NULL; - struct ldap_adddeflist *adp, *prevadp = NULL; - struct ldap_tmplitem *rowp = NULL, *ip, *previp = NULL; - - *tmplp = NULL; - - /* - * template name comes first - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { - LDAP_VFREE( toks ); - return( tokcnt == 0 ? 0 : LDAP_TMPL_ERR_SYNTAX ); - } - - if (( tmpl = (struct ldap_disptmpl *)LDAP_CALLOC( 1, - sizeof( struct ldap_disptmpl ))) == NULL ) { - LDAP_VFREE( toks ); - return( LDAP_TMPL_ERR_MEM ); - } - tmpl->dt_name = toks[ 0 ]; - LDAP_FREE( (char *)toks ); - - /* - * template plural name comes next - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - tmpl->dt_pluralname = toks[ 0 ]; - LDAP_FREE( (char *)toks ); - - /* - * template icon name is next - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - tmpl->dt_iconname = toks[ 0 ]; - LDAP_FREE( (char *)toks ); - - /* - * template options come next - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) < 1 ) { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - for ( i = 0; toks[ i ] != NULL; ++i ) { - for ( j = 0; tmploptions[ j ] != NULL; ++j ) { - if ( strcasecmp( toks[ i ], tmploptions[ j ] ) == 0 ) { - tmpl->dt_options |= tmploptvals[ j ]; - } - } - } - LDAP_VFREE( toks ); - - /* - * object class list is next - */ - while (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) > 0 ) { - if (( ocp = (struct ldap_oclist *)LDAP_CALLOC( 1, - sizeof( struct ldap_oclist ))) == NULL ) { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_MEM ); - } - ocp->oc_objclasses = toks; - if ( tmpl->dt_oclist == NULL ) { - tmpl->dt_oclist = ocp; - } else { - prevocp->oc_next = ocp; - } - prevocp = ocp; - } - if ( tokcnt < 0 ) { - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - - /* - * read name of attribute to authenticate as - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - if ( toks[ 0 ][ 0 ] != '\0' ) { - tmpl->dt_authattrname = toks[ 0 ]; - } else { - LDAP_FREE( toks[ 0 ] ); - } - LDAP_FREE( (char *)toks ); - - /* - * read default attribute to use for RDN - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - tmpl->dt_defrdnattrname = toks[ 0 ]; - LDAP_FREE( (char *)toks ); - - /* - * read default location for new entries - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - if ( toks[ 0 ][ 0 ] != '\0' ) { - tmpl->dt_defaddlocation = toks[ 0 ]; - } else { - LDAP_FREE( toks[ 0 ] ); - } - LDAP_FREE( (char *)toks ); - - /* - * read list of rules used to define default values for new entries - */ - while (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) > 0 ) { - if ( strcasecmp( ADDEF_CONSTANT, toks[ 0 ] ) == 0 ) { - adsource = LDAP_ADSRC_CONSTANTVALUE; - } else if ( strcasecmp( ADDEF_ADDERSDN, toks[ 0 ] ) == 0 ) { - adsource = LDAP_ADSRC_ADDERSDN; - } else { - adsource = 0; - } - if ( adsource == 0 || tokcnt < 2 || - ( adsource == LDAP_ADSRC_CONSTANTVALUE && tokcnt != 3 ) || - ( adsource == LDAP_ADSRC_ADDERSDN && tokcnt != 2 )) { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - - if (( adp = (struct ldap_adddeflist *)LDAP_CALLOC( 1, - sizeof( struct ldap_adddeflist ))) == NULL ) { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_MEM ); - } - adp->ad_source = adsource; - adp->ad_attrname = toks[ 1 ]; - if ( adsource == LDAP_ADSRC_CONSTANTVALUE ) { - adp->ad_value = toks[ 2 ]; - } - LDAP_FREE( toks[ 0 ] ); - LDAP_FREE( (char *)toks ); - - if ( tmpl->dt_adddeflist == NULL ) { - tmpl->dt_adddeflist = adp; - } else { - prevadp->ad_next = adp; - } - prevadp = adp; - } - - /* - * item list is next - */ - samerow = 0; - while (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) > 0 ) { - if ( strcasecmp( toks[ 0 ], "item" ) == 0 ) { - if ( tokcnt < 4 ) { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - - if (( ip = (struct ldap_tmplitem *)LDAP_CALLOC( 1, - sizeof( struct ldap_tmplitem ))) == NULL ) { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_MEM ); - } - - /* - * find syntaxid from config file string - */ - while (( itemopts = strrchr( toks[ 1 ], ',' )) != NULL ) { - *itemopts++ = '\0'; - for ( i = 0; itemoptions[ i ] != NULL; ++i ) { - if ( strcasecmp( itemopts, itemoptions[ i ] ) == 0 ) { - break; - } - } - if ( itemoptions[ i ] == NULL ) { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - ip->ti_options |= itemoptvals[ i ]; - } - - for ( i = 0; itemtypes[ i ] != NULL; ++i ) { - if ( strcasecmp( toks[ 1 ], itemtypes[ i ] ) == 0 ) { - break; - } - } - if ( itemtypes[ i ] == NULL ) { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - - LDAP_FREE( toks[ 0 ] ); - LDAP_FREE( toks[ 1 ] ); - ip->ti_syntaxid = itemsynids[ i ]; - ip->ti_label = toks[ 2 ]; - if ( toks[ 3 ][ 0 ] == '\0' ) { - ip->ti_attrname = NULL; - LDAP_FREE( toks[ 3 ] ); - } else { - ip->ti_attrname = toks[ 3 ]; - } - if ( toks[ 4 ] != NULL ) { /* extra args. */ - for ( i = 0; toks[ i + 4 ] != NULL; ++i ) { - ; - } - if (( ip->ti_args = (char **) LDAP_CALLOC( i + 1, sizeof( char * ))) - == NULL ) { - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_MEM ); - } - for ( i = 0; toks[ i + 4 ] != NULL; ++i ) { - ip->ti_args[ i ] = toks[ i + 4 ]; - } - } - LDAP_FREE( (char *)toks ); - - if ( tmpl->dt_items == NULL ) { - tmpl->dt_items = rowp = ip; - } else if ( samerow ) { - previp->ti_next_in_row = ip; - } else { - rowp->ti_next_in_col = ip; - rowp = ip; - } - previp = ip; - samerow = 0; - } else if ( strcasecmp( toks[ 0 ], "samerow" ) == 0 ) { - LDAP_VFREE( toks ); - samerow = 1; - } else { - LDAP_VFREE( toks ); - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - } - if ( tokcnt < 0 ) { - free_disptmpl( tmpl ); - return( LDAP_TMPL_ERR_SYNTAX ); - } - - *tmplp = tmpl; - return( 0 ); -} diff --git a/libraries/libldap/dsparse.c b/libraries/libldap/dsparse.c deleted file mode 100644 index 2b7771c5bd..0000000000 --- a/libraries/libldap/dsparse.c +++ /dev/null @@ -1,195 +0,0 @@ -/* $OpenLDAP$ */ -/* - * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file - */ -/* Portions - * Copyright (c) 1993, 1994 Regents of the University of Michigan. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that this notice is preserved and that due credit is given - * to the University of Michigan at Ann Arbor. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific prior written permission. This software - * is provided ``as is'' without express or implied warranty. - * - * dsparse.c: parsing routines used by display template and search - * preference file library routines for LDAP clients. - * - * 7 March 1994 by Mark C Smith - */ - -#include "portable.h" - -#include -#include - -#include -#include - -#ifdef HAVE_SYS_FILE_H -#include -#endif - -#include "ldap-int.h" - -static int next_line LDAP_P(( char **bufp, ber_len_t *blenp, char **linep )); -static char *next_token LDAP_P(( char ** sp )); - - -int -ldap_int_next_line_tokens( char **bufp, ber_len_t *blenp, char ***toksp ) -{ - char *p, *line, *token, **toks; - int rc, tokcnt; - - *toksp = NULL; - - if (( rc = next_line( bufp, blenp, &line )) <= 0 ) { - return( rc ); - } - - if (( toks = (char **)LDAP_CALLOC( 1, sizeof( char * ))) == NULL ) { - LBER_FREE( line ); - return( -1 ); - } - tokcnt = 0; - - p = line; - while (( token = next_token( &p )) != NULL ) { - if (( toks = (char **)LDAP_REALLOC( toks, ( tokcnt + 2 ) * - sizeof( char * ))) == NULL ) { - LBER_FREE( (char *)toks ); - LBER_FREE( line ); - return( -1 ); - } - toks[ tokcnt ] = token; - toks[ ++tokcnt ] = NULL; - } - - if ( tokcnt == 1 && strcasecmp( toks[ 0 ], "END" ) == 0 ) { - tokcnt = 0; - LDAP_VFREE( toks ); - toks = NULL; - } - - LBER_FREE( line ); - - if ( tokcnt == 0 ) { - if ( toks != NULL ) { - LBER_FREE( (char *)toks ); - } - } else { - *toksp = toks; - } - - return( tokcnt ); -} - - -static int -next_line( char **bufp, ber_len_t *blenp, char **linep ) -{ - char *linestart, *line, *p; - ber_slen_t plen; - - linestart = *bufp; - p = *bufp; - plen = *blenp; - - do { - for ( linestart = p; plen > 0; ++p, --plen ) { - if ( *p == '\r' ) { - if ( plen > 1 && *(p+1) == '\n' ) { - ++p; - --plen; - } - break; - } - - if ( *p == '\n' ) { - if ( plen > 1 && *(p+1) == '\r' ) { - ++p; - --plen; - } - break; - } - } - ++p; - --plen; - } while ( plen > 0 && ( *linestart == '#' || linestart + 1 == p )); - - - *bufp = p; - *blenp = plen; - - - if ( plen <= 0 ) { - *linep = NULL; - return( 0 ); /* end of file */ - } - - if (( line = LDAP_MALLOC( p - linestart )) == NULL ) { - *linep = NULL; - return( -1 ); /* fatal error */ - } - - AC_MEMCPY( line, linestart, p - linestart ); - line[ p - linestart - 1 ] = '\0'; - *linep = line; - return( strlen( line )); -} - - -static char * -next_token( char **sp ) -{ - int in_quote = 0; - char *p, *tokstart, *t; - - if ( **sp == '\0' ) { - return( NULL ); - } - - p = *sp; - - while ( LDAP_SPACE( (unsigned char) *p )) { /* skip leading white space */ - ++p; - } - - if ( *p == '\0' ) { - return( NULL ); - } - - if ( *p == '\"' ) { - in_quote = 1; - ++p; - } - t = tokstart = p; - - for ( ;; ) { - if ( *p == '\0' || ( LDAP_SPACE( (unsigned char) *p ) && !in_quote )) { - if ( *p != '\0' ) { - ++p; - } - *t++ = '\0'; /* end of token */ - break; - } - - if ( *p == '\"' ) { - in_quote = !in_quote; - ++p; - } else { - *t++ = *p++; - } - } - - *sp = p; - - if ( t == tokstart ) { - return( NULL ); - } - - return( LDAP_STRDUP( tokstart )); -} diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index e4b4983177..f682cc8736 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -396,21 +396,15 @@ LDAP_F (int) ldap_int_client_controls LDAP_P(( LDAP *ld, LDAPControl **ctrlp )); -/* - * in dsparse.c - */ -LDAP_F (int) ldap_int_next_line_tokens LDAP_P(( char **bufp, ber_len_t *blenp, char ***toksp )); - -#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND /* * in kerberos.c */ +#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND LDAP_F (char *) ldap_get_kerberosv4_credentials LDAP_P(( LDAP *ld, LDAP_CONST char *who, LDAP_CONST char *service, ber_len_t *len )); - #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */ diff --git a/libraries/libldap/ldapsearchprefs.conf b/libraries/libldap/ldapsearchprefs.conf deleted file mode 100644 index 4dfb7a8b45..0000000000 --- a/libraries/libldap/ldapsearchprefs.conf +++ /dev/null @@ -1,154 +0,0 @@ -# $OpenLDAP$ -# Version should be 1 now -Version 1 -# -# -# Name for this search object -People -# options (the only one supported right now is "internal" which means that -# this search object should not be presented directly to the user) -# use "" for none -"" -# Label to place before text box user types in -"Search For:" -# Filter prefix to append to all "More Choices" searches -"(&(objectClass=person)" -# Tag to use for "Fewer Choices" searches - from ldapfilter.conf file -"xax500" -# If a search results in > 1 match, retrieve this attribute to help -# user disambiguate the entries... -title -# ...and label it with this string: -"Title" -# Search scope to use when searching -subtree -# Follows a list of "More Choices" search options. Format is: -# Label, attribute, select-bitmap, extra attr display name, extra attr ldap name -# If last two are null, "Fewer Choices" name/attributes used -"Common Name" cn 11111 "" "" -"Surname" sn 11111 "" "" -"Business Phone" "telephoneNumber" 11101 "" "" -"E-Mail Address" "mail" 11111 "" "" -"Uniqname" "uid" 11111 "" "" -"Title" title 11111 "" "" -END -# Match types -"exactly matches" "(%a=%v))" -"approximately matches" "(%a~=%v))" -"starts with" "(%a=%v*))" -"ends with" "(%a=*%v))" -"contains" "(%a=*%v*))" -END -# -# -# -Groups -"" -"Search For:" -"(&(objectClass=rfc822MailGroup)" -"xax500" -multilineDescription -"Description" -subtree -"Common Name" cn 11111 "" "" -"Description" multilineDescription 11101 "" "" -"Owner" "owner" 00001 "owner" "Owner" -"X.500 Member" "member" 00001 "" "" -"E-Mail Member" "mail" 00101 "" "" -END -"exactly matches" "(%a=%v))" -"approximately matches" "(%a~=%v))" -"starts with" "(%a=%v*))" -"ends with" "(%a=*%v))" -"contains" "(%a=*%v*))" -END -# -# -# -"Joinable Groups" -"" -"Search For:" -"(&(&(objectClass=rfc822MailGroup)(joinable=TRUE))" -"xax500" -multilineDescription -"Description" -subtree -"Common Name" cn 11111 "" "" -"Description" multilineDescription 11101 "" "" -"Owner" "owner" 00001 "owner" "Owner" -"X.500 Member" "member" 00001 "" "" -"E-Mail Member" "mail" 00101 "" "" -END -"exactly matches" "(%a=%v))" -"approximately matches" "(%a~=%v))" -"starts with" "(%a=%v*))" -"ends with" "(%a=*%v))" -"contains" "(%a=*%v*))" -END -# -# -# -Services -"" -"Search For:" -"(&(objectClass=service)" -"xax500" -multilineDescription -"Description" -subtree -"Common Name" cn 11111 "" "" -"Description" multilineDescription 11101 "" "" -"Owner" "owner" 00001 "owner" "Owner" -"Keywords" "keywords" 11111 "" "" -"Hours" "hoursOfOperation" 11111 "" "" -END -"exactly matches" "(%a=%v))" -"approximately matches" "(%a~=%v))" -"starts with" "(%a=%v*))" -"ends with" "(%a=*%v))" -"contains" "(%a=*%v*))" -END -# -# -# -Organizations -"" -"Search For:" -"(&(objectClass=organization)" -"xax500" -multilineDescription -"Description" -subtree -"Name" organizationName 01111 "" "" -"Location" localityName 11111 "" "" -"Phone Number" "telephoneNumber" 10111 "" "" -"Description" description 10111 "" "" -END -"exactly matches" "(%a=%v))" -"approximately matches" "(%a~=%v))" -"starts with" "(%a=%v*))" -"ends with" "(%a=*%v))" -"contains" "(%a=*%v*))" -END -# -# -# -Documents -"" -"Search For:" -"(&(objectClass=document)" -"xax500" -multilineDescription -"Description" -subtree -"Document Title" cn 11111 "" "" -"Keyword" "keywords" 11111 "" "" -"Category" "category" 11111 "" "" -"Document Number" "documentIdentifier" 11111 "" "" -END -"exactly matches" "(%a=%v))" -"approximately matches" "(%a~=%v))" -"starts with" "(%a=%v*))" -"ends with" "(%a=*%v))" -"contains" "(%a=*%v*))" -END diff --git a/libraries/libldap/ldaptemplates.conf b/libraries/libldap/ldaptemplates.conf deleted file mode 100644 index 40c1d8bbae..0000000000 --- a/libraries/libldap/ldaptemplates.conf +++ /dev/null @@ -1,678 +0,0 @@ -# $OpenLDAP$ -########################################################################## -# LDAP display templates -########################################################################## - -# -# Version must be 1 -# -Version 1 - -########################################################################## -# U-M Person template -########################################################################## -# -# template name and plural name come first -"U-M Person" -"U-M People" - -# name of the icon that is associated with this template -"person icon" - -# blank-separated list of template options ("" for none) -# addable - end-user should be allowed to add these types of entries -# modrdn - end-user can change the name of these entries -# altview - this template is referred to in another template's -# "linkact" item -"addable" - -# -# objectclass list -umichPerson person -END - -# -# name of attribute to authenticate as ("" means auth as this entry) -"" - -# -# default attribute name to use when forming RDN of a new entry -# -cn - -# -# default location when adding new entries (DN; "" means no default) -"o=University of Michigan, c=US" - -# -# rules used to define default values for new entries -END - -# -# -# list of items for display -# each line is either: -# item (type) (attribute) (attr name) (extra args...) -# to define an item or -# samerow -# to keep the next item on the same row as the previous -# -# valid types are: -# cis - case ignore string -# mls - multiline string -# dn - -# mail - case ignore string that contains an RFC822 mail address -# bool - boolean value -# jpeg - inlined JPEG image -# jpegbtn - JPEG image button -# fax - inlined Fax image -# faxbtn - Fax image button -# audiobtn - audio button -# time - time value -# date - time value displayed as a date only -# url - labeled URL for links to items in WWW -# searchact - search action -# linkact - link to another template -# -# valid options (comma separated list appended to the type) are: -# ro - attribute is read only; don't let user edit it -# sort - order the values of this attribute -# 1val - disallow entry of multiple values -# required - this attribute should have at least one value -# hide - don't show this item if attribute has no values -# hideiffalse - hide item if value is FALSE (for type 'bool' only) -# -item jpegbtn "View Photo" jpegPhoto "Next Photo" -item audiobtn "Play Sound" audio -item cis,ro,sort "Also Known As" cn -item mail "E-Mail Address" mail -item cis "Work Phone" telephoneNumber -item cis "Fax Number" facsimileTelephoneNumber -item cis "Pager Number" pager -item mls "Work Address" postalAddress -item cis,sort "Title" title -item cis,ro "Uniqname" uid -item mls "Description" multiLineDescription -item cis "Home Phone" homePhone -item mls "Home Address" homePostalAddress -item url "More Info (URL)" labeledURL -item dn,sort "See Also" seeAlso -item cis "Favorite Beverage" drink -item cis "Notice" notice -item bool,hideiffalse "On Vacation" onVacation -item mls,1val "Vacation Message" vacationMessage -item bool,hideiffalse "Do Not Allow Updates" noBatchUpdates -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -item searchact "Find Groups Added To" "" "-dnt" "(&(objectclass=rfc822mailgroup)(member=%v))" "multiLineDescription" "Description" "" -item searchact "List Owned Groups" "" "-dnt" "(&(objectclass=rfc822mailgroup)(owner=%v))" "title" "Title" "" -item linkact "Other Addresses" "" "other addresses" -END - - -########################################################################## -# Person template -########################################################################## -"Person" -"People" -"person icon" - -# template options -addable -# -# objectclass list -person -END -# name of attribute to authenticate as -"" - -# default attribute name to use when forming RDN of a new entry -# -cn - -# default location when adding new entries -"" - -# -# rules used to define default values for new entries -END - -# -# list of items for display -item jpegbtn "View Photo" jpegPhoto "Next Photo" -item audiobtn "Play Sound" audio -item cis,sort "Also Known As" cn -item cis,sort "Title" title -item mls "Work Address" postalAddress -item cis "Work Phone" telephoneNumber -item cis "Fax Number" facsimileTelephoneNumber -item cis "Pager Number" pager -item mls "Home Address" homePostalAddress -item cis "Home Phone" homePhone -item cis "User ID" uid -item mail "E-Mail Address" mail -item cis "Description" description -item cis "Favorite Beverage" drink -item dn,sort "See Also" seeAlso -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -END - - -########################################################################## -# Group template -########################################################################## -"Group" -"Groups" -"group icon" - -# template options -addable modrdn - -# objectclass list -rfc822MailGroup -END - -# name of attribute to authenticate as -"owner" - -# default attribute name to use when forming RDN of a new entry -# -cn - -# default location when adding new entries -"ou=User Groups, ou=Groups, o=University of Michigan, c=US" - -# -# rules used to define default values for new entries -constant "associatedDomain" "umich.edu" -constant "joinable" "FALSE" -addersdn "owner" -addersdn "member" -addersdn "errorsTo" -addersdn "requestsTo" -END - -# -# -# list of items for display -# each line is either: -# item (type) (attribute) (attr name) (extra args...) -# to define an item or -# samerow -# -# list of items for display -item cis,sort "Also Known As" cn -item mls "Description" multiLineDescription -item cis "Phone Number" telephoneNumber -item cis "Fax Number" facsimileTelephoneNumber -item mls "Address" postalAddress -item dn,required,sort "Owner" owner -item url "More Info (URL)" labeledURL -item dn,sort "See Also" seeAlso -item dn,sort "Errors To" errorsTo -item dn,sort "Requests To" requestsTo -item cis "Associated Domain" associatedDomain -item cis "Moderator" moderator -item bool "Suppress 'No E-Mail Address' Errors" suppressNoEmailError -item bool "Others May Join" joinable -item dn,sort "X.500 Members" member -item mail,sort "E-Mail Errors To" rfc822ErrorsTo -item mail,sort "E-Mail Requests To" rfc822RequestsTo -item mail,sort "E-Mail Members" mail -item cis "Notice" notice -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -item searchact "Subscribers" "" "-dnt" "memberOfGroup=%v" "title" "Title" "joinable" -item verifyact "Verify Members" "member" "mail" "E-Mail Address" -END - -########################################################################## -# Organization template -########################################################################## -"Organization" -"Organizations" -"organization icon" - -# template options -"" - -# objectclass list -organization -END - -# name of attribute to authenticate as -"" - -# default attribute name to use when forming RDN of a new entry -o - -# default location when adding new entries -"" - -# rules used to define default values for new entries -constant "o" "foo" -END - -# -# -# list of items for display -# each line is either: -# item (type) (attribute) (attr name) (extra args...) -# to define an item or -# samerow -# -# list of items for display -item cis,sort "Name" o -item cis "Location" l -item mls "Address" postalAddress -item cis "Phone Number" telephoneNumber -item cis "Fax Number" facsimileTelephoneNumber -item cis "Description" description -item dn,sort "See Also" seeAlso -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -END - - -########################################################################## -# Service template -########################################################################## -"Service" -"Services" -"service icon" - -# template options -"addable" - -# objectclass list -service -END - -# name of attribute to authenticate as -"owner" - -# default attribute name to use when forming RDN of a new entry -cn - -# default location when adding new entries -"ou=Services, o=University of Michigan, c=US" - -# rules used to define default values for new entries -addersdn "owner" -END - -# -# -# list of items for display -# each line is either: -# item (type) (attribute) (attr name) (extra args...) -# to define an item or -# samerow -# -# list of items for display -item jpegbtn "View Photo" jpegPhoto -item cis,sort "Name" cn -item mls "Description" multilineDescription -item cis "Provider" provider -item cis,sort "Service Area" serviceArea -item mail "E-mail Address" mail -item cis "Phone" telephoneNumber -item cis "Fax Number" facsimileTelephoneNumber -item mls "Postal Address" postalAddress -item cis "Hours" hoursOfOperation -item url "More Info (URL)" labeledURL -item dn,sort "Depends On" dependentUpon -item dn,sort "See Also" seeAlso -item cis,sort "Platform" platform -item cis,sort "Product" product -item cis,sort "Keywords" keywords -item cis "FCE Rating" serviceRating -item date "Date Rated" ratingTime -item mls "Rating Description" ratingDescription -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -item dn,required,sort "Owner" owner -END - - -########################################################################## -# Organizational Role template -########################################################################## -"Organizational Role" -"Organizational Roles" -"person icon" - -# template options -"" - -# objectclass list -organizationalRole -END - -# name of attribute to authenticate as -"" - -# default attribute name to use when forming RDN of a new entry -cn - -# default location when adding new entries -"" - -# rules used to define default values for new entries -END - -# -# -# list of items for display -# each line is either: -# item (type) (attribute) (attr name) (extra args...) -# to define an item or -# samerow -# -# list of items for display -item cis,sort "Name" cn -item cis "Description" description -item dn "Role Occupant" roleOccupant -item dn,sort "See Also" seeAlso -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -END - - -########################################################################## -# Organizational Unit template -########################################################################## -"Organizational Unit" -"Organizational Units" -"organization icon" - -# template options -"" - -# objectclass list -organizationalUnit -END - -# name of attribute to authenticate as -"" - -# default attribute name to use when forming RDN of a new entry -cn - -# default location when adding new entries -"" - -# rules used to define default values for new entries -END - -# Item list -item cis "Organization Unit Name" ou -item cis "Title" title -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -END - - - -########################################################################## -# Application Entity template -########################################################################## -"Application Entity" -"Application Entities" -"application icon" - -# template options -"" - -# objectclass list -applicationEntity -END - -# name of attribute to authenticate as -"" - -# default attribute name to use when forming RDN of a new entry -cn - -# default location when adding new entries -"" - -# rules used to define default values for new entries -END - -# Item list -item cis,sort "Name" cn -item cis "Location" l -item cis "Description" description -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -END - -########################################################################## -# Document template -########################################################################## -"Document" -"Documents" -"document icon" - -# template options -"" - -# objectclass list -document -umichDocument -END - -# name of attribute to authenticate as -"" - -# default attribute name to use when forming RDN of a new entry -cn - -# default location when adding new entries -"" - -# rules used to define default values for new entries -END - -# -# Item list -item cis "Document ID" documentIdentifier -item cis "Title" documentTitle -item cis "Series Title" documentSeriesTitle -item cis "Version" documentVersion -item cis,sort "Service Area" serviceArea -item mls "Abstract" multiLineAbstract -item url "More Info (URL)" labeledURL -item dn,sort "Availability" documentAvailable -item dn,sort "See Also" seeAlso -item cis,sort "Platform" platform -item cis,sort "Product" product -item cis,sort "Keyword" keywords -item dn,sort "Author" documentAuthor -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -item dn,required "Owner" owner -END - -########################################################################## -# Document description template -########################################################################## -"DocumentDescription" -"DocumentDescriptions" -"document description icon" - -# template options -"" - -# objectclass list -documentDescription -END - -# name of attribute to authenticate as -"" - -# default attribute name to use when forming RDN of a new entry -cn - -# default location when adding new entries -"" - -# rules used to define default values for new entries -END - -# -# Item list -item mls "Description" multilineDescription -item url "More Info (URL)" labeledURL -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -item dn,required "Owner" owner -END - -########################################################################## -# Image template -########################################################################## -"Image" -"Images" -"image icon" - -# template options -"" - -# objectclass list -image -END - -# name of attribute to authenticate as -"" - -# default attribute name to use when forming RDN of a new entry -cn - -# default location when adding new entries -"" - -# rules used to define default values for new entries -END - -# -# Item list -item cis "Name" cn -item mls "Description" multilineDescription -item jpegbtn "View Photo(s)" jpegPhoto -item cis "Citation" citation -item cis "Copyright" copyright -item cis "Keywords" keywords -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -item dn,required "Owner" owner -END - - - -########################################################################## -# Country template -########################################################################## -"Country" -"Countries" -"country icon" - -# template options -"" - -# objectclass list -friendlyCountry -END - -# name of attribute to authenticate as -"" - -# default attribute name to use when forming RDN of a new entry -c - -# default location when adding new entries -"" - -# rules used to define default values for new entries -END - -# Item list -item cis "Country Name" co -item cis "Country Code" c -item cis "Description" description -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -END - -########################################################################## -# Locality template -########################################################################## -"Locality" -"Localities" -"locality icon" - -# template options -"" - -# objectclass list -locality -END - -# name of attribute to authenticate as -"" - -# default attribute name to use when forming RDN of a new entry -l - -# default location when adding new entries -"" - -# rules used to define default values for new entries -END - -# -# Item list -item cis "Name" l -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -END - - -########################################################################## -# "Other Addresses" template -########################################################################## -"Others Addresses" -"Other Addresses" -"other addr icon" - -# template options -"altview" - -# objectclass list -END - -# name of attribute to authenticate as -"" - -# default attribute name to use when forming RDN of a new entry -"" - -# default location when adding new entries -"" - -# rules used to define default values for new entries -END - -# Item list -item cis "Street Address" streetAddress -item cis "Locality" l -item cis "State or Province" st -item cis "Postal Code" postalCode -item cis,hide "X.400 Address" mhsORAddresses -item cis,hide "X.400 Address" textEncodedORAddress -Item cis "Other Mailbox" otherMailbox -item time,ro "Last Modified" lastModifiedTime -item dn,ro "Modified By" lastModifiedBy -END diff --git a/libraries/libldap/srchpref.c b/libraries/libldap/srchpref.c deleted file mode 100644 index 8f34f509f2..0000000000 --- a/libraries/libldap/srchpref.c +++ /dev/null @@ -1,419 +0,0 @@ -/* $OpenLDAP$ */ -/* - * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file - */ -/* Portions - * Copyright (c) 1993, 1994 Regents of the University of Michigan. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that this notice is preserved and that due credit is given - * to the University of Michigan at Ann Arbor. The name of the University - * may not be used to endorse or promote products derived from this - * software without specific prior written permission. This software - * is provided ``as is'' without express or implied warranty. - * - * searchpref.c: search preferences library routines for LDAP clients - * 17 May 1994 by Gordon Good - */ - -#include "portable.h" - -#include - -#include - -#include -#include -#include -#include - -#ifdef HAVE_SYS_FILE_H -#include -#endif - -#include "ldap-int.h" -#include "srchpref.h" - -#include "ldap-int.h" - -static void free_searchobj LDAP_P(( struct ldap_searchobj *so )); -static int read_next_searchobj LDAP_P(( char **bufp, ber_len_t *blenp, - struct ldap_searchobj **sop, int soversion )); - - -static const char *const sobjoptions[] = { - "internal", - NULL -}; - - -static const unsigned long sobjoptvals[] = { - LDAP_SEARCHOBJ_OPT_INTERNAL, -}; - - -int -ldap_init_searchprefs( char *file, struct ldap_searchobj **solistp ) -{ - FILE *fp; - char *buf; - long rlen, len; - int rc, eof; - - if (( fp = fopen( file, "r" )) == NULL ) { - return( LDAP_SEARCHPREF_ERR_FILE ); - } - - if ( fseek( fp, 0L, SEEK_END ) != 0 ) { /* move to end to get len */ - fclose( fp ); - return( LDAP_SEARCHPREF_ERR_FILE ); - } - - len = ftell( fp ); - - if ( fseek( fp, 0L, SEEK_SET ) != 0 ) { /* back to start of file */ - fclose( fp ); - return( LDAP_SEARCHPREF_ERR_FILE ); - } - - if (( buf = LDAP_MALLOC( (size_t)len )) == NULL ) { - fclose( fp ); - return( LDAP_SEARCHPREF_ERR_MEM ); - } - - rlen = fread( buf, 1, (size_t)len, fp ); - eof = feof( fp ); - fclose( fp ); - - if ( rlen != len && !eof ) { /* error: didn't get the whole file */ - LDAP_FREE( buf ); - return( LDAP_SEARCHPREF_ERR_FILE ); - } - - rc = ldap_init_searchprefs_buf( buf, rlen, solistp ); - LDAP_FREE( buf ); - - return( rc ); -} - - -int -ldap_init_searchprefs_buf( - char *buf, - ber_len_t buflen, - struct ldap_searchobj **solistp ) -{ - int rc = -1, version; - char **toks; - struct ldap_searchobj *prevso, *so; - - *solistp = prevso = NULL; - - if ( ldap_int_next_line_tokens( &buf, &buflen, &toks ) != 2 || - strcasecmp( toks[ 0 ], "version" ) != 0 ) { - LDAP_VFREE( toks ); - return( LDAP_SEARCHPREF_ERR_SYNTAX ); - } - version = atoi( toks[ 1 ] ); - LDAP_VFREE( toks ); - if ( version != LDAP_SEARCHPREF_VERSION && - version != LDAP_SEARCHPREF_VERSION_ZERO ) { - return( LDAP_SEARCHPREF_ERR_VERSION ); - } - - while ( buflen > 0 && ( rc = read_next_searchobj( &buf, &buflen, &so, - version )) == 0 && so != NULL ) { - if ( prevso == NULL ) { - *solistp = so; - } else { - prevso->so_next = so; - } - prevso = so; - } - - if ( rc != 0 ) { - ldap_free_searchprefs( *solistp ); - } - - return( rc ); -} - - - -void -ldap_free_searchprefs( struct ldap_searchobj *solist ) -{ - struct ldap_searchobj *so, *nextso; - - if ( solist != NULL ) { - for ( so = solist; so != NULL; so = nextso ) { - nextso = so->so_next; - free_searchobj( so ); - } - } - /* XXX XXX need to do some work here */ -} - - -static void -free_searchobj( struct ldap_searchobj *so ) -{ - if ( so != NULL ) { - if ( so->so_objtypeprompt != NULL ) { - LDAP_FREE( so->so_objtypeprompt ); - } - if ( so->so_prompt != NULL ) { - LDAP_FREE( so->so_prompt ); - } - if ( so->so_filterprefix != NULL ) { - LDAP_FREE( so->so_filterprefix ); - } - if ( so->so_filtertag != NULL ) { - LDAP_FREE( so->so_filtertag ); - } - if ( so->so_defaultselectattr != NULL ) { - LDAP_FREE( so->so_defaultselectattr ); - } - if ( so->so_defaultselecttext != NULL ) { - LDAP_FREE( so->so_defaultselecttext ); - } - if ( so->so_salist != NULL ) { - struct ldap_searchattr *sa, *nextsa; - for ( sa = so->so_salist; sa != NULL; sa = nextsa ) { - nextsa = sa->sa_next; - if ( sa->sa_attrlabel != NULL ) { - LDAP_FREE( sa->sa_attrlabel ); - } - if ( sa->sa_attr != NULL ) { - LDAP_FREE( sa->sa_attr ); - } - if ( sa->sa_selectattr != NULL ) { - LDAP_FREE( sa->sa_selectattr ); - } - if ( sa->sa_selecttext != NULL ) { - LDAP_FREE( sa->sa_selecttext ); - } - LDAP_FREE( sa ); - } - } - if ( so->so_smlist != NULL ) { - struct ldap_searchmatch *sm, *nextsm; - for ( sm = so->so_smlist; sm != NULL; sm = nextsm ) { - nextsm = sm->sm_next; - if ( sm->sm_matchprompt != NULL ) { - LDAP_FREE( sm->sm_matchprompt ); - } - if ( sm->sm_filter != NULL ) { - LDAP_FREE( sm->sm_filter ); - } - LDAP_FREE( sm ); - } - } - LDAP_FREE( so ); - } -} - - - -struct ldap_searchobj * -ldap_first_searchobj( struct ldap_searchobj *solist ) -{ - return( solist ); -} - - -struct ldap_searchobj * -ldap_next_searchobj( struct ldap_searchobj *solist, struct ldap_searchobj *so ) -{ - return( so == NULL ? so : so->so_next ); -} - - - -static int -read_next_searchobj( - char **bufp, - ber_len_t *blenp, - struct ldap_searchobj **sop, - int soversion ) -{ - int i, j, tokcnt; - char **toks; - struct ldap_searchobj *so; - struct ldap_searchattr **sa; - struct ldap_searchmatch **sm; - - *sop = NULL; - - /* - * Object type prompt comes first - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { - LDAP_VFREE( toks ); - return( tokcnt == 0 ? 0 : LDAP_SEARCHPREF_ERR_SYNTAX ); - } - - if (( so = (struct ldap_searchobj *)LDAP_CALLOC( 1, - sizeof( struct ldap_searchobj ))) == NULL ) { - LDAP_VFREE( toks ); - return( LDAP_SEARCHPREF_ERR_MEM ); - } - so->so_objtypeprompt = toks[ 0 ]; - LDAP_FREE( (char *)toks ); - - /* - * if this is post-version zero, options come next - */ - if ( soversion > LDAP_SEARCHPREF_VERSION_ZERO ) { - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) < 1 ) { - LDAP_VFREE( toks ); - ldap_free_searchprefs( so ); - return( LDAP_SEARCHPREF_ERR_SYNTAX ); - } - for ( i = 0; toks[ i ] != NULL; ++i ) { - for ( j = 0; sobjoptions[ j ] != NULL; ++j ) { - if ( strcasecmp( toks[ i ], sobjoptions[ j ] ) == 0 ) { - so->so_options |= sobjoptvals[ j ]; - } - } - } - LDAP_VFREE( toks ); - } - - /* - * "Fewer choices" prompt is next - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { - LDAP_VFREE( toks ); - ldap_free_searchprefs( so ); - return( LDAP_SEARCHPREF_ERR_SYNTAX ); - } - so->so_prompt = toks[ 0 ]; - LDAP_FREE( (char *)toks ); - - /* - * Filter prefix for "More Choices" searching is next - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { - LDAP_VFREE( toks ); - ldap_free_searchprefs( so ); - return( LDAP_SEARCHPREF_ERR_SYNTAX ); - } - so->so_filterprefix = toks[ 0 ]; - LDAP_FREE( (char *)toks ); - - /* - * "Fewer Choices" filter tag comes next - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { - LDAP_VFREE( toks ); - ldap_free_searchprefs( so ); - return( LDAP_SEARCHPREF_ERR_SYNTAX ); - } - so->so_filtertag = toks[ 0 ]; - LDAP_FREE( (char *)toks ); - - /* - * Selection (disambiguation) attribute comes next - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { - LDAP_VFREE( toks ); - ldap_free_searchprefs( so ); - return( LDAP_SEARCHPREF_ERR_SYNTAX ); - } - so->so_defaultselectattr = toks[ 0 ]; - LDAP_FREE( (char *)toks ); - - /* - * Label for selection (disambiguation) attribute - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { - LDAP_VFREE( toks ); - ldap_free_searchprefs( so ); - return( LDAP_SEARCHPREF_ERR_SYNTAX ); - } - so->so_defaultselecttext = toks[ 0 ]; - LDAP_FREE( (char *)toks ); - - /* - * Search scope is next - */ - if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) { - LDAP_VFREE( toks ); - ldap_free_searchprefs( so ); - return( LDAP_SEARCHPREF_ERR_SYNTAX ); - } - if ( !strcasecmp(toks[ 0 ], "subtree" )) { - so->so_defaultscope = LDAP_SCOPE_SUBTREE; - } else if ( !strcasecmp(toks[ 0 ], "onelevel" )) { - so->so_defaultscope = LDAP_SCOPE_ONELEVEL; - } else if ( !strcasecmp(toks[ 0 ], "base" )) { - so->so_defaultscope = LDAP_SCOPE_BASE; - } else { - ldap_free_searchprefs( so ); - return( LDAP_SEARCHPREF_ERR_SYNTAX ); - } - LDAP_VFREE( toks ); - - - /* - * "More Choices" search option list comes next - */ - sa = &( so->so_salist ); - while (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) > 0 ) { - if ( tokcnt < 5 ) { - LDAP_VFREE( toks ); - ldap_free_searchprefs( so ); - return( LDAP_SEARCHPREF_ERR_SYNTAX ); - } - if (( *sa = ( struct ldap_searchattr * ) LDAP_CALLOC( 1, - sizeof( struct ldap_searchattr ))) == NULL ) { - LDAP_VFREE( toks ); - ldap_free_searchprefs( so ); - return( LDAP_SEARCHPREF_ERR_MEM ); - } - ( *sa )->sa_attrlabel = toks[ 0 ]; - ( *sa )->sa_attr = toks[ 1 ]; - ( *sa )->sa_selectattr = toks[ 3 ]; - ( *sa )->sa_selecttext = toks[ 4 ]; - /* Deal with bitmap */ - ( *sa )->sa_matchtypebitmap = 0; - for ( i = strlen( toks[ 2 ] ) - 1, j = 0; i >= 0; i--, j++ ) { - if ( toks[ 2 ][ i ] == '1' ) { - ( *sa )->sa_matchtypebitmap |= (1 << j); - } - } - LDAP_FREE( toks[ 2 ] ); - LDAP_FREE( ( char * ) toks ); - sa = &(( *sa )->sa_next); - } - *sa = NULL; - - /* - * Match types are last - */ - sm = &( so->so_smlist ); - while (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) > 0 ) { - if ( tokcnt < 2 ) { - LDAP_VFREE( toks ); - ldap_free_searchprefs( so ); - return( LDAP_SEARCHPREF_ERR_SYNTAX ); - } - if (( *sm = ( struct ldap_searchmatch * ) LDAP_CALLOC( 1, - sizeof( struct ldap_searchmatch ))) == NULL ) { - LDAP_VFREE( toks ); - ldap_free_searchprefs( so ); - return( LDAP_SEARCHPREF_ERR_MEM ); - } - ( *sm )->sm_matchprompt = toks[ 0 ]; - ( *sm )->sm_filter = toks[ 1 ]; - LDAP_FREE( ( char * ) toks ); - sm = &(( *sm )->sm_next ); - } - *sm = NULL; - - *sop = so; - return( 0 ); -} diff --git a/libraries/libldap/tmpltest.c b/libraries/libldap/tmpltest.c deleted file mode 100644 index 711884d9ac..0000000000 --- a/libraries/libldap/tmpltest.c +++ /dev/null @@ -1,280 +0,0 @@ -/* $OpenLDAP$ */ -/* - * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file - */ -#include "portable.h" - -#include - -#include - -#include -#include - -#ifdef HAVE_CONSOLE_H -#include -#endif /* HAVE_CONSOLE_H */ - -#include -#include -#include - -static void dump_tmpl ( struct ldap_disptmpl *tmpl ); -static void dump_srchpref( struct ldap_searchobj *sp ); - -#define NULLSTRINGIFNULL( s ) ( (s) == NULL ? "(null)" : (s) ) - -int -main( int argc, char **argv ) -{ - struct ldap_disptmpl *templates, *dtp; - struct ldap_searchobj *so, *sop; - int err; - -#ifdef HAVE_CONSOLE_H - ccommand( &argv ); - for ( argc = 0; argv[ argc ] != NULL; ++argc ) { - ; - } - cshow( stdout ); -#endif /* MACOS */ - - if (( err = ldap_init_templates( "ldaptemplates.conf", &templates )) - != 0 ) { - fprintf( stderr, "ldap_init_templates failed (%d)\n", err ); - exit( EXIT_FAILURE ); - } - - if (( err = ldap_init_searchprefs( "ldapsearchprefs.conf", &so )) - != 0 ) { - fprintf( stderr, "ldap_init_searchprefs failed (%d)\n", err ); - exit( EXIT_FAILURE ); - } - - if ( argc == 1 ) { - printf( "*** Display Templates:\n" ); - for ( dtp = ldap_first_disptmpl( templates ); dtp != NULL; - dtp = ldap_next_disptmpl( templates, dtp )) { - dump_tmpl( dtp ); - printf( "\n\n" ); - } - - printf( "\n\n*** Search Objects:\n" ); - for ( sop = ldap_first_searchobj( so ); sop != NULL; - sop = ldap_next_searchobj( so, sop )) { - dump_srchpref( sop ); - printf( "\n\n" ); - } - - } else { - if (( dtp = ldap_oc2template( ++argv, templates )) == NULL ) { - fprintf( stderr, "no matching template found\n" ); - } else { - dump_tmpl( dtp ); - } - } - - - ldap_free_templates( templates ); - ldap_free_searchprefs( so ); - - exit( EXIT_SUCCESS ); -} - - -static const char *const syn_name[] = { - "?", "CIS", "MLS", "DN", "BOOL", "JPEG", "JPEGBTN", "FAX", "FAXBTN", - "AUDIOBTN", "TIME", "DATE", "URL", "SEARCHACT", "LINKACT", "ADDDNACT", - "VERIFYACT", -}; - -static const char *const syn_type[] = { - "?", "txt", "img", "?", "bool", "?", "?", "?", "btn", - "?", "?", "?", "?", "?", "?", "?", - "action", "?" -}; - -static char *includeattrs[] = { "objectClass", "sn", NULL }; - -static const char *const item_opts[] = { - "ro", "sort", "1val", "hide", "required", "hideiffalse", NULL -}; - -static const unsigned long item_opt_vals[] = { - LDAP_DITEM_OPT_READONLY, LDAP_DITEM_OPT_SORTVALUES, - LDAP_DITEM_OPT_SINGLEVALUED, LDAP_DITEM_OPT_HIDEIFEMPTY, - LDAP_DITEM_OPT_VALUEREQUIRED, LDAP_DITEM_OPT_HIDEIFFALSE, -}; - - -static void -dump_tmpl( struct ldap_disptmpl *tmpl ) -{ - struct ldap_tmplitem *rowp, *colp; - int i, rowcnt, colcnt; - char **fetchattrs; - struct ldap_oclist *ocp; - struct ldap_adddeflist *adp; - - printf( "** Template \"%s\" (plural \"%s\", icon \"%s\")\n", - NULLSTRINGIFNULL( tmpl->dt_name ), - NULLSTRINGIFNULL( tmpl->dt_pluralname ), - NULLSTRINGIFNULL( tmpl->dt_iconname )); - - printf( "object class list:\n" ); - for ( ocp = tmpl->dt_oclist; ocp != NULL; ocp = ocp->oc_next ) { - for ( i = 0; ocp->oc_objclasses[ i ] != NULL; ++i ) { - printf( "%s%s", i == 0 ? " " : " & ", - NULLSTRINGIFNULL( ocp->oc_objclasses[ i ] )); - } - putchar( '\n' ); - } - putchar( '\n' ); - - printf( "template options: " ); - if ( tmpl->dt_options == 0L ) { - printf( "NONE\n" ); - } else { - printf( "%s %s %s\n", LDAP_IS_DISPTMPL_OPTION_SET( tmpl, - LDAP_DTMPL_OPT_ADDABLE ) ? "addable" : "", - LDAP_IS_DISPTMPL_OPTION_SET( tmpl, LDAP_DTMPL_OPT_ALLOWMODRDN ) - ? "modrdn" : "", - LDAP_IS_DISPTMPL_OPTION_SET( tmpl, LDAP_DTMPL_OPT_ALTVIEW ) - ? "altview" : "" ); - } - - printf( "authenticate as attribute: %s\n", tmpl->dt_authattrname != NULL ? - tmpl->dt_authattrname : "" ); - - printf( "default RDN attribute: %s\n", tmpl->dt_defrdnattrname != NULL ? - tmpl->dt_defrdnattrname : "NONE" ); - - printf( "default add location: %s\n", tmpl->dt_defaddlocation != NULL ? - tmpl->dt_defaddlocation : "NONE" ); - - printf( "\nnew entry value default rules:\n" ); - for ( adp = tmpl->dt_adddeflist; adp != NULL; adp = adp->ad_next ) { - if ( adp->ad_source == LDAP_ADSRC_CONSTANTVALUE ) { - printf( " attribute %s <-- constant value \"%s\"\n", - NULLSTRINGIFNULL( adp->ad_attrname), - NULLSTRINGIFNULL( adp->ad_value )); - } else { - printf( " attribute %s <-- adder's DN\n", - NULLSTRINGIFNULL( adp->ad_attrname )); - } - } - putchar( '\n' ); - - printf( "\nfetch attributes & values:\n" ); - if (( fetchattrs = ldap_tmplattrs( tmpl, includeattrs, 1, - LDAP_SYN_OPT_DEFER )) == NULL ) { - printf( " \n" ); - } else { - for ( i = 0; fetchattrs[ i ] != NULL; ++i ) { - printf( " %s\n", fetchattrs[ i ] ); - free( fetchattrs[ i ] ); - } - free( (char *)fetchattrs ); - } - - printf( "\nfetch attributes only:\n" ); - if (( fetchattrs = ldap_tmplattrs( tmpl, NULL, 0, - LDAP_SYN_OPT_DEFER )) == NULL ) { - printf( " \n" ); - } else { - for ( i = 0; fetchattrs[ i ] != NULL; ++i ) { - printf( " %s\n", fetchattrs[ i ] ); - free( fetchattrs[ i ] ); - } - free( (char *)fetchattrs ); - } - - printf( "\ntemplate items:\n" ); - rowcnt = 0; - for ( rowp = ldap_first_tmplrow( tmpl ); rowp != NULL; - rowp = ldap_next_tmplrow( tmpl, rowp )) { - ++rowcnt; - colcnt = 0; - for ( colp = ldap_first_tmplcol( tmpl, rowp ); colp != NULL; - colp = ldap_next_tmplcol( tmpl, rowp, colp )) { - ++colcnt; - printf( " %2d-%d: %s (%s%s", rowcnt, colcnt, - syn_name[ colp->ti_syntaxid & 0x0000FFFF ], - syn_type[ LDAP_GET_SYN_TYPE( colp->ti_syntaxid ) >> 24 ], - (( LDAP_GET_SYN_OPTIONS( colp->ti_syntaxid ) & - LDAP_SYN_OPT_DEFER ) != 0 ) ? ",defer" : "" ); - - for ( i = 0; item_opts[ i ] != NULL; ++i ) { - if ( LDAP_IS_TMPLITEM_OPTION_SET( colp, item_opt_vals[ i ] )) { - printf( ",%s", NULLSTRINGIFNULL( item_opts[ i ] )); - } - } - - printf( "), %s, %s", NULLSTRINGIFNULL( colp->ti_attrname ), - NULLSTRINGIFNULL( colp->ti_label )); - if ( colp->ti_args != NULL ) { - printf( ",args=" ); - for ( i = 0; colp->ti_args[ i ] != NULL; ++i ) { - printf( "<%s>", NULLSTRINGIFNULL( colp->ti_args[ i ] )); - } - } - - putchar( '\n' ); - } - } -} - - -static void -dump_srchpref( struct ldap_searchobj *so ) -{ - int i; - struct ldap_searchattr *sa; - struct ldap_searchmatch *sm; - - printf( "Object type prompt: %s\n", - NULLSTRINGIFNULL( so->so_objtypeprompt )); - printf( "Options: %s\n", - LDAP_IS_SEARCHOBJ_OPTION_SET( so, LDAP_SEARCHOBJ_OPT_INTERNAL ) ? - "internal" : "NONE" ); - printf( "Prompt: %s\n", NULLSTRINGIFNULL( so->so_prompt )); - printf( "Scope: " ); - switch ( so->so_defaultscope ) { - case LDAP_SCOPE_BASE: - printf( "LDAP_SCOPE_BASE" ); - break; - case LDAP_SCOPE_ONELEVEL: - printf( "LDAP_SCOPE_ONELEVEL" ); - break; - case LDAP_SCOPE_SUBTREE: - printf( "LDAP_SCOPE_SUBTREE" ); - break; - default: - printf("*** unknown!" ); - } - puts( "\n" ); - printf( "Filter prefix: %s\n", - NULLSTRINGIFNULL( so->so_filterprefix )); - printf( "Filter tag: %s\n", - NULLSTRINGIFNULL( so->so_filtertag )); - printf( "Default select attr: %s\n", - NULLSTRINGIFNULL( so->so_defaultselectattr )); - printf( "Default select text: %s\n", - NULLSTRINGIFNULL( so->so_defaultselecttext )); - printf( "Searchable attributes ---- \n" ); - for ( sa = so->so_salist; sa != NULL; sa = sa->sa_next ) { - printf( " Label: %s\n", NULLSTRINGIFNULL( sa->sa_attrlabel )); - printf( " Attribute: %s\n", NULLSTRINGIFNULL( sa->sa_attr )); - printf( " Select attr: %s\n", NULLSTRINGIFNULL( sa->sa_selectattr )); - printf( " Select text: %s\n", NULLSTRINGIFNULL( sa->sa_selecttext )); - printf( " Match types ---- \n" ); - for ( i = 0, sm = so->so_smlist; sm != NULL; i++, sm = sm->sm_next ) { - if (( sa->sa_matchtypebitmap >> i ) & 1 ) { - printf( " %s (%s)\n", - NULLSTRINGIFNULL( sm->sm_matchprompt ), - NULLSTRINGIFNULL( sm->sm_filter )); - } - } - } -} diff --git a/libraries/libldap_r/Makefile.in b/libraries/libldap_r/Makefile.in index 92f2303ec6..a8a5117d0c 100644 --- a/libraries/libldap_r/Makefile.in +++ b/libraries/libldap_r/Makefile.in @@ -14,7 +14,7 @@ XXSRCS = apitest.c test.c tmpltest.c extended.c \ bind.c controls.c open.c result.c error.c compare.c search.c \ modify.c add.c modrdn.c delete.c abandon.c cache.c cyrus.c \ getfilter.c sasl.c sbind.c kbind.c unbind.c \ - free.c disptmpl.c srchpref.c dsparse.c tmplout.c sort.c \ + free.c tmplout.c sort.c \ getdn.c getentry.c getattr.c getvalues.c addentry.c \ request.c os-ip.c url.c sortctrl.c vlvctrl.c \ init.c options.c print.c string.c util-int.c schema.c \ @@ -30,7 +30,7 @@ OBJS = threads.lo rdwr.lo tpool.lo \ bind.lo controls.lo open.lo result.lo error.lo compare.lo search.lo \ modify.lo add.lo modrdn.lo delete.lo abandon.lo cache.lo cyrus.lo \ getfilter.lo sasl.lo sbind.lo kbind.lo unbind.lo \ - free.lo disptmpl.lo srchpref.lo dsparse.lo tmplout.lo sort.lo \ + free.lo tmplout.lo sort.lo \ getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \ request.lo os-ip.lo url.lo sortctrl.lo vlvctrl.lo \ init.lo options.lo print.lo string.lo util-int.lo schema.lo \ @@ -66,8 +66,6 @@ apitest: $(LIBRARY) apitest.o $(LDAP_LIBLBER_DEPEND) $(LTLINK) -o $@ apitest.o $(LIBS) ltest: $(LIBRARY) test.o $(LDAP_LIBLBER_DEPEND) $(LTLINK) -o $@ test.o $(LIBS) -ttest: $(LIBRARY) tmpltest.o $(LDAP_LIBLBER_DEPEND) - $(LTLINK) -o $@ tmpltest.o $(LIBS) install-local: $(CFFILES) FORCE -$(MKDIR) $(DESTDIR)$(libdir) -- 2.39.5