Constify char * arguments of APIs

Closes GH-5676.
This commit is contained in:
twosee 2020-06-07 17:01:19 +08:00 committed by Nikita Popov
parent f6db43fec8
commit 88355dd338
89 changed files with 366 additions and 329 deletions

View File

@ -116,7 +116,7 @@ TSRM_TLS uint8_t in_main_thread = 0;
TSRM_TLS uint8_t is_thread_shutdown = 0;
/* Startup TSRM (call once for the entire process) */
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename)
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, const char *debug_filename)
{/*{{{*/
#ifdef TSRM_WIN32
tls_key = TlsAlloc();
@ -698,7 +698,7 @@ int tsrm_error(int level, const char *format, ...)
#endif
void tsrm_error_set(int level, char *debug_filename)
void tsrm_error_set(int level, const char *debug_filename)
{/*{{{*/
tsrm_error_level = level;

View File

@ -79,7 +79,7 @@ extern "C" {
#endif
/* startup/shutdown */
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename);
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, const char *debug_filename);
TSRM_API void tsrm_shutdown(void);
/* environ lock API */
@ -115,7 +115,7 @@ typedef void (*tsrm_shutdown_func_t)(void);
TSRM_API int tsrm_error(int level, const char *format, ...);
TSRM_API void tsrm_error_set(int level, char *debug_filename);
TSRM_API void tsrm_error_set(int level, const char *debug_filename);
/* utility functions */
TSRM_API THREAD_T tsrm_thread_id(void);

View File

@ -443,7 +443,7 @@ TSRM_API FILE *popen(const char *command, const char *type)
return popen_ex(command, type, NULL, NULL);
}/*}}}*/
TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env)
TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, const char *env)
{/*{{{*/
FILE *stream = NULL;
int fno, type_len, read, mode;

View File

@ -94,7 +94,7 @@ const char * tsrm_win32_get_path_sid_key(const char *pathname, size_t pathname_l
TSRM_API void tsrm_win32_startup(void);
TSRM_API void tsrm_win32_shutdown(void);
TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env);
TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, const char *env);
TSRM_API FILE *popen(const char *command, const char *type);
TSRM_API int pclose(FILE *stream);
TSRM_API int tsrm_win32_access(const char *pathname, int mode);

View File

@ -78,7 +78,7 @@ ZEND_API void (*zend_interrupt_function)(zend_execute_data *execute_data);
ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message);
void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_list ap);
void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap);
ZEND_API char *(*zend_getenv)(char *name, size_t name_len);
ZEND_API char *(*zend_getenv)(const char *name, size_t name_len);
ZEND_API zend_string *(*zend_resolve_path)(const char *filename, size_t filename_len);
ZEND_API int (*zend_post_startup_cb)(void) = NULL;
ZEND_API void (*zend_post_shutdown_cb)(void) = NULL;

View File

@ -198,7 +198,7 @@ typedef struct _zend_utility_functions {
int (*stream_open_function)(const char *filename, zend_file_handle *handle);
void (*printf_to_smart_string_function)(smart_string *buf, const char *format, va_list ap);
void (*printf_to_smart_str_function)(smart_str *buf, const char *format, va_list ap);
char *(*getenv_function)(char *name, size_t name_len);
char *(*getenv_function)(const char *name, size_t name_len);
zend_string *(*resolve_path_function)(const char *filename, size_t filename_len);
} zend_utility_functions;
@ -286,7 +286,7 @@ extern ZEND_API void (*zend_on_timeout)(int seconds);
extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle);
extern void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_list ap);
extern void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap);
extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len);
extern ZEND_API char *(*zend_getenv)(const char *name, size_t name_len);
extern ZEND_API zend_string *(*zend_resolve_path)(const char *filename, size_t filename_len);
/* These two callbacks are especially for opcache */

View File

@ -2716,7 +2716,7 @@ ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, int name_lengt
/* Disabled functions support */
ZEND_API int zend_disable_function(char *function_name, size_t function_name_length) /* {{{ */
ZEND_API int zend_disable_function(const char *function_name, size_t function_name_length) /* {{{ */
{
return zend_hash_str_del(CG(function_table), function_name, function_name_length);
}
@ -2753,7 +2753,7 @@ static const zend_function_entry disabled_class_new[] = {
ZEND_FE_END
};
ZEND_API int zend_disable_class(char *class_name, size_t class_name_length) /* {{{ */
ZEND_API int zend_disable_class(const char *class_name, size_t class_name_length) /* {{{ */
{
zend_class_entry *disabled_class;
zend_string *key;

View File

@ -334,8 +334,8 @@ ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zen
#define zend_register_ns_class_alias(ns, name, ce) \
zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce, 1)
ZEND_API int zend_disable_function(char *function_name, size_t function_name_length);
ZEND_API int zend_disable_class(char *class_name, size_t class_name_length);
ZEND_API int zend_disable_function(const char *function_name, size_t function_name_length);
ZEND_API int zend_disable_class(const char *class_name, size_t class_name_length);
ZEND_API ZEND_COLD void zend_wrong_param_count(void);

View File

