X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_functions.c;h=617d223f1f335d381bdd085c04c7654c48a0dfa8;hp=2bcdd212725188791493e1cccaa081844f05ba5e;hb=b562e34cf4f8c8fae7b8fe773e0eed71592b09c2;hpb=a4b593d03ef14d9bc422cbe6ce471a7b5b8abe5d diff --git a/http_functions.c b/http_functions.c index 2bcdd21..617d223 100644 --- a/http_functions.c +++ b/http_functions.c @@ -31,9 +31,9 @@ #include "php_http.h" #include "php_http_std_defs.h" #include "php_http_api.h" -#include "php_http_auth_api.h" #include "php_http_request_api.h" #include "php_http_cache_api.h" +#include "php_http_request_method_api.h" #include "php_http_request_api.h" #include "php_http_date_api.h" #include "php_http_headers_api.h" @@ -408,7 +408,7 @@ PHP_FUNCTION(ob_etaghandler) } Z_TYPE_P(return_value) = IS_STRING; - http_ob_etaghandler(data, data_len, &Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value), mode); + http_ob_etaghandler(data, data_len, &Z_STRVAL_P(return_value), (uint *) &Z_STRLEN_P(return_value), mode); } /* }}} */ @@ -615,14 +615,15 @@ PHP_FUNCTION(http_send_stream) PHP_FUNCTION(http_chunked_decode) { char *encoded = NULL, *decoded = NULL; - int encoded_len = 0, decoded_len = 0; + size_t decoded_len = 0; + int encoded_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &encoded, &encoded_len) != SUCCESS) { RETURN_FALSE; } if (NULL != http_chunked_decode(encoded, encoded_len, &decoded, &decoded_len)) { - RETURN_STRINGL(decoded, decoded_len, 0); + RETURN_STRINGL(decoded, (int) decoded_len, 0); } else { RETURN_FALSE; } @@ -1156,116 +1157,6 @@ PHP_FUNCTION(http_request_method_name) #endif /* }}} HAVE_CURL */ - -/* {{{ proto bool http_auth_basic(string user, string pass[, string realm = "Restricted"]) - * - * Example: - *
- * Authorization failed!');
- * }
- * ?>
- * 
- */ -PHP_FUNCTION(http_auth_basic) -{ - char *realm = NULL, *user, *pass, *suser, *spass; - int r_len, u_len, p_len; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s", &user, &u_len, &pass, &p_len, &realm, &r_len) != SUCCESS) { - RETURN_FALSE; - } - - if (!realm) { - realm = "Restricted"; - } - - if (SUCCESS != http_auth_basic_credentials(&suser, &spass)) { - http_auth_basic_header(realm); - RETURN_FALSE; - } - - if (strcasecmp(suser, user)) { - http_auth_basic_header(realm); - RETURN_FALSE; - } - - if (strcmp(spass, pass)) { - http_auth_basic_header(realm); - RETURN_FALSE; - } - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto bool http_auth_basic_cb(mixed callback[, string realm = "Restricted"]) - * - * Example: - *
- * quoteSmart($user);
- *     if (strlen($realpass = $db->getOne($query)) {
- *         return $pass === $realpass;
- *     }
- *     return false;
- * }
- * if (!http_auth_basic_cb('auth_cb')) {
- *     die('

Authorization failed

'); - * } - * ?> - *
- */ -PHP_FUNCTION(http_auth_basic_cb) -{ - zval *cb; - char *realm = NULL, *user, *pass; - int r_len; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|s", &cb, &realm, &r_len) != SUCCESS) { - RETURN_FALSE; - } - - if (!realm) { - realm = "Restricted"; - } - - if (SUCCESS != http_auth_basic_credentials(&user, &pass)) { - http_auth_basic_header(realm); - RETURN_FALSE; - } - { - zval *zparams[2] = {NULL, NULL}, retval; - int result = 0; - - MAKE_STD_ZVAL(zparams[0]); - MAKE_STD_ZVAL(zparams[1]); - ZVAL_STRING(zparams[0], user, 0); - ZVAL_STRING(zparams[1], pass, 0); - - if (SUCCESS == call_user_function(EG(function_table), NULL, cb, - &retval, 2, zparams TSRMLS_CC)) { - result = Z_LVAL(retval); - } - - efree(user); - efree(pass); - efree(zparams[0]); - efree(zparams[1]); - - if (!result) { - http_auth_basic_header(realm); - } - - RETURN_BOOL(result); - } -} -/* }}}*/ - /* {{{ Sara Golemons http_build_query() */ #ifndef ZEND_ENGINE_2 @@ -1310,13 +1201,6 @@ PHP_FUNCTION(http_build_query) PHP_FUNCTION(http_test) { - ulong idx; - char *key; - zval **data; - FOREACH_HASH_KEYVAL(&EG(symbol_table), key, idx, data) { - convert_to_string_ex(data); - fprintf(stderr, "\t %s => %s\n", key, Z_STRVAL_PP(data)); - } } /*