Diff for /embedaddon/php/ext/standard/streamsfuncs.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 23:48:02 version 1.1.1.2, 2012/05/29 12:34:43
Line 106  PHP_FUNCTION(stream_socket_client) Line 106  PHP_FUNCTION(stream_socket_client)
   
         context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT);          context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT);
   
         if (context) {  
                 zend_list_addref(context->rsrc_id);  
         }  
   
         if (flags & PHP_STREAM_CLIENT_PERSISTENT) {          if (flags & PHP_STREAM_CLIENT_PERSISTENT) {
                 spprintf(&hashkey, 0, "stream_socket_client__%s", host);                  spprintf(&hashkey, 0, "stream_socket_client__%s", host);
         }          }
Line 132  PHP_FUNCTION(stream_socket_client) Line 128  PHP_FUNCTION(stream_socket_client)
                 ZVAL_STRING(zerrstr, "", 1);                  ZVAL_STRING(zerrstr, "", 1);
         }          }
   
        stream = php_stream_xport_create(host, host_len, ENFORCE_SAFE_MODE | REPORT_ERRORS,        stream = php_stream_xport_create(host, host_len, REPORT_ERRORS,
                         STREAM_XPORT_CLIENT | (flags & PHP_STREAM_CLIENT_CONNECT ? STREAM_XPORT_CONNECT : 0) |                          STREAM_XPORT_CLIENT | (flags & PHP_STREAM_CLIENT_CONNECT ? STREAM_XPORT_CONNECT : 0) |
                         (flags & PHP_STREAM_CLIENT_ASYNC_CONNECT ? STREAM_XPORT_CONNECT_ASYNC : 0),                          (flags & PHP_STREAM_CLIENT_ASYNC_CONNECT ? STREAM_XPORT_CONNECT_ASYNC : 0),
                         hashkey, &tv, context, &errstr, &err);                          hashkey, &tv, context, &errstr, &err);
Line 208  PHP_FUNCTION(stream_socket_server) Line 204  PHP_FUNCTION(stream_socket_server)
                 ZVAL_STRING(zerrstr, "", 1);                  ZVAL_STRING(zerrstr, "", 1);
         }          }
   
        stream = php_stream_xport_create(host, host_len, ENFORCE_SAFE_MODE | REPORT_ERRORS,        stream = php_stream_xport_create(host, host_len, REPORT_ERRORS,
                         STREAM_XPORT_SERVER | flags,                          STREAM_XPORT_SERVER | flags,
                         NULL, NULL, context, &errstr, &err);                          NULL, NULL, context, &errstr, &err);
   
Line 395  PHP_FUNCTION(stream_socket_recvfrom) Line 391  PHP_FUNCTION(stream_socket_recvfrom)
                 }                  }
                 read_buf[recvd] = '\0';                  read_buf[recvd] = '\0';
   
                if (PG(magic_quotes_runtime)) {                RETURN_STRINGL(read_buf, recvd, 0);
                        Z_TYPE_P(return_value) = IS_STRING; 
                        Z_STRVAL_P(return_value) = php_addslashes(Z_STRVAL_P(return_value), Z_STRLEN_P(return_value), &Z_STRLEN_P(return_value), 1 TSRMLS_CC); 
                        return; 
                } else { 
                        RETURN_STRINGL(read_buf, recvd, 0); 
                } 
         }          }
   
         efree(read_buf);          efree(read_buf);
