Back to index

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

Go to the source code of this file.

Defines

#define pemalloc_rel_orig(size, persistent)   pemalloc((size), (persistent))
#define perealloc_rel_orig(ptr, size, persistent)   perealloc((ptr), (size), (persistent))
#define emalloc_rel_orig(size)   emalloc((size))
#define STREAM_DEBUG   0
#define STREAM_WRAPPER_PLAIN_FILES   ((php_stream_wrapper*)-1)
#define MAP_FAILED   ((void *) -1)
#define CHUNK_SIZE   8192
#define S_ISREG(mode)   (((mode)&S_IFMT) == S_IFREG)

Functions

void php_stream_mode_sanitize_fdopen_fopencookie (php_stream *stream, char *result)
void php_stream_tidy_wrapper_error_log (php_stream_wrapper *wrapper TSRMLS_DC)
void php_stream_display_wrapper_errors (php_stream_wrapper *wrapper, const char *path, const char *caption TSRMLS_DC)

Define Documentation

#define CHUNK_SIZE   8192

Definition at line 49 of file php_streams_int.h.

#define emalloc_rel_orig (   size)    emalloc((size))

Definition at line 39 of file php_streams_int.h.

#define MAP_FAILED   ((void *) -1)

Definition at line 46 of file php_streams_int.h.

#define pemalloc_rel_orig (   size,
  persistent 
)    pemalloc((size), (persistent))

Definition at line 37 of file php_streams_int.h.

#define perealloc_rel_orig (   ptr,
  size,
  persistent 
)    perealloc((ptr), (size), (persistent))

Definition at line 38 of file php_streams_int.h.

#define S_ISREG (   mode)    (((mode)&S_IFMT) == S_IFREG)

Definition at line 59 of file php_streams_int.h.

#define STREAM_DEBUG   0

Definition at line 42 of file php_streams_int.h.

#define STREAM_WRAPPER_PLAIN_FILES   ((php_stream_wrapper*)-1)

Definition at line 43 of file php_streams_int.h.


Function Documentation

void php_stream_display_wrapper_errors ( php_stream_wrapper *  wrapper,
const char *  path,
const char *caption  TSRMLS_DC 
)

Definition at line 152 of file streams.c.

{
       char *tmp = estrdup(path);
       char *msg;
       int free_msg = 0;
       php_stream_wrapper orig_wrapper;

       if (wrapper) {
              if (wrapper->err_count > 0) {
                     int i;
                     size_t l;
                     int brlen;
                     char *br;

                     if (PG(html_errors)) {
                            brlen = 7;
                            br = "<br />\n";
                     } else {
                            brlen = 1;
                            br = "\n";
                     }

                     for (i = 0, l = 0; i < wrapper->err_count; i++) {
                            l += strlen(wrapper->err_stack[i]);
                            if (i < wrapper->err_count - 1) {
                                   l += brlen;
                            }
                     }
                     msg = emalloc(l + 1);
                     msg[0] = '\0';
                     for (i = 0; i < wrapper->err_count; i++) {
                            strcat(msg, wrapper->err_stack[i]);
                            if (i < wrapper->err_count - 1) {
                                   strcat(msg, br);
                            }
                     }

                     free_msg = 1;
              } else {
                     if (wrapper == &php_plain_files_wrapper) {
                            msg = strerror(errno);
                     } else {
                            msg = "operation failed";
                     }
              }
       } else {
              msg = "no suitable wrapper could be found";
       }

       php_strip_url_passwd(tmp);
       if (wrapper) {
              /* see bug #52935 */
              orig_wrapper = *wrapper;
              wrapper->err_stack = NULL;
              wrapper->err_count = 0;
       }
       php_error_docref1(NULL TSRMLS_CC, tmp, E_WARNING, "%s: %s", caption, msg);
       if (wrapper) {
              *wrapper = orig_wrapper;
       }
       efree(tmp);
       if (free_msg) {
              efree(msg);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void php_stream_mode_sanitize_fdopen_fopencookie ( php_stream *  stream,
char *  result 
)

Definition at line 149 of file cast.c.

{
       /* replace modes not supported by fdopen and fopencookie, but supported 
        * by PHP's fread(), so that their calls won't fail */
       const char *cur_mode = stream->mode;
       int         has_plus = 0,
                      has_bin  = 0,
                            i,
                            res_curs = 0;

       if (cur_mode[0] == 'r' || cur_mode[0] == 'w' || cur_mode[0] == 'a') {
              result[res_curs++] = cur_mode[0];
       } else {
              /* assume cur_mode[0] is 'c' or 'x'; substitute by 'w', which should not
               * truncate anything in fdopen/fopencookie */
              result[res_curs++] = 'w';

              /* x is allowed (at least by glibc & compat), but not as the 1st mode
               * as in PHP and in any case is (at best) ignored by fdopen and fopencookie */
       }
       
       /* assume current mode has at most length 4 (e.g. wbn+) */
       for (i = 1; i < 4 && cur_mode[i] != '\0'; i++) {
              if (cur_mode[i] == 'b') {
                     has_bin = 1;
              } else if (cur_mode[i] == '+') {
                     has_plus = 1;
              }
              /* ignore 'n', 't' or other stuff */
       }

       if (has_bin) {
              result[res_curs++] = 'b';
       }
       if (has_plus) {
              result[res_curs++] = '+';
       }

       result[res_curs] = '\0';
}

Here is the caller graph for this function:

void php_stream_tidy_wrapper_error_log ( php_stream_wrapper *wrapper  TSRMLS_DC)

Definition at line 218 of file streams.c.

{
       if (wrapper) {
              /* tidy up the error stack */
              int i;

              for (i = 0; i < wrapper->err_count; i++) {
                     efree(wrapper->err_stack[i]);
              }
              if (wrapper->err_stack) {
                     efree(wrapper->err_stack);
              }
              wrapper->err_stack = NULL;
              wrapper->err_count = 0;
       }
}

Here is the caller graph for this function: