Commit:15e76e6a98ded4f28aa8d5a91b2286497e44fc5b
Author:Stanislav Malyshev Tue, 29 Jan 2013 15:02:55
-0800
Parents: 26de5cc57fa39b9682cd5523711638d98fa6fddd
Branches: PHP-5.5 master
Link:
http://git.php.net/?p=php-src.git;a=commitdiff;h=15e76e6a98ded4f28aa8d5a91b2286497e44fc5b
Log:
forgot this file :(
Changed paths:
A ext/curl/curl_file.c
Diff:
diff --git a/ext/curl/curl_file.c b/ext/curl/curl_file.c
new file mode 100644
index 000..2717678
--- /dev/null
+++ b/ext/curl/curl_file.c
@@ -0,0 +1,176 @@
+/*
+ +--+
+ | PHP Version 5|
+ +--+
+ | Copyright (c) 1997-2013 The PHP Group|
+ +--+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is|
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | lice...@php.net so we can mail you a copy immediately. |
+ +--+
+ | Author: Stanislav Malyshev |
+ +--+
+ */
+
+/* $Id$ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "php.h"
+#include "php_curl.h"
+#if HAVE_CURL
+
+PHP_CURL_API zend_class_entry *curl_CURLFile_class;
+
+static void curlfile_ctor(INTERNAL_FUNCTION_PARAMETERS)
+{
+ char *fname = NULL, *mime = NULL, *postname = NULL;
+ int fname_len, mime_len, postname_len;
+ zval *cf = return_value;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ss", &fname,
&fname_len, &mime, &mime_len, &postname, &postname_len) == FAILURE) {
+ return;
+ }
+
+ if (fname) {
+ zend_update_property_string(curl_CURLFile_class, cf, "name",
sizeof("name")-1, fname TSRMLS_CC);
+ }
+
+ if (mime) {
+ zend_update_property_string(curl_CURLFile_class, cf, "mime",
sizeof("mime")-1, mime TSRMLS_CC);
+ }
+
+ if (postname) {
+ zend_update_property_string(curl_CURLFile_class, cf,
"postname", sizeof("postname")-1, postname TSRMLS_CC);
+ }
+}
+
+/* {{{ proto string CURLFile::__construct(string $name, [string $mimetype [,
string $postfilename]])
+ Create the CURLFile object */
+ZEND_METHOD(CURLFile, __construct)
+{
+ return_value = getThis();
+ curlfile_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+/* }}} */
+
+/* {{{ proto string curl_file_create(string $name, [string $mimetype [, string
$postfilename]])
+ Create the CURLFile object */
+PHP_FUNCTION(curl_file_create)
+{
+object_init_ex( return_value, curl_CURLFile_class );
+curlfile_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+/* }}} */
+
+static void curlfile_get_property(char *name, INTERNAL_FUNCTION_PARAMETERS)
+{
+ zval *res;
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+ res = zend_read_property(curl_CURLFile_class, getThis(), name,
strlen(name), 1 TSRMLS_CC);
+ *return_value = *res;
+ zval_copy_ctor(return_value);
+ INIT_PZVAL(return_value);
+}
+
+static void curlfile_set_property(char *name, INTERNAL_FUNCTION_PARAMETERS)
+{
+ char *arg = NULL;
+ int arg_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg,
&arg_len) == FAILURE) {
+ return;
+ }
+ zend_update_property_string(curl_CURLFile_class, getThis(), name,
strlen(name), arg TSRMLS_CC);
+}
+
+/* {{{ proto string CURLFile::getFilename()
+ Get file name */
+ZEND_METHOD(CURLFile, getFilename)
+{
+ curlfile_get_property("name", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+/* }}} */
+
+/* {{{ proto string CURLFile::getMimeType()
+ Get MIME type */
+ZEND_METHOD(CURLFile, getMimeType)
+{
+ curlfile_get_property("mime", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+/* }}} */
+
+/* {{{ proto string CURLFile::getPostFilename()
+ Get file name for POST */
+ZEND_METHOD(CURLFile, getPostFilename)
+{
+ curlfile_get_property("postname", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+/* }}} */
+
+/* {{{ proto string CURLFile::setMimeType(string $mime)
+ Set MIME type */
+ZEND_METHOD(CURLFile, setMimeType)
+{
+ curlfile_set_property("mime", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+/* }}} */
+
+/* {{{ proto string CURLFile::setPostFilename(string $name)
+ Set file name for POST */
+ZEND_METHOD(CURLFile, setPostFilename)