本文整理汇总了C++中php_stream_close函数的典型用法代码示例。如果您正苦于以下问题:C++ php_stream_close函数的具体用法?C++ php_stream_close怎么用?C++ php_stream_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了php_stream_close函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dba_close
/* {{{ dba_close
*/
static void dba_close(dba_info *info)
{
if (info->hnd) {
info->hnd->close(info);
}
if (info->path) {
pefree(info->path, info->flags&DBA_PERSISTENT);
}
if (info->fp && info->fp != info->lock.fp) {
if (info->flags & DBA_PERSISTENT) {
php_stream_pclose(info->fp);
} else {
php_stream_close(info->fp);
}
}
if (info->lock.fp) {
if (info->flags & DBA_PERSISTENT) {
php_stream_pclose(info->lock.fp);
} else {
php_stream_close(info->lock.fp);
}
}
if (info->lock.name) {
pefree(info->lock.name, info->flags&DBA_PERSISTENT);
}
pefree(info, info->flags&DBA_PERSISTENT);
}
开发者ID:Jille,项目名称:php-src,代码行数:29,代码来源:dba.c
示例2: _jsr_file_get_contents
static zval* _jsr_file_get_contents()
{
TSRMLS_FETCH();
zval *payload;
MAKE_STD_ZVAL(payload);
zend_bool use_include_path = 0;
php_stream *stream;
int len;
long offset = -1;
long maxlen = PHP_STREAM_COPY_ALL;
zval *zcontext = NULL;
php_stream_context *context = NULL;
char *contents;
context = php_stream_context_from_zval(zcontext, 0);
stream = php_stream_open_wrapper_ex("php://input", "rb",
(use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS,
NULL, context);
if (!stream) {
ZVAL_NULL(payload);
php_stream_close(stream);
return payload;
}
if (offset > 0 && php_stream_seek(stream, offset, SEEK_SET) < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", offset);
php_stream_close(stream);
ZVAL_NULL(payload);
return payload;
}
if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) {
#if PHP_API_VERSION < 20100412
if (PG(magic_quotes_runtime)) {
contents = php_addslashes(contents, len, &len, 1 TSRMLS_CC);
}
#endif
ZVAL_STRINGL(payload, contents, len, 1);
php_stream_close(stream);
return payload;
} else if (len == 0) {
ZVAL_STRING(payload, "", 0);
php_stream_close(stream);
return payload;
} else {
ZVAL_NULL(payload);
php_stream_close(stream);
return payload;
}
}
开发者ID:guoyu07,项目名称:JsonRPC,代码行数:59,代码来源:jsr_server.c
示例3: PHP_METHOD
/** {{{ 从文件载入js代码 */
PHP_METHOD(HyperMobile, loadjsfromfile) {
char *filename;
int filename_len;
char *contents;//,*err;
php_stream *stream;
int len;
zval *self,*value;
/* Parse arguments */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
return;
}
self=getThis();
if (strlen(filename) != filename_len) {
RETURN_FALSE;
}
stream = php_stream_open_wrapper(filename, "rb",
ENFORCE_SAFE_MODE | REPORT_ERRORS,
NULL);
if (!stream) {
RETURN_FALSE;
}
if ((len = php_stream_copy_to_mem(stream, &contents, PHP_STREAM_COPY_ALL, 0)) > 0) {
if (PG(magic_quotes_runtime)) {
contents = php_addslashes(contents, len, &len, 1 TSRMLS_CC); /* 1 = free source string */
}
php_stream_close(stream);
//
MAKE_STD_ZVAL(value);
ZVAL_STRING(value,contents,0);
zend_update_property(Z_OBJCE_P(self),self,ZEND_STRL("js_content"),value TSRMLS_CC);
RETURN_TRUE;
} else if (len == 0) {
php_stream_close(stream);
MAKE_STD_ZVAL(value);
// err = ;
ZVAL_STRING(value,"file content is empty",0);
zend_update_property(Z_OBJCE_P(self),self,ZEND_STRL("err_msg"),value TSRMLS_CC);
zend_update_property_bool(Z_OBJCE_P(self),self,ZEND_STRL("error"),1 TSRMLS_CC);
RETURN_FALSE;
} else {
php_stream_close(stream);
MAKE_STD_ZVAL(value);
ZVAL_STRING(value,"unknown error",0);
zend_update_property(Z_OBJCE_P(self),self,ZEND_STRL("err_msg"),value TSRMLS_CC);
zend_update_property_bool(Z_OBJCE_P(self),self,ZEND_STRL("error"),1 TSRMLS_CC);
RETURN_FALSE;
}
}
开发者ID:BriquzStudio,项目名称:HyperMobile-phpext,代码行数:56,代码来源:HyperMobile.c
示例4: cli_register_file_handles
static void cli_register_file_handles(void) /* {{{ */
{
zval zin, zout, zerr;
php_stream *s_in, *s_out, *s_err;
php_stream_context *sc_in=NULL, *sc_out=NULL, *sc_err=NULL;
zend_constant ic, oc, ec;
s_in = php_stream_open_wrapper_ex("php://stdin", "rb", 0, NULL, sc_in);
s_out = php_stream_open_wrapper_ex("php://stdout", "wb", 0, NULL, sc_out);
s_err = php_stream_open_wrapper_ex("php://stderr", "wb", 0, NULL, sc_err);
if (s_in==NULL || s_out==NULL || s_err==NULL) {
if (s_in) php_stream_close(s_in);
if (s_out) php_stream_close(s_out);
if (s_err) php_stream_close(s_err);
return;
}
#if PHP_DEBUG
/* do not close stdout and stderr */
s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE;
s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE;
#endif
s_in_process = s_in;
php_stream_to_zval(s_in, &zin);
php_stream_to_zval(s_out, &zout);
php_stream_to_zval(s_err, &zerr);
ZVAL_COPY_VALUE(&ic.value, &zin);
ic.flags = CONST_CS;
ic.name = zend_string_init("STDIN", sizeof("STDIN")-1, 1);
ic.module_number = 0;
zend_register_constant(&ic);
ZVAL_COPY_VALUE(&oc.value, &zout);
oc.flags = CONST_CS;
oc.name = zend_string_init("STDOUT", sizeof("STDOUT")-1, 1);
oc.module_number = 0;
zend_register_constant(&oc);
ZVAL_COPY_VALUE(&ec.value, &zerr);
ec.flags = CONST_CS;
ec.name = zend_string_init("STDERR", sizeof("STDERR")-1, 1);
ec.module_number = 0;
zend_register_constant(&ec);
}
开发者ID:EleTeam,项目名称:php-src,代码行数:48,代码来源:php_cli.c
示例5: ftp_close
/* {{{ ftp_close
*/
ftpbuf_t*
ftp_close(ftpbuf_t *ftp)
{
if (ftp == NULL) {
return NULL;
}
if (ftp->data) {
data_close(ftp, ftp->data);
}
if (ftp->stream && ftp->closestream) {
php_stream_close(ftp->stream);
}
if (ftp->fd != -1) {
#ifdef HAVE_FTP_SSL
if (ftp->ssl_active) {
SSL_shutdown(ftp->ssl_handle);
SSL_free(ftp->ssl_handle);
}
#endif
closesocket(ftp->fd);
}
ftp_gc(ftp);
efree(ftp);
return NULL;
}
开发者ID:LTD-Beget,项目名称:php-src,代码行数:27,代码来源:ftp.c
示例6: zephir_file_get_contents
void zephir_file_get_contents(zval *return_value, zval *filename)
{
zend_string *contents;
php_stream *stream;
long maxlen = PHP_STREAM_COPY_ALL;
zval *zcontext = NULL;
php_stream_context *context = NULL;
if (Z_TYPE_P(filename) != IS_STRING) {
php_error_docref(NULL, E_WARNING, "Invalid arguments supplied for zephir_file_get_contents()");
RETVAL_FALSE;
return;
}
context = php_stream_context_from_zval(zcontext, 0);
stream = php_stream_open_wrapper_ex(Z_STRVAL_P(filename), "rb", 0 | REPORT_ERRORS, NULL, context);
if (!stream) {
RETURN_FALSE;
}
if ((contents = php_stream_copy_to_mem(stream, maxlen, 0)) != NULL) {
RETVAL_STR(contents);
} else {
RETVAL_EMPTY_STRING();
}
php_stream_close(stream);
}
开发者ID:oscarmolinadev,项目名称:zephir,代码行数:29,代码来源:file.c
示例7: PHP_FUNCTION
/* {{{ proto int readgzfile(string filename [, int use_include_path])
Output a .gz-file */
static PHP_FUNCTION(readgzfile)
{
char *filename;
size_t filename_len;
int flags = REPORT_ERRORS;
php_stream *stream;
size_t size;
zend_long use_include_path = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|l", &filename, &filename_len, &use_include_path) == FAILURE) {
return;
}
if (use_include_path) {
flags |= USE_PATH;
}
stream = php_stream_gzopen(NULL, filename, "rb", flags, NULL, NULL STREAMS_CC);
if (!stream) {
RETURN_FALSE;
}
size = php_stream_passthru(stream);
php_stream_close(stream);
RETURN_LONG(size);
}
开发者ID:Furgas,项目名称:php-src,代码行数:28,代码来源:zlib.c
示例8: php_stream_ftp_stream_close
/* {{{ php_stream_ftp_stream_close
*/
static int php_stream_ftp_stream_close(php_stream_wrapper *wrapper, php_stream *stream)
{
php_stream *controlstream = stream->wrapperthis;
int ret = 0;
if (controlstream) {
if (strpbrk(stream->mode, "wa+")) {
char tmp_line[512];
int result;
/* For write modes close data stream first to signal EOF to server */
result = GET_FTP_RESULT(controlstream);
if (result != 226 && result != 250) {
php_error_docref(NULL, E_WARNING, "FTP server error %d:%s", result, tmp_line);
ret = EOF;
}
}
php_stream_write_string(controlstream, "QUIT\r\n");
php_stream_close(controlstream);
stream->wrapperthis = NULL;
}
return ret;
}
开发者ID:AmesianX,项目名称:php-src,代码行数:27,代码来源:ftp_fopen_wrapper.c
示例9: ftp_close
/* {{{ ftp_close
*/
ftpbuf_t*
ftp_close(ftpbuf_t *ftp)
{
if (ftp == NULL) {
return NULL;
}
if (ftp->data) {
data_close(ftp, ftp->data);
}
if (ftp->stream && ftp->closestream) {
TSRMLS_FETCH();
php_stream_close(ftp->stream);
}
if (ftp->fd != -1) {
#if HAVE_OPENSSL_EXT
if (ftp->ssl_active) {
SSL_shutdown(ftp->ssl_handle);
SSL_free(ftp->ssl_handle);
}
#endif
closesocket(ftp->fd);
}
ftp_gc(ftp);
efree(ftp);
return NULL;
}
开发者ID:90youth,项目名称:php-src,代码行数:28,代码来源:ftp.c
示例10: php_hash_do_hash
static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_bool raw_output_default) /* {{{ */
{
char *algo, *data, *digest;
int algo_len, data_len;
zend_bool raw_output = raw_output_default;
const php_hash_ops *ops;
void *context;
php_stream *stream = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &algo, &algo_len, &data, &data_len, &raw_output) == FAILURE) {
return;
}
ops = php_hash_fetch_ops(algo, algo_len);
if (!ops) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown hashing algorithm: %s", algo);
RETURN_FALSE;
}
if (isfilename) {
if (CHECK_NULL_PATH(data, data_len)) {
RETURN_FALSE;
}
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);
if (!stream) {
/* Stream will report errors opening file */
RETURN_FALSE;
}
}
context = emalloc(ops->context_size);
ops->hash_init(context);
if (isfilename) {
char buf[1024];
int n;
while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
ops->hash_update(context, (unsigned char *) buf, n);
}
php_stream_close(stream);
} else {
ops->hash_update(context, (unsigned char *) data, data_len);
}
digest = emalloc(ops->digest_size + 1);
ops->hash_final((unsigned char *) digest, context);
efree(context);
if (raw_output) {
digest[ops->digest_size] = 0;
RETURN_STRINGL(digest, ops->digest_size, 0);
} else {
char *hex_digest = safe_emalloc(ops->digest_size, 2, 1);
php_hash_bin2hex(hex_digest, (unsigned char *) digest, ops->digest_size);
hex_digest[2 * ops->digest_size] = 0;
efree(digest);
RETURN_STRINGL(hex_digest, 2 * ops->digest_size, 0);
}
}
开发者ID:31H0B1eV,项目名称:php-src,代码行数:60,代码来源:hash.c
示例11: PHP_METHOD
/**
* Gets HTTP raw request body
*
* @return string
*/
PHP_METHOD(Phalcon_Http_Request, getRawBody)
{
zval raw = {}, *zcontext = NULL;
zend_string *content;
php_stream_context *context;
php_stream *stream;
long int maxlen;
phalcon_read_property(&raw, getThis(), SL("_rawBody"), PH_NOISY);
if (Z_TYPE(raw) == IS_STRING) {
RETURN_CTORW(&raw);
}
context = php_stream_context_from_zval(zcontext, 0);
stream = php_stream_open_wrapper_ex("php://input", "rb", REPORT_ERRORS, NULL, context);
maxlen = PHP_STREAM_COPY_ALL;
if (!stream) {
RETURN_FALSE;
}
content = php_stream_copy_to_mem(stream, maxlen, 0);
if (content != NULL) {
RETVAL_STR(content);
phalcon_update_property_zval(getThis(), SL("_rawBody"), return_value);
} else {
RETVAL_FALSE;
}
php_stream_close(stream);
}
开发者ID:dreamsxin,项目名称:cphalcon7,代码行数:36,代码来源:request.c
示例12: ZEND_METHOD
ZEND_METHOD(hprose_bytes_io, load) {
php_stream *stream;
char *filename;
#if PHP_MAJOR_VERSION < 7
char *buf;
#else
zend_string *s;
#endif
length_t len;
HPROSE_OBJECT_INTERN(bytes_io);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &len) == FAILURE) {
return;
}
stream = php_stream_open_wrapper(filename, "rb", REPORT_ERRORS, NULL);
if (stream == NULL) {
RETURN_FALSE;
}
#if PHP_MAJOR_VERSION < 7
if ((len = php_stream_copy_to_mem(stream, &buf, PHP_STREAM_COPY_ALL, HB_PERSISTENT_P(intern->_this))) > 0) {
hprose_bytes_io_close(intern->_this);
intern->_this->buf = buf;
HB_CAP_P(intern->_this) = len;
HB_LEN_P(intern->_this) = len;
HB_POS_P(intern->_this) = 0;
intern->mark = -1;
}
#else
if ((s = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, HB_PERSISTENT_P(intern->_this))) != NULL) {
hprose_bytes_io_close(intern->_this);
intern->_this->s = s;
HB_CAP_P(intern->_this) = HB_LEN_P(intern->_this);
HB_POS_P(intern->_this) = 0;
intern->mark = -1;
}
#endif
else if (len == 0) {
hprose_bytes_io_close(intern->_this);
intern->mark = -1;
}
else {
php_stream_close(stream);
RETURN_FALSE;
}
php_stream_close(stream);
RETURN_TRUE;
}
开发者ID:hakiu,项目名称:hprose-pecl,代码行数:46,代码来源:hprose_bytes_io.c
示例13: stream_cookie_closer
static int stream_cookie_closer(void *cookie)
{
php_stream *stream = (php_stream*)cookie;
TSRMLS_FETCH();
/* prevent recursion */
stream->fclose_stdiocast = PHP_STREAM_FCLOSE_NONE;
return php_stream_close(stream);
}
开发者ID:practicalweb,项目名称:php-src,代码行数:9,代码来源:cast.c
示例14: PHP_METHOD
/**
* override __call()
* it require two parameters, func_name and args
**/
PHP_METHOD(McpackHessianClient, __call) {
zend_class_entry *ce;
zval *p_this, *args, *params, *result, *method, *tmp;
char *func_name, *ret_str = NULL;
int func_name_len = 0;
size_t return_len = 0, max_len = 1024 * 1024 * 1024;
p_this = getThis();
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, p_this,
"Osz", &ce, mcphessian_ce_ptr, &func_name, &func_name_len, &args) == FAILURE) {
php_error(E_WARNING, "parse parameters error.");
RETURN_NULL();
}
// init params
MAKE_STD_ZVAL(params);
array_init(params);
add_assoc_string(params, "jsonrpc", "2.0", 0);
add_assoc_string(params, "method", func_name, 0);
add_assoc_zval(params, "params", args);
add_assoc_string(params, "id", "123456", 0);
zval *pack = array2mcpack(params);
// post data
zval *z_url = zend_read_property(mcphessian_ce_ptr, p_this, ZEND_STRL("url"), 1 TSRMLS_CC);
convert_to_string(z_url);
char *url = Z_STRVAL_P(z_url);
php_stream_context *context = php_stream_context_alloc();
MAKE_STD_ZVAL(method);
ZVAL_STRING(method, "POST", 0);
php_stream_context_set_option(context, "http", "method", method);
php_stream_context_set_option(context, "http", "content", pack);
// read data from stream
php_stream *stream = php_stream_open_wrapper_ex(url, "rb", REPORT_ERRORS, NULL, context);
if (stream) {
ret_str = php_stream_get_line(stream, NULL, max_len, &return_len);
} else {
php_error(E_WARNING, "failed to open stream %s.", url);
RETURN_NULL();
}
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, ret_str, return_len, 0);
result = mcpack2array(tmp);
php_stream_close(stream);
efree(ret_str);
// get result from array
zval **ret_val;
if (zend_hash_exists(Z_ARRVAL_P(result), "result", 7)) {
zend_hash_find(Z_ARRVAL_P(result), "result", 7, (void **)&ret_val);
RETURN_ZVAL(*ret_val, 1, 0);
} else {
php_error(E_WARNING, "return value illegal.");
RETURN_NULL();
}
}
开发者ID:Raaaay,项目名称:mcphessian,代码行数:61,代码来源:mcphessian.c
示例15: php_mail_log_to_file
void php_mail_log_to_file(char *filename, char *message, size_t message_size TSRMLS_DC) {
/* Write 'message' to the given file. */
uint flags = IGNORE_URL_WIN | REPORT_ERRORS | STREAM_DISABLE_OPEN_BASEDIR;
php_stream *stream = php_stream_open_wrapper(filename, "a", flags, NULL);
if (stream) {
php_stream_write(stream, message, message_size);
php_stream_close(stream);
}
}
开发者ID:mania25,项目名称:diy-project,代码行数:9,代码来源:mail.c
示例16: PHP_METHOD
/**
* Prints out HTTP response to the client
*
* @return Phalcon\Http\ResponseInterface
*/
PHP_METHOD(Phalcon_Http_Response, send){
zval *sent, *headers, *cookies, *content, *file;
PHALCON_MM_GROW();
PHALCON_OBS_VAR(sent);
phalcon_read_property_this(&sent, this_ptr, SL("_sent"), PH_NOISY_CC);
if (PHALCON_IS_FALSE(sent)) {
/**
* Send headers
*/
PHALCON_OBS_VAR(headers);
phalcon_read_property_this(&headers, this_ptr, SL("_headers"), PH_NOISY_CC);
if (Z_TYPE_P(headers) == IS_OBJECT) {
phalcon_call_method_noret(headers, "send");
}
PHALCON_OBS_VAR(cookies);
phalcon_read_property_this(&cookies, this_ptr, SL("_cookies"), PH_NOISY_CC);
if (Z_TYPE_P(cookies) == IS_OBJECT) {
phalcon_call_method_noret(cookies, "send");
}
/**
* Output the response body
*/
PHALCON_OBS_VAR(content);
phalcon_read_property_this(&content, this_ptr, SL("_content"), PH_NOISY_CC);
if (Z_STRLEN_P(content)) {
zend_print_zval(content, 0);
}
else {
PHALCON_OBS_VAR(file);
phalcon_read_property_this(&file, this_ptr, SL("_file"), PH_NOISY_CC);
if (Z_STRLEN_P(file)) {
php_stream *stream;
stream = php_stream_open_wrapper(Z_STRVAL_P(file), "rb", REPORT_ERRORS, NULL);
if (stream != NULL) {
php_stream_passthru(stream);
php_stream_close(stream);
}
}
}
phalcon_update_property_bool(this_ptr, SL("_sent"), 1 TSRMLS_CC);
RETURN_THIS();
}
PHALCON_THROW_EXCEPTION_STR(phalcon_http_response_exception_ce, "Response was already sent");
return;
}
开发者ID:11mariom,项目名称:cphalcon,代码行数:61,代码来源:response.c
示例17: _php_image_stream_ctxfreeandclose
static void _php_image_stream_ctxfreeandclose(struct gdIOCtx *ctx) /* {{{ */
{
if(ctx->data) {
php_stream_close((php_stream *) ctx->data);
ctx->data = NULL;
}
if(ctx) {
efree(ctx);
}
} /* }}} */
开发者ID:DaveRandom,项目名称:php-src,代码行数:11,代码来源:gd_ctx.c
示例18: _php_image_stream_ctxfree
static void _php_image_stream_ctxfree(struct gdIOCtx *ctx)
{
TSRMLS_FETCH();
if(ctx->data) {
php_stream_close((php_stream *) ctx->data);
ctx->data = NULL;
}
if(ctx) {
efree(ctx);
}
}
开发者ID:1HLtd,项目名称:php-src,代码行数:12,代码来源:gd_ctx.c
示例19: mysqlnd_local_infile_end
/* {{{ mysqlnd_local_infile_end */
static
void mysqlnd_local_infile_end(void * ptr)
{
MYSQLND_INFILE_INFO *info = (MYSQLND_INFILE_INFO *)ptr;
if (info) {
/* php_stream_close segfaults on NULL */
if (info->fd) {
php_stream_close(info->fd);
info->fd = NULL;
}
mnd_efree(info);
}
}
开发者ID:Distrotech,项目名称:php-src,代码行数:15,代码来源:mysqlnd_loaddata.c
示例20: ZSTR_EMPTY_ALLOC
static zend_string *php_tidy_file_to_mem(char *filename, zend_bool use_include_path)
{
php_stream *stream;
zend_string *data = NULL;
if (!(stream = php_stream_open_wrapper(filename, "rb", (use_include_path ? USE_PATH : 0), NULL))) {
return NULL;
}
if ((data = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0)) == NULL) {
data = ZSTR_EMPTY_ALLOC();
}
php_stream_close(stream);
return data;
}
开发者ID:CooCoooo,项目名称:php-src,代码行数:15,代码来源:tidy.c
注:本文中的php_stream_close函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论