Line 417  PHP_FUNCTION(stream_get_contents) Line 407  PHP_FUNCTION(stream_get_contents)
         zval            *zsrc;          zval            *zsrc;
         long            maxlen          = PHP_STREAM_COPY_ALL,          long            maxlen          = PHP_STREAM_COPY_ALL,
                                 desiredpos      = -1L;                                  desiredpos      = -1L;
        int                     len,        int                     len;
                                newlen; 
         char            *contents       = NULL;          char            *contents       = NULL;
   
         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|ll", &zsrc, &maxlen, &desiredpos) == FAILURE) {          if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|ll", &zsrc, &maxlen, &desiredpos) == FAILURE) {
Line 450  PHP_FUNCTION(stream_get_contents) Line 439  PHP_FUNCTION(stream_get_contents)
         len = php_stream_copy_to_mem(stream, &contents, maxlen, 0);          len = php_stream_copy_to_mem(stream, &contents, maxlen, 0);
   
         if (contents) {          if (contents) {
                 if (len && PG(magic_quotes_runtime)) {  
                         contents = php_addslashes(contents, len, &newlen, 1 TSRMLS_CC); /* 1 = free source string */  
                         len = newlen;  
                 }  
                 RETVAL_STRINGL(contents, len, 0);                  RETVAL_STRINGL(contents, len, 0);
         } else {          } else {
                 RETVAL_EMPTY_STRING();                  RETVAL_EMPTY_STRING();
Line 557  PHP_FUNCTION(stream_get_transports) Line 542  PHP_FUNCTION(stream_get_transports)
 {  {
         HashTable *stream_xport_hash;          HashTable *stream_xport_hash;
         char *stream_xport;          char *stream_xport;
        int stream_xport_len;        uint stream_xport_len;
         ulong num_key;          ulong num_key;
   
         if (zend_parse_parameters_none() == FAILURE) {          if (zend_parse_parameters_none() == FAILURE) {
Line 586  PHP_FUNCTION(stream_get_wrappers) Line 571  PHP_FUNCTION(stream_get_wrappers)
 {  {
         HashTable *url_stream_wrappers_hash;          HashTable *url_stream_wrappers_hash;
         char *stream_protocol;          char *stream_protocol;
        int key_flags, stream_protocol_len = 0;        int key_flags;
         uint stream_protocol_len = 0;
         ulong num_key;          ulong num_key;
   
         if (zend_parse_parameters_none() == FAILURE) {          if (zend_parse_parameters_none() == FAILURE) {
Line 662  static int stream_array_from_fd_set(zval *stream_array Line 648  static int stream_array_from_fd_set(zval *stream_array
         zend_hash_init(new_hash, zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);          zend_hash_init(new_hash, zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);
   
         for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));          for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
                 zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == SUCCESS;                 zend_hash_has_more_elements(Z_ARRVAL_P(stream_array)) == SUCCESS;
                  zend_hash_move_forward(Z_ARRVAL_P(stream_array))) {                   zend_hash_move_forward(Z_ARRVAL_P(stream_array))) {
   
                   int type;
                   char *key;
                   uint key_len;
                   ulong num_ind;
   
                   type = zend_hash_get_current_key_ex(Z_ARRVAL_P(stream_array),
                                   &key, &key_len, &num_ind, 0, NULL);
                   if (type == HASH_KEY_NON_EXISTANT ||
                           zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == FAILURE) {
                           continue; /* should not happen */
                   }
   
                 php_stream_from_zval_no_verify(stream, elem);                  php_stream_from_zval_no_verify(stream, elem);
                 if (stream == NULL) {                  if (stream == NULL) {
                         continue;                          continue;
Line 676  static int stream_array_from_fd_set(zval *stream_array Line 674  static int stream_array_from_fd_set(zval *stream_array
                  */                   */
                 if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1) && this_fd != -1) {                  if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1) && this_fd != -1) {
                         if (PHP_SAFE_FD_ISSET(this_fd, fds)) {                          if (PHP_SAFE_FD_ISSET(this_fd, fds)) {
                                zend_hash_next_index_insert(new_hash, (void *)elem, sizeof(zval *), (void **)&dest_elem);                                if (type == HASH_KEY_IS_LONG) {
                                         zend_hash_index_update(new_hash, num_ind, (void *)elem, sizeof(zval *), (void **)&dest_elem);
                                 } else { /* HASH_KEY_IS_STRING */
                                         zend_hash_update(new_hash, key, key_len, (void *)elem, sizeof(zval *), (void **)&dest_elem);
                                 }
                                 
                                 if (dest_elem) {                                  if (dest_elem) {
                                         zval_add_ref(dest_elem);                                          zval_add_ref(dest_elem);
                                 }                                  }
Line 907  static int parse_context_options(php_stream_context *c Line 910  static int parse_context_options(php_stream_context *c
         HashPosition pos, opos;          HashPosition pos, opos;
         zval **wval, **oval;          zval **wval, **oval;
         char *wkey, *okey;          char *wkey, *okey;
        int wkey_len, okey_len;        uint wkey_len, okey_len;
         int ret = SUCCESS;          int ret = SUCCESS;
         ulong num_key;          ulong num_key;
   
Line 970  static php_stream_context *decode_context_param(zval * Line 973  static php_stream_context *decode_context_param(zval *
 {  {
         php_stream_context *context = NULL;          php_stream_context *context = NULL;
   
        context = zend_fetch_resource(&contextresource TSRMLS_CC, -1, NULL, NULL, 1, php_le_stream_context());        context = zend_fetch_resource(&contextresource TSRMLS_CC, -1, NULL, NULL, 1, php_le_stream_context(TSRMLS_C));
         if (context == NULL) {          if (context == NULL) {
                 php_stream *stream;                  php_stream *stream;
   
Line 983  static php_stream_context *decode_context_param(zval * Line 986  static php_stream_context *decode_context_param(zval *
                                    param, but then something is called which requires a context.                                     param, but then something is called which requires a context.
                                    Don't give them the default one though since they already said they                                     Don't give them the default one though since they already said they
                                    didn't want it. */                                     didn't want it. */
                                context = stream->context = php_stream_context_alloc();                                context = stream->context = php_stream_context_alloc(TSRMLS_C);
                         }                          }
                 }                  }
         }          }
Line 1109  PHP_FUNCTION(stream_context_get_default) Line 1112  PHP_FUNCTION(stream_context_get_default)
         }          }
   
         if (FG(default_context) == NULL) {          if (FG(default_context) == NULL) {
                FG(default_context) = php_stream_context_alloc();                FG(default_context) = php_stream_context_alloc(TSRMLS_C);
         }          }
         context = FG(default_context);          context = FG(default_context);
   
Line 1133  PHP_FUNCTION(stream_context_set_default) Line 1136  PHP_FUNCTION(stream_context_set_default)
         }          }
   
         if (FG(default_context) == NULL) {          if (FG(default_context) == NULL) {
                FG(default_context) = php_stream_context_alloc();                FG(default_context) = php_stream_context_alloc(TSRMLS_C);
         }          }
         context = FG(default_context);          context = FG(default_context);
   
Line 1154  PHP_FUNCTION(stream_context_create) Line 1157  PHP_FUNCTION(stream_context_create)
                 RETURN_FALSE;                  RETURN_FALSE;
         }          }
   
        context = php_stream_context_alloc();        context = php_stream_context_alloc(TSRMLS_C);
   
         if (options) {          if (options) {
                 parse_context_options(context, options TSRMLS_CC);                  parse_context_options(context, options TSRMLS_CC);
Line 1413  PHP_FUNCTION(stream_set_write_buffer) Line 1416  PHP_FUNCTION(stream_set_write_buffer)
         }          }
   
         RETURN_LONG(ret == 0 ? 0 : EOF);          RETURN_LONG(ret == 0 ? 0 : EOF);
   }
   /* }}} */
   
   /* {{{ proto int stream_set_chunk_size(resource fp, int chunk_size)
      Set the stream chunk size */
   PHP_FUNCTION(stream_set_chunk_size)
   {
           int                     ret;
           long            csize;
           zval            *zstream;
           php_stream      *stream;
   
           if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &zstream, &csize) == FAILURE) {
                   RETURN_FALSE;
           }
   
           if (csize <= 0) {
                   php_error_docref(NULL TSRMLS_CC, E_WARNING, "The chunk size must be a positive integer, given %ld", csize);
                   RETURN_FALSE;
           }
           /* stream.chunk_size is actually a size_t, but php_stream_set_option 
            * can only use an int to accept the new value and return the old one.
            * In any case, values larger than INT_MAX for a chunk size make no sense.
            */
           if (csize > INT_MAX) {
                   php_error_docref(NULL TSRMLS_CC, E_WARNING, "The chunk size cannot be larger than %d", INT_MAX);
                   RETURN_FALSE;
           }
           
           php_stream_from_zval(stream, &zstream);
   
           ret = php_stream_set_option(stream, PHP_STREAM_OPTION_SET_CHUNK_SIZE, (int)csize, NULL);
           
           RETURN_LONG(ret > 0 ? (long)ret : (long)EOF);
 }  }
 /* }}} */  /* }}} */
   

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>