@ -1720,7 +1720,7 @@ void zend_do_extended_fcall_end(void) /* {{{ */
}
/* }}} */
zend_bool zend_is_auto_global_str(char *name, size_t len) /* {{{ */ {
zend_bool zend_is_auto_global_str(const char *name, size_t len) /* {{{ */ {
zend_auto_global *auto_global;
if ((auto_global = zend_hash_str_find_ptr(CG(auto_globals), name, len)) != NULL) {

View File

@ -844,7 +844,7 @@ typedef struct _zend_auto_global {
ZEND_API int zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback);
ZEND_API void zend_activate_auto_globals(void);
ZEND_API zend_bool zend_is_auto_global(zend_string *name);
ZEND_API zend_bool zend_is_auto_global_str(char *name, size_t len);
ZEND_API zend_bool zend_is_auto_global_str(const char *name, size_t len);
ZEND_API size_t zend_dirname(char *path, size_t len);
ZEND_API void zend_set_function_arg_flags(zend_function *func);

View File

@ -26,7 +26,7 @@
#include "php_com_dotnet_internal.h"
PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, size_t string_len, int codepage)
PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(const char *string, size_t string_len, int codepage)
{
OLECHAR *olestring = NULL;
DWORD flags = codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS;

View File

@ -260,7 +260,7 @@ ITypeLib *php_com_cache_typelib(ITypeLib* TL, char *cache_key, zend_long cache_k
return result;
}
PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string,
PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(const char *search_string,
int codepage, int *cached)
{
ITypeLib *TL;

View File

@ -82,7 +82,7 @@ int php_com_saproxy_create(zend_object *com_object, zval *proxy_out, zval *index
/* com_olechar.c */
PHP_COM_DOTNET_API char *php_com_olestring_to_string(OLECHAR *olestring,
size_t *string_len, int codepage);
PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string,
PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(const char *string,
size_t string_len, int codepage);
@ -130,7 +130,7 @@ PHP_COM_DOTNET_API void php_com_wrap_variant(zval *z, VARIANT *v,
PHP_COM_DOTNET_API int php_com_safearray_get_elem(VARIANT *array, VARIANT *dest, LONG dim1);
/* com_typeinfo.c */
PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string,
PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(const char *search_string,
int codepage, int *cached);
PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codepage);
PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode,

View File

@ -617,7 +617,7 @@ static const char *php_date_short_day_name(timelib_sll y, timelib_sll m, timelib
/* }}} */
/* {{{ date_format - (gm)date helper */
static zend_string *date_format(char *format, size_t format_len, timelib_time *t, int localtime)
static zend_string *date_format(const char *format, size_t format_len, timelib_time *t, int localtime)
{
smart_str string = {0};
size_t i;
@ -798,7 +798,7 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime)
}
/* }}} */
PHPAPI zend_string *php_format_date(char *format, size_t format_len, time_t ts, int localtime) /* {{{ */
PHPAPI zend_string *php_format_date(const char *format, size_t format_len, time_t ts, int localtime) /* {{{ */
{
timelib_time *t;
timelib_tzinfo *tzi;
@ -982,14 +982,14 @@ PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb)
/* }}} */
/* {{{ php_parse_date: Backwards compatibility function */
PHPAPI zend_long php_parse_date(char *string, zend_long *now)
PHPAPI zend_long php_parse_date(const char *string, zend_long *now)
{
timelib_time *parsed_time;
timelib_error_container *error = NULL;
int error2;
zend_long retval;
parsed_time = timelib_strtotime(string, strlen(string), &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
parsed_time = timelib_strtotime((char *) string, strlen(string), &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
if (error->error_count) {
timelib_time_dtor(parsed_time);
timelib_error_container_dtor(error);
@ -2187,7 +2187,7 @@ static void php_date_get_current_time_with_fraction(time_t *sec, suseconds_t *us
#endif
}
PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, size_t time_str_len, char *format, zval *timezone_object, int ctor) /* {{{ */
PHPAPI int php_date_initialize(php_date_obj *dateobj, const char *time_str, size_t time_str_len, const char *format, zval *timezone_object, int ctor) /* {{{ */
{
timelib_time *now;
timelib_tzinfo *tzi = NULL;
@ -2202,9 +2202,18 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
timelib_time_dtor(dateobj->time);
}
if (format) {
dateobj->time = timelib_parse_from_format(format, time_str_len ? time_str : "", time_str_len ? time_str_len : 0, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
if (time_str_len == 0) {
time_str = "";
}
// TODO: drop this const casts
dateobj->time = timelib_parse_from_format((char *) format, (char *) time_str, time_str_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
} else {
dateobj->time = timelib_strtotime(time_str_len ? time_str : "now", time_str_len ? time_str_len : sizeof("now") -1, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
if (time_str_len == 0) {
time_str = "now";
time_str_len = sizeof("now") - 1;
}
// TODO: drop this const casts
dateobj->time = timelib_strtotime((char *) time_str, time_str_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
}
/* update last errors and warnings */

View File

@ -108,14 +108,14 @@ ZEND_END_MODULE_GLOBALS(date)
PHPAPI time_t php_time(void);
/* Backwards compatibility wrapper */
PHPAPI zend_long php_parse_date(char *string, zend_long *now);
PHPAPI zend_long php_parse_date(const char *string, zend_long *now);
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt);
PHPAPI int php_idate(char format, time_t ts, int localtime);
#define _php_strftime php_strftime
PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm);
PHPAPI zend_string *php_format_date(char *format, size_t format_len, time_t ts, int localtime);
PHPAPI zend_string *php_format_date(const char *format, size_t format_len, time_t ts, int localtime);
/* Mechanism to set new TZ database */
PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb);
@ -131,7 +131,7 @@ PHPAPI zend_class_entry *php_date_get_period_ce(void);
/* Functions for creating DateTime objects, and initializing them from a string */
PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object);
PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, size_t time_str_len, char *format, zval *timezone_object, int ctor);
PHPAPI int php_date_initialize(php_date_obj *dateobj, const char *time_str, size_t time_str_len, const char *format, zval *timezone_object, int ctor);
#endif /* PHP_DATE_H */

View File

@ -75,7 +75,7 @@ static const filter_list_entry filter_list[] = {
#define PARSE_SESSION 6
#endif
static unsigned int php_sapi_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len);
static unsigned int php_sapi_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len);
static unsigned int php_sapi_filter_init(void);
/* {{{ filter_module_entry
@ -360,7 +360,7 @@ handle_default:
}
/* }}} */
static unsigned int php_sapi_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len) /* {{{ */
static unsigned int php_sapi_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len) /* {{{ */
{
zval new_var, raw_var;
zval *array_ptr = NULL, *orig_array_ptr = NULL;

View File

@ -195,7 +195,7 @@ static const char *php_json_get_error_msg(php_json_error_code error_code) /* {{{
}
/* }}} */
PHP_JSON_API int php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth) /* {{{ */
PHP_JSON_API int php_json_decode_ex(zval *return_value, const char *str, size_t str_len, zend_long options, zend_long depth) /* {{{ */
{
php_json_parser parser;

View File

@ -301,7 +301,7 @@ static const php_json_parser_methods default_parser_methods =
PHP_JSON_API void php_json_parser_init_ex(php_json_parser *parser,
zval *return_value,
char *str,
const char *str,
size_t str_len,
int options,
int max_depth,
@ -317,7 +317,7 @@ PHP_JSON_API void php_json_parser_init_ex(php_json_parser *parser,
PHP_JSON_API void php_json_parser_init(php_json_parser *parser,
zval *return_value,
char *str,
const char *str,
size_t str_len,
int options,
int max_depth)

View File

@ -91,7 +91,7 @@ static int php_json_ucs2_to_int(php_json_scanner *s, int size)
return php_json_ucs2_to_int_ex(s, size, 1);
}
void php_json_scanner_init(php_json_scanner *s, char *str, size_t str_len, int options)
void php_json_scanner_init(php_json_scanner *s, const char *str, size_t str_len, int options)
{
s->cursor = (php_json_ctype *) str;
s->limit = (php_json_ctype *) str + str_len;

View File

@ -98,9 +98,9 @@ ZEND_TSRMLS_CACHE_EXTERN()
PHP_JSON_API int php_json_encode_ex(smart_str *buf, zval *val, int options, zend_long depth);
PHP_JSON_API int php_json_encode(smart_str *buf, zval *val, int options);
PHP_JSON_API int php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth);
PHP_JSON_API int php_json_decode_ex(zval *return_value, const char *str, size_t str_len, zend_long options, zend_long depth);
static inline int php_json_decode(zval *return_value, char *str, int str_len, zend_bool assoc, zend_long depth)
static inline int php_json_decode(zval *return_value, const char *str, int str_len, zend_bool assoc, zend_long depth)
{
return php_json_decode_ex(return_value, str, str_len, assoc ? PHP_JSON_OBJECT_AS_ARRAY : 0, depth);
}

View File

@ -61,7 +61,7 @@ struct _php_json_parser {
PHP_JSON_API void php_json_parser_init_ex(
php_json_parser *parser,
zval *return_value,
char *str,
const char *str,
size_t str_len,
int options,
int max_depth,
@ -70,7 +70,7 @@ PHP_JSON_API void php_json_parser_init_ex(
PHP_JSON_API void php_json_parser_init(
php_json_parser *parser,
zval *return_value,
char *str,
const char *str,
size_t str_len,
int options,
int max_depth);

View File

@ -40,7 +40,7 @@ typedef struct _php_json_scanner {
} php_json_scanner;
void php_json_scanner_init(php_json_scanner *scanner, char *str, size_t str_len, int options);
void php_json_scanner_init(php_json_scanner *scanner, const char *str, size_t str_len, int options);
int php_json_scan(php_json_scanner *s);
#endif /* PHP_JSON_SCANNER_H */

View File

@ -4798,7 +4798,7 @@ static int accel_finish_startup(void)
int (*orig_header_handler)(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers) = sapi_module.header_handler;
int (*orig_send_headers)(sapi_headers_struct *sapi_headers) = sapi_module.send_headers;
void (*orig_send_header)(sapi_header_struct *sapi_header, void *server_context)= sapi_module.send_header;
char *(*orig_getenv)(char *name, size_t name_len) = sapi_module.getenv;
char *(*orig_getenv)(const char *name, size_t name_len) = sapi_module.getenv;
size_t (*orig_ub_write)(const char *str, size_t str_length) = sapi_module.ub_write;
void (*orig_flush)(void *server_context) = sapi_module.flush;
uint32_t orig_compiler_options = CG(compiler_options);

View File

@ -6888,7 +6888,7 @@ static void php_openssl_load_cipher_mode(struct php_openssl_cipher_mode *mode, c
}
/* }}} */
static int php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_required_len,
static int php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv_required_len,
zend_bool *free_iv, EVP_CIPHER_CTX *cipher_ctx, struct php_openssl_cipher_mode *mode) /* {{{ */
{
char *iv_new;
@ -6942,9 +6942,9 @@ static int php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_requir
static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
EVP_CIPHER_CTX *cipher_ctx, struct php_openssl_cipher_mode *mode,
char **ppassword, size_t *ppassword_len, zend_bool *free_password,
char **piv, size_t *piv_len, zend_bool *free_iv,
char *tag, int tag_len, zend_long options, int enc) /* {{{ */
const char **ppassword, size_t *ppassword_len, zend_bool *free_password,
const char **piv, size_t *piv_len, zend_bool *free_iv,
const char *tag, int tag_len, zend_long options, int enc) /* {{{ */
{
unsigned char *key;
int key_len, password_len;
@ -7014,8 +7014,8 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
static int php_openssl_cipher_update(const EVP_CIPHER *cipher_type,
EVP_CIPHER_CTX *cipher_ctx, struct php_openssl_cipher_mode *mode,
zend_string **poutbuf, int *poutlen, char *data, size_t data_len,
char *aad, size_t aad_len, int enc) /* {{{ */
zend_string **poutbuf, int *poutlen, const char *data, size_t data_len,
const char *aad, size_t aad_len, int enc) /* {{{ */
{
int i = 0;
@ -7025,7 +7025,7 @@ static int php_openssl_cipher_update(const EVP_CIPHER *cipher_type,
return FAILURE;
}
if (mode->is_aead && !EVP_CipherUpdate(cipher_ctx, NULL, &i, (unsigned char *)aad, (int)aad_len)) {
if (mode->is_aead && !EVP_CipherUpdate(cipher_ctx, NULL, &i, (const unsigned char *) aad, (int) aad_len)) {
php_openssl_store_errors();
php_error_docref(NULL, E_WARNING, "Setting of additional application data failed");
return FAILURE;
@ -7034,7 +7034,7 @@ static int php_openssl_cipher_update(const EVP_CIPHER *cipher_type,
*poutbuf = zend_string_alloc((int)data_len + EVP_CIPHER_block_size(cipher_type), 0);
if (!EVP_CipherUpdate(cipher_ctx, (unsigned char*)ZSTR_VAL(*poutbuf),
&i, (unsigned char *)data, (int)data_len)) {
&i, (const unsigned char *)data, (int)data_len)) {
/* we don't show warning when we fail but if we ever do, then it should look like this:
if (mode->is_single_run_aead && !enc) {
php_error_docref(NULL, E_WARNING, "Tag verifycation failed");
@ -7054,7 +7054,14 @@ static int php_openssl_cipher_update(const EVP_CIPHER *cipher_type,
/* }}} */
PHP_OPENSSL_API zend_string* php_openssl_encrypt(char *data, size_t data_len, char *method, size_t method_len, char *password, size_t password_len, zend_long options, char *iv, size_t iv_len, zval *tag, zend_long tag_len, char *aad, size_t aad_len)
PHP_OPENSSL_API zend_string* php_openssl_encrypt(
const char *data, size_t data_len,
const char *method, size_t method_len,
const char *password, size_t password_len,
zend_long options,
const char *iv, size_t iv_len,
zval *tag, zend_long tag_len,
const char *aad, size_t aad_len)
{
const EVP_CIPHER *cipher_type;
EVP_CIPHER_CTX *cipher_ctx;
@ -7130,10 +7137,10 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(char *data, size_t data_len, ch
}
if (free_password) {
efree(password);
efree((void *) password);
}
if (free_iv) {
efree(iv);
efree((void *) iv);
}
EVP_CIPHER_CTX_reset(cipher_ctx);
EVP_CIPHER_CTX_free(cipher_ctx);
@ -7163,7 +7170,14 @@ PHP_FUNCTION(openssl_encrypt)
}
/* }}} */
PHP_OPENSSL_API zend_string* php_openssl_decrypt(char *data, size_t data_len, char *method, size_t method_len, char *password, size_t password_len, zend_long options, char *iv, size_t iv_len, char *tag, zend_long tag_len, char *aad, size_t aad_len)
PHP_OPENSSL_API zend_string* php_openssl_decrypt(
const char *data, size_t data_len,
const char *method, size_t method_len,
const char *password, size_t password_len,
zend_long options,
const char *iv, size_t iv_len,
const char *tag, zend_long tag_len,
const char *aad, size_t aad_len)
{
const EVP_CIPHER *cipher_type;
EVP_CIPHER_CTX *cipher_ctx;
@ -7222,10 +7236,10 @@ PHP_OPENSSL_API zend_string* php_openssl_decrypt(char *data, size_t data_len, ch
}
if (free_password) {
efree(password);
efree((void *) password);
}
if (free_iv) {
efree(iv);
efree((void *) iv);
}
if (base64_str) {
zend_string_release_ex(base64_str, 0);
@ -7262,7 +7276,7 @@ PHP_FUNCTION(openssl_decrypt)
}
/* }}} */
PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(char *method)
PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(const char *method)
{
const EVP_CIPHER *cipher_type;

View File

@ -92,16 +92,24 @@ php_stream_transport_factory_func php_openssl_ssl_socket_factory;
void php_openssl_store_errors();
PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(char *method);
PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(const char *method);
PHP_OPENSSL_API zend_string* php_openssl_random_pseudo_bytes(zend_long length);
PHP_OPENSSL_API zend_string* php_openssl_encrypt(char *data, size_t data_len,
char *method, size_t method_len, char *password,
size_t password_len, zend_long options, char *iv, size_t iv_len,
zval *tag, zend_long tag_len, char *aad, size_t add_len);
PHP_OPENSSL_API zend_string* php_openssl_decrypt(char *data, size_t data_len,
char *method, size_t method_len, char *password,
size_t password_len, zend_long options, char *iv, size_t iv_len,
char *tag, zend_long tag_len, char *aad, size_t add_len);
PHP_OPENSSL_API zend_string* php_openssl_encrypt(
const char *data, size_t data_len,
const char *method, size_t method_len,
const char *password, size_t password_len,
zend_long options,
const char *iv, size_t iv_len,
zval *tag, zend_long tag_len,
const char *aad, size_t aad_len);
PHP_OPENSSL_API zend_string* php_openssl_decrypt(
const char *data, size_t data_len,
const char *method, size_t method_len,
const char *password, size_t password_len,
zend_long options,
const char *iv, size_t iv_len,
const char *tag, zend_long tag_len,
const char *aad, size_t aad_len);
PHP_MINIT_FUNCTION(openssl);
PHP_MSHUTDOWN_FUNCTION(openssl);

View File

@ -555,12 +555,12 @@ static zend_string **make_subpats_table(uint32_t num_subpats, pcre_cache_entry *
/* {{{ static calculate_unit_length */
/* Calculates the byte length of the next character. Assumes valid UTF-8 for PCRE2_UTF. */
static zend_always_inline size_t calculate_unit_length(pcre_cache_entry *pce, char *start)
static zend_always_inline size_t calculate_unit_length(pcre_cache_entry *pce, const char *start)
{
size_t unit_len;
if (pce->compile_options & PCRE2_UTF) {
char *end = start;
const char *end = start;
/* skip continuation bytes */
while ((*++end & 0xC0) == 0x80);
@ -1038,7 +1038,7 @@ static inline void add_offset_pair(
/* }}} */
static void populate_subpat_array(
zval *subpats, char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names,
zval *subpats, const char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names,
uint32_t num_subpats, int count, const PCRE2_SPTR mark, zend_long flags) {
zend_bool offset_capture = (flags & PREG_OFFSET_CAPTURE) != 0;
zend_bool unmatched_as_null = (flags & PREG_UNMATCHED_AS_NULL) != 0;
@ -1531,7 +1531,7 @@ static int preg_get_backref(char **str, int *backref)
/* {{{ preg_do_repl_func
*/
static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cache *fcc, char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names, uint32_t num_subpats, int count, const PCRE2_SPTR mark, zend_long flags)
static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cache *fcc, const char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names, uint32_t num_subpats, int count, const PCRE2_SPTR mark, zend_long flags)
{
zend_string *result_str;
zval retval; /* Function return value */
@ -1570,7 +1570,7 @@ static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cach
*/
PHPAPI zend_string *php_pcre_replace(zend_string *regex,
zend_string *subject_str,
char *subject, size_t subject_len,
const char *subject, size_t subject_len,
zend_string *replace_str,
size_t limit, size_t *replace_count)
{
@ -1596,7 +1596,7 @@ PHPAPI zend_string *php_pcre_replace(zend_string *regex,
/* }}} */
/* {{{ php_pcre_replace_impl() */
PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count)
PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count)
{
uint32_t options; /* Execution options */
int count; /* Count of matched subpatterns */
@ -1610,10 +1610,10 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
size_t last_end_offset; /* Where the last search ended */
char *walkbuf, /* Location of current replacement in the result */
*walk, /* Used to walk the replacement string */
*match, /* The current match */
*piece, /* The current piece of subject */
*replace_end, /* End of replacement string */
walk_last; /* Last walked character */
const char *match, /* The current match */
*piece, /* The current piece of subject */
*replace_end; /* End of replacement string */
size_t result_len; /* Length of result */
zend_string *result; /* Result of replacement */
pcre2_match_data *match_data;
@ -1838,7 +1838,7 @@ error:
/* }}} */
/* {{{ php_pcre_replace_func_impl() */
static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, size_t subject_len, zend_fcall_info *fci, zend_fcall_info_cache *fcc, size_t limit, size_t *replace_count, zend_long flags)
static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_fcall_info *fci, zend_fcall_info_cache *fcc, size_t limit, size_t *replace_count, zend_long flags)
{
uint32_t options; /* Execution options */
int count; /* Count of matched subpatterns */
@ -1849,7 +1849,7 @@ static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_strin
size_t alloc_len; /* Actual allocated length */
PCRE2_SIZE start_offset; /* Where the new search starts */
size_t last_end_offset; /* Where the last search ended */
char *match, /* The current match */
const char *match, /* The current match */
*piece; /* The current piece of subject */
size_t result_len; /* Length of result */
zend_string *result; /* Result of replacement */

View File

@ -25,7 +25,7 @@
#include <locale.h>
PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count);
PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count);
PHPAPI pcre2_code* pcre_get_compiled_regex(zend_string *regex, uint32_t *capture_count);
PHPAPI pcre2_code* pcre_get_compiled_regex_ex(zend_string *regex, uint32_t *capture_count, uint32_t *preg_options, uint32_t *coptions);
@ -53,7 +53,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, zval *return_value,
zval *subpats, int global, int use_flags, zend_long flags, zend_off_t start_offset);
PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str,
PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str,
size_t limit, size_t *replace_count);
PHPAPI void php_pcre_split_impl( pcre_cache_entry *pce, zend_string *subject_str, zval *return_value,

View File

@ -36,12 +36,12 @@
#define YYFILL(n) { RET(PDO_PARSER_EOI); }
typedef struct Scanner {
char *ptr, *cur, *tok, *end;
const char *ptr, *cur, *tok, *end;
} Scanner;
static int scan(Scanner *s)
{
char *cursor = s->cur;
const char *cursor = s->cur;
s->tok = cursor;
/*!re2c
@ -68,9 +68,9 @@ static int scan(Scanner *s)
}
struct placeholder {
char *pos;
const char *pos;
size_t len;
size_t qlen; /* quoted length of value */
size_t qlen; /* quoted length of value */
char *quoted; /* quoted value */
int freeq;
int bindno;
@ -81,11 +81,12 @@ static void free_param_name(zval *el) {
efree(Z_PTR_P(el));
}
PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len,
PDO_API int pdo_parse_params(pdo_stmt_t *stmt, const char *inquery, size_t inquery_len,
char **outquery, size_t *outquery_len)
{
Scanner s;
char *ptr, *newbuffer;
const char *ptr;
char *newbuffer;
ptrdiff_t t;
uint32_t bindno = 0;
int ret = 0, escapes = 0;

View File

@ -677,7 +677,7 @@ PDO_API int php_pdo_parse_data_source(const char *data_source,
PDO_API zend_class_entry *php_pdo_get_dbh_ce(void);
PDO_API zend_class_entry *php_pdo_get_exception(void);
PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len,
PDO_API int pdo_parse_params(pdo_stmt_t *stmt, const char *inquery, size_t inquery_len,
char **outquery, size_t *outquery_len);
PDO_API void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt,

View File

@ -168,12 +168,12 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
case PHAR_MIME_OTHER:
/* send headers, output file contents */
efree(basename);
ctr.line_len = spprintf(&(ctr.line), 0, "Content-type: %s", mime_type);
ctr.line_len = spprintf((char **) &(ctr.line), 0, "Content-type: %s", mime_type);
sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
efree(ctr.line);
ctr.line_len = spprintf(&(ctr.line), 0, "Content-length: %u", info->uncompressed_filesize);
efree((void *) ctr.line);
ctr.line_len = spprintf((char **) &(ctr.line), 0, "Content-length: %u", info->uncompressed_filesize);
sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
efree(ctr.line);
efree((void *) ctr.line);
if (FAILURE == sapi_send_headers()) {
zend_bailout();
@ -790,9 +790,9 @@ PHP_METHOD(Phar, webPhar)
ctr.response_code = 0;
if (path_info[strlen(path_info)-1] == '/') {
ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry + 1);
ctr.line_len = spprintf((char **) &(ctr.line), 4096, "Location: %s%s", path_info, entry + 1);
} else {
ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry);
ctr.line_len = spprintf((char **) &(ctr.line), 4096, "Location: %s%s", path_info, entry);
}
if (not_cgi) {
@ -805,7 +805,7 @@ PHP_METHOD(Phar, webPhar)
sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
sapi_send_headers();
efree(ctr.line);
efree((void *) ctr.line);
zend_bailout();
}
}

View File

@ -247,7 +247,7 @@ PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS);
PHPAPI int php_session_validate_sid(PS_VALIDATE_SID_ARGS);
PHPAPI int php_session_update_timestamp(PS_UPDATE_TIMESTAMP_ARGS);
PHPAPI void session_adapt_url(const char *, size_t, char **, size_t *);
PHPAPI void session_adapt_url(const char *url, size_t url_len, char **new_url, size_t *new_len);
PHPAPI int php_session_destroy(void);
PHPAPI void php_add_session_var(zend_string *name);
@ -260,12 +260,11 @@ PHPAPI int php_session_register_serializer(const char *name,
zend_string *(*encode)(PS_SERIALIZER_ENCODE_ARGS),
int (*decode)(PS_SERIALIZER_DECODE_ARGS));
PHPAPI void php_session_set_id(char *id);
PHPAPI int php_session_start(void);
PHPAPI int php_session_flush(int write);
PHPAPI const ps_module *_php_find_ps_module(char *name);
PHPAPI const ps_serializer *_php_find_ps_serializer(char *name);
PHPAPI const ps_module *_php_find_ps_module(const char *name);
PHPAPI const ps_serializer *_php_find_ps_serializer(const char *name);
PHPAPI int php_session_valid_key(const char *key);
PHPAPI int php_session_reset_id(void);

View File

@ -1374,7 +1374,7 @@ static int php_session_send_cookie(void) /* {{{ */
}
/* }}} */
PHPAPI const ps_module *_php_find_ps_module(char *name) /* {{{ */
PHPAPI const ps_module *_php_find_ps_module(const char *name) /* {{{ */
{
const ps_module *ret = NULL;
const ps_module **mod;
@ -1390,7 +1390,7 @@ PHPAPI const ps_module *_php_find_ps_module(char *name) /* {{{ */
}
/* }}} */
PHPAPI const ps_serializer *_php_find_ps_serializer(char *name) /* {{{ */
PHPAPI const ps_serializer *_php_find_ps_serializer(const char *name) /* {{{ */
{
const ps_serializer *ret = NULL;
const ps_serializer *mod;
@ -1648,10 +1648,10 @@ static int php_session_reset(void) /* {{{ */
/* This API is not used by any PHP modules including session currently.
session_adapt_url() may be used to set Session ID to target url without
starting "URL-Rewriter" output handler. */
PHPAPI void session_adapt_url(const char *url, size_t urllen, char **new, size_t *newlen) /* {{{ */
PHPAPI void session_adapt_url(const char *url, size_t url_len, char **new_url, size_t *new_len) /* {{{ */
{
if (APPLY_TRANS_SID && (PS(session_status) == php_session_active)) {
*new = php_url_scanner_adapt_single_url(url, urllen, PS(session_name), ZSTR_VAL(PS(id)), newlen, 1);
*new_url = php_url_scanner_adapt_single_url(url, url_len, PS(session_name), ZSTR_VAL(PS(id)), new_len, 1);
}
}
/* }}} */

View File

@ -1472,13 +1472,13 @@ PHP_FUNCTION(error_log)
/* }}} */
/* For BC (not binary-safe!) */
PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers) /* {{{ */
PHPAPI int _php_error_log(int opt_err, const char *message, const char *opt, const char *headers) /* {{{ */
{
return _php_error_log_ex(opt_err, message, (opt_err == 3) ? strlen(message) : 0, opt, headers);
}
/* }}} */
PHPAPI int _php_error_log_ex(int opt_err, char *message, size_t message_len, char *opt, char *headers) /* {{{ */
PHPAPI int _php_error_log_ex(int opt_err, const char *message, size_t message_len, const char *opt, const char *headers) /* {{{ */
{
php_stream *stream = NULL;
size_t nbytes;
@ -1870,7 +1870,7 @@ PHP_FUNCTION(register_shutdown_function)
}
/* }}} */
PHPAPI zend_bool register_user_shutdown_function(char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry) /* {{{ */
PHPAPI zend_bool register_user_shutdown_function(const char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry) /* {{{ */
{
if (!BG(user_shutdown_function_names)) {
ALLOC_HASHTABLE(BG(user_shutdown_function_names));
@ -1882,7 +1882,7 @@ PHPAPI zend_bool register_user_shutdown_function(char *function_name, size_t fun
}
/* }}} */
PHPAPI zend_bool remove_user_shutdown_function(char *function_name, size_t function_len) /* {{{ */
PHPAPI zend_bool remove_user_shutdown_function(const char *function_name, size_t function_len) /* {{{ */
{
if (BG(user_shutdown_function_names)) {
return zend_hash_str_del(BG(user_shutdown_function_names), function_name, function_len) != FAILURE;

View File

@ -47,8 +47,8 @@ PHP_RSHUTDOWN_FUNCTION(user_filters);
PHP_RSHUTDOWN_FUNCTION(browscap);
/* Left for BC (not binary safe!) */
PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers);
PHPAPI int _php_error_log_ex(int opt_err, char *message, size_t message_len, char *opt, char *headers);
PHPAPI int _php_error_log(int opt_err, const char *message, const char *opt, const char *headers);
PHPAPI int _php_error_log_ex(int opt_err, const char *message, size_t message_len, const char *opt, const char *headers);
PHPAPI int php_prefix_varname(zval *result, zend_string *prefix, const char *var_name, size_t var_name_len, zend_bool add_underscore);
#define MT_N (624)
@ -150,8 +150,8 @@ typedef struct _php_shutdown_function_entry {
int arg_count;
} php_shutdown_function_entry;
PHPAPI extern zend_bool register_user_shutdown_function(char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry);
PHPAPI extern zend_bool remove_user_shutdown_function(char *function_name, size_t function_len);
PHPAPI extern zend_bool register_user_shutdown_function(const char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry);
PHPAPI extern zend_bool remove_user_shutdown_function(const char *function_name, size_t function_len);
PHPAPI extern zend_bool append_user_shutdown_function(php_shutdown_function_entry shutdown_function_entry);
PHPAPI void php_call_shutdown_functions(void);

View File

@ -70,7 +70,7 @@ PHPAPI PHP_FUNCTION(dl)
/* {{{ php_load_shlib
*/
PHPAPI void *php_load_shlib(char *path, char **errp)
PHPAPI void *php_load_shlib(const char *path, char **errp)
{
void *handle;
char *err;
@ -98,7 +98,7 @@ PHPAPI void *php_load_shlib(char *path, char **errp)
/* {{{ php_load_extension
*/
PHPAPI int php_load_extension(char *filename, int type, int start_now)
PHPAPI int php_load_extension(const char *filename, int type, int start_now)
{
void *handle;
char *libpath;
@ -243,35 +243,47 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now)
}
/* }}} */
#else
static void php_dl_error(const char *filename)
{
php_error_docref(NULL, E_WARNING, "Cannot dynamically load %s - dynamic modules are not supported", filename);
}
PHPAPI void *php_load_shlib(const char *path, char **errp)
{
php_dl_error(filename);
(*errp) = estrdup("No DL support");
}
PHPAPI int php_load_extension(const char *filename, int type, int start_now)
{
php_dl_error(filename);
return FAILURE;
}
#endif
/* {{{ php_dl
*/
PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now)
PHPAPI void php_dl(const char *file, int type, zval *return_value, int start_now)
{
/* Load extension */
if (php_load_extension(file, type, start_now) == FAILURE) {
RETVAL_FALSE;
} else {
RETVAL_TRUE;
}
/* Load extension */
if (php_load_extension(file, type, start_now) == FAILURE) {
RETVAL_FALSE;
} else {
RETVAL_TRUE;
}
}
/* }}} */
PHP_MINFO_FUNCTION(dl)
{
php_info_print_table_row(2, "Dynamic Library Support", "enabled");
}
#if defined(HAVE_LIBDL)
#define PHP_DL_SUPPORT_STATUS "enabled"
#else
PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now)
{
php_error_docref(NULL, E_WARNING, "Cannot dynamically load %s - dynamic modules are not supported", file);
RETVAL_FALSE;
}
PHP_MINFO_FUNCTION(dl)
{
PUTS("Dynamic Library support not available<br />.\n");
}
#define PHP_DL_SUPPORT_STATUS "unavailable"
#endif
php_info_print_table_row(2, "Dynamic Library Support", PHP_DL_SUPPORT_STATUS);
}

View File

@ -19,9 +19,9 @@
#ifndef DL_H
#define DL_H
PHPAPI int php_load_extension(char *filename, int type, int start_now);
PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now);
PHPAPI void *php_load_shlib(char *path, char **errp);
PHPAPI int php_load_extension(const char *filename, int type, int start_now);
PHPAPI void php_dl(const char *file, int type, zval *return_value, int start_now);
PHPAPI void *php_load_shlib(const char *path, char **errp);
/* dynamic loading functions */
PHPAPI PHP_FUNCTION(dl);

View File

@ -111,7 +111,7 @@ static size_t handle_line(int type, zval *array, char *buf, size_t bufl) {
* If type==3, output will be printed binary, no lines will be saved or returned (passthru)
*
*/
PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value)
PHPAPI int php_exec(int type, const char *cmd, zval *array, zval *return_value)
{
FILE *fp;
char *buf;
@ -282,7 +282,7 @@ PHP_FUNCTION(passthru)
*NOT* safe for binary strings
*/
PHPAPI zend_string *php_escape_shell_cmd(char *str)
PHPAPI zend_string *php_escape_shell_cmd(const char *str)
{
register size_t x, y;
size_t l = strlen(str);
@ -389,7 +389,7 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str)
/* {{{ php_escape_shell_arg
*/
PHPAPI zend_string *php_escape_shell_arg(char *str)
PHPAPI zend_string *php_escape_shell_arg(const char *str)
{
size_t x, y = 0;
size_t l = strlen(str);

View File

@ -20,8 +20,8 @@
PHP_MINIT_FUNCTION(proc_open);
PHP_MINIT_FUNCTION(exec);
PHPAPI zend_string *php_escape_shell_cmd(char *);
PHPAPI zend_string *php_escape_shell_arg(char *);
PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value);
PHPAPI zend_string *php_escape_shell_cmd(const char *str);
PHPAPI zend_string *php_escape_shell_arg(const char *str);
PHPAPI int php_exec(int type, const char *cmd, zval *array, zval *return_value);
#endif /* EXEC_H */

View File

@ -34,15 +34,17 @@ PHP_FUNCTION(header)
{
zend_bool rep = 1;
sapi_header_line ctr = {0};
char *line;
size_t len;
ZEND_PARSE_PARAMETERS_START(1, 3)
Z_PARAM_STRING(ctr.line, len)
Z_PARAM_STRING(line, len)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(rep)
Z_PARAM_LONG(ctr.response_code)
ZEND_PARSE_PARAMETERS_END();
ctr.line = line;
ctr.line_len = (uint32_t)len;
sapi_header_op(rep ? SAPI_HEADER_REPLACE:SAPI_HEADER_ADD, &ctr);
}
@ -53,13 +55,15 @@ PHP_FUNCTION(header)
PHP_FUNCTION(header_remove)
{
sapi_header_line ctr = {0};
char *line = NULL;
size_t len = 0;
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(ctr.line, len)
Z_PARAM_STRING(line, len)
ZEND_PARSE_PARAMETERS_END();
ctr.line = line;
ctr.line_len = (uint32_t)len;
sapi_header_op(ZEND_NUM_ARGS() == 0 ? SAPI_HEADER_DELETE_ALL : SAPI_HEADER_DELETE, &ctr);
}

View File

@ -367,7 +367,7 @@ static inline unsigned int get_next_char(
/* {{{ entity_charset determine_charset
* Returns the charset identifier based on an explicitly provided charset,
* the internal_encoding and default_charset ini settings, or UTF-8 by default. */
static enum entity_charset determine_charset(char *charset_hint, zend_bool quiet)
static enum entity_charset determine_charset(const char *charset_hint, zend_bool quiet)
{
if (!charset_hint || !*charset_hint) {
charset_hint = get_default_charset();
@ -979,7 +979,7 @@ static entity_table_opt determine_entity_table(int all, int doctype)
* only the basic ones, i.e., those in basic_entities_ex + the numeric entities
* that correspond to quotes.
*/
PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int flags, char *hint_charset)
PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int flags, const char *hint_charset)
{
zend_string *ret;
enum entity_charset charset;
@ -1015,7 +1015,7 @@ PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int fl
}
/* }}} */
PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset)
PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset)
{
return php_escape_html_entities_ex(old, oldlen, all, flags, hint_charset, 1, /* quiet */ 0);
}
@ -1103,7 +1103,7 @@ static inline void find_entity_for_char_basic(
/* {{{ php_escape_html_entities
*/
PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset, zend_bool double_encode, zend_bool quiet)
PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset, zend_bool double_encode, zend_bool quiet)
{
size_t cursor, maxlen, len;
zend_string *replaced;

View File

@ -44,9 +44,9 @@
void register_html_constants(INIT_FUNC_ARGS);
PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset);
PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset, zend_bool double_encode, zend_bool quiet);
PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int flags, char *hint_charset);
PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset);
PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset, zend_bool double_encode, zend_bool quiet);
PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int flags, const char *hint_charset);
PHPAPI unsigned int php_next_utf8_char(const unsigned char *str, size_t str_len, size_t *cursor, int *status);
#endif /* HTML_H */

View File

@ -25,7 +25,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
const char *num_prefix, size_t num_prefix_len,
const char *key_prefix, size_t key_prefix_len,
const char *key_suffix, size_t key_suffix_len,
zval *type, char *arg_sep, int enc_type)
zval *type, const char *arg_sep, int enc_type)
{
zend_string *key = NULL;
char *newprefix, *p;

View File

@ -1293,7 +1293,7 @@ PHP_FUNCTION(image_type_to_extension)
/* {{{ php_imagetype
detect filetype from first bytes */
PHPAPI int php_getimagetype(php_stream * stream, char *input, char *filetype)
PHPAPI int php_getimagetype(php_stream * stream, const char *input, char *filetype)
{
char tmp[12];
int twelve_bytes_read;

View File

@ -57,7 +57,7 @@ static ZEND_COLD int php_info_print_html_esc(const char *str, size_t len) /* {{{
size_t written;
zend_string *new_str;
new_str = php_escape_html_entities((unsigned char *) str, len, 0, ENT_QUOTES, "utf-8");
new_str = php_escape_html_entities((const unsigned char *) str, len, 0, ENT_QUOTES, "utf-8");
written = php_output_write(ZSTR_VAL(new_str), ZSTR_LEN(new_str));
zend_string_free(new_str);
return written;
@ -249,9 +249,9 @@ PHPAPI ZEND_COLD void ZEND_COLD php_info_print_style(void)
/* {{{ php_info_html_esc
*/
PHPAPI ZEND_COLD zend_string *php_info_html_esc(char *string)
PHPAPI ZEND_COLD zend_string *php_info_html_esc(const char *string)
{
return php_escape_html_entities((unsigned char *) string, strlen(string), 0, ENT_QUOTES, NULL);
return php_escape_html_entities((const unsigned char *) string, strlen(string), 0, ENT_QUOTES, NULL);
}
/* }}} */
@ -1095,7 +1095,7 @@ PHPAPI ZEND_COLD void php_info_print_hr(void) /* {{{ */
}
/* }}} */
PHPAPI ZEND_COLD void php_info_print_table_colspan_header(int num_cols, char *header) /* {{{ */
PHPAPI ZEND_COLD void php_info_print_table_colspan_header(int num_cols, const char *header) /* {{{ */
{
int spaces;

File diff suppressed because one or more lines are too long

View File

@ -386,7 +386,7 @@ void php_mail_log_to_file(char *filename, char *message, size_t message_size) {
}
static int php_mail_detect_multiple_crlf(char *hdr) {
static int php_mail_detect_multiple_crlf(const char *hdr) {
/* This function detects multiple/malformed multiple newlines. */
if (!hdr || !strlen(hdr)) {
@ -425,7 +425,7 @@ static int php_mail_detect_multiple_crlf(char *hdr) {
/* {{{ php_mail
*/
PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd)
PHPAPI int php_mail(const char *to, const char *subject, const char *message, const char *headers, const char *extra_cmd)
{
#ifdef PHP_WIN32
int tsm_err;
@ -436,14 +436,15 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
char *sendmail_path = INI_STR("sendmail_path");
char *sendmail_cmd = NULL;
char *mail_log = INI_STR("mail.log");
char *hdr = headers;
const char *hdr = headers;
char *ahdr = NULL;
#if PHP_SIGCHILD
void (*sig_handler)() = NULL;
#endif
#define MAIL_RET(val) \
if (hdr != headers) { \
efree(hdr); \
if (ahdr != NULL) { \
efree(ahdr); \
} \
return val; \
@ -486,10 +487,11 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
f = php_basename(tmp, strlen(tmp), NULL, 0);
if (headers != NULL && *headers) {
spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s\r\n%s", php_getuid(), ZSTR_VAL(f), headers);
spprintf(&ahdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s\r\n%s", php_getuid(), ZSTR_VAL(f), headers);
} else {
spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s", php_getuid(), ZSTR_VAL(f));
spprintf(&ahdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s", php_getuid(), ZSTR_VAL(f));
}
hdr = ahdr;
zend_string_release_ex(f, 0);
}

View File

@ -1026,8 +1026,8 @@ PHPAPI zend_string *_php_math_number_format(double d, int dec, char dec_point, c
return _php_math_number_format_ex(d, dec, &dec_point, 1, &thousand_sep, 1);
}
PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_point,
size_t dec_point_len, char *thousand_sep, size_t thousand_sep_len)
PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, const char *dec_point,
size_t dec_point_len, const char *thousand_sep, size_t thousand_sep_len)
{
zend_string *res;
zend_string *tmpbuf;

View File

@ -24,7 +24,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
const char *num_prefix, size_t num_prefix_len,
const char *key_prefix, size_t key_prefix_len,
const char *key_suffix, size_t key_suffix_len,
zval *type, char *arg_sep, int enc_type);
zval *type, const char *arg_sep, int enc_type);
#define php_url_encode_hash(ht, formstr) php_url_encode_hash_ex((ht), (formstr), NULL, 0, NULL, 0, NULL, 0, NULL)
#endif

View File

@ -50,7 +50,7 @@ typedef enum
PHP_MINIT_FUNCTION(imagetypes);
PHPAPI int php_getimagetype(php_stream *stream, char *input, char *filetype);
PHPAPI int php_getimagetype(php_stream *stream, const char *input, char *filetype);
PHPAPI char * php_image_type_to_mime_type(int image_type);

View File

@ -20,7 +20,7 @@
PHP_MINFO_FUNCTION(mail);
PHPAPI zend_string *php_mail_build_headers(HashTable *headers);
PHPAPI extern int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd);
PHPAPI extern int php_mail(const char *to, const char *subject, const char *message, const char *headers, const char *extra_cmd);
#define PHP_MAIL_BUILD_HEADER_CHECK(target, s, key, val) \
do { \

View File

@ -18,9 +18,9 @@
#ifndef PHP_MATH_H
#define PHP_MATH_H
PHPAPI double _php_math_round(double, int, int);
PHPAPI zend_string *_php_math_number_format(double, int, char, char);
PHPAPI zend_string *_php_math_number_format_ex(double, int, char *, size_t, char *, size_t);
PHPAPI double _php_math_round(double value, int places, int mode);
PHPAPI zend_string *_php_math_number_format(double d, int dec, char dec_point, char thousand_sep);
PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, const char *dec_point, size_t dec_point_len, const char *thousand_sep, size_t thousand_sep_len);
PHPAPI zend_string * _php_math_longtobase(zval *arg, int base);
PHPAPI zend_long _php_math_basetolong(zval *arg, int base);
PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret);

View File

@ -42,22 +42,22 @@ PHPAPI zend_string *php_string_tolower(zend_string *s);
PHPAPI char *php_strtr(char *str, size_t len, const char *str_from, const char *str_to, size_t trlen);
PHPAPI zend_string *php_addslashes(zend_string *str);
PHPAPI void php_stripslashes(zend_string *str);
PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, char *what, size_t what_len);
PHPAPI zend_string *php_addcslashes(zend_string *str, char *what, size_t what_len);
PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, const char *what, size_t what_len);
PHPAPI zend_string *php_addcslashes(zend_string *str, const char *what, size_t what_len);
PHPAPI void php_stripcslashes(zend_string *str);
PHPAPI zend_string *php_basename(const char *s, size_t len, char *suffix, size_t sufflen);
PHPAPI zend_string *php_basename(const char *s, size_t len, const char *suffix, size_t sufflen);
PHPAPI size_t php_dirname(char *str, size_t len);
PHPAPI char *php_stristr(char *s, char *t, size_t s_len, size_t t_len);
PHPAPI zend_string *php_str_to_str(const char *haystack, size_t length, const char *needle,
size_t needle_len, const char *str, size_t str_len);
PHPAPI zend_string *php_trim(zend_string *str, char *what, size_t what_len, int mode);
PHPAPI zend_string *php_trim(zend_string *str, const char *what, size_t what_len, int mode);
PHPAPI size_t php_strip_tags(char *rbuf, size_t len, const char *allow, size_t allow_len);
PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, const char *allow, size_t allow_len, zend_bool allow_tag_spaces);
PHPAPI void php_implode(const zend_string *delim, HashTable *arr, zval *return_value);
PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return_value, zend_long limit);
PHPAPI size_t php_strspn(char *s1, char *s2, char *s1_end, char *s2_end);
PHPAPI size_t php_strcspn(char *s1, char *s2, char *s1_end, char *s2_end);
PHPAPI size_t php_strspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end);
PHPAPI size_t php_strcspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end);
PHPAPI int string_natural_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive);
PHPAPI int string_natural_compare_function(zval *result, zval *op1, zval *op2);

