/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* tmplout.c: display template library output routines for LDAP clients
* 12 April 1994 by Mark C Smith
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <tzfile.h>
#include <stdlib.h>
#ifdef MACOS
#include "macos.h"
#else /* MACOS */
#ifdef DOS
#include <malloc.h>
#include "msdos.h"
#else /* DOS */
#endif /* DOS */
#endif /* MACOS */
#ifdef VMS
#endif /* VMS */
#include "lber.h"
#include "ldap.h"
#include "ldap-private.h"
#include "ldap-int.h"
#ifdef SUN
/*
* to include definition of FILTERFILE and or TEMPLATEFILE
*/
#include "ldapconfig.h"
#endif
#ifdef NEEDPROTOS
#else /* NEEDPROTOS */
static int do_entry2text();
static int do_entry2text_search();
static int do_vals2text();
static int max_label_len();
static int output_label();
static int output_dn();
static void strcat_escaped();
static char *time2text();
static int searchaction();
#endif /* NEEDPROTOS */
int
char *buf, /* NULL for "use internal" */
struct ldap_disptmpl *tmpl,
char **defattrs,
char ***defvals,
void *writeparm,
char *eol,
int rdncount,
unsigned int opts
)
{
#if defined( SUN ) && defined( _REENTRANT )
int rv;
#endif
#if defined( SUN ) && defined( _REENTRANT )
return( rv );
#else
#endif
}
int
char *buf, /* NULL for "use internal" */
struct ldap_disptmpl *tmpl,
char **defattrs,
char ***defvals,
void *writeparm,
char *eol,
int rdncount,
unsigned int opts,
char *base,
char *urlprefix
)
{
#if defined( SUN ) && defined( _REENTRANT )
int rv;
#endif
}
#if defined( SUN ) && defined( _REENTRANT )
return( rv );
#else
#endif
}
static int
char *buf, /* NULL for use-internal */
char *base, /* used for search actions */
struct ldap_disptmpl *tmpl,
char **defattrs,
char ***defvals,
void *writeparm,
char *eol,
int rdncount,
unsigned int opts,
char *urlprefix /* if non-NULL, do HTML */
)
{
}
}
freebuf = 1;
} else {
freebuf = 0;
}
if ( html ) {
/*
* add HTML intro. and title
*/
if (!(( opts & LDAP_DISP_OPT_HTMLBODYONLY ) != 0 )) {
}
if (( opts & LDAP_DISP_OPT_NONLEAF ) != 0 &&
char *untagged;
/*
* add "Move Up" link
*/
if ( i > 1 ) {
}
}
} else {
untagged = "=The World";
}
"%s\">Move Up To <EM>%s</EM></A>%s<BR>",
/*
* add "Browse" link
*/
ldap_value_free( vals );
}
} else {
}
} else {
}
err = LDAP_SUCCESS;
char *attr;
freevals = 0;
break;
}
}
}
}
} else {
freevals = 1;
}
}
if ( freevals ) {
ldap_value_free( vals );
}
}
} else {
freevals = 0;
if ( !LDAP_IS_TMPLITEM_OPTION_SET( colp,
== 0 ) {
break;
}
}
}
}
} else {
freevals = 1;
if ( LDAP_IS_TMPLITEM_OPTION_SET( colp,
}
}
/*
* don't bother even calling do_vals2text() if no values
* or boolean with value false and "hide if false" option set
*/
show = 0;
}
if (( opts & LDAP_DISP_OPT_DOSEARCHACTIONS ) != 0 ) {
}
}
show = 0;
}
if ( show ) {
}
if ( freevals ) {
ldap_value_free( vals );
}
}
}
}
}
if ( freebuf ) {
}
return( err );
}
int
char *dn, /* if NULL, use entry */
char *base, /* if NULL, no search actions */
char **defattrs,
char ***defvals,
void *writeparm,
char *eol,
int rdncount, /* if 0, display full DN */
unsigned int opts
)
{
#if defined( SUN ) && defined( _REENTRANT )
int rv;
#endif
#if defined( SUN ) && defined( _REENTRANT )
return( rv );
#else
#endif
}
int
char *dn, /* if NULL, use entry */
char *base, /* if NULL, no search actions */
char **defattrs,
char ***defvals,
void *writeparm,
char *eol,
int rdncount, /* if 0, display full DN */
unsigned int opts,
char *urlprefix
)
{
#if defined( SUN ) && defined( _REENTRANT )
int rv;
#endif
#if defined( SUN ) && defined( _REENTRANT )
return( rv );
#else
#endif
}
static int
char *dn, /* if NULL, use entry */
char *base, /* if NULL, no search actions */
char **defattrs,
char ***defvals,
void *writeparm,
char *eol,
int rdncount, /* if 0, display full DN */
unsigned int opts,
char *urlprefix
)
{
}
}
}
freetmpls = 1;
}
if ( freetmpls ) {
}
}
freedn = 1;
}
ocattrs[0] = OCATTRNAME;
#ifdef CLDAP
if ( LDAP_IS_CLDAP( ld ))
else
#endif /* CLDAP */
if ( err == LDAP_SUCCESS ) {
}
}
ldap_value_free( vals );
}
}
ldap_msgfree( ldmp );
}
}
fetchattrs = NULL;
} else {
}
#ifdef CLDAP
if ( LDAP_IS_CLDAP( ld ))
else
#endif /* CLDAP */
if ( freedn ) {
}
if ( fetchattrs != NULL ) {
}
if ( err != LDAP_SUCCESS ||
if ( freetmpls ) {
}
}
if ( freetmpls ) {
}
ldap_msgfree( ldmp );
return( err );
}
int
char *buf, /* NULL for "use internal" */
char **vals,
char *label,
int labelwidth, /* 0 means use default */
unsigned int syntaxid,
void *writeparm,
char *eol,
int rdncount
)
{
#if defined( SUN ) && defined( _REENTRANT )
int rv;
#endif
#if defined( SUN ) && defined( _REENTRANT )
return( rv );
#else
#endif
}
int
char *buf, /* NULL for "use internal" */
char **vals,
char *label,
int labelwidth, /* 0 means use default */
unsigned int syntaxid,
void *writeparm,
char *eol,
int rdncount,
char *urlprefix
)
{
#if defined( SUN ) && defined( _REENTRANT )
int rv;
#endif
}
#if defined( SUN ) && defined( _REENTRANT )
return( rv );
#else
#endif
}
static int
char *buf, /* NULL for "use internal" */
char **vals,
char *label,
int labelwidth, /* 0 means use default */
unsigned int syntaxid,
void *writeparm,
char *eol,
int rdncount,
char *urlprefix
)
{
char *p, *s, *outval;
return( LDAP_SUCCESS );
}
switch( LDAP_GET_SYN_TYPE( syntaxid )) {
case LDAP_SYN_TYPE_TEXT:
case LDAP_SYN_TYPE_BOOLEAN:
break; /* we only bother with these two types... */
default:
return( LDAP_SUCCESS );
}
if ( labelwidth == 0 || labelwidth < 0 ) {
}
}
freebuf = 1;
} else {
freebuf = 0;
}
for ( p = vals[ i ]; *p != '\0'; ++p ) {
if ( !isascii( *p )) {
break;
}
}
notascii = ( *p != '\0' );
: vals[ i ];
writeoutval = 0; /* if non-zero, write outval after switch */
switch( syntaxid ) {
case LDAP_SYN_CASEIGNORESTR:
++writeoutval;
break;
case LDAP_SYN_RFC822ADDR:
if ( html ) {
} else {
++writeoutval;
}
break;
case LDAP_SYN_DN: /* for now */
break;
case LDAP_SYN_MULTILINESTR:
if ( i > 0 && !html ) {
}
p = s = outval;
*s++ = '\0';
while ( isspace( *s )) {
++s;
}
if ( html ) {
} else {
}
p = s;
}
outval = p;
++writeoutval;
break;
case LDAP_SYN_BOOLEAN:
++writeoutval;
break;
case LDAP_SYN_TIME:
case LDAP_SYN_DATE:
++writeoutval;
break;
case LDAP_SYN_LABELEDURL:
*p++ = '\0';
while ( isspace( *p )) {
++p;
}
s = outval;
*s++ = '\0';
while ( isspace( *s )) {
++s;
}
p = outval;
} else {
s = "URL";
p = outval;
}
/*
* at this point `s' points to the label & `p' to the URL
*/
if ( html ) {
} else {
}
break;
default:
}
if ( writeoutval ) {
if ( html ) {
} else {
}
}
}
if ( freebuf ) {
}
return( LDAP_SUCCESS );
}
static int
{
maxlen = 0;
}
}
}
return( maxlen );
}
static int
{
char *p;
if ( html ) {
} else {
*p++ = ' ';
}
*p = '\0';
}
}
static int
{
char **dnrdns;
int i;
return( -1 );
}
} else if ( width > 0 ) {
} else {
*buf = '\0';
}
++i ) {
if ( i > 0 ) {
}
}
}
}
( c >= '@' && c <= 'Z' ) || \
( c == '_' ) || \
( c >= 'a' && c <= 'z' ))
static void
{
char *p, *q;
for ( q = s2; *q != '\0'; ++q ) {
if ( HREF_CHAR_ACCEPTABLE( *q )) {
*p++ = *q;
} else {
*p++ = '%';
*p++ = hexdig[ *q >> 4 ];
*p++ = hexdig[ *q & 0x0F ];
}
}
*p = '\0';
}
static char *
{
struct tm t;
int century;
return( fmterr );
}
if ( !isdigit( *p )) {
return( fmterr );
}
}
p = ldtimestr;
/* tm_year is the offset of number of years from TM_YEAR_BASE */
/*strftime will return for e.g. Thu Aug 19 2001 */
return( fmterr );
}
if (dateonly) {
}
return( timestr );
}
/* gtime.c - inverse gmtime */
#endif /* !MACOS */
/* gtime(): the inverse of localtime().
This routine was supplied by Mike Accetta at CMU many years ago.
*/
static int dmsize[] = {
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
#define dysize(y) \
(((y) % 4) ? 365 : (((y) % 100) ? 366 : (((y) % 400) ? 365 : 366)))
/* */
{
register int i,
sec,
mins,
hour,
mday,
mon,
year;
return ((time_t) -1);
if (hour == 24) {
hour = 0;
mday++;
}
result = 0L;
for (i = 1970; i < year; i++)
result++;
while (--mon)
return result;
}
static int
{
;
}
if ( i < 3 ) {
return( LDAP_PARAM_ERROR );
}
return( LDAP_PARAM_ERROR );
} else {
}
if ( html ) {
/*
* if we are generating HTML, we add an HREF link that embodies this
* search action as an LDAP URL, instead of actually doing the search
* now.
*/
}
return( LDAP_LOCAL_ERROR );
}
return( LDAP_SUCCESS );
}
#ifdef CLDAP
if ( LDAP_IS_CLDAP( ld ))
else
#endif /* CLDAP */
== NULL ) {
} else {
}
}
}
ldap_msgfree( ldmp );
}
ldap_value_free( vals );
}
}