Back to index

php5  5.3.10
Classes | Defines | Functions | Variables
memory.c File Reference
#include "php.h"

Go to the source code of this file.

Classes

struct  php_stream_memory_data
struct  php_stream_temp_data

Defines

#define _GNU_SOURCE

Functions

PHPAPI int php_url_decode (char *str, int len)
PHPAPI unsigned char * php_base64_decode (const unsigned char *str, int length, int *ret_length)
static size_t php_stream_memory_write (php_stream *stream, const char *buf, size_t count TSRMLS_DC)
static size_t php_stream_memory_read (php_stream *stream, char *buf, size_t count TSRMLS_DC)
static int php_stream_memory_close (php_stream *stream, int close_handle TSRMLS_DC)
static int php_stream_memory_flush (php_stream *stream TSRMLS_DC)
static int php_stream_memory_seek (php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
static int php_stream_memory_cast (php_stream *stream, int castas, void **ret TSRMLS_DC)
static int php_stream_memory_stat (php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC)
static int php_stream_memory_set_option (php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC)
PHPAPI php_stream * _php_stream_memory_create (int mode STREAMS_DC TSRMLS_DC)
PHPAPI php_stream * _php_stream_memory_open (int mode, char *buf, size_t length STREAMS_DC TSRMLS_DC)
PHPAPI char * _php_stream_memory_get_buffer (php_stream *stream, size_t *length STREAMS_DC TSRMLS_DC)
static size_t php_stream_temp_write (php_stream *stream, const char *buf, size_t count TSRMLS_DC)
static size_t php_stream_temp_read (php_stream *stream, char *buf, size_t count TSRMLS_DC)
static int php_stream_temp_close (php_stream *stream, int close_handle TSRMLS_DC)
static int php_stream_temp_flush (php_stream *stream TSRMLS_DC)
static int php_stream_temp_seek (php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC)
static int php_stream_temp_cast (php_stream *stream, int castas, void **ret TSRMLS_DC)
static int php_stream_temp_stat (php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC)
static int php_stream_temp_set_option (php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC)
PHPAPI php_stream * _php_stream_temp_create (int mode, size_t max_memory_usage STREAMS_DC TSRMLS_DC)
PHPAPI php_stream * _php_stream_temp_open (int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC TSRMLS_DC)
static php_stream * php_stream_url_wrap_rfc2397 (php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)

Variables

PHPAPI php_stream_ops php_stream_memory_ops
PHPAPI php_stream_ops php_stream_temp_ops
PHPAPI php_stream_ops php_stream_rfc2397_ops
PHPAPI php_stream_wrapper_ops php_stream_rfc2397_wops
PHPAPI php_stream_wrapper php_stream_rfc2397_wrapper

Class Documentation

struct php_stream_memory_data

Definition at line 39 of file memory.c.

Class Members
char * data
size_t fpos
size_t fsize
int mode
php_stream ** owner_ptr
size_t smax
struct php_stream_temp_data

Definition at line 355 of file memory.c.

Class Members
php_stream * innerstream
zval * meta
int mode
size_t smax

Define Documentation

#define _GNU_SOURCE

Definition at line 21 of file memory.c.


Function Documentation

PHPAPI php_stream* _php_stream_memory_create ( int mode STREAMS_DC  TSRMLS_DC)

Definition at line 293 of file memory.c.

{
       php_stream_memory_data *self;
       php_stream *stream;

       self = emalloc(sizeof(*self));
       self->data = NULL;
       self->fpos = 0;
       self->fsize = 0;
       self->smax = ~0u;
       self->mode = mode;
       self->owner_ptr = NULL;
       
       stream = php_stream_alloc_rel(&php_stream_memory_ops, self, 0, mode & TEMP_STREAM_READONLY ? "rb" : "w+b");
       stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
       return stream;
}
PHPAPI char* _php_stream_memory_get_buffer ( php_stream *  stream,
size_t *length STREAMS_DC  TSRMLS_DC 
)

Definition at line 339 of file memory.c.

{
       php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract;

       assert(ms != NULL);
       assert(length != 0);

       *length = ms->fsize;
       return ms->data;
}
PHPAPI php_stream* _php_stream_memory_open ( int  mode,
char *  buf,
size_t length STREAMS_DC  TSRMLS_DC 
)

Definition at line 314 of file memory.c.

{
       php_stream *stream;
       php_stream_memory_data *ms;

       if ((stream = php_stream_memory_create_rel(mode)) != NULL) {
              ms = (php_stream_memory_data*)stream->abstract;
              
              if (mode == TEMP_STREAM_READONLY || mode == TEMP_STREAM_TAKE_BUFFER) {
                     /* use the buffer directly */
                     ms->data = buf;
                     ms->fsize = length;
              } else {
                     if (length) {
                            assert(buf != NULL);
                            php_stream_write(stream, buf, length);
                     }
              }
       }
       return stream;
}
PHPAPI php_stream* _php_stream_temp_create ( int  mode,
size_t max_memory_usage STREAMS_DC  TSRMLS_DC 
)

Definition at line 554 of file memory.c.

{
       php_stream_temp_data *self;
       php_stream *stream;

       self = ecalloc(1, sizeof(*self));
       self->smax = max_memory_usage;
       self->mode = mode;
       self->meta = NULL;
       stream = php_stream_alloc_rel(&php_stream_temp_ops, self, 0, mode & TEMP_STREAM_READONLY ? "rb" : "w+b");
       stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
       self->innerstream = php_stream_memory_create_rel(mode);
       php_stream_auto_cleanup(self->innerstream); /* do not warn if innerstream is GC'ed before stream */
       ((php_stream_memory_data*)self->innerstream->abstract)->owner_ptr = &self->innerstream;

       return stream;
}
PHPAPI php_stream* _php_stream_temp_open ( int  mode,
size_t  max_memory_usage,
char *  buf,
size_t length STREAMS_DC  TSRMLS_DC 
)

Definition at line 575 of file memory.c.

{
       php_stream *stream;
       php_stream_temp_data *ts;
       off_t newoffs;

       if ((stream = php_stream_temp_create_rel(mode, max_memory_usage)) != NULL) {
              if (length) {
                     assert(buf != NULL);
                     php_stream_temp_write(stream, buf, length TSRMLS_CC);
                     php_stream_temp_seek(stream, 0, SEEK_SET, &newoffs TSRMLS_CC);
              }
              ts = (php_stream_temp_data*)stream->abstract;
              assert(ts != NULL);
              ts->mode = mode;
       }
       return stream;
}

Here is the call graph for this function:

PHPAPI unsigned char* php_base64_decode ( const unsigned char *  str,
int  length,
int ret_length 
)

Definition at line 137 of file base64.c.

{
       return php_base64_decode_ex(str, length, ret_length, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int php_stream_memory_cast ( php_stream *  stream,
int  castas,
void **ret  TSRMLS_DC 
) [static]

Definition at line 198 of file memory.c.

{
       return FAILURE;
}
static int php_stream_memory_close ( php_stream *  stream,
int close_handle  TSRMLS_DC 
) [static]

Definition at line 107 of file memory.c.

{
       php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract;
       assert(ms != NULL);

       if (ms->data && close_handle && ms->mode != TEMP_STREAM_READONLY) {
              efree(ms->data);
       }
       if (ms->owner_ptr) {
              *ms->owner_ptr = NULL;
       }
       efree(ms);
       return 0;
}
static int php_stream_memory_flush ( php_stream *stream  TSRMLS_DC) [static]

Definition at line 125 of file memory.c.

{
       /* nothing to do here */
       return 0;
}
static size_t php_stream_memory_read ( php_stream *  stream,
char *  buf,
size_t count  TSRMLS_DC 
) [static]

Definition at line 86 of file memory.c.

{
       php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract;
       assert(ms != NULL);

       if (ms->fpos + count >= ms->fsize) {
              count = ms->fsize - ms->fpos;
              stream->eof = 1;
       }
       if (count) {
              assert(ms->data!= NULL);
              assert(buf!= NULL);
              memcpy(buf, ms->data+ms->fpos, count);
              ms->fpos += count;
       }
       return count;
}
static int php_stream_memory_seek ( php_stream *  stream,
off_t  offset,
int  whence,
off_t *newoffs  TSRMLS_DC 
) [static]

Definition at line 134 of file memory.c.

{
       php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract;
       assert(ms != NULL);

       switch(whence) {
              case SEEK_CUR:
                     if (offset < 0) {
                            if (ms->fpos < (size_t)(-offset)) {
                                   ms->fpos = 0;
                                   *newoffs = -1;
                                   return -1;
                            } else {
                                   ms->fpos = ms->fpos + offset;
                                   *newoffs = ms->fpos;
                                   stream->eof = 0;
                                   return 0;
                            }
                     } else {
                            if (ms->fpos + (size_t)(offset) > ms->fsize) {
                                   ms->fpos = ms->fsize;
                                   *newoffs = -1;
                                   return -1;
                            } else {
                                   ms->fpos = ms->fpos + offset;
                                   *newoffs = ms->fpos;
                                   stream->eof = 0;
                                   return 0;
                            }
                     }
              case SEEK_SET:
                     if (ms->fsize < (size_t)(offset)) {
                            ms->fpos = ms->fsize;
                            *newoffs = -1;
                            return -1;
                     } else {
                            ms->fpos = offset;
                            *newoffs = ms->fpos;
                            stream->eof = 0;
                            return 0;
                     }
              case SEEK_END:
                     if (offset > 0) {
                            ms->fpos = ms->fsize;
                            *newoffs = -1;
                            return -1;
                     } else if (ms->fsize < (size_t)(-offset)) {
                            ms->fpos = 0;
                            *newoffs = -1;
                            return -1;
                     } else {
                            ms->fpos = ms->fsize + offset;
                            *newoffs = ms->fpos;
                            stream->eof = 0;
                            return 0;
                     }
              default:
                     *newoffs = ms->fpos;
                     return -1;
       }
}
static int php_stream_memory_set_option ( php_stream *  stream,
int  option,
int  value,
void *ptrparam  TSRMLS_DC 
) [static]

Definition at line 247 of file memory.c.

{
       php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract;
       size_t newsize;
       
       switch(option) {
              case PHP_STREAM_OPTION_TRUNCATE_API:
                     switch (value) {
                            case PHP_STREAM_TRUNCATE_SUPPORTED:
                                   return PHP_STREAM_OPTION_RETURN_OK;

                            case PHP_STREAM_TRUNCATE_SET_SIZE:
                                   if (ms->mode & TEMP_STREAM_READONLY) {
                                          return PHP_STREAM_OPTION_RETURN_ERR;
                                   }
                                   newsize = *(size_t*)ptrparam;
                                   if (newsize <= ms->fsize) {
                                          if (newsize < ms->fpos) {
                                                 ms->fpos = newsize;
                                          }
                                   } else {
                                          ms->data = erealloc(ms->data, newsize);
                                          memset(ms->data+ms->fsize, 0, newsize - ms->fsize);
                                          ms->fsize = newsize;
                                   }
                                   ms->fsize = newsize;
                                   return PHP_STREAM_OPTION_RETURN_OK;
                     }
              default:
                     return PHP_STREAM_OPTION_RETURN_NOTIMPL;
       }
}
static int php_stream_memory_stat ( php_stream *  stream,
php_stream_statbuf *ssb  TSRMLS_DC 
) [static]

Definition at line 204 of file memory.c.

{
       time_t timestamp = 0;
       php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract;
       assert(ms != NULL);

       memset(ssb, 0, sizeof(php_stream_statbuf));
       /* read-only across the board */
       
       ssb->sb.st_mode = ms->mode & TEMP_STREAM_READONLY ? 0444 : 0666;

       ssb->sb.st_size = ms->fsize;
       ssb->sb.st_mode |= S_IFREG; /* regular file */

#ifdef NETWARE
       ssb->sb.st_mtime.tv_sec = timestamp;
       ssb->sb.st_atime.tv_sec = timestamp;
       ssb->sb.st_ctime.tv_sec = timestamp;
#else
       ssb->sb.st_mtime = timestamp;
       ssb->sb.st_atime = timestamp;
       ssb->sb.st_ctime = timestamp;
#endif

       ssb->sb.st_nlink = 1;
       ssb->sb.st_rdev = -1;
       /* this is only for APC, so use /dev/null device - no chance of conflict there! */
       ssb->sb.st_dev = 0xC;
       /* generate unique inode number for alias/filename, so no phars will conflict */
       ssb->sb.st_ino = 0;

#ifndef PHP_WIN32
       ssb->sb.st_blksize = -1;
#endif

#if !defined(PHP_WIN32) && !defined(__BEOS__)
       ssb->sb.st_blocks = -1;
#endif

       return 0;
}
static size_t php_stream_memory_write ( php_stream *  stream,
const char *  buf,
size_t count  TSRMLS_DC 
) [static]

Definition at line 50 of file memory.c.

{
       php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract;
       assert(ms != NULL);

       if (ms->mode & TEMP_STREAM_READONLY) {
              return 0;
       }
       if (ms->fpos + count > ms->fsize) {
              char *tmp;

              if (!ms->data) {
                     tmp = emalloc(ms->fpos + count);
              } else {
                     tmp = erealloc(ms->data, ms->fpos + count);
              }
              if (!tmp) {
                     count = ms->fsize - ms->fpos + 1;
              } else {
                     ms->data = tmp;
                     ms->fsize = ms->fpos + count;
              }
       }
       if (!ms->data)
              count = 0;
       if (count) {
              assert(buf!= NULL);
              memcpy(ms->data+ms->fpos, (char*)buf, count);
              ms->fpos += count;
       }
       return count;
}
static int php_stream_temp_cast ( php_stream *  stream,
int  castas,
void **ret  TSRMLS_DC 
) [static]

Definition at line 466 of file memory.c.

{
       php_stream_temp_data *ts = (php_stream_temp_data*)stream->abstract;
       php_stream *file;
       size_t memsize;
       char *membuf;
       off_t pos;

       assert(ts != NULL);

       if (!ts->innerstream) {
              return FAILURE;
       }
       if (php_stream_is(ts->innerstream, PHP_STREAM_IS_STDIO)) {
              return php_stream_cast(ts->innerstream, castas, ret, 0);
       }

       /* we are still using a memory based backing. If they are if we can be
        * a FILE*, say yes because we can perform the conversion.
        * If they actually want to perform the conversion, we need to switch
        * the memory stream to a tmpfile stream */

       if (ret == NULL && castas == PHP_STREAM_AS_STDIO) {
              return SUCCESS;
       }

       /* say "no" to other stream forms */
       if (ret == NULL) {
              return FAILURE;
       }

       /* perform the conversion and then pass the request on to the innerstream */
       membuf = php_stream_memory_get_buffer(ts->innerstream, &memsize);
       file = php_stream_fopen_tmpfile();
       php_stream_write(file, membuf, memsize);
       pos = php_stream_tell(ts->innerstream);

       php_stream_close(ts->innerstream);
       ts->innerstream = file;
       php_stream_seek(ts->innerstream, pos, SEEK_SET);

       return php_stream_cast(ts->innerstream, castas, ret, 1);
}
static int php_stream_temp_close ( php_stream *  stream,
int close_handle  TSRMLS_DC 
) [static]

Definition at line 410 of file memory.c.

{
       php_stream_temp_data *ts = (php_stream_temp_data*)stream->abstract;
       int ret;

       assert(ts != NULL);

       if (ts->innerstream) {
              ret = php_stream_free(ts->innerstream, PHP_STREAM_FREE_CLOSE | (close_handle ? 0 : PHP_STREAM_FREE_PRESERVE_HANDLE));
       } else {
              ret = 0;
       }
       
       if (ts->meta) {
              zval_ptr_dtor(&ts->meta);
       }

       efree(ts);

       return ret;
}
static int php_stream_temp_flush ( php_stream *stream  TSRMLS_DC) [static]

Definition at line 435 of file memory.c.

{
       php_stream_temp_data *ts = (php_stream_temp_data*)stream->abstract;
       assert(ts != NULL);

       return ts->innerstream ? php_stream_flush(ts->innerstream) : -1;
}
static size_t php_stream_temp_read ( php_stream *  stream,
char *  buf,
size_t count  TSRMLS_DC 
) [static]

Definition at line 389 of file memory.c.

{
       php_stream_temp_data *ts = (php_stream_temp_data*)stream->abstract;
       size_t got;

       assert(ts != NULL);

       if (!ts->innerstream) {
              return -1;
       }
       
       got = php_stream_read(ts->innerstream, buf, count);
       
       stream->eof = ts->innerstream->eof;
       
       return got;
}
static int php_stream_temp_seek ( php_stream *  stream,
off_t  offset,
int  whence,
off_t *newoffs  TSRMLS_DC 
) [static]

Definition at line 446 of file memory.c.

{
       php_stream_temp_data *ts = (php_stream_temp_data*)stream->abstract;
       int ret;

       assert(ts != NULL);

       if (!ts->innerstream) {
              *newoffs = -1;
              return -1;
       }
       ret = php_stream_seek(ts->innerstream, offset, whence);
       *newoffs = php_stream_tell(ts->innerstream);
       stream->eof = ts->innerstream->eof;
       
       return ret;
}

Here is the caller graph for this function:

static int php_stream_temp_set_option ( php_stream *  stream,
int  option,
int  value,
void *ptrparam  TSRMLS_DC 
) [static]

Definition at line 522 of file memory.c.

{
       php_stream_temp_data *ts = (php_stream_temp_data*)stream->abstract;
       
       switch(option) {
              case PHP_STREAM_OPTION_META_DATA_API:
                     if (ts->meta) {
                            zend_hash_copy(Z_ARRVAL_P((zval*)ptrparam), Z_ARRVAL_P(ts->meta), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
                     }
                     return PHP_STREAM_OPTION_RETURN_OK;
              default:
                     if (ts->innerstream) {
                            return php_stream_set_option(ts->innerstream, option, value, ptrparam);
                     }
                     return PHP_STREAM_OPTION_RETURN_NOTIMPL;
       }
}

Here is the call graph for this function:

static int php_stream_temp_stat ( php_stream *  stream,
php_stream_statbuf *ssb  TSRMLS_DC 
) [static]

Definition at line 511 of file memory.c.

{
       php_stream_temp_data *ts = (php_stream_temp_data*)stream->abstract;

       if (!ts || !ts->innerstream) {
              return -1;
       }
       return php_stream_stat(ts->innerstream, ssb);
}
static size_t php_stream_temp_write ( php_stream *  stream,
const char *  buf,
size_t count  TSRMLS_DC 
) [static]

Definition at line 364 of file memory.c.

{
       php_stream_temp_data *ts = (php_stream_temp_data*)stream->abstract;
       assert(ts != NULL);

       if (!ts->innerstream) {
              return -1;
       }
       if (php_stream_is(ts->innerstream, PHP_STREAM_IS_MEMORY)) {
              size_t memsize;
              char *membuf = php_stream_memory_get_buffer(ts->innerstream, &memsize);

              if (memsize + count >= ts->smax) {
                     php_stream *file = php_stream_fopen_tmpfile();
                     php_stream_write(file, membuf, memsize);
                     php_stream_close(ts->innerstream);
                     ts->innerstream = file;
              }
       }
       return php_stream_write(ts->innerstream, buf, count);
}

Here is the caller graph for this function:

static php_stream* php_stream_url_wrap_rfc2397 ( php_stream_wrapper *  wrapper,
char *  path,
char *  mode,
int  options,
char **  opened_path,
php_stream_context *context STREAMS_DC  TSRMLS_DC 
) [static]

Definition at line 605 of file memory.c.

{
       php_stream *stream;
       php_stream_temp_data *ts;
       char *comma, *semi, *sep, *key;
       size_t mlen, dlen, plen, vlen;
       off_t newoffs;
       zval *meta = NULL;
       int base64 = 0, ilen;

       if (memcmp(path, "data:", 5)) {
              return NULL;
       }

       path += 5;
       dlen = strlen(path);

       if (dlen >= 2 && path[0] == '/' && path[1] == '/') {
              dlen -= 2;
              path += 2;
       }

       if ((comma = memchr(path, ',', dlen)) == NULL) {
              php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "rfc2397: no comma in URL");
              return NULL;
       }

       if (comma != path) {
              /* meta info */
              mlen = comma - path;
              dlen -= mlen;
              semi = memchr(path, ';', mlen);
              sep = memchr(path, '/', mlen);
              
              if (!semi && !sep) {
                     php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "rfc2397: illegal media type");
                     return NULL;
              }

              MAKE_STD_ZVAL(meta);
              array_init(meta);
              if (!semi) { /* there is only a mime type */
                     add_assoc_stringl(meta, "mediatype", path, mlen, 1);
                     mlen = 0;
              } else if (sep && sep < semi) { /* there is a mime type */
                     plen = semi - path;
                     add_assoc_stringl(meta, "mediatype", path, plen, 1);
                     mlen -= plen;
                     path += plen;
              } else if (semi != path || mlen != sizeof(";base64")-1 || memcmp(path, ";base64", sizeof(";base64")-1)) { /* must be error since parameters are only allowed after mediatype */
                     zval_ptr_dtor(&meta);
                     php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "rfc2397: illegal media type");
                     return NULL;
              }
              /* get parameters and potentially ';base64' */
              while(semi && (semi == path)) {
                     path++;
                     mlen--;
                     sep = memchr(path, '=', mlen);
                     semi = memchr(path, ';', mlen);
                     if (!sep || (semi && semi < sep)) { /* must be ';base64' or failure */
                            if (mlen != sizeof("base64")-1 || memcmp(path, "base64", sizeof("base64")-1)) {
                                   /* must be error since parameters are only allowed after mediatype and we have no '=' sign */
                                   zval_ptr_dtor(&meta);
                                   php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "rfc2397: illegal parameter");
                                   return NULL;
                            }
                            base64 = 1;
                            mlen -= sizeof("base64") - 1;
                            path += sizeof("base64") - 1;
                            break;
                     }
                     /* found parameter ... the heart of cs ppl lies in +1/-1 or was it +2 this time? */
                     plen = sep - path;
                     vlen = (semi ? semi - sep : mlen - plen) - 1 /* '=' */;
                     key = estrndup(path, plen);
                     add_assoc_stringl_ex(meta, key, plen + 1, sep + 1, vlen, 1);
                     efree(key);
                     plen += vlen + 1;
                     mlen -= plen;
                     path += plen;
              }
              if (mlen) {
                     zval_ptr_dtor(&meta);
                     php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "rfc2397: illegal URL");
                     return NULL;
              }
       } else {
              MAKE_STD_ZVAL(meta);
              array_init(meta);
       }
       add_assoc_bool(meta, "base64", base64);

       /* skip ',' */
       comma++;
       dlen--;

       if (base64) {
              comma = (char*)php_base64_decode((const unsigned char *)comma, dlen, &ilen);
              if (!comma) {
                     zval_ptr_dtor(&meta);
                     php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "rfc2397: unable to decode");
                     return NULL;
              }
       } else {
              comma = estrndup(comma, dlen);
              ilen = dlen = php_url_decode(comma, dlen);
       }

       if ((stream = php_stream_temp_create_rel(0, ~0u)) != NULL) {
              /* store data */
              php_stream_temp_write(stream, comma, ilen TSRMLS_CC);
              php_stream_temp_seek(stream, 0, SEEK_SET, &newoffs TSRMLS_CC);
              /* set special stream stuff (enforce exact mode) */
              vlen = strlen(mode);
              if (vlen >= sizeof(stream->mode)) {
                     vlen = sizeof(stream->mode) - 1;
              }
              memcpy(stream->mode, mode, vlen);
              stream->mode[vlen] = '\0';
              stream->ops = &php_stream_rfc2397_ops;
              ts = (php_stream_temp_data*)stream->abstract;
              assert(ts != NULL);
              ts->mode = mode && mode[0] == 'r' && mode[1] != '+' ? TEMP_STREAM_READONLY : 0;
              ts->meta = meta;
       }
       efree(comma);

       return stream;
}

Here is the call graph for this function:

PHPAPI int php_url_decode ( char *  str,
int  len 
)

Definition at line 566 of file url.c.

{
       char *dest = str;
       char *data = str;

       while (len--) {
              if (*data == '+') {
                     *dest = ' ';
              }
              else if (*data == '%' && len >= 2 && isxdigit((int) *(data + 1)) 
                             && isxdigit((int) *(data + 2))) {
#ifndef CHARSET_EBCDIC
                     *dest = (char) php_htoi(data + 1);
#else
                     *dest = os_toebcdic[(char) php_htoi(data + 1)];
#endif
                     data += 2;
                     len -= 2;
              } else {
                     *dest = *data;
              }
              data++;
              dest++;
       }
       *dest = '\0';
       return dest - str;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
 {
       php_stream_url_wrap_rfc2397,
       NULL, 
       NULL, 
       NULL, 
       NULL, 
       "RFC2397",
       NULL, 
       NULL, 
       NULL, 
       NULL  
}

Definition at line 736 of file memory.c.

PHPAPI php_stream_wrapper php_stream_rfc2397_wrapper
Initial value:

Definition at line 749 of file memory.c.