View File

@ -17,7 +17,7 @@
#ifndef PHP_UUENCODE_H
#define PHP_UUENCODE_H
PHPAPI zend_string *php_uudecode(char *src, size_t src_len);
PHPAPI zend_string *php_uuencode(char *src, size_t src_len);
PHPAPI zend_string *php_uudecode(const char *src, size_t src_len);
PHPAPI zend_string *php_uuencode(const char *src, size_t src_len);
#endif /* PHP_UUENCODE_H */

View File

@ -21,7 +21,7 @@
#include "sha1.h"
#include "md5.h"
PHPAPI void make_sha1_digest(char *sha1str, unsigned char *digest)
PHPAPI void make_sha1_digest(char *sha1str, const unsigned char *digest)
{
make_digest_ex(sha1str, digest, 20);
}

View File

@ -29,6 +29,6 @@ typedef struct {
PHPAPI void PHP_SHA1Init(PHP_SHA1_CTX *);
PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, size_t);
PHPAPI void PHP_SHA1Final(unsigned char[20], PHP_SHA1_CTX *);
PHPAPI void make_sha1_digest(char *sha1str, unsigned char *digest);
PHPAPI void make_sha1_digest(char *sha1str, const unsigned char *digest);
#endif

View File

@ -765,7 +765,7 @@ static inline int php_charmask(const unsigned char *input, size_t len, char *mas
* mode 3 : trim left and right
* what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0')
*/
static zend_always_inline zend_string *php_trim_int(zend_string *str, char *what, size_t what_len, int mode)
static zend_always_inline zend_string *php_trim_int(zend_string *str, const char *what, size_t what_len, int mode)
{
const char *start = ZSTR_VAL(str);
const char *end = start + ZSTR_LEN(str);
@ -793,7 +793,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, char *what
}
}
} else {
php_charmask((unsigned char*)what, what_len, mask);
php_charmask((const unsigned char *) what, what_len, mask);
if (mode & 1) {
while (start != end) {
@ -857,7 +857,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, char *what
* mode 3 : trim left and right
* what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0')
*/
PHPAPI zend_string *php_trim(zend_string *str, char *what, size_t what_len, int mode)
PHPAPI zend_string *php_trim(zend_string *str, const char *what, size_t what_len, int mode)
{
return php_trim_int(str, what, what_len, mode);
}
@ -1508,7 +1508,7 @@ PHP_FUNCTION(strtolower)
/* {{{ php_basename
*/
PHPAPI zend_string *php_basename(const char *s, size_t len, char *suffix, size_t suffix_len)
PHPAPI zend_string *php_basename(const char *s, size_t len, const char *suffix, size_t suffix_len)
{
/* State 0 is directly after a directory separator (or at the start of the string).
* State 1 is everything else. */
@ -1745,7 +1745,7 @@ PHPAPI char *php_stristr(char *s, char *t, size_t s_len, size_t t_len)
/* {{{ php_strspn
*/
PHPAPI size_t php_strspn(char *s1, char *s2, char *s1_end, char *s2_end)
PHPAPI size_t php_strspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end)
{
register const char *p = s1, *spanp;
register char c = *p;
@ -1763,7 +1763,7 @@ cont:
/* {{{ php_strcspn
*/
PHPAPI size_t php_strcspn(char *s1, char *s2, char *s1_end, char *s2_end)
PHPAPI size_t php_strcspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end)
{
register const char *p, *spanp;
register char c = *s1;
@ -2720,7 +2720,7 @@ PHP_FUNCTION(ucwords)
RETURN_EMPTY_STRING();
}
php_charmask((unsigned char *)delims, delims_len, mask);
php_charmask((const unsigned char *) delims, delims_len, mask);
ZVAL_STRINGL(return_value, ZSTR_VAL(str), ZSTR_LEN(str));
r = Z_STRVAL_P(return_value);
@ -3642,7 +3642,7 @@ PHPAPI void php_stripcslashes(zend_string *str)
/* {{{ php_addcslashes_str
*/
PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, char *what, size_t wlength)
PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, const char *what, size_t wlength)
{
char flags[256];
char *target;
@ -3651,7 +3651,7 @@ PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, char *what,
size_t newlen;
zend_string *new_str = zend_string_safe_alloc(4, len, 0, 0);
php_charmask((unsigned char *)what, wlength, flags);
php_charmask((const unsigned char *) what, wlength, flags);
for (source = str, end = source + len, target = ZSTR_VAL(new_str); source < end; source++) {
c = *source;
@ -3685,7 +3685,7 @@ PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, char *what,
/* {{{ php_addcslashes
*/
PHPAPI zend_string *php_addcslashes(zend_string *str, char *what, size_t wlength)
PHPAPI zend_string *php_addcslashes(zend_string *str, const char *what, size_t wlength)
{
return php_addcslashes_str(ZSTR_VAL(str), ZSTR_LEN(str), what, wlength);
}
@ -5909,7 +5909,7 @@ PHP_FUNCTION(str_word_count)
}
if (char_list) {
php_charmask((unsigned char *)char_list, char_list_len, ch);
php_charmask((const unsigned char *) char_list, char_list_len, ch);
}
p = ZSTR_VAL(str);

View File

@ -24,10 +24,10 @@ PHP_RINIT_FUNCTION(url_scanner_ex);
PHP_RSHUTDOWN_FUNCTION(url_scanner_ex);
PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen, int encode);
PHPAPI int php_url_scanner_add_session_var(char *name, size_t name_len, char *value, size_t value_len, int encode);
PHPAPI int php_url_scanner_add_session_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode);
PHPAPI int php_url_scanner_reset_session_var(zend_string *name, int encode);
PHPAPI int php_url_scanner_reset_session_vars(void);
PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, size_t value_len, int encode);
PHPAPI int php_url_scanner_add_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode);
PHPAPI int php_url_scanner_reset_var(zend_string *name, int encode);
PHPAPI int php_url_scanner_reset_vars(void);

