Back to index

php5  5.3.10
Functions
stream.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

php_urlphar_parse_url (php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC)
 Open a phar file for streams API.
void phar_entry_remove (phar_entry_data *idata, char **error TSRMLS_DC)
 Removes an entry, either by actually removing it or by marking it.
static php_stream * phar_wrapper_open_url (php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)
static int phar_wrapper_rename (php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC)
static int phar_wrapper_unlink (php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC)
static int phar_wrapper_stat (php_stream_wrapper *wrapper, char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC)
static size_t phar_stream_write (php_stream *stream, const char *buf, size_t count TSRMLS_DC)
static size_t phar_stream_read (php_stream *stream, char *buf, size_t count TSRMLS_DC)
static int phar_stream_close (php_stream *stream, int close_handle TSRMLS_DC)
static int phar_stream_flush (php_stream *stream TSRMLS_DC)
static int phar_stream_seek (php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC)
static int phar_stream_stat (php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC)

Function Documentation

void phar_entry_remove ( phar_entry_data idata,
char **error  TSRMLS_DC 
)

Removes an entry, either by actually removing it or by marking it.

Definition at line 459 of file phar.c.

{
       phar_archive_data *phar;

       phar = idata->phar;

       if (idata->internal_file->fp_refcount < 2) {
              if (idata->fp && idata->fp != idata->phar->fp && idata->fp != idata->phar->ufp && idata->fp != idata->internal_file->fp) {
                     php_stream_close(idata->fp);
              }
              zend_hash_del(&idata->phar->manifest, idata->internal_file->filename, idata->internal_file->filename_len);
              idata->phar->refcount--;
              efree(idata);
       } else {
              idata->internal_file->is_deleted = 1;
              phar_entry_delref(idata TSRMLS_CC);
       }

       if (!phar->donotflush) {
              phar_flush(phar, 0, 0, 0, error TSRMLS_CC);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

php_url* phar_parse_url ( php_stream_wrapper *  wrapper,
char *  filename,
char *  mode,
int options  TSRMLS_DC 
)

Open a phar file for streams API.

Definition at line 59 of file stream.c.

{
       php_url *resource;
       char *arch = NULL, *entry = NULL, *error;
       int arch_len, entry_len;

       if (strlen(filename) < 7 || strncasecmp(filename, "phar://", 7)) {
              return NULL;
       }
       if (mode[0] == 'a') {
              if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
                     php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: open mode append not supported");
              }
              return NULL;
       }
       if (phar_split_fname(filename, strlen(filename), &arch, &arch_len, &entry, &entry_len, 2, (mode[0] == 'w' ? 2 : 0) TSRMLS_CC) == FAILURE) {
              if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
                     if (arch && !entry) {
                            php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: no directory in \"%s\", must have at least phar://%s/ for root directory (always use full path to a new phar)", filename, arch);
                            arch = NULL;
                     } else {
                            php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url or non-existent phar \"%s\"", filename);
                     }
              }
              return NULL;
       }
       resource = ecalloc(1, sizeof(php_url));
       resource->scheme = estrndup("phar", 4);
       resource->host = arch;

       resource->path = entry;
#if MBO_0
              if (resource) {
                     fprintf(stderr, "Alias:     %s\n", alias);
                     fprintf(stderr, "Scheme:    %s\n", resource->scheme);
/*                   fprintf(stderr, "User:      %s\n", resource->user);*/
/*                   fprintf(stderr, "Pass:      %s\n", resource->pass ? "***" : NULL);*/
                     fprintf(stderr, "Host:      %s\n", resource->host);
/*                   fprintf(stderr, "Port:      %d\n", resource->port);*/
                     fprintf(stderr, "Path:      %s\n", resource->path);
/*                   fprintf(stderr, "Query:     %s\n", resource->query);*/
/*                   fprintf(stderr, "Fragment:  %s\n", resource->fragment);*/
              }
#endif
       if (mode[0] == 'w' || (mode[0] == 'r' && mode[1] == '+')) {
              phar_archive_data **pphar = NULL, *phar;

              if (PHAR_GLOBALS->request_init && PHAR_GLOBALS->phar_fname_map.arBuckets && FAILURE == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **)&pphar)) {
                     pphar = NULL;
              }
              if (PHAR_G(readonly) && (!pphar || !(*pphar)->is_data)) {
                     if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
                            php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: write operations disabled by the php.ini setting phar.readonly");
                     }
                     php_url_free(resource);
                     return NULL;
              }
              if (phar_open_or_create_filename(resource->host, arch_len, NULL, 0, 0, options, &phar, &error TSRMLS_CC) == FAILURE)
              {
                     if (error) {
                            if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
                                   php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
                            }
                            efree(error);
                     }
                     php_url_free(resource);
                     return NULL;
              }
              if (phar->is_persistent && FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) {
                     if (error) {
                            spprintf(&error, 0, "Cannot open cached phar '%s' as writeable, copy on write failed", resource->host);
                            if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
                                   php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
                            }
                            efree(error);
                     }
                     php_url_free(resource);
                     return NULL;
              }
       } else {
              if (phar_open_from_filename(resource->host, arch_len, NULL, 0, options, NULL, &error TSRMLS_CC) == FAILURE)
              {
                     if (error) {
                            if (!(options & PHP_STREAM_URL_STAT_QUIET)) {
                                   php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s", error);
                            }
                            efree(error);
                     }
                     php_url_free(resource);
                     return NULL;
              }
       }
       return resource;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int phar_stream_close ( php_stream *  stream,
int close_handle  TSRMLS_DC 
) [static]
static int phar_stream_flush ( php_stream *stream  TSRMLS_DC) [static]
static size_t phar_stream_read ( php_stream *  stream,
char *  buf,
size_t count  TSRMLS_DC 
) [static]
static int phar_stream_seek ( php_stream *  stream,
off_t  offset,
int  whence,
off_t *newoffset  TSRMLS_DC 
) [static]
static int phar_stream_stat ( php_stream *  stream,
php_stream_statbuf *ssb  TSRMLS_DC 
) [static]
static size_t phar_stream_write ( php_stream *  stream,
const char *  buf,
size_t count  TSRMLS_DC 
) [static]
static php_stream* phar_wrapper_open_url ( php_stream_wrapper *  wrapper,
char *  path,
char *  mode,
int  options,
char **  opened_path,
php_stream_context *context STREAMS_DC  TSRMLS_DC 
) [static]
static int phar_wrapper_rename ( php_stream_wrapper *  wrapper,
char *  url_from,
char *  url_to,
int  options,
php_stream_context *context  TSRMLS_DC 
) [static]
static int phar_wrapper_stat ( php_stream_wrapper *  wrapper,
char *  url,
int  flags,
php_stream_statbuf ssb,
php_stream_context *context  TSRMLS_DC 
) [static]
static int phar_wrapper_unlink ( php_stream_wrapper *  wrapper,
char *  url,
int  options,
php_stream_context *context  TSRMLS_DC 
) [static]