]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/getvalues.c
rename ldap_pvt_init_utils() to ldap_int_utils_init() and provide
[openldap] / libraries / libldap / getvalues.c
index 52802aa6cabe42c8cf3f6c073c0fd9bfb289f80b..865688e535635a37966e574e856a3a0fe58cf21a 100644 (file)
@@ -1,41 +1,32 @@
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  getvalues.c
  */
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
+#include "portable.h"
 
 #include <stdio.h>
-#include <ctype.h>
-#include <string.h>
 #include <stdlib.h>
 
-#ifdef MACOS
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "ldap-int.h"
 
 char **
-ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target )
+ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
 {
        BerElement      ber;
-       char            attr[LDAP_MAX_ATTR_LEN];
+       char            *attr;
        int             found = 0;
-       long            len;
        char            **vals;
 
        Debug( LDAP_DEBUG_TRACE, "ldap_get_values\n", 0, 0, 0 );
@@ -43,8 +34,7 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target )
        ber = *entry->lm_ber;
 
        /* skip sequence, dn, sequence of, and snag the first attr */
-       len = sizeof(attr);
-       if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
+       if ( ber_scanf( &ber, "{x{{a", &attr ) == LBER_ERROR ) {
                ld->ld_errno = LDAP_DECODING_ERROR;
                return( NULL );
        }
@@ -54,16 +44,22 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target )
 
        /* break out on success, return out on error */
        while ( ! found ) {
-               len = sizeof(attr);
-               if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
+               free(attr);
+               attr = NULL;
+
+               if ( ber_scanf( &ber, "x}{a", &attr ) == LBER_ERROR ) {
                        ld->ld_errno = LDAP_DECODING_ERROR;
                        return( NULL );
                }
 
                if ( strcasecmp( target, attr ) == 0 )
                        break;
+
        }
 
+       free(attr);
+       attr = NULL;
+
        /* 
         * if we get this far, we've found the attribute and are sitting
         * just before the set of values.
@@ -78,12 +74,11 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target )
 }
 
 struct berval **
-ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target )
+ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
 {
        BerElement      ber;
-       char            attr[LDAP_MAX_ATTR_LEN];
+       char            *attr;
        int             found = 0;
-       long            len;
        struct berval   **vals;
 
        Debug( LDAP_DEBUG_TRACE, "ldap_get_values_len\n", 0, 0, 0 );
@@ -91,8 +86,7 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target )
        ber = *entry->lm_ber;
 
        /* skip sequence, dn, sequence of, and snag the first attr */
-       len = sizeof(attr);
-       if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
+       if ( ber_scanf( &ber, "{x{{a", &attr ) == LBER_ERROR ) {
                ld->ld_errno = LDAP_DECODING_ERROR;
                return( NULL );
        }
@@ -102,8 +96,10 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target )
 
        /* break out on success, return out on error */
        while ( ! found ) {
-               len = sizeof(attr);
-               if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
+               free( attr );
+               attr = NULL;
+
+               if ( ber_scanf( &ber, "x}{a", &attr ) == LBER_ERROR ) {
                        ld->ld_errno = LDAP_DECODING_ERROR;
                        return( NULL );
                }
@@ -112,6 +108,9 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target )
                        break;
        }
 
+       free( attr );
+       attr = NULL;
+
        /* 
         * if we get this far, we've found the attribute and are sitting
         * just before the set of values.