CVS update: php31/os/nt

From: Date: Thu, 03 Sep 1998 07:11:22 +0000
Subject: CVS update: php31/os/nt
Groups: php.dev 
Request: Send a blank email to php-dev+get-772@lists.php.net to get a copy of this message
Date: Thursday September 3, 1998 @ 3:11 Author: shane Update of /repository/php31/os/nt In directory asf:/u2/tmp/cvs-serv19580/os/nt Modified Files: registry.c registry.h Log Message: Now here's a ton of work! per server directives working via registry per directory directives writen, untested registry functions using automated config main.c now uses automated config added some stuff to automated config info uses automated config dl fix Index: php31/os/nt/registry.c diff -c php31/os/nt/registry.c:1.3 php31/os/nt/registry.c:1.4 *** php31/os/nt/registry.c:1.3 Wed Sep 2 15:34:44 1998 --- php31/os/nt/registry.c Thu Sep 3 03:11:21 1998 *************** *** 59,65 **** p = strrchr(path, '\\'); if (!p) { php3_error(E_WARNING, "invalid registry key name '%s'", value_name); ! return 0; } key_name = estrdup(p+1); *p = 0; --- 59,67 ---- p = strrchr(path, '\\'); if (!p) { php3_error(E_WARNING, "invalid registry key name '%s'", value_name); ! efree(root); ! efree(path); ! return NULL; } key_name = estrdup(p+1); *p = 0; *************** *** 75,93 **** if (!found) { php3_error(E_WARNING, "Unknown registry root key '%s'", root); ! return 0; } status = RegOpenKeyEx(root_keys[i].hkey, path, 0, KEY_READ, &hkey); if (status != ERROR_SUCCESS) { ! php3_error(E_WARNING, "Failed to open registry key, Windows error %d", status); ! return 0; } /* Determine necessary size of buffer */ status = RegQueryValueEx(hkey, key_name, 0, dwType, NULL, &dwBufSize); if (status != ERROR_SUCCESS) { ! php3_error(E_WARNING, "Failed to read registry value, Windows error %d", status); return 0; } if (dwBufSize < 1) --- 77,104 ---- if (!found) { php3_error(E_WARNING, "Unknown registry root key '%s'", root); ! efree(root); ! efree(path); ! efree(key_name); ! return NULL; } status = RegOpenKeyEx(root_keys[i].hkey, path, 0, KEY_READ, &hkey); if (status != ERROR_SUCCESS) { ! //php3_error(E_WARNING, "Failed to open registry key, Windows error %d", status); ! efree(root); ! efree(path); ! efree(key_name); ! return NULL; } /* Determine necessary size of buffer */ status = RegQueryValueEx(hkey, key_name, 0, dwType, NULL, &dwBufSize); if (status != ERROR_SUCCESS) { ! //php3_error(E_WARNING, "Failed to read registry value, Windows error %d", status); ! efree(root); ! efree(path); ! efree(key_name); return 0; } if (dwBufSize < 1) *************** *** 97,107 **** status = RegQueryValueEx(hkey, key_name, 0, dwType, pbuffer, &dwBufSize); RegCloseKey(hkey); ! if (status != ERROR_SUCCESS) { php3_error(E_WARNING, "Failed to read registry value, Windows error %d", status); return 0; } ! efree(root); efree(path); efree(key_name); --- 108,122 ---- status = RegQueryValueEx(hkey, key_name, 0, dwType, pbuffer, &dwBufSize); RegCloseKey(hkey); ! /* dont want this error message here ! if (0 && status != ERROR_SUCCESS) { php3_error(E_WARNING, "Failed to read registry value, Windows error %d", status); + efree(root); + efree(path); + efree(key_name); return 0; } ! */ efree(root); efree(path); efree(key_name); *************** *** 468,474 **** DWORD dwType, dwValue, dwbSize, dwSize, i; RegKey *pRegKey; pval tmp; ! int numread=0; /* first, check to see if HKEY_LOCAL_MACHINE\Software\PHP\use_reg = 1 */ snprintf(regkey,1024,"%s%s",PHP_REG_KEY,"use_reg"); --- 483,489 ---- DWORD dwType, dwValue, dwbSize, dwSize, i; RegKey *pRegKey; pval tmp; ! int numread=0,enable_dl=0; /* first, check to see if HKEY_LOCAL_MACHINE\Software\PHP\use_reg = 1 */ snprintf(regkey,1024,"%s%s",PHP_REG_KEY,"use_reg"); *************** *** 483,488 **** --- 498,508 ---- efree(pbuffer); if (dwValue != 1) return 0; + tmp.value.str.val = php3_strndup("1",1); + tmp.value.str.len = 1; + tmp.type = IS_STRING; + _php3_hash_update(&configuration_hash,"use_registry",sizeof("use_registry"),(void *) &tmp,sizeof(pval),NULL); + snprintf(regkey,1024,"%s%s",PHP_REG_KEY,"DefaultConfig"); if (pRegKey = _php3_win32_reg_open(regkey _INLINE_TLS)) { /* ok default keys exist */ *************** *** 507,562 **** OutputDebugString("\n"); } #endif ! if (strcmp(key,"extensions")) { ! /* ok, we have the keyname and it's value, ! lets put it into the config hash */ ! tmp.value.str.val = php3_strndup(pbuffer,dwbSize); ! tmp.value.str.len = dwbSize; ! tmp.type = IS_STRING; ! _php3_hash_update(&configuration_hash,key,dwSize+1,(void *) &tmp,sizeof(pval),NULL); ! } else { ! char *p1, *p2; ! /*we have to split the data into the different dl names */ ! p1=pbuffer; ! while (p1) { ! p2 = strstr(p1," "); ! if (p2) { ! *p2 = '\0'; ! if (p1 && *p1) php3_dladd(p1); ! *p2 = ' '; ! if (*(p2+1)) { ! p1 = p2+1; ! } else { ! p1 = NULL; ! } ! } else if (*p1) { ! php3_dladd(p1); ! p1 = NULL; ! } ! } } } numread++; } ! efree(key); ! key = NULL; ! efree(pbuffer); ! pbuffer = NULL; ! } #if 0 ! { ! char buf[4]; ! OutputDebugString("Number of entries = "); ! snprintf(buf,4,"%u",pRegKey->dwcValues); ! OutputDebugString(buf); ! OutputDebugString("\n"); ! OutputDebugString("Entries read = "); ! snprintf(buf,4,"%d",numread); ! OutputDebugString(buf); ! OutputDebugString("\n"); ! } #endif _php3_win32_reg_close(pRegKey _INLINE_TLS); --- 527,563 ---- OutputDebugString("\n"); } #endif ! ! if (!stricmp(key,"enable_dl")) { ! if (pbuffer[0] == '1') enable_dl = 1; } + /* ok, we have the keyname and it's value, + lets put it into the config hash */ + tmp.value.str.val = php3_strndup(pbuffer,dwbSize); + tmp.value.str.len = dwbSize; + tmp.type = IS_STRING; + _php3_hash_update(&configuration_hash,key,dwSize+1,(void *) &tmp,sizeof(pval),NULL); } numread++; } ! efree(key); ! key = NULL; ! efree(pbuffer); ! pbuffer = NULL; } #if 0 ! { ! char buf[4]; ! OutputDebugString("Number of entries = "); ! snprintf(buf,4,"%u",pRegKey->dwcValues); ! OutputDebugString(buf); ! OutputDebugString("\n"); ! OutputDebugString("Entries read = "); ! snprintf(buf,4,"%d",numread); ! OutputDebugString(buf); ! OutputDebugString("\n"); ! } #endif _php3_win32_reg_close(pRegKey _INLINE_TLS); *************** *** 565,574 **** tmp.value.str.len = 8; tmp.type = IS_STRING; _php3_hash_update(&configuration_hash,"cfg_file_path",sizeof("cfg_file_path"),(void *) &tmp,sizeof(pval),NULL); ! ! /* temporarily do not use registry, until completely working */ ! return 1; } /* now we will read our default registry and hash it */ return 0; } --- 566,700 ---- tmp.value.str.len = 8; tmp.type = IS_STRING; _php3_hash_update(&configuration_hash,"cfg_file_path",sizeof("cfg_file_path"),(void *) &tmp,sizeof(pval),NULL); ! ! /* load the extensions */ ! snprintf(regkey,1024,"%s%s",PHP_REG_KEY,"Extensions"); ! if (enable_dl && (pRegKey = _php3_win32_reg_open(regkey _INLINE_TLS))) { ! /* ok default keys exist */ ! for (i=0;i < pRegKey->dwcValues; i++){ ! /* allocate memory for keynames and values. */ ! dwSize = (pRegKey->dwcMaxValueName+1); ! key=emalloc(dwSize); ! dwbSize = (pRegKey->dwcMaxValueData+1); ! pbuffer=emalloc(dwbSize); ! if (_php3_win32_reg_read_value(pRegKey, key, &dwSize, &dwType, pbuffer, &dwbSize _INLINE_TLS)) { ! if (dwType == REG_DWORD) { ! dwValue = *((DWORD *) pbuffer); ! if (dwValue) php3_dladd(key); ! } ! } ! efree(key); ! key = NULL; ! efree(pbuffer); ! pbuffer = NULL; ! } ! _php3_win32_reg_close(pRegKey _INLINE_TLS); ! ! return 1; ! } } /* now we will read our default registry and hash it */ return 0; } + + + + _reg_value *_reg_get_server_val(char *server, int type, char *var_name){ + DWORD dwType; + TCHAR regkey[1024]; + TCHAR *temp; + _reg_value *value=emalloc(sizeof(_reg_value)); + + value->lval=0; + + snprintf(regkey, 1024, "%s%s\\%s", PHP_REG_KEY, server, var_name); + switch (type) { + case 1: + temp=_php3_win32_reg_read(regkey,&dwType); + if (temp) { + value->lval=atol(temp); + efree(temp); + } + return value; + break; + case 2: + value->strval=_php3_win32_reg_read(regkey,&dwType); + return value; + break; + default: + efree(value); + return NULL; + break; + } + } + + + void _reg_get_server_config(char *server INLINE_TLS){ + int i=0; + + #define AC_REGISTRY_TABLE + #include "automated_configuration_definitions.h" + #include "automated_configuration.h" + #undef AC_REGISTRY_TABLE + + while(php3_reg_vars[i].name){ + if(php3_reg_vars[i].user_modify){ + php3_reg_vars[i].value = _reg_get_server_val( + server, + php3_reg_vars[i].type, php3_reg_vars[i].name); + OutputDebugString(php3_reg_vars[i].name); + OutputDebugString(" = "); + switch (php3_reg_vars[i].type) { + case AC_LONG: + if(php3_reg_vars[i].value->lval) { + char buf[5]; + snprintf(buf,4,"%u",php3_reg_vars[i].value->lval); + OutputDebugString(buf); + (*(DWORD *)php3_reg_vars[i].address) = php3_reg_vars[i].value->lval; + } + break; + case AC_STRING: + if(php3_reg_vars[i].value->strval) { + OutputDebugString(php3_reg_vars[i].value->strval); + (*(char **)php3_reg_vars[i].address) = php3_reg_vars[i].value->strval; + } + break; + } + OutputDebugString("\n"); + if(php3_reg_vars[i].value)efree(php3_reg_vars[i].value); + } + i++; + } + } + + + void _reg_get_directory_config(INLINE_TLS_VOID){ + char regkey[1024]; + + if(GLOBAL(php3_ini)->use_registry_dir && GLOBAL(sapi_rqst)->server_name && GLOBAL(sapi_rqst)->path_info){ + snprintf(regkey, 1024, "%s\\%s", GLOBAL(sapi_rqst)->server_name, GLOBAL(sapi_rqst)->path_info); + CONVERT_TO_WIN_FS(regkey); + _reg_get_server_config(regkey _INLINE_TLS); + } + } + + /* FIXME not finished here on down. */ + + void _reg_free_server_config(INLINE_TLS_VOID){ + char *server=NULL; + int i; + #define AC_REGISTRY_TABLE + #include "automated_configuration_definitions.h" + #include "automated_configuration.h" + #undef AC_REGISTRY_TABLE + + while(php3_reg_vars[i].name){ + if(php3_reg_vars[i].value){ + if(php3_reg_vars[i].value->strval){ + efree(php3_reg_vars[i].value->strval); + } + efree(php3_reg_vars[i].value); + } + } + } + Index: php31/os/nt/registry.h diff -c php31/os/nt/registry.h:1.3 php31/os/nt/registry.h:1.4 *** php31/os/nt/registry.h:1.3 Wed Sep 2 15:18:28 1998 --- php31/os/nt/registry.h Thu Sep 3 03:11:21 1998 *************** *** 24,29 **** --- 24,43 ---- FILETIME ftLastWriteTime; // Last write time. } RegKey; + typedef union { + DWORD lval; + TCHAR *strval; + } _reg_value; + + struct _php3_reg_vars{ + char *name; + void *address; + int type; + int user_modify; + _reg_value *value; + }; + + extern int _php3_win32_reg_init(INLINE_TLS_VOID); extern PHPAPI BYTE *_php3_win32_reg_read(char *value_name, DWORD *dwType); extern PHPAPI RegKey *_php3_win32_reg_open(char *value_name INLINE_TLS); *************** *** 32,37 **** --- 46,54 ---- extern PHPAPI int _php3_win32_reg_rewind(RegKey *pRegKey INLINE_TLS); extern PHPAPI int _php3_win32_reg_close(RegKey *pRegKey INLINE_TLS); extern int _reg_get_default_config(INLINE_TLS_VOID); + extern void _reg_get_server_config(char *server_name INLINE_TLS); + extern void _reg_get_directory_config(INLINE_TLS_VOID); + extern void _reg_free_server_config(INLINE_TLS_VOID); /* Win32 functions */ extern void php3_win32_reg_read(INTERNAL_FUNCTION_PARAMETERS); -- 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 (#772) next »