Lines Matching refs:handle
52 static size_t zend_stream_stdio_reader(void *handle, char *buf, size_t len) /* {{{ */ in zend_stream_stdio_reader() argument
54 return fread(buf, 1, len, (FILE*)handle); in zend_stream_stdio_reader()
57 static void zend_stream_stdio_closer(void *handle) /* {{{ */ in zend_stream_stdio_closer() argument
59 if (handle && (FILE*)handle != stdin) { in zend_stream_stdio_closer()
60 fclose((FILE*)handle); in zend_stream_stdio_closer()
64 static size_t zend_stream_stdio_fsizer(void *handle) /* {{{ */ in zend_stream_stdio_fsizer() argument
67 if (handle && zend_fstat(fileno((FILE*)handle), &buf) == 0) { in zend_stream_stdio_fsizer()
91 stream->handle = stream->mmap.old_handle; in zend_stream_unmap()
97 if (stream->mmap.old_closer && stream->handle) { in zend_stream_mmap_closer()
98 stream->mmap.old_closer(stream->handle); in zend_stream_mmap_closer()
111 return file_handle->handle.stream.mmap.len; in zend_stream_fsize()
114 return file_handle->handle.stream.fsizer(file_handle->handle.stream.handle); in zend_stream_fsize()
116 if (file_handle->handle.fp && zend_fstat(fileno(file_handle->handle.fp), &buf) == 0) { in zend_stream_fsize()
128 ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle) /* {{{ */ in zend_stream_open() argument
131 return zend_stream_open_function(filename, handle); in zend_stream_open()
133 handle->type = ZEND_HANDLE_FP; in zend_stream_open()
134 handle->opened_path = NULL; in zend_stream_open()
135 handle->handle.fp = zend_fopen(filename, &handle->opened_path); in zend_stream_open()
136 handle->filename = filename; in zend_stream_open()
137 handle->free_filename = 0; in zend_stream_open()
138 memset(&handle->handle.stream.mmap, 0, sizeof(zend_mmap)); in zend_stream_open()
140 return (handle->handle.fp) ? SUCCESS : FAILURE; in zend_stream_open()
147 if (file_handle->handle.stream.reader(file_handle->handle.stream.handle, &buf, sizeof(buf))) { in zend_stream_getc()
155 if (!zend_stream_is_mmap(file_handle) && file_handle->handle.stream.isatty) { in zend_stream_read()
168 return file_handle->handle.stream.reader(file_handle->handle.stream.handle, buf, len); in zend_stream_read()
185 file_handle->handle.fp = fdopen(file_handle->handle.fd, "rb"); in zend_stream_fixup()
188 if (!file_handle->handle.fp) { in zend_stream_fixup()
191 memset(&file_handle->handle.stream.mmap, 0, sizeof(zend_mmap)); in zend_stream_fixup()
192 …file_handle->handle.stream.isatty = isatty(fileno((FILE *)file_handle->handle.stream.handle)) … in zend_stream_fixup()
193 file_handle->handle.stream.reader = (zend_stream_reader_t)zend_stream_stdio_reader; in zend_stream_fixup()
194 file_handle->handle.stream.closer = (zend_stream_closer_t)zend_stream_stdio_closer; in zend_stream_fixup()
195 file_handle->handle.stream.fsizer = (zend_stream_fsizer_t)zend_stream_stdio_fsizer; in zend_stream_fixup()
196 memset(&file_handle->handle.stream.mmap, 0, sizeof(file_handle->handle.stream.mmap)); in zend_stream_fixup()
203 file_handle->handle.stream.mmap.pos = 0; in zend_stream_fixup()
204 *buf = file_handle->handle.stream.mmap.buf; in zend_stream_fixup()
205 *len = file_handle->handle.stream.mmap.len; in zend_stream_fixup()
220 if (old_type == ZEND_HANDLE_FP && !file_handle->handle.stream.isatty && size) { in zend_stream_fixup()
224 if (file_handle->handle.fp && in zend_stream_fixup()
228 … *buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), 0); in zend_stream_fixup()
230 zend_long offset = ftell(file_handle->handle.fp); in zend_stream_fixup()
231 file_handle->handle.stream.mmap.map = *buf; in zend_stream_fixup()
237 file_handle->handle.stream.mmap.buf = *buf; in zend_stream_fixup()
238 file_handle->handle.stream.mmap.len = size; in zend_stream_fixup()
244 file_handle->handle.stream.mmap.map = 0; in zend_stream_fixup()
245 file_handle->handle.stream.mmap.buf = *buf = safe_emalloc(1, size, ZEND_MMAP_AHEAD); in zend_stream_fixup()
246 file_handle->handle.stream.mmap.len = zend_stream_read(file_handle, *buf, size); in zend_stream_fixup()
261 file_handle->handle.stream.mmap.map = 0; in zend_stream_fixup()
262 file_handle->handle.stream.mmap.len = size; in zend_stream_fixup()
266 file_handle->handle.stream.mmap.buf = *buf; in zend_stream_fixup()
269 if (file_handle->handle.stream.mmap.len == 0) { in zend_stream_fixup()
271 file_handle->handle.stream.mmap.buf = *buf; in zend_stream_fixup()
275 …memset(file_handle->handle.stream.mmap.buf + file_handle->handle.stream.mmap.len, 0, ZEND_MMAP_AHE… in zend_stream_fixup()
281 file_handle->handle.stream.mmap.pos = 0; in zend_stream_fixup()
282 file_handle->handle.stream.mmap.old_handle = file_handle->handle.stream.handle; in zend_stream_fixup()
283 file_handle->handle.stream.mmap.old_closer = file_handle->handle.stream.closer; in zend_stream_fixup()
284 file_handle->handle.stream.handle = &file_handle->handle.stream; in zend_stream_fixup()
285 file_handle->handle.stream.closer = (zend_stream_closer_t)zend_stream_mmap_closer; in zend_stream_fixup()
287 *buf = file_handle->handle.stream.mmap.buf; in zend_stream_fixup()
288 *len = file_handle->handle.stream.mmap.len; in zend_stream_fixup()
300 fclose(fh->handle.fp); in zend_file_handle_dtor()
304 if (fh->handle.stream.closer && fh->handle.stream.handle) { in zend_file_handle_dtor()
305 fh->handle.stream.closer(fh->handle.stream.handle); in zend_file_handle_dtor()
307 fh->handle.stream.handle = NULL; in zend_file_handle_dtor()
333 return fh1->handle.fd == fh2->handle.fd; in zend_compare_file_handles()
335 return fh1->handle.fp == fh2->handle.fp; in zend_compare_file_handles()
337 return fh1->handle.stream.handle == fh2->handle.stream.handle; in zend_compare_file_handles()
339 return (fh1->handle.stream.handle == &fh1->handle.stream && in zend_compare_file_handles()
340 fh2->handle.stream.handle == &fh2->handle.stream && in zend_compare_file_handles()
341 fh1->handle.stream.mmap.old_handle == fh2->handle.stream.mmap.old_handle) in zend_compare_file_handles()
342 || fh1->handle.stream.handle == fh2->handle.stream.handle; in zend_compare_file_handles()