cvs: php4 /main main.c php_main.h

From: Date: Fri, 27 Oct 2000 10:16:54 +0000
Subject: cvs: php4 /main main.c php_main.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-2288@lists.php.net to get a copy of this message
sas Fri Oct 27 03:16:54 2000 EDT Modified files: /php4/main main.c php_main.h Log: Utility function for sapi modules (it is not in SAPI.c, because it relies on php_base64_encode). Index: php4/main/main.c diff -u php4/main/main.c:1.328 php4/main/main.c:1.329 --- php4/main/main.c:1.328 Thu Oct 26 14:16:12 2000 +++ php4/main/main.c Fri Oct 27 03:16:54 2000 @@ -19,7 +19,7 @@ */ -/* $Id: main.c,v 1.328 2000/10/26 21:16:12 sas Exp $ */ +/* $Id: main.c,v 1.329 2000/10/27 10:16:54 sas Exp $ */ #include <stdio.h> @@ -1212,6 +1212,31 @@ if (old_cwd[0] != '\0') V_CHDIR(old_cwd); free_alloca(old_cwd); +} + +PHPAPI int php_handle_auth_data(const char *auth SLS_DC) +{ + int ret = -1; + + if (auth && auth[0] != '\0' + && strncmp(auth, "Basic ", 6) == 0) { + char *pass; + char *user; + + user = php_base64_decode(auth + 6, strlen(auth) - 6, NULL); + if (user) { + pass = strchr(user, ':'); + if (pass) { + *pass++ = '\0'; + SG(request_info).auth_user = user; + SG(request_info).auth_password = estrdup(pass); + ret = 0; + } else { + efree(user); + } + } + } + return ret; } PHPAPI int php_lint_script(zend_file_handle *file CLS_DC ELS_DC PLS_DC) Index: php4/main/php_main.h diff -u php4/main/php_main.h:1.4 php4/main/php_main.h:1.5 --- php4/main/php_main.h:1.4 Thu Oct 26 14:16:12 2000 +++ php4/main/php_main.h Fri Oct 27 03:16:54 2000 @@ -18,7 +18,7 @@ */ -/* $Id: php_main.h,v 1.4 2000/10/26 21:16:12 sas Exp $ */ +/* $Id: php_main.h,v 1.5 2000/10/27 10:16:54 sas Exp $ */ #ifndef PHP_MAIN_H @@ -44,6 +44,7 @@ PHPAPI int php_handle_special_queries(SLS_D PLS_DC); PHPAPI int php_lint_script(zend_file_handle *file CLS_DC ELS_DC PLS_DC); +PHPAPI int php_handle_auth_data(const char *auth SLS_DC); extern void php_call_shutdown_functions(void);

« previous php.cvs (#2288) next »