char **argv = NULL, **envp = NULL;
char **current_arg, **pair;
int pair_length;
- char *key;
- uint key_length;
+ zend_string *key;
char *path;
- int path_len;
- ulong key_num;
+ size_t path_len;
+ zend_ulong key_num;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|aa", &path, &path_len, &args, &envs) == FAILURE) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|aa", &path, &path_len, &args, &envs) == FAILURE) {
++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|aa", &path, &path_len, &args, &envs) == FAILURE) {
return;
}
php_stream_context *context = NULL;
php_stream *dirp;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|r", &dirname, &dir_len, &zcontext) == FAILURE) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|r", &dirname, &dir_len, &zcontext) == FAILURE) {
++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|r", &dirname, &dir_len, &zcontext) == FAILURE) {
RETURN_NULL();
}
PHP_FUNCTION(chroot)
{
char *str;
- int ret, str_len;
+ int ret;
+ size_t str_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str, &str_len) == FAILURE) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &str, &str_len) == FAILURE) {
++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &str, &str_len) == FAILURE) {
RETURN_FALSE;
}
PHP_FUNCTION(tempnam)
{
char *dir, *prefix;
- int dir_len, prefix_len;
- size_t p_len;
- char *opened_path;
- char *p;
+ size_t dir_len, prefix_len;
+ zend_string *opened_path;
int fd;
+ zend_string *p;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &dir, &dir_len, &prefix, &prefix_len) == FAILURE) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pp", &dir, &dir_len, &prefix, &prefix_len) == FAILURE) {
++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &dir, &dir_len, &prefix, &prefix_len) == FAILURE) {
return;
}
zval *zcontext = NULL;
php_stream_context *context;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|r", &dir, &dir_len, &zcontext) == FAILURE) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|r", &dir, &dir_len, &zcontext) == FAILURE) {
++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|r", &dir, &dir_len, &zcontext) == FAILURE) {
RETURN_FALSE;
}
#include "php_variables.h"
#include "rfc1867.h"
#include "ext/standard/php_string.h"
-#include "ext/standard/php_smart_str.h"
++#include "ext/standard/php_smart_string.h"
#if defined(PHP_WIN32) && !defined(HAVE_ATOLL)
# define atoll(s) _atoi64(s)
}
/* parse headers */
-static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header TSRMLS_DC)
+static int multipart_buffer_headers(multipart_buffer *self, zend_llist *header)
{
char *line;
- mime_header_entry prev_entry = {0}, entry;
- int prev_len, cur_len;
+ mime_header_entry entry = {0};
- smart_str buf_value = {0};
++ smart_string buf_value = {0};
+ char *key = NULL;
/* didn't find boundary, abort */
- if (!find_boundary(self, self->boundary TSRMLS_CC)) {
+ if (!find_boundary(self, self->boundary)) {
return 0;
}
/* get lines of text, or CRLF_CRLF */
- while( (line = get_line(self TSRMLS_CC)) && line[0] != '\0' )
+ while( (line = get_line(self)) && line[0] != '\0' )
{
/* add header to table */
- char *key = line;
char *value = NULL;
- if (php_rfc1867_encoding_translation(TSRMLS_C)) {
- self->input_encoding = zend_multibyte_encoding_detector((unsigned char *)line, strlen(line), self->detect_order, self->detect_order_size TSRMLS_CC);
+ if (php_rfc1867_encoding_translation()) {
+ self->input_encoding = zend_multibyte_encoding_detector((const unsigned char *) line, strlen(line), self->detect_order, self->detect_order_size);
}
/* space in the beginning means same header */
}
if (value) {
- *value = 0;
+ if(buf_value.c && key) {
+ /* new entry, add the old one to the list */
- smart_str_0(&buf_value);
++ smart_string_0(&buf_value);
+ entry.key = key;
+ entry.value = buf_value.c;
+ zend_llist_add_element(header, &entry);
+ buf_value.c = NULL;
+ key = NULL;
+ }
+
+ *value = '\0';
do { value++; } while(isspace(*value));
- entry.value = estrdup(value);
- entry.key = estrdup(key);
-
- } else if (zend_llist_count(header)) { /* If no ':' on the line, add to previous line */
-
- prev_len = (int)strlen(prev_entry.value);
- cur_len = (int)strlen(line);
-
- entry.value = emalloc(prev_len + cur_len + 1);
- memcpy(entry.value, prev_entry.value, prev_len);
- memcpy(entry.value + prev_len, line, cur_len);
- entry.value[cur_len + prev_len] = '\0';
-
- entry.key = estrdup(prev_entry.key);
-
- zend_llist_remove_tail(header);
+ key = estrdup(line);
- smart_str_appends(&buf_value, value);
++ smart_string_appends(&buf_value, value);
+ } else if (buf_value.c) { /* If no ':' on the line, add to previous line */
- smart_str_appends(&buf_value, line);
++ smart_string_appends(&buf_value, line);
} else {
continue;
}
- smart_str_0(&buf_value);
+ }
+
+ if(buf_value.c && key) {
+ /* add the last one to the list */
++ smart_string_0(&buf_value);
+ entry.key = key;
+ entry.value = buf_value.c;
zend_llist_add_element(header, &entry);
- prev_entry = entry;
}
return 1;