]> git.sur5r.net Git - openldap/blobdiff - clients/ud/print.c
Don't depend error handling on exact resultCode.
[openldap] / clients / ud / print.c
index de0a946a90803417b39c85dac33f7531e9f949aa..5d4414ee550ca141591cd7a2d6c19a4fb0ce3046 100644 (file)
@@ -1,3 +1,8 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 /*
  * Copyright (c) 1991, 1993 
  * Regents of the University of Michigan.  All rights reserved.
@@ -51,6 +56,8 @@ static char *person_attr_print_order[] = {
        "memberOfGroup",
        "lastModifiedBy",
        "lastModifiedTime",
+       "modifiersname",
+       "modifytimestamp",
        NULL
 };
 
@@ -73,6 +80,10 @@ static char *group_attr_print_order[] = {
        "labeledURL",
        "lastModifiedBy",
        "lastModifiedTime",
+       "modifiersname",
+       "modifytimestamp",
+       "creatorsname",
+       "createtimestamp",
        NULL
 };
 
@@ -194,6 +205,12 @@ print_an_entry( void )
        if (debug & D_TRACE)
                printf("->print_an_entry()\n");
 #endif
+
+       if( Entry.name == NULL ) {
+               printf(" No Entry found.\n");
+               return;
+       }
+
        printf(" \"%s\"\n", Entry.name);
        
        /*
@@ -415,7 +432,7 @@ clear_entry( void )
                printf(" Clearing entry \"%s\"\n", Entry.name);
 #endif
        if (Entry.DN != NULL)
-               Free(Entry.DN);
+               ldap_memfree(Entry.DN);
        if (Entry.name != NULL)
                Free(Entry.name);
        Entry.may_join = FALSE;
@@ -536,7 +553,7 @@ print_one_URL( char *s, int label_lead, char *tag, int url_lead )
 }
 
 
-#define GET2BYTENUM( p )       (( *p - '0' ) * 10 + ( *(p+1) - '0' ))
+#define GET2BYTENUM( p )       (( *(p) - '0' ) * 10 + ( *((p)+1) - '0' ))
 
 static char *
 time2text( char *ldtimestr, int dateonly )
@@ -544,20 +561,34 @@ time2text( char *ldtimestr, int dateonly )
     struct tm          t;
     char               *p, *timestr, zone, *fmterr = "badly formatted time";
     time_t             gmttime;
+       int ndigits;
 
-    memset( (char *)&t, 0, sizeof( struct tm ));
-    if ( strlen( ldtimestr ) < 13 ) {
-       return( fmterr );
+       if (strlen( ldtimestr ) < 12 ) {
+               return( fmterr );
+       }
+
+    for ( ndigits=0; isdigit((unsigned char) ldtimestr[ndigits]); ndigits++) {
+               ; /* EMPTY */
     }
 
-    for ( p = ldtimestr; p - ldtimestr < 12; ++p ) {
-       if ( !isdigit( (unsigned char) *p )) {
+       if ( ndigits != 12 && ndigits != 14) {
            return( fmterr );
        }
-    }
+       
+    memset( (char *)&t, 0, sizeof( struct tm ));
 
     p = ldtimestr;
-    t.tm_year = GET2BYTENUM( p ); p += 2;
+
+       if( ndigits == 14) {
+               /* came with a century */
+               /* POSIX says tm_year should be year - 1900 */
+       t.tm_year = 100 * GET2BYTENUM( p ) - 1900;
+               p += 2;
+       } else {
+       t.tm_year = 0;
+       }
+    t.tm_year += GET2BYTENUM( p ); p += 2;
+
     t.tm_mon = GET2BYTENUM( p ) - 1; p += 2;
     t.tm_mday = GET2BYTENUM( p ); p += 2;
     t.tm_hour = GET2BYTENUM( p ); p += 2;
@@ -576,7 +607,6 @@ time2text( char *ldtimestr, int dateonly )
        SAFEMEMCPY( timestr + 11, timestr + 20, strlen( timestr + 20 ) + 1 );
     }
 
-    Free ( ldtimestr );
     return( strdup( timestr ) );
 }
 
@@ -596,7 +626,19 @@ int        dmsize[] = {
 #define        dysize(y)       \
        (((y) % 4) ? 365 : (((y) % 100) ? 366 : (((y) % 400) ? 365 : 366)))
 
-#define        YEAR(y)         ((y) >= 100 ? (y) : (y) + 1900)
+/*
+ * Y2K YEAR
+ */
+       /* per STDC & POSIX tm_year *should* be offset by 1900 */
+#define YEAR_POSIX(y)          ((y) + 1900)
+
+       /*
+        * year is < 1900, year is offset by 1900
+        */
+#define YEAR_CAREFUL(y)                ((y) < 1900 ? (y) + 1900 : (y))
+
+#define YEAR(y) YEAR_CAREFUL(y)
+
 
 /* \f */