View File

@ -725,7 +725,7 @@ static void php_url_scanner_output_handler(char *output, size_t output_len, char
php_url_scanner_session_handler_impl(output, output_len, handled_output, handled_output_len, mode, 0);
}
static inline int php_url_scanner_add_var_impl(char *name, size_t name_len, char *value, size_t value_len, int encode, int type)
static inline int php_url_scanner_add_var_impl(const char *name, size_t name_len, const char *value, size_t value_len, int encode, int type)
{
smart_str sname = {0};
smart_str svalue = {0};
@ -758,9 +758,9 @@ static inline int php_url_scanner_add_var_impl(char *name, size_t name_len, char
smart_str_appendl(&sname, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded);
encoded = php_raw_url_encode(value, value_len);
smart_str_appendl(&svalue, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded);
encoded = php_escape_html_entities_ex((unsigned char*)name, name_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, NULL, /* double_encode */ 0, /* quiet */ 1);
encoded = php_escape_html_entities_ex((const unsigned char *) name, name_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, NULL, /* double_encode */ 0, /* quiet */ 1);
smart_str_appendl(&hname, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded);
encoded = php_escape_html_entities_ex((unsigned char*)value, value_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, NULL, /* double_encode */ 0, /* quiet */ 1);
encoded = php_escape_html_entities_ex((const unsigned char *) value, value_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, NULL, /* double_encode */ 0, /* quiet */ 1);
smart_str_appendl(&hvalue, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded);
} else {
smart_str_appendl(&sname, name, name_len);
@ -788,13 +788,13 @@ static inline int php_url_scanner_add_var_impl(char *name, size_t name_len, char
}
PHPAPI int php_url_scanner_add_session_var(char *name, size_t name_len, char *value, size_t value_len, int encode)
PHPAPI int php_url_scanner_add_session_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode)
{
return php_url_scanner_add_var_impl(name, name_len, value, value_len, encode, 1);
}
PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, size_t value_len, int encode)
PHPAPI int php_url_scanner_add_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode)
{
return php_url_scanner_add_var_impl(name, name_len, value, value_len, encode, 0);
}
@ -860,7 +860,7 @@ static inline int php_url_scanner_reset_var_impl(zend_string *name, int encode,
encoded = php_raw_url_encode(ZSTR_VAL(name), ZSTR_LEN(name));
smart_str_appendl(&sname, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
zend_string_free(encoded);
encoded = php_escape_html_entities_ex((unsigned char *)ZSTR_VAL(name), ZSTR_LEN(name), 0, ENT_QUOTES|ENT_SUBSTITUTE, SG(default_charset), /* double_encode */ 0, /* quiet */ 1);
encoded = php_escape_html_entities_ex((const unsigned char *) ZSTR_VAL(name), ZSTR_LEN(name), 0, ENT_QUOTES|ENT_SUBSTITUTE, SG(default_charset), /* double_encode */ 0, /* quiet */ 1);
smart_str_appendl(&hname, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
zend_string_free(encoded);
} else {

View File

@ -61,10 +61,11 @@
#define PHP_UU_DEC(c) (((c) - ' ') & 077)
PHPAPI zend_string *php_uuencode(char *src, size_t src_len) /* {{{ */
PHPAPI zend_string *php_uuencode(const char *src, size_t src_len) /* {{{ */
{
size_t len = 45;
unsigned char *p, *s, *e, *ee;
unsigned char *p;
const unsigned char *s, *e, *ee;
zend_string *dest;
/* encoded length is ~ 38% greater than the original
@ -125,10 +126,11 @@ PHPAPI zend_string *php_uuencode(char *src, size_t src_len) /* {{{ */
}
/* }}} */
PHPAPI zend_string *php_uudecode(char *src, size_t src_len) /* {{{ */
PHPAPI zend_string *php_uudecode(const char *src, size_t src_len) /* {{{ */
{
size_t len, total_len=0;
char *s, *e, *p, *ee;
char *p;
const char *s, *e, *ee;
zend_string *dest;
dest = zend_string_alloc((size_t) ceil(src_len * 0.75), 0);

View File

@ -610,7 +610,7 @@ static void sapi_remove_header(zend_llist *l, char *name, size_t len) {
}
}
SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace)
SAPI_API int sapi_add_header_ex(const char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace)
{
sapi_header_line ctr = {0};
int r;
@ -622,7 +622,7 @@ SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_
&ctr);
if (!duplicate)
efree(header_line);
efree((void *) header_line);
return r;
}
@ -682,7 +682,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
if (!p->line || !p->line_len) {
return FAILURE;
}
header_line = p->line;
header_line = estrndup(p->line, p->line_len);
header_line_len = p->line_len;
http_response_code = p->response_code;
break;
@ -699,8 +699,6 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
return FAILURE;
}
header_line = estrndup(header_line, header_line_len);
/* cut off trailing spaces, linefeeds and carriage-returns */
if (header_line_len && isspace(header_line[header_line_len-1])) {
do {
@ -982,7 +980,7 @@ SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zva
return SUCCESS;
}
SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void))
SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void))
{
if (SG(sapi_started) && EG(current_execute_data)) {
return FAILURE;
@ -1014,7 +1012,7 @@ SAPI_API zend_stat_t *sapi_get_stat(void)
}
}
SAPI_API char *sapi_getenv(char *name, size_t name_len)
SAPI_API char *sapi_getenv(const char *name, size_t name_len)
{
if (!strncasecmp(name, "HTTP_PROXY", name_len)) {
/* Ugly fix for HTTP_PROXY issue, see bug #72573 */
@ -1101,10 +1099,10 @@ SAPI_API void sapi_terminate_process(void) {
}
}
SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */
SAPI_API void sapi_add_request_header(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */
{
zval *return_value = (zval*)arg;
char *str = NULL;
char *buf = NULL;
ALLOCA_FLAG(use_heap)
@ -1115,11 +1113,12 @@ SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val
var[3] == 'P' &&
var[4] == '_') {
char *p;
const char *p;
char *str;
var_len -= 5;
p = var + 5;
var = str = do_alloca(var_len + 1, use_heap);
var = str = buf = do_alloca(var_len + 1, use_heap);
*str++ = *p++;
while (*p) {
if (*p == '_') {
@ -1145,8 +1144,8 @@ SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val
return;
}
add_assoc_stringl_ex(return_value, var, var_len, val, val_len);
if (str) {
free_alloca(var, use_heap);
if (buf) {
free_alloca(buf, use_heap);
}
}
/* }}} */

View File

@ -145,7 +145,7 @@ SAPI_API void sapi_shutdown(void);
SAPI_API void sapi_activate(void);
SAPI_API void sapi_deactivate(void);
SAPI_API void sapi_initialize_empty_request(void);
SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
SAPI_API void sapi_add_request_header(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
END_EXTERN_C()
/*
@ -160,7 +160,7 @@ END_EXTERN_C()
*/
typedef struct {
char *line; /* If you allocated this, you need to free it yourself */
const char *line; /* If you allocated this, you need to free it yourself */
size_t line_len;
zend_long response_code; /* long due to zend_parse_parameters compatibility */
} sapi_header_line;
@ -177,7 +177,7 @@ BEGIN_EXTERN_C()
SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg);
/* Deprecated functions. Use sapi_header_op instead. */
SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace);
SAPI_API int sapi_add_header_ex(const char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace);
#define sapi_add_header(a, b, c) sapi_add_header_ex((a),(b),(c),1)
@ -190,11 +190,11 @@ SAPI_API int sapi_register_post_entry(const sapi_post_entry *post_entry);
SAPI_API void sapi_unregister_post_entry(const sapi_post_entry *post_entry);
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(void));
SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray));
SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void));
SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void));
SAPI_API int sapi_flush(void);
SAPI_API zend_stat_t *sapi_get_stat(void);
SAPI_API char *sapi_getenv(char *name, size_t name_len);
SAPI_API char *sapi_getenv(const char *name, size_t name_len);
SAPI_API char *sapi_get_default_content_type(void);
SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header);
@ -223,7 +223,7 @@ struct _sapi_module_struct {
size_t (*ub_write)(const char *str, size_t str_length);
void (*flush)(void *server_context);
zend_stat_t *(*get_stat)(void);
char *(*getenv)(char *name, size_t name_len);
char *(*getenv)(const char *name, size_t name_len);
void (*sapi_error)(int type, const char *error_msg, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
@ -235,7 +235,7 @@ struct _sapi_module_struct {
char *(*read_cookies)(void);
void (*register_server_variables)(zval *track_vars_array);
void (*log_message)(char *message, int syslog_type_int);
void (*log_message)(const char *message, int syslog_type_int);
double (*get_request_time)(void);
void (*terminate_process)(void);
@ -255,7 +255,7 @@ struct _sapi_module_struct {
int (*get_target_uid)(uid_t *);
int (*get_target_gid)(gid_t *);
unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len);
unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len);
void (*ini_defaults)(HashTable *configuration_hash);
int phpinfo_as_text;
@ -288,7 +288,7 @@ struct _sapi_post_entry {
#define SAPI_POST_HANDLER_FUNC(post_handler) void post_handler(char *content_type_dup, void *arg)
#define SAPI_TREAT_DATA_FUNC(treat_data) void treat_data(int arg, char *str, zval* destArray)
#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len)
#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len)
BEGIN_EXTERN_C()
SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data);

View File

@ -75,7 +75,7 @@ typedef enum _fcgi_protocol_status {
/* FastCGI client API */
typedef void (*fcgi_apply_func)(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
typedef void (*fcgi_apply_func)(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
#define FCGI_HASH_TABLE_SIZE 128
#define FCGI_HASH_TABLE_MASK (FCGI_HASH_TABLE_SIZE - 1)

View File

@ -822,7 +822,7 @@ PHPAPI int php_get_module_initialized(void)
/* {{{ php_log_err_with_severity
*/
PHPAPI ZEND_COLD void php_log_err_with_severity(char *log_message, int syslog_type_int)
PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int)
{
int fd = -1;
time_t error_time;

View File

@ -768,7 +768,7 @@ PHPAPI php_socket_t php_network_accept_incoming(php_socket_t srvsock,
/* {{{ php_network_connect_socket_to_host */
php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short port,
int socktype, int asynchronous, struct timeval *timeout, zend_string **error_string,
int *error_code, char *bindto, unsigned short bindport, long sockopts
int *error_code, const char *bindto, unsigned short bindport, long sockopts
)
{
int num_addrs, n, fatal = 0;
@ -1307,7 +1307,7 @@ struct hostent * gethostname_re (const char *host,struct hostent *hostbuf,char *
#endif
#endif
PHPAPI struct hostent* php_network_gethostbyname(char *name) {
PHPAPI struct hostent* php_network_gethostbyname(const char *name) {
#if !defined(HAVE_GETHOSTBYNAME_R)
return gethostbyname(name);
#else

View File

@ -318,7 +318,7 @@ PHPAPI int php_get_module_initialized(void);
#else
#define php_log_err(msg) php_log_err_with_severity(msg, 5)
#endif
PHPAPI ZEND_COLD void php_log_err_with_severity(char *log_message, int syslog_type_int);
PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int);
int Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
int cfgparse(void);
END_EXTERN_C()

View File

@ -778,7 +778,7 @@ void php_ini_register_extensions(void)
/* {{{ php_parse_user_ini_file
*/
PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash)
PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename, HashTable *target_hash)
{
zend_stat_t sb;
char ini_file[MAXPATHLEN];

View File

@ -29,7 +29,7 @@ PHPAPI zval *cfg_get_entry(const char *name, size_t name_length);
PHPAPI int cfg_get_long(const char *varname, zend_long *result);
PHPAPI int cfg_get_double(const char *varname, double *result);
PHPAPI int cfg_get_string(const char *varname, char **result);
PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash);
PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename, HashTable *target_hash);
PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage);
PHPAPI int php_ini_has_per_dir_config(void);
PHPAPI int php_ini_has_per_host_config(void);

View File

@ -40,12 +40,12 @@
BEGIN_EXTERN_C()
PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC);
PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC);
PHPAPI php_stream *_php_stream_memory_open(int mode, const char *buf, size_t length STREAMS_DC);
PHPAPI char *_php_stream_memory_get_buffer(php_stream *stream, size_t *length STREAMS_DC);
PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC);
PHPAPI php_stream *_php_stream_temp_create_ex(int mode, size_t max_memory_usage, const char *tmpdir STREAMS_DC);
PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC);
PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, const char *buf, size_t length STREAMS_DC);
PHPAPI int php_stream_mode_from_str(const char *mode);
PHPAPI const char *_php_stream_mode_to_str(int mode);

