]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/tmplout.c
Braced ldap_connect_to_path() in #ifdef LDAP_PF_LOCAL so as to compile
[openldap] / libraries / libldap / tmplout.c
index 7a19d55f02e26ee8b3c9d8920999b245c88b7874..e804fe0be74e32349653fd5b8fd69289caeea443 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -10,7 +11,9 @@
 #include "portable.h"
 
 #include <stdio.h>
-#include <stdlib.h>
+
+#include <ac/socket.h>
+#include <ac/stdlib.h>
 
 #include <ac/ctype.h>
 #include <ac/string.h>
 #include <sys/file.h>
 #endif
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
+#include <disptmpl.h>
 
 #include "ldap_log.h"
-#include "disptmpl.h"
 
 #include "ldap-int.h"
-#include "ldapconfig.h"
+#include "ldap_defaults.h"
+
+#define writeptype ldap_writeptype
 
 /* local functions */
 static int do_entry2text LDAP_P((
@@ -271,9 +275,9 @@ do_entry2text(
        }
     } else {
        for ( rowp = ldap_first_tmplrow( tmpl );
-               NONFATAL_LDAP_ERR( err ) && rowp != NULLTMPLITEM;
+               NONFATAL_LDAP_ERR( err ) && rowp != NULL;
                rowp = ldap_next_tmplrow( tmpl, rowp )) {
-           for ( colp = ldap_first_tmplcol( tmpl, rowp ); colp != NULLTMPLITEM;
+           for ( colp = ldap_first_tmplcol( tmpl, rowp ); colp != NULL;
                    colp = ldap_next_tmplcol( tmpl, rowp, colp )) {
                vals = NULL;
                if ( colp->ti_attrname == NULL || ( vals = ldap_get_values( ld,
@@ -423,7 +427,7 @@ do_entry2text_search(
     struct ldap_disptmpl       *tmpl;
     struct timeval             timeout;
 
-    if ( dn == NULL && entry == NULLMSG ) {
+    if ( dn == NULL && entry == NULL ) {
        ld->ld_errno = LDAP_PARAM_ERROR;
        return( ld->ld_errno );
     }
@@ -464,7 +468,7 @@ do_entry2text_search(
 
 
     if ( tmpllist != NULL ) {
-       ldmp = NULLMSG;
+       ldmp = NULL;
 
        if ( entry == NULL ) {
            char        *ocattrs[2];
@@ -768,9 +772,9 @@ max_label_len( struct ldap_disptmpl *tmpl )
 
     maxlen = 0;
 
-    for ( rowp = ldap_first_tmplrow( tmpl ); rowp != NULLTMPLITEM;
+    for ( rowp = ldap_first_tmplrow( tmpl ); rowp != NULL;
            rowp = ldap_next_tmplrow( tmpl, rowp )) {
-       for ( colp = ldap_first_tmplcol( tmpl, rowp ); colp != NULLTMPLITEM;
+       for ( colp = ldap_first_tmplcol( tmpl, rowp ); colp != NULL;
                colp = ldap_next_tmplcol( tmpl, rowp, colp )) {
            if (( len = strlen( colp->ti_label )) > maxlen ) {
                maxlen = len;
@@ -906,8 +910,17 @@ time2text( char *ldtimestr, int dateonly )
                /* POSIX says tm_year should be year - 1900 */
        t.tm_year = 100 * GET2BYTENUM( p ) - 1900;
                p += 2;
+               t.tm_year += GET2BYTENUM( p ); p += 2;
+
+       } else {
+               /* came without a century */
+               t.tm_year = GET2BYTENUM( p ); p += 2;
+
+               /* Y2K hack - 2 digit years < 70 are 21st century */
+               if( t.tm_year < 70 ) {
+                       t.tm_year += 100;
+               }
        }
-    t.tm_year = GET2BYTENUM( p ); p += 2;
 
     t.tm_mon = GET2BYTENUM( p ) - 1; p += 2;
     t.tm_mday = GET2BYTENUM( p ); p += 2;
@@ -948,7 +961,7 @@ static const int dmsize[] = {
 /*
  * Y2K YEAR
  */
-       /* per POSIX tm_year should be offset by 1900 */
+       /* per STDC & POSIX tm_year should be offset by 1900 */
 #define YEAR_POSIX(y)          ((y) + 1900)
 
        /*
@@ -956,15 +969,6 @@ static const int dmsize[] = {
         */
 #define YEAR_CAREFUL(y)                ((y) < 1900 ? (y) + 1900 : (y))
 
-       /*
-       ** if year is < 1990 and < 70 must be offset by 2000 as Unix epoch
-       ** started in 1970.  if year is < 1990 but >= 70, offset by 1900.
-       ** if year is >= 1900, it must be the real year.
-       */ 
-#define YEAR_PEDANTIC(y)               ((y) < 1900 \
-                                               ? ((y) < 70 ? (y) + 2000 ? (y) + 1900) \
-                                               : (y))
-
 #define YEAR(y) YEAR_CAREFUL(y)
 
 /* \f */
@@ -1040,6 +1044,8 @@ searchaction( LDAP *ld, char *buf, char *base, LDAPMessage *entry, char *dn,
        return( LDAP_PARAM_ERROR );
     } else if ( strcasecmp( attr, "-dnt" ) == 0 ) {
        value = dn;
+    } else if ( strcasecmp( attr, "-dn" ) == 0 ) {
+       value = dn;
     } else if (( vals = ldap_get_values( ld, entry, attr )) != NULL ) {
        value = vals[ 0 ];
     } else {