1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC) { int fd = -1; int mode_rw = 0; php_stream * stream = NULL; char *p, *token = NULL, *pathdup; zend_long max_memory; FILE *file = NULL; #ifdef PHP_WIN32 int pipe_requested = 0; #endif if (!strncasecmp(path, "php://", 6)) { path += 6; } if (!strncasecmp(path, "temp", 4)) {...} if (!strcasecmp(path, "memory")) {...} if (!strcasecmp(path, "output")) {...} if (!strcasecmp(path, "input")) {...} if (!strcasecmp(path, "stdin")) { ... } else if (!strcasecmp(path, "stdout")) { ... } else if (!strcasecmp(path, "stderr")) { ... } else if (!strncasecmp(path, "fd/", 3)) { ... } else if (!strncasecmp(path, "filter/", 7)) {
if (strchr(mode, 'r') || strchr(mode, '+')) { mode_rw |= PHP_STREAM_FILTER_READ; } if (strchr(mode, 'w') || strchr(mode, '+') || strchr(mode, 'a')) { mode_rw |= PHP_STREAM_FILTER_WRITE; } pathdup = estrndup(path + 6, strlen(path + 6)); p = strstr(pathdup, "/resource="); if (!p) { zend_throw_error(NULL, "No URL resource specified"); efree(pathdup); return NULL; } if (!(stream = php_stream_open_wrapper(p + 10, mode, options, opened_path))) { efree(pathdup); return NULL; } *p = '\0'; p = php_strtok_r(pathdup + 1, "/", &token); while (p) { if (!strncasecmp(p, "read=", 5)) { php_stream_apply_filter_list(stream, p + 5, 1, 0); } else if (!strncasecmp(p, "write=", 6)) { php_stream_apply_filter_list(stream, p + 6, 0, 1); } else { php_stream_apply_filter_list(stream, p, mode_rw & PHP_STREAM_FILTER_READ, mode_rw & PHP_STREAM_FILTER_WRITE); } p = php_strtok_r(NULL, "/", &token); } efree(pathdup); if (EG(exception)) { php_stream_close(stream); return NULL; } return stream; } else { return NULL; } ... }
|