CVS update: php3/functions

From: Date: Sun, 30 Aug 1998 19:06:45 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-671@lists.php.net to get a copy of this message
Date: Sunday August 30, 1998 @ 15:06 Author: shane Update of /repository/php3/functions In directory asf:/u2/tmp/cvs-serv26260/functions Modified Files: ldap.c php3_ldap.h Log Message: Backport ldap changes from 3.1 tree. This only effects windows compilation, should be no effect on unix. Tested with NS Ldap 3.0 library. Index: php3/functions/ldap.c diff -c php3/functions/ldap.c:1.54 php3/functions/ldap.c:1.55 *** php3/functions/ldap.c:1.54 Fri Aug 21 09:30:40 1998 --- php3/functions/ldap.c Sun Aug 30 15:06:44 1998 *************** *** 29,37 **** */ ! /* $Id: ldap.c,v 1.54 1998/08/21 13:30:40 rasmus Exp $ */ ! #ifndef MSVC5 #include "config.h" #endif #include "php.h" --- 29,47 ---- */ ! /* $Id: ldap.c,v 1.55 1998/08/30 19:06:44 shane Exp $ */ ! #define IS_EXT_MODULE ! #if !PHP_31 && defined(THREAD_SAFE) ! #undef THREAD_SAFE ! #endif ! #ifdef THREAD_SAFE ! #include "tls.h" ! DWORD ldapTLS; ! static int numthreads=0; ! void *ldap_mutex; ! #endif ! #if !(WIN32|WINNT) #include "config.h" #endif #include "php.h" *************** *** 40,48 **** --- 50,63 ---- #if HAVE_LDAP #if COMPILE_DL + #if PHP_31 + #include "ext/phpdl.h" + #include "ext/standard/dl.h" + #else #include "dl/phpdl.h" #include "functions/dl.h" #endif + #endif #include "php3_list.h" #include "php3_ldap.h" *************** *** 59,83 **** #define __STDC__ 1 #endif #include "functions/php3_string.h" - #include <lber.h> - #include <ldap.h> #if THREAD_SAFE & HAVE_NSLDAP #include "php3_threads.h" - struct ldap_thread_fns tfns; /* Structure for LDAP error values */ ! struct ldap_error { ! int le_errno; /* Corresponds to the LDAP error code */ ! char *le_matched; /* Matching components of the DN, ! if an NO_SUCH_OBJECT error occurred */ ! char *le_errmsg; /* Error message */ ! }; ! void *ldapkey; #endif - ldap_module php3_ldap_module; /* --- 74,97 ---- #define __STDC__ 1 #endif + #if PHP_31 + #include "ext/standard/php3_string.h" + #else #include "functions/php3_string.h" + #endif #if THREAD_SAFE & HAVE_NSLDAP #include "php3_threads.h" /* Structure for LDAP error values */ ! #define LDAP_TLS_VARS ldap_module *PHP3_TLS_GET(ldapTLS,php3_ldap_module) ! #define LDAP_GLOBAL(a) php3_ldap_module->a ! #else ! #define LDAP_TLS_VARS ! #define LDAP_GLOBAL(a) php3_ldap_module.a ! ldap_module php3_ldap_module; #endif /* *************** *** 113,119 **** php3_module_entry ldap_module_entry = { ! "LDAP", ldap_functions, php3_minit_ldap, NULL, NULL, NULL, php3_info_ldap, STANDARD_MODULE_PROPERTIES }; --- 127,133 ---- php3_module_entry ldap_module_entry = { ! "LDAP", ldap_functions, php3_minit_ldap, php3_mshutdown_ldap, NULL, NULL, php3_info_ldap, STANDARD_MODULE_PROPERTIES }; *************** *** 123,164 **** #endif ! #if THREAD_SAFE && HAVE_NSLDAP /* Function for setting thread-specific LDAP error values */ static void php3_ldap_set_ld_error( int err, char *matched, char *errmsg, void *dummy ) { ! struct ldap_error *le; ! /* Get the data structure specific to the calling thread */ ! le = GET_TLS_DATA( ldapkey ); /* Set the error code returned by the LDAP operation */ ! le->le_errno = err; /* Specify the components of the DN that matched (if an "NO_SUCH_OBJECT" error occurred */ ! if ( le->le_matched != NULL ) { ! ldap_memfree( le->le_matched ); } ! le->le_matched = matched; /* Specify the error message corresponding to the error code */ ! if ( le->le_errmsg != NULL ) { ! ldap_memfree( le->le_errmsg ); } ! le->le_errmsg = errmsg; } /* Function for getting the thread-specific LDAP error values */ static int php3_ldap_get_ld_error( char **matched, char **errmsg, void *dummy ) { ! struct ldap_error *le; ! /* Get the data values specific to the calling thread */ ! le = GET_TLS_DATA( ldapkey ); /* Retrieve the error values */ if ( matched != NULL ) { ! *matched = le->le_matched; } if ( errmsg != NULL ) { ! *errmsg = le->le_errmsg; } ! return( le->le_errno ); } /* Function for setting the value of the errno variable */ --- 137,175 ---- #endif ! #if 0 /* see my note in php3_ldap.h. smc */ /* Function for setting thread-specific LDAP error values */ static void php3_ldap_set_ld_error( int err, char *matched, char *errmsg, void *dummy ) { ! LDAP_TLS_VARS; ! /* Set the error code returned by the LDAP operation */ ! LDAP_GLOBAL(le_errno) = err; /* Specify the components of the DN that matched (if an "NO_SUCH_OBJECT" error occurred */ ! if ( LDAP_GLOBAL(le_matched) != NULL ) { ! ldap_memfree( LDAP_GLOBAL(le_matched) ); } ! LDAP_GLOBAL(le_matched) = matched; /* Specify the error message corresponding to the error code */ ! if ( LDAP_GLOBAL(le_errmsg) != NULL ) { ! ldap_memfree( LDAP_GLOBAL(le_errmsg) ); } ! LDAP_GLOBAL(le_errmsg) = errmsg; } /* Function for getting the thread-specific LDAP error values */ static int php3_ldap_get_ld_error( char **matched, char **errmsg, void *dummy ) { ! LDAP_TLS_VARS; /* Retrieve the error values */ if ( matched != NULL ) { ! *matched = LDAP_GLOBAL(le_matched); } if ( errmsg != NULL ) { ! *errmsg = LDAP_GLOBAL(le_errmsg); } ! return( LDAP_GLOBAL(le_errno) ); } /* Function for setting the value of the errno variable */ *************** *** 172,184 **** { return( errno ); } ! #endif static void _close_ldap_link(LDAP *ld) { ldap_unbind_s(ld); /* php3_printf("Freeing ldap connection");*/ ! php3_ldap_module.num_links--; } --- 183,196 ---- { return( errno ); } ! #endif /* THREAD_SAFE && NSLDAP */ static void _close_ldap_link(LDAP *ld) { + LDAP_TLS_VARS; ldap_unbind_s(ld); /* php3_printf("Freeing ldap connection");*/ ! LDAP_GLOBAL(num_links)--; } *************** *** 189,245 **** int php3_minit_ldap(INIT_FUNC_ARGS) { ! #if THREAD_SAFE && HAVE_NSLDAP /* Set up the ldap_thread_fns structure with pointers to the functions that you want called */ ! memset( &tfns, '\0', sizeof(struct ldap_thread_fns) ); /* Specify the functions that you want called */ /* Call the my_mutex_alloc() function whenever mutexes need to be allocated */ ! tfns.ltf_mutex_alloc = (void *(*)(void)) php3_mutex_alloc; /* Call the my_mutex_free() function whenever mutexes need to be destroyed */ ! tfns.ltf_mutex_free = (void (*)(void *)) php3_mutex_free; /* Call the pthread_mutex_lock() function whenever a thread needs to lock a mutex. */ ! tfns.ltf_mutex_lock = (int (*)(void *)) php3_mutex_lock; /* Call the pthread_mutex_unlock() function whenever a thread needs to unlock a mutex. */ ! tfns.ltf_mutex_unlock = (int (*)(void *)) php3_mutex_unlock; /* Call the get_errno() function to get the value of errno */ ! tfns.ltf_get_errno = php3_ldap_get_errno; /* Call the set_errno() function to set the value of errno */ ! tfns.ltf_set_errno = php3_ldap_set_errno; /* Call the get_ld_error() function to get error values from calls to functions in the libldap library */ ! tfns.ltf_get_lderrno = php3_ldap_get_ld_error; /* Call the set_ld_error() function to set error values for calls to functions in the libldap library */ ! tfns.ltf_set_lderrno = php3_ldap_set_ld_error; /* Don't pass any extra parameter to the functions for getting and setting libldap function call errors */ ! tfns.ltf_lderrno_arg = NULL; /* Set the session option that specifies the functions to call for multi-threaded clients */ ! if (ldap_set_option( ld, LDAP_OPT_THREAD_FN_PTRS, (void *) &tfns)!= 0) { ldap_perror( ld, "ldap_set_option: thread pointers" ); } #endif ! if (cfg_get_long("ldap.max_links", &php3_ldap_module.max_links) == FAILURE) { ! php3_ldap_module.max_links = -1; } ! if (cfg_get_string("ldap.base_dn", &php3_ldap_module.base_dn) == FAILURE) { ! php3_ldap_module.base_dn = NULL; } ! php3_ldap_module.le_result = register_list_destructors(_free_ldap_result, NULL); ! php3_ldap_module.le_link = register_list_destructors(_close_ldap_link, NULL); ldap_module_entry.type = type; return SUCCESS; } void php3_info_ldap(void) { --- 201,288 ---- int php3_minit_ldap(INIT_FUNC_ARGS) { ! #if defined(THREAD_SAFE) ! ldap_module *php3_ldap_module; ! PHP3_MUTEX_ALLOC(ldap_mutex); ! PHP3_MUTEX_LOCK(ldap_mutex); ! numthreads++; ! if (numthreads==1){ ! if (!PHP3_TLS_PROC_STARTUP(ldapTLS)){ ! PHP3_MUTEX_UNLOCK(ldap_mutex); ! PHP3_MUTEX_FREE(ldap_mutex); ! return 0; ! } ! } ! PHP3_MUTEX_UNLOCK(ldap_mutex); ! if(!PHP3_TLS_THREAD_INIT(ldapTLS,php3_ldap_module,ldap_module)) ! return 0; ! #if 0 /*HAVE_NSLDAP*/ /* Set up the ldap_thread_fns structure with pointers to the functions that you want called */ ! memset( &LDAP_GLOBAL(tfns), '\0', sizeof(struct ldap_thread_fns) ); /* Specify the functions that you want called */ /* Call the my_mutex_alloc() function whenever mutexes need to be allocated */ ! LDAP_GLOBAL(tfns).ltf_mutex_alloc = (void *(*)(void)) php3_mutex_alloc; /* Call the my_mutex_free() function whenever mutexes need to be destroyed */ ! LDAP_GLOBAL(tfns).ltf_mutex_free = (void (*)(void *)) php3_mutex_free; /* Call the pthread_mutex_lock() function whenever a thread needs to lock a mutex. */ ! LDAP_GLOBAL(tfns).ltf_mutex_lock = (int (*)(void *)) php3_mutex_lock; /* Call the pthread_mutex_unlock() function whenever a thread needs to unlock a mutex. */ ! LDAP_GLOBAL(tfns).ltf_mutex_unlock = (int (*)(void *)) php3_mutex_unlock; /* Call the get_errno() function to get the value of errno */ ! LDAP_GLOBAL(tfns).ltf_get_errno = php3_ldap_get_errno; /* Call the set_errno() function to set the value of errno */ ! LDAP_GLOBAL(tfns).ltf_set_errno = php3_ldap_set_errno; /* Call the get_ld_error() function to get error values from calls to functions in the libldap library */ ! LDAP_GLOBAL(tfns).ltf_get_lderrno = php3_ldap_get_ld_error; /* Call the set_ld_error() function to set error values for calls to functions in the libldap library */ ! LDAP_GLOBAL(tfns).ltf_set_lderrno = php3_ldap_set_ld_error; /* Don't pass any extra parameter to the functions for getting and setting libldap function call errors */ ! LDAP_GLOBAL(tfns).ltf_lderrno_arg = NULL; /* Set the session option that specifies the functions to call for multi-threaded clients */ ! if (ldap_set_option( ld, LDAP_OPT_THREAD_FN_PTRS, (void *) &LDAP_GLOBAL(tfns))!= 0) { ldap_perror( ld, "ldap_set_option: thread pointers" ); } + #endif #endif ! if (cfg_get_long("ldap.max_links", &LDAP_GLOBAL(max_links)) == FAILURE) { ! LDAP_GLOBAL(max_links) = -1; } ! if (cfg_get_string("ldap.base_dn", &LDAP_GLOBAL(base_dn)) == FAILURE) { ! LDAP_GLOBAL(base_dn) = NULL; } ! LDAP_GLOBAL(le_result) = register_list_destructors(_free_ldap_result, NULL); ! LDAP_GLOBAL(le_link) = register_list_destructors(_close_ldap_link, NULL); + /*FIXME is this safe in threaded environment? if so, please comment*/ ldap_module_entry.type = type; return SUCCESS; } + int php3_mshutdown_ldap(void){ + #ifdef THREAD_SAFE + LDAP_TLS_VARS; + PHP3_TLS_THREAD_FREE(php3_ldap_module); + PHP3_MUTEX_LOCK(ldap_mutex); + numthreads--; + if (!numthreads) { + PHP3_TLS_PROC_SHUTDOWN(ldapTLS); + } + PHP3_MUTEX_UNLOCK(ldap_mutex); + PHP3_MUTEX_FREE(ldap_mutex); + #endif + return SUCCESS; + } void php3_info_ldap(void) { *************** *** 250,272 **** /* Print version information */ SDKVersion = ldap_version( &ver ); #endif ! if (php3_ldap_module.max_links == -1) { strcpy(maxl, "Unlimited"); } else { ! snprintf(maxl, 15, "%ld", php3_ldap_module.max_links); maxl[15] = 0; } php3_printf("<table>" "<tr><td>Total links:</td><td>%d/%s</td></tr>\n" ! "<tr><td>RCS Version:</td><td>$Id: ldap.c,v 1.54 1998/08/21 13:30:40 rasmus Exp $</td></tr>\n" #if HAVE_NSLDAP "<tr><td>SDK Version:</td><td>%f</td></tr>" "<tr><td>Highest LDAP Protocol Supported:</td><td>%f</td></tr>" "<tr><td>SSL Level Supported:</td><td>%f</td></tr>" #endif ! ,php3_ldap_module.num_links,maxl #if HAVE_NSLDAP ,SDKVersion/100.0,ver.protocol_version/100.0,ver.SSL_version/100.0 #endif --- 293,316 ---- /* Print version information */ SDKVersion = ldap_version( &ver ); #endif + LDAP_TLS_VARS; ! if (LDAP_GLOBAL(max_links) == -1) { strcpy(maxl, "Unlimited"); } else { ! snprintf(maxl, 15, "%ld", LDAP_GLOBAL(max_links)); maxl[15] = 0; } php3_printf("<table>" "<tr><td>Total links:</td><td>%d/%s</td></tr>\n" ! "<tr><td>RCS Version:</td><td>$Id: ldap.c,v 1.55 1998/08/30 19:06:44 shane Exp $</td></tr>\n" #if HAVE_NSLDAP "<tr><td>SDK Version:</td><td>%f</td></tr>" "<tr><td>Highest LDAP Protocol Supported:</td><td>%f</td></tr>" "<tr><td>SSL Level Supported:</td><td>%f</td></tr>" #endif ! ,LDAP_GLOBAL(num_links),maxl #if HAVE_NSLDAP ,SDKVersion/100.0,ver.protocol_version/100.0,ver.SSL_version/100.0 #endif *************** *** 290,295 **** --- 334,340 ---- /* char *hashed_details; int hashed_details_length;*/ LDAP *ldap; + LDAP_TLS_VARS; switch(ARG_COUNT(ht)) { case 0: *************** *** 340,347 **** break; } ! if (php3_ldap_module.max_links!=-1 && php3_ldap_module.num_links>=php3_ldap_module.max_links) { ! php3_error(E_WARNING, "LDAP: Too many open links (%d)", php3_ldap_module.num_links); RETURN_FALSE; } --- 385,392 ---- break; } ! if (LDAP_GLOBAL(max_links)!=-1 && LDAP_GLOBAL(num_links)>=LDAP_GLOBAL(max_links)) { ! php3_error(E_WARNING, "LDAP: Too many open links (%d)", LDAP_GLOBAL(num_links)); RETURN_FALSE; } *************** *** 349,355 **** if ( ldap == NULL ) { RETURN_FALSE; } else { ! RETURN_LONG(php3_list_insert((void*)ldap,php3_ldap_module.le_link)); } } --- 394,400 ---- if ( ldap == NULL ) { RETURN_FALSE; } else { ! RETURN_LONG(php3_list_insert((void*)ldap,LDAP_GLOBAL(le_link))); } } *************** *** 357,369 **** static LDAP * _get_ldap_link(pval *link, HashTable *list) { ! LDAP *ldap; ! int type; convert_to_long(link); ldap = (LDAP *) php3_list_find(link->value.lval, &type); ! if (!ldap || !(type == php3_ldap_module.le_link)) { php3_error(E_WARNING, "%d is not a LDAP link index", link->value.lval); return NULL; } --- 402,415 ---- static LDAP * _get_ldap_link(pval *link, HashTable *list) { ! LDAP *ldap; ! int type; ! LDAP_TLS_VARS; convert_to_long(link); ldap = (LDAP *) php3_list_find(link->value.lval, &type); ! if (!ldap || !(type == LDAP_GLOBAL(le_link))) { php3_error(E_WARNING, "%d is not a LDAP link index", link->value.lval); return NULL; } *************** *** 373,385 **** static LDAPMessage * _get_ldap_result(pval *result, HashTable *list) { ! LDAPMessage *ldap_result; ! int type; convert_to_long(result); ldap_result = (LDAPMessage *) php3_list_find(result->value.lval, &type); ! if (!ldap_result || type != php3_ldap_module.le_result) { php3_error(E_WARNING, "%d is not a LDAP result index", result->value.lval); return NULL; } --- 419,432 ---- static LDAPMessage * _get_ldap_result(pval *result, HashTable *list) { ! LDAPMessage *ldap_result; ! int type; ! LDAP_TLS_VARS; convert_to_long(result); ldap_result = (LDAPMessage *) php3_list_find(result->value.lval, &type); ! if (!ldap_result || type != LDAP_GLOBAL(le_result)) { php3_error(E_WARNING, "%d is not a LDAP result index", result->value.lval); return NULL; } *************** *** 390,402 **** static LDAPMessage * _get_ldap_result_entry(pval *result, HashTable *list) { ! LDAPMessage *ldap_result_entry; ! int type; convert_to_long(result); ldap_result_entry = (LDAPMessage *) php3_list_find(result->value.lval, &type); ! if (!ldap_result_entry || type != php3_ldap_module.le_result_entry) { php3_error(E_WARNING, "%d is not a LDAP result entry index", result->value.lval); return NULL; } --- 437,450 ---- static LDAPMessage * _get_ldap_result_entry(pval *result, HashTable *list) { ! LDAPMessage *ldap_result_entry; ! int type; ! LDAP_TLS_VARS; convert_to_long(result); ldap_result_entry = (LDAPMessage *) php3_list_find(result->value.lval, &type); ! if (!ldap_result_entry || type != LDAP_GLOBAL(le_result_entry)) { php3_error(E_WARNING, "%d is not a LDAP result entry index", result->value.lval); return NULL; } *************** *** 407,419 **** static BerElement * _get_ber_entry(pval *berp, HashTable *list) { ! BerElement *ber; ! int type; convert_to_long(berp); ber = (BerElement *) php3_list_find(berp->value.lval, &type); ! if ( type != php3_ldap_module.le_ber_entry) { php3_error(E_WARNING, "%d is not a BerElement index", berp->value.lval); return NULL; } --- 455,468 ---- static BerElement * _get_ber_entry(pval *berp, HashTable *list) { ! BerElement *ber; ! int type; ! LDAP_TLS_VARS; convert_to_long(berp); ber = (BerElement *) php3_list_find(berp->value.lval, &type); ! if ( type != LDAP_GLOBAL(le_ber_entry)) { php3_error(E_WARNING, "%d is not a BerElement index", berp->value.lval); return NULL; } *************** *** 505,517 **** static void php3_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) { ! pval *link, *base_dn, *filter, *attrs, *attr; ! char *ldap_base_dn, *ldap_filter; ! LDAP *ldap; ! char **ldap_attrs = NULL; ! int attrsonly; ! LDAPMessage *ldap_result; ! int num_attribs=0, i; switch(ARG_COUNT(ht)) { case 3 : --- 554,567 ---- static void php3_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) { ! pval *link, *base_dn, *filter, *attrs, *attr; ! char *ldap_base_dn, *ldap_filter; ! LDAP *ldap; ! char **ldap_attrs = NULL; ! int attrsonly; ! LDAPMessage *ldap_result; ! int num_attribs=0, i; ! LDAP_TLS_VARS; switch(ARG_COUNT(ht)) { case 3 : *************** *** 587,593 **** #endif RETVAL_FALSE; } else { ! RETVAL_LONG(php3_list_insert(ldap_result, php3_ldap_module.le_result)); } if (ldap_attrs != NULL) { --- 637,643 ---- #endif RETVAL_FALSE; } else { ! RETVAL_LONG(php3_list_insert(ldap_result, LDAP_GLOBAL(le_result))); } if (ldap_attrs != NULL) { *************** *** 659,668 **** void php3_ldap_first_entry(INTERNAL_FUNCTION_PARAMETERS) { ! pval *result, *link; ! LDAP *ldap; ! LDAPMessage *ldap_result; ! LDAPMessage *ldap_result_entry; if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result) == FAILURE) { WRONG_PARAM_COUNT; --- 709,719 ---- void php3_ldap_first_entry(INTERNAL_FUNCTION_PARAMETERS) { ! pval *result, *link; ! LDAP *ldap; ! LDAPMessage *ldap_result; ! LDAPMessage *ldap_result_entry; ! LDAP_TLS_VARS; if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result) == FAILURE) { WRONG_PARAM_COUNT; *************** *** 678,693 **** /* php3_error(E_WARNING, "LDAP: Unable to read the entries from result : %s", ldap_err2string(ldap->ld_errno));*/ RETURN_FALSE; } else { ! RETURN_LONG(php3_list_insert(ldap_result_entry, php3_ldap_module.le_result_entry)); } } void php3_ldap_next_entry(INTERNAL_FUNCTION_PARAMETERS) { ! pval *result_entry, *link; ! LDAP *ldap; ! LDAPMessage *ldap_result_entry, *ldap_result_entry_next; if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result_entry) == FAILURE) { WRONG_PARAM_COUNT; --- 729,745 ---- /* php3_error(E_WARNING, "LDAP: Unable to read the entries from result : %s", ldap_err2string(ldap->ld_errno));*/ RETURN_FALSE; } else { ! RETURN_LONG(php3_list_insert(ldap_result_entry, LDAP_GLOBAL(le_result)_entry)); } } void php3_ldap_next_entry(INTERNAL_FUNCTION_PARAMETERS) { ! pval *result_entry, *link; ! LDAP *ldap; ! LDAPMessage *ldap_result_entry, *ldap_result_entry_next; ! LDAP_TLS_VARS; if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &link, &result_entry) == FAILURE) { WRONG_PARAM_COUNT; *************** *** 704,710 **** RETURN_FALSE; } else { /* php3_list_delete(result->value.lval); */ ! RETURN_LONG(php3_list_insert(ldap_result_entry_next, php3_ldap_module.le_result_entry)); } } --- 756,762 ---- RETURN_FALSE; } else { /* php3_list_delete(result->value.lval); */ ! RETURN_LONG(php3_list_insert(ldap_result_entry_next, LDAP_GLOBAL(le_result)_entry)); } } *************** *** 767,773 **** for(i=0; i<num_values; i++) { add_index_string(&tmp2, i, ldap_value[i], 1); } ! free(ldap_value); _php3_hash_update(tmp1.value.ht, _php3_strtolower(attribute), strlen(attribute)+1, (void *) &tmp2, sizeof(pval), NULL); add_index_string(&tmp1, attr_count, attribute, 1); --- 819,825 ---- for(i=0; i<num_values; i++) { add_index_string(&tmp2, i, ldap_value[i], 1); } ! ldap_value_free(ldap_value); _php3_hash_update(tmp1.value.ht, _php3_strtolower(attribute), strlen(attribute)+1, (void *) &tmp2, sizeof(pval), NULL); add_index_string(&tmp1, attr_count, attribute, 1); *************** *** 792,802 **** void php3_ldap_first_attribute(INTERNAL_FUNCTION_PARAMETERS) { ! pval *result,*link,*berp; ! LDAP *ldap; ! LDAPMessage *ldap_result_entry; ! BerElement *ber; ! char *attribute; if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &link, &result,&berp) == FAILURE || ParameterPassedByReference(ht,3)==0 ) { WRONG_PARAM_COUNT; --- 844,855 ---- void php3_ldap_first_attribute(INTERNAL_FUNCTION_PARAMETERS) { ! pval *result,*link,*berp; ! LDAP *ldap; ! LDAPMessage *ldap_result_entry; ! BerElement *ber; ! char *attribute; ! LDAP_TLS_VARS; if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &link, &result,&berp) == FAILURE || ParameterPassedByReference(ht,3)==0 ) { WRONG_PARAM_COUNT; *************** *** 814,820 **** } else { /* brep is passed by ref so we do not have to account for memory */ berp->type=IS_LONG; ! berp->value.lval=php3_list_insert(ber, php3_ldap_module.le_ber_entry); RETVAL_STRING(attribute,1); #ifdef WINDOWS --- 867,873 ---- } else { /* brep is passed by ref so we do not have to account for memory */ berp->type=IS_LONG; ! berp->value.lval=php3_list_insert(ber, LDAP_GLOBAL(le_ber_entry)); RETVAL_STRING(attribute,1); #ifdef WINDOWS *************** *** 898,904 **** for(i=0; i<num_values; i++) { add_index_string(&tmp, i, ldap_value[i], 1); } ! free(ldap_value); _php3_hash_update(return_value->value.ht, attribute, strlen(attribute)+1, (void *) &tmp, sizeof(pval), NULL); add_index_string(return_value, count, attribute, 1); --- 951,957 ---- for(i=0; i<num_values; i++) { add_index_string(&tmp, i, ldap_value[i], 1); } ! ldap_value_free(ldap_value); _php3_hash_update(return_value->value.ht, attribute, strlen(attribute)+1, (void *) &tmp, sizeof(pval), NULL); add_index_string(return_value, count, attribute, 1); Index: php3/functions/php3_ldap.h diff -c php3/functions/php3_ldap.h:1.21 php3/functions/php3_ldap.h:1.22 *** php3/functions/php3_ldap.h:1.21 Mon Aug 10 01:27:56 1998 --- php3/functions/php3_ldap.h Sun Aug 30 15:06:45 1998 *************** *** 29,35 **** */ ! /* $Id: php3_ldap.h,v 1.21 1998/08/10 05:27:56 rasmus Exp $ */ #ifndef _PHP3_LDAP_H #define _PHP3_LDAP_H --- 29,35 ---- */ ! /* $Id: php3_ldap.h,v 1.22 1998/08/30 19:06:45 shane Exp $ */ #ifndef _PHP3_LDAP_H #define _PHP3_LDAP_H *************** *** 40,51 **** --- 40,54 ---- #endif #if HAVE_LDAP + #include <lber.h> + #include <ldap.h> extern php3_module_entry ldap_module_entry; #define ldap_module_ptr &ldap_module_entry /* LDAP functions */ extern int php3_minit_ldap(INIT_FUNC_ARGS); + extern int php3_mshutdown_ldap(void); extern void php3_info_ldap(void); *************** *** 88,96 **** --- 91,116 ---- char *base_dn; int le_result, le_result_entry, le_ber_entry; int le_link; + + /* I just found out that the thread safe features + of the netscape ldap library are only required if + multiple threads are accessing the same LDAP + structure. Since we are not doing that, we do + not need to use this feature. I am leaving the + code here anyway just in case. smc + */ + #if 0 + struct ldap_thread_fns tfns; + int le_errno; /* Corresponds to the LDAP error code */ + char *le_matched; /* Matching components of the DN, + if an NO_SUCH_OBJECT error occurred */ + char *le_errmsg; /* Error message */ + #endif } ldap_module; + #ifndef THREAD_SAFE extern ldap_module php3_ldap_module; + #endif #else -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#671) next »