View File

@ -241,7 +241,7 @@ PHPAPI void php_network_freeaddresses(struct sockaddr **sal);
PHPAPI php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short port,
int socktype, int asynchronous, struct timeval *timeout, zend_string **error_string,
int *error_code, char *bindto, unsigned short bindport, long sockopts
int *error_code, const char *bindto, unsigned short bindport, long sockopts
);
PHPAPI int php_network_connect_socket(php_socket_t sockfd,
@ -315,7 +315,7 @@ PHPAPI void php_network_populate_name_from_sockaddr(
PHPAPI int php_network_parse_network_address_with_port(const char *addr,
zend_long addrlen, struct sockaddr *sa, socklen_t *sl);
PHPAPI struct hostent* php_network_gethostbyname(char *name);
PHPAPI struct hostent* php_network_gethostbyname(const char *name);
PHPAPI int php_set_sock_blocking(php_socket_t socketd, int block);
END_EXTERN_C()

View File

@ -30,13 +30,13 @@
void _php_import_environment_variables(zval *array_ptr);
PHPAPI void (*php_import_environment_variables)(zval *array_ptr) = _php_import_environment_variables;
PHPAPI void php_register_variable(char *var, char *strval, zval *track_vars_array)
PHPAPI void php_register_variable(const char *var, const char *strval, zval *track_vars_array)
{
php_register_variable_safe(var, strval, strlen(strval), track_vars_array);
}
/* binary-safe version */
PHPAPI void php_register_variable_safe(char *var, char *strval, size_t str_len, zval *track_vars_array)
PHPAPI void php_register_variable_safe(const char *var, const char *strval, size_t str_len, zval *track_vars_array)
{
zval new_entry;
assert(strval != NULL);
@ -60,7 +60,7 @@ static zend_always_inline void php_register_variable_quick(const char *name, siz
zend_string_release_ex(key, 0);
}
PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars_array)
PHPAPI void php_register_variable_ex(const char *var_name, zval *val, zval *track_vars_array)
{
char *p = NULL;
char *ip = NULL; /* index pointer */
@ -593,11 +593,10 @@ zend_bool php_std_auto_global_callback(char *name, uint32_t name_len)
/* {{{ php_build_argv
*/
PHPAPI void php_build_argv(char *s, zval *track_vars_array)
PHPAPI void php_build_argv(const char *s, zval *track_vars_array)
{
zval arr, argc, tmp;
int count = 0;
char *ss, *space;
if (!(SG(request_info).argc || track_vars_array)) {
return;
@ -615,24 +614,18 @@ PHPAPI void php_build_argv(char *s, zval *track_vars_array)
}
}
} else if (s && *s) {
ss = s;
while (ss) {
space = strchr(ss, '+');
if (space) {
*space = '\0';
}
while (1) {
const char *space = strchr(s, '+');
/* auto-type */
ZVAL_STRING(&tmp, ss);
ZVAL_STRINGL(&tmp, s, space ? space - s : strlen(s));
count++;
if (zend_hash_next_index_insert(Z_ARRVAL(arr), &tmp) == NULL) {
zend_string_efree(Z_STR(tmp));
}
if (space) {
*space = '+';
ss = space + 1;
} else {
ss = space;
if (!space) {
break;
}
s = space + 1;
}
}

View File

@ -32,12 +32,12 @@
BEGIN_EXTERN_C()
void php_startup_auto_globals(void);
extern PHPAPI void (*php_import_environment_variables)(zval *array_ptr);
PHPAPI void php_register_variable(char *var, char *val, zval *track_vars_array);
PHPAPI void php_register_variable(const char *var, const char *val, zval *track_vars_array);
/* binary-safe version */
PHPAPI void php_register_variable_safe(char *var, char *val, size_t val_len, zval *track_vars_array);
PHPAPI void php_register_variable_ex(char *var, zval *val, zval *track_vars_array);
PHPAPI void php_register_variable_safe(const char *var, const char *val, size_t val_len, zval *track_vars_array);
PHPAPI void php_register_variable_ex(const char *var, zval *val, zval *track_vars_array);
PHPAPI void php_build_argv(char *s, zval *track_vars_array);
PHPAPI void php_build_argv(const char *s, zval *track_vars_array);
PHPAPI int php_hash_environment(void);
END_EXTERN_C()

View File

@ -315,7 +315,7 @@ PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC)
/* {{{ */
PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC)
PHPAPI php_stream *_php_stream_memory_open(int mode, const char *buf, size_t length STREAMS_DC)
{
php_stream *stream;
php_stream_memory_data *ms;
@ -325,7 +325,7 @@ PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length ST
if (mode == TEMP_STREAM_READONLY || mode == TEMP_STREAM_TAKE_BUFFER) {
/* use the buffer directly */
ms->data = buf;
ms->data = (char *) buf;
ms->fsize = length;
} else {
if (length) {
@ -598,7 +598,7 @@ PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STR
/* }}} */
/* {{{ _php_stream_temp_open */
PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC)
PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, const char *buf, size_t length STREAMS_DC)
{
php_stream *stream;
php_stream_temp_data *ts;

View File

@ -243,7 +243,7 @@ php_apache_sapi_read_cookies(void)
}
static char *
php_apache_sapi_getenv(char *name, size_t name_len)
php_apache_sapi_getenv(const char *name, size_t name_len)
{
php_struct *ctx = SG(server_context);
const char *env_var;
@ -305,7 +305,7 @@ php_apache_sapi_flush(void *server_context)
}
}
static void php_apache_sapi_log_message(char *msg, int syslog_type_int)
static void php_apache_sapi_log_message(const char *msg, int syslog_type_int)
{
php_struct *ctx;
int aplog_type = APLOG_ERR;
@ -354,7 +354,7 @@ static void php_apache_sapi_log_message(char *msg, int syslog_type_int)
}
}
static void php_apache_sapi_log_message_ex(char *msg, request_rec *r)
static void php_apache_sapi_log_message_ex(const char *msg, request_rec *r)
{
if (r) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, msg, r->filename);

View File

@ -553,7 +553,7 @@ static char *cgi_getenv_win32(const char *name, size_t name_len)
}
#endif
static char *sapi_cgi_getenv(char *name, size_t name_len)
static char *sapi_cgi_getenv(const char *name, size_t name_len)
{
#ifndef PHP_WIN32
return getenv(name);
@ -562,7 +562,7 @@ static char *sapi_cgi_getenv(char *name, size_t name_len)
#endif
}
static char *sapi_fcgi_getenv(char *name, size_t name_len)
static char *sapi_fcgi_getenv(const char *name, size_t name_len)
{
/* when php is started by mod_fastcgi, no regular environment
* is provided to PHP. It is always sent to PHP at the start
@ -646,10 +646,10 @@ static char *sapi_fcgi_read_cookies(void)
return FCGI_GETENV(request, "HTTP_COOKIE");
}
static void cgi_php_load_env_var(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg)
static void cgi_php_load_env_var(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg)
{
zval *array_ptr = (zval*)arg;
int filter_arg = (Z_ARR_P(array_ptr) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV]))?PARSE_ENV:PARSE_SERVER;
zval *array_ptr = (zval *) arg;
int filter_arg = (Z_ARR_P(array_ptr) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV])) ? PARSE_ENV : PARSE_SERVER;
size_t new_val_len;
if (sapi_module.input_filter(filter_arg, var, &val, strlen(val), &new_val_len)) {
@ -747,7 +747,7 @@ static void sapi_cgi_register_variables(zval *track_vars_array)
}
}
static void sapi_cgi_log_message(char *message, int syslog_type_int)
static void sapi_cgi_log_message(const char *message, int syslog_type_int)
{
if (fcgi_is_fastcgi() && CGIG(fcgi_logging)) {
fcgi_request *request;

View File

@ -354,7 +354,7 @@ static void sapi_cli_register_variables(zval *track_vars_array) /* {{{ */
}
/* }}} */
static void sapi_cli_log_message(char *message, int syslog_type_int) /* {{{ */
static void sapi_cli_log_message(const char *message, int syslog_type_int) /* {{{ */
{
fprintf(stderr, "%s\n", message);
#ifdef PHP_WIN32

View File

@ -748,7 +748,7 @@ static void sapi_cli_server_register_variables(zval *track_vars_array) /* {{{ */
zend_hash_apply_with_arguments(&client->request.headers, (apply_func_args_t)sapi_cli_server_register_entry_cb, 1, track_vars_array);
} /* }}} */
static void sapi_cli_server_log_write(int type, char *msg) /* {{{ */
static void sapi_cli_server_log_write(int type, const char *msg) /* {{{ */
{
char buf[52];
@ -777,7 +777,7 @@ static void sapi_cli_server_log_write(int type, char *msg) /* {{{ */
#endif
} /* }}} */
static void sapi_cli_server_log_message(char *msg, int syslog_type_int) /* {{{ */
static void sapi_cli_server_log_message(const char *msg, int syslog_type_int) /* {{{ */
{
sapi_cli_server_log_write(PHP_CLI_SERVER_LOG_MESSAGE, msg);
} /* }}} */
@ -1979,7 +1979,7 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server
php_cli_server_content_sender_ctor(&client->content_sender);
client->content_sender_initialized = 1;
escaped_request_uri = php_escape_html_entities_ex((unsigned char *)client->request.request_uri, client->request.request_uri_len, 0, ENT_QUOTES, NULL, /* double_encode */ 0, /* quiet */ 0);
escaped_request_uri = php_escape_html_entities_ex((const unsigned char *) client->request.request_uri, client->request.request_uri_len, 0, ENT_QUOTES, NULL, /* double_encode */ 0, /* quiet */ 0);
{
static const char prologue_template[] = "<!doctype html><html><head><title>%d %s</title>";

View File

@ -91,9 +91,9 @@ static void php_embed_send_header(sapi_header_struct *sapi_header, void *server_
{
}
static void php_embed_log_message(char *message, int syslog_type_int)
static void php_embed_log_message(const char *message, int syslog_type_int)
{
fprintf (stderr, "%s\n", message);
fprintf(stderr, "%s\n", message);
}
static void php_embed_register_variables(zval *track_vars_array)

View File

@ -107,7 +107,7 @@ static int parent = 1;
static int request_body_fd;
static int fpm_is_running = 0;
static char *sapi_cgibin_getenv(char *name, size_t name_len);
static char *sapi_cgibin_getenv(const char *name, size_t name_len);
static void fastcgi_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg);
#define PHP_MODE_STANDARD 1
@ -464,7 +464,7 @@ static size_t sapi_cgi_read_post(char *buffer, size_t count_bytes) /* {{{ */
}
/* }}} */
static char *sapi_cgibin_getenv(char *name, size_t name_len) /* {{{ */
static char *sapi_cgibin_getenv(const char *name, size_t name_len) /* {{{ */
{
/* if fpm has started, use fcgi env */
if (fpm_is_running) {
@ -501,10 +501,10 @@ static char *sapi_cgi_read_cookies(void) /* {{{ */
}
/* }}} */
static void cgi_php_load_env_var(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */
static void cgi_php_load_env_var(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */
{
zval *array_ptr = (zval*)arg;
int filter_arg = (Z_ARR_P(array_ptr) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV]))?PARSE_ENV:PARSE_SERVER;
zval *array_ptr = (zval *) arg;
int filter_arg = (Z_ARR_P(array_ptr) == Z_ARR(PG(http_globals)[TRACK_VARS_ENV])) ? PARSE_ENV : PARSE_SERVER;
size_t new_val_len;
if (sapi_module.input_filter(filter_arg, var, &val, strlen(val), &new_val_len)) {
@ -607,7 +607,7 @@ void sapi_cgi_log_fastcgi(int level, char *message, size_t len)
/* {{{ sapi_cgi_log_message
*/
static void sapi_cgi_log_message(char *message, int syslog_type_int)
static void sapi_cgi_log_message(const char *message, int syslog_type_int)
{
zlog_msg(ZLOG_NOTICE, "PHP message: ", message);
}

View File

@ -48,7 +48,7 @@ static int fpm_php_zend_ini_alter_master(char *name, int name_length, char *new_
}
/* }}} */
static void fpm_php_disable(char *value, int (*zend_disable)(char *, size_t)) /* {{{ */
static void fpm_php_disable(char *value, int (*zend_disable)(const char *, size_t)) /* {{{ */
{
char *s = 0, *e = value;

View File

@ -488,7 +488,7 @@ int fpm_status_handle_request(void) /* {{{ */
if (!encode) {
query_string = proc.query_string;
} else {
tmp_query_string = php_escape_html_entities_ex((unsigned char *)proc.query_string, strlen(proc.query_string), 1, ENT_HTML_IGNORE_ERRORS & ENT_COMPAT, NULL, /* double_encode */ 1, /* quiet */ 0);
tmp_query_string = php_escape_html_entities_ex((const unsigned char *) proc.query_string, strlen(proc.query_string), 1, ENT_HTML_IGNORE_ERRORS & ENT_COMPAT, NULL, /* double_encode */ 1, /* quiet */ 0);
query_string = ZSTR_VAL(tmp_query_string);
}
}

View File

@ -72,7 +72,7 @@ static void register_variables(zval *track_vars_array)
php_import_environment_variables(track_vars_array);
}
static void log_message(char *message, int level)
static void log_message(const char *message, int level)
{
}

View File

@ -191,7 +191,7 @@ static int sapi_lsapi_deactivate(void)
/* {{{ sapi_lsapi_getenv
*/
static char *sapi_lsapi_getenv( char * name, size_t name_len )
static char *sapi_lsapi_getenv(const char * name, size_t name_len )
{
if ( lsapi_mode ) {
return LSAPI_GetEnv( name );
@ -509,7 +509,7 @@ static int sapi_lsapi_send_headers(sapi_headers_struct *sapi_headers)
/* {{{ sapi_lsapi_send_headers
*/
static void sapi_lsapi_log_message(char *message, int syslog_type_int)
static void sapi_lsapi_log_message(const char *message, int syslog_type_int)
{
char buf[8192];
int len = strlen( message );
@ -521,7 +521,7 @@ static void sapi_lsapi_log_message(char *message, int syslog_type_int)
len = 8191;
++len;
}
LSAPI_Write_Stderr( message, len);
LSAPI_Write_Stderr( message, len );
}
/* }}} */

View File

@ -772,7 +772,7 @@ static void php_sapi_phpdbg_send_header(sapi_header_struct *sapi_header, void *s
}
/* }}} */
static void php_sapi_phpdbg_log_message(char *message, int syslog_type_int) /* {{{ */
static void php_sapi_phpdbg_log_message(const char *message, int syslog_type_int) /* {{{ */
{
/*
* We must not request TSRM before being booted

View File

@ -737,10 +737,9 @@ PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, zend_bool allow_async
return SUCCESS;
} /* }}} */
PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */
PHPDBG_API char *phpdbg_read_input(const char *buffered) /* {{{ */
{
char buf[PHPDBG_MAX_CMD];
char *cmd = NULL;
char *buffer = NULL;
if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) != PHPDBG_IS_STOPPING) {
@ -755,11 +754,12 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */
#endif
{
phpdbg_write("prompt", "", "%s", phpdbg_get_prompt());
phpdbg_consume_stdin_line(cmd = buf);
phpdbg_consume_stdin_line(buf);
buffer = estrdup(buf);
}
#ifdef HAVE_PHPDBG_READLINE
else {
cmd = readline(phpdbg_get_prompt());
char *cmd = readline(phpdbg_get_prompt());
PHPDBG_G(last_was_newline) = 1;
if (!cmd) {
@ -768,19 +768,13 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */
}
add_history(cmd);
buffer = estrdup(cmd);
free(cmd);
}
#endif
} else {
cmd = buffered;
buffer = estrdup(buffered);
}
buffer = estrdup(cmd);
#ifdef HAVE_PHPDBG_READLINE
if (!buffered && cmd && !(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && isatty(PHPDBG_G(io)[PHPDBG_STDIN].fd)) {
free(cmd);
}
#endif
}
if (buffer && isspace(*buffer)) {

View File

@ -125,8 +125,8 @@ typedef struct {
/*
* Input Management
*/
PHPDBG_API char* phpdbg_read_input(char *buffered);
PHPDBG_API void phpdbg_destroy_input(char**);
PHPDBG_API char *phpdbg_read_input(const char *buffered);
PHPDBG_API void phpdbg_destroy_input(char **input);
PHPDBG_API int phpdbg_ask_user_permission(const char *question);
/**

View File

@ -375,7 +375,7 @@ void phpdbg_print_opcodes_class(const char *class) {
phpdbg_print_opcodes_ce(ce);
}
PHPDBG_API void phpdbg_print_opcodes(char *function)
PHPDBG_API void phpdbg_print_opcodes(const char *function)
{
if (function == NULL) {
phpdbg_print_opcodes_main();
@ -401,12 +401,12 @@ PHPDBG_API void phpdbg_print_opcodes(char *function)
}
} ZEND_HASH_FOREACH_END();
} else {
function = zend_str_tolower_dup(function, strlen(function));
char *function_lowercase = zend_str_tolower_dup(function, strlen(function));
if (strstr(function, "::") == NULL) {
phpdbg_print_opcodes_function(function, strlen(function));
if (strstr(function_lowercase, "::") == NULL) {
phpdbg_print_opcodes_function(function_lowercase, strlen(function_lowercase));
} else {
char *method_name, *class_name = strtok(function, "::");
char *method_name, *class_name = strtok(function_lowercase, "::");
if ((method_name = strtok(NULL, "::")) == NULL) {
phpdbg_print_opcodes_class(class_name);
} else {
@ -414,6 +414,6 @@ PHPDBG_API void phpdbg_print_opcodes(char *function)
}
}
efree(function);
efree(function_lowercase);
}
}

View File

@ -33,7 +33,7 @@ PHPDBG_PRINT(method);
PHPDBG_PRINT(func);
PHPDBG_PRINT(stack);
PHPDBG_API void phpdbg_print_opcodes(char *function);
PHPDBG_API void phpdbg_print_opcodes(const char *function);
extern const phpdbg_command_t phpdbg_print_commands[];

View File

@ -122,7 +122,7 @@ static char *ErrorMessages[] =
* Returns NULL on error, or the new char* buffer on success.
* You have to take care and efree() the buffer on your own.
*/
static zend_string *php_win32_mail_trim_header(char *header)
static zend_string *php_win32_mail_trim_header(const char *header)
{
zend_string *result, *result2;
zend_string *replace;
@ -176,14 +176,14 @@ static zend_string *php_win32_mail_trim_header(char *header)
//
// See SendText() for additional args!
//********************************************************************/
PHPAPI int TSendMail(char *host, int *error, char **error_message,
char *headers, char *Subject, char *mailTo, char *data,
PHPAPI int TSendMail(const char *host, int *error, char **error_message,
const char *headers, const char *Subject, const char *mailTo, const char *data,
char *mailCc, char *mailBcc, char *mailRPath)
{
int ret;
char *RPath = NULL;
zend_string *headers_lc = NULL, *headers_trim = NULL; /* headers_lc is only created if we've a header at all */
char *pos1 = NULL, *pos2 = NULL;
const char *pos1 = NULL, *pos2 = NULL;
if (host == NULL) {
*error = BAD_MAIL_HOST;
@ -216,7 +216,7 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
RPath = estrdup(INI_STR("sendmail_from"));
} else if (headers_lc) {
int found = 0;
char *lookup = ZSTR_VAL(headers_lc);
const char *lookup = ZSTR_VAL(headers_lc);
while (lookup) {
pos1 = strstr(lookup, "from:");
@ -352,12 +352,13 @@ PHPAPI char *GetSMErrorText(int index)
// Author/Date: jcar 20/9/96
// History:
//*******************************************************************/
static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailBcc, char *data,
char *headers, char *headers_lc, char **error_message)
static int SendText(char *RPath, const char *Subject, const char *mailTo, char *mailCc, char *mailBcc, const char *data,
const char *headers, char *headers_lc, char **error_message)
{
int res;
char *p;
char *tempMailTo, *token, *pos1, *pos2;
char *tempMailTo, *token;
const char *pos1, *pos2;
char *server_response = NULL;
char *stripped_header = NULL;
zend_string *data_cln;
@ -633,7 +634,7 @@ static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char
return (SUCCESS);
}
static int addToHeader(char **header_buffer, const char *specifier, char *string)
static int addToHeader(char **header_buffer, const char *specifier, const char *string)
{
*header_buffer = erealloc(*header_buffer, strlen(*header_buffer) + strlen(specifier) + strlen(string) + 1);
sprintf(*header_buffer + strlen(*header_buffer), specifier, string);
@ -651,7 +652,7 @@ static int addToHeader(char **header_buffer, const char *specifier, char *string
// Author/Date: jcar 20/9/96
// History:
//********************************************************************/
static int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders)
static int PostHeader(char *RPath, const char *Subject, const char *mailTo, char *xheaders)
{
/* Print message header according to RFC 822 */
/* Return-path, Received, Date, From, Subject, Sender, To, cc */

View File

@ -32,16 +32,16 @@
#define MAX_ERROR_INDEX 22 /* Always last error message + 1 */
PHPAPI int TSendMail(char *smtpaddr, int *returnerror, char **error_message,
char *RPath, char *Subject, char *mailTo, char *data,
PHPAPI int TSendMail(const char *host, int *error, char **error_message,
const char *headers, const char *Subject, const char *mailTo, const char *data,
char *mailCc, char *mailBcc, char *mailRPath);
PHPAPI void TSMClose(void);
static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailBcc, char *data,
char *headers, char *headers_lc, char **error_message);
static int SendText(char *RPath, const char *Subject, const char *mailTo, char *mailCc, char *mailBcc, const char *data,
const char *headers, char *headers_lc, char **error_message);
PHPAPI char *GetSMErrorText(int index);
static int MailConnect();
static int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders);
static int PostHeader(char *RPath, const char *Subject, const char *mailTo, char *xheaders);
static int Post(LPCSTR msg);
static int Ack(char **server_response);
static unsigned long GetAddr(LPSTR szHost);