Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67687 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 882 invoked from network); 11 Jun 2013 13:58:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jun 2013 13:58:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=bleakwind@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=bleakwind@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.53 as permitted sender) X-PHP-List-Original-Sender: bleakwind@gmail.com X-Host-Fingerprint: 209.85.215.53 mail-la0-f53.google.com Received: from [209.85.215.53] ([209.85.215.53:64661] helo=mail-la0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0B/59-35222-BEC27B15 for ; Tue, 11 Jun 2013 09:58:05 -0400 Received: by mail-la0-f53.google.com with SMTP id fs12so5367305lab.40 for ; Tue, 11 Jun 2013 06:58:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=xvcvM/XbqTUaCzcPhg5GFbFkPTPZwFwX3ymz0uakWJo=; b=s6zMhGnzSgO6dNyAaiwUU4QUyCGbm/NqrlASYl82QqX23e9udpuDT7pvLNEuH6vCNP QKc+laLRDs3CZgvN8JOyEaKFRx7HxcYTYMOvLMXHdp4PgrYsVHdBs2+qzgae1/01DIYl tRqL8LgObB077+Ym0lIWRRfcfjqiRXICrqR3O5c63gULSGeiFzne6p8qrn7S0sGtqMWF KpQXtv4QC9dCkuib5+u61JZpbvECMZghQ//2aXEDxcDMuqnBPCt77M1d7zzOT6huOhjL wnp4Fu3BuhLtIOeXrgKkagN+gTzV4KLBc582xmaqLNEDs0PCbWUC0aJqlHhaOQfsiuDy Wd4A== MIME-Version: 1.0 X-Received: by 10.112.138.230 with SMTP id qt6mr8917256lbb.34.1370959080418; Tue, 11 Jun 2013 06:58:00 -0700 (PDT) Received: by 10.112.168.70 with HTTP; Tue, 11 Jun 2013 06:58:00 -0700 (PDT) Date: Tue, 11 Jun 2013 21:58:00 +0800 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=089e0112c742fd760b04dee14825 Subject: php extension about php_stream_fopen_tmpfile() From: bleakwind@gmail.com (Bleakwind) --089e0112c742fd760b04dee14825 Content-Type: text/plain; charset=UTF-8 I write a php extension. How can I user Zend API do that? where can I find some doc about file_handle->handle ? ZEND_API zend_op_array *(*org_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); ZEND_API zend_op_array *sead_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) { php_stream *stream; char *data_decode; int data_decode_len; /* ... */ /* Zend API Begin: This unsuccessful */ php_stream *tmpstream; if ((tmpstream = php_stream_fopen_tmpfile()) == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create temporary file. Check permissions in temporary files directory."); php_stream_close(stream); return org_compile_file(file_handle, type TSRMLS_CC); } numbytes = php_stream_write(tmpstream, data_decode, data_decode_len); if (numbytes != data_decode_len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", numbytes, data_decode_len); numbytes = -1; } php_stream_rewind(tmpstream); /* Zend API End */ /* C Begin: This is OK */ FILE *tmpstream; tmpstream = tmpfile(); fwrite(data_decode, data_decode_len, 1, tmpstream); rewind(tmpstream); /* C End */ file_handle->handle.fp = tmpstream; file_handle->type = ZEND_HANDLE_FP; file_handle->opened_path = expand_filepath(file_handle->filename, NULL TSRMLS_CC); return org_compile_file(file_handle, type TSRMLS_CC); } --089e0112c742fd760b04dee14825--