• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ php_stream_write函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中php_stream_write函数的典型用法代码示例。如果您正苦于以下问题:C++ php_stream_write函数的具体用法?C++ php_stream_write怎么用?C++ php_stream_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了php_stream_write函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: flatfile_store

/* {{{ flatfile_store
 */
int flatfile_store(flatfile *dba, datum key_datum, datum value_datum, int mode TSRMLS_DC) {
	if (mode == FLATFILE_INSERT) {
		if (flatfile_findkey(dba, key_datum TSRMLS_CC)) {
			return 1;
		}
		php_stream_seek(dba->fp, 0L, SEEK_END);
		php_stream_printf(dba->fp TSRMLS_CC, "%zu\n", key_datum.dsize);
		php_stream_flush(dba->fp);
		if (php_stream_write(dba->fp, key_datum.dptr, key_datum.dsize) < key_datum.dsize) {
			return -1;
		}
		php_stream_printf(dba->fp TSRMLS_CC, "%zu\n", value_datum.dsize);
		php_stream_flush(dba->fp);
		if (php_stream_write(dba->fp, value_datum.dptr, value_datum.dsize) < value_datum.dsize) {
			return -1;
		}
	} else { /* FLATFILE_REPLACE */
		flatfile_delete(dba, key_datum TSRMLS_CC);
		php_stream_printf(dba->fp TSRMLS_CC, "%zu\n", key_datum.dsize);
		php_stream_flush(dba->fp);
		if (php_stream_write(dba->fp, key_datum.dptr, key_datum.dsize) < key_datum.dsize) {
			return -1;
		}
		php_stream_printf(dba->fp TSRMLS_CC, "%zu\n", value_datum.dsize);
		if (php_stream_write(dba->fp, value_datum.dptr, value_datum.dsize) < value_datum.dsize) {
			return -1;
		}
	}

	php_stream_flush(dba->fp);
	return 0;
}
开发者ID:Doap,项目名称:php-src,代码行数:34,代码来源:flatfile.c


示例2: on_data_available

static size_t on_data_available(char *data, size_t size, size_t nmemb, void *ctx)
{
	php_stream *stream = (php_stream *) ctx;
	php_curl_stream *curlstream = (php_curl_stream *) stream->abstract;
	size_t wrote;
	TSRMLS_FETCH();

	/* TODO: I'd like to deprecate this.
	 * This code is here because until we start getting real data, we don't know
	 * if we have had all of the headers 
	 * */
	if (curlstream->readbuffer.writepos == 0) {
		zval *sym;

		if (!EG(active_symbol_table)) {
			zend_rebuild_symbol_table(TSRMLS_C);
		}
		MAKE_STD_ZVAL(sym);
		*sym = *curlstream->headers;
		zval_copy_ctor(sym);
		ZEND_SET_SYMBOL(EG(active_symbol_table), "http_response_header", sym);
	}
	
	php_stream_seek(curlstream->readbuffer.buf, curlstream->readbuffer.writepos, SEEK_SET);
	wrote = php_stream_write(curlstream->readbuffer.buf, data, size * nmemb);
	curlstream->readbuffer.writepos = php_stream_tell(curlstream->readbuffer.buf);

	return wrote;
}
开发者ID:Calado,项目名称:php-src,代码行数:29,代码来源:streams.c


示例3: php_stream_input_read

static size_t php_stream_input_read(php_stream *stream, char *buf, size_t count) /* {{{ */
{
	php_stream_input_t *input = stream->abstract;
	size_t read;

	if (!SG(post_read) && SG(read_post_bytes) < (int64_t)(input->position + count)) {
		/* read requested data from SAPI */
		size_t read_bytes = sapi_read_post_block(buf, count);

		if (read_bytes > 0) {
			php_stream_seek(input->body, 0, SEEK_END);
			php_stream_write(input->body, buf, read_bytes);
		}
	}

	if (!input->body->readfilters.head) {
		/* If the input stream contains filters, it's not really seekable. The
			input->position is likely to be wrong for unfiltered data. */
		php_stream_seek(input->body, input->position, SEEK_SET);
	}
	read = php_stream_read(input->body, buf, count);

	if (!read || read == (size_t) -1) {
		stream->eof = 1;
	} else {
		input->position += read;
	}

	return read;
}
开发者ID:PeeHaa,项目名称:php-src,代码行数:30,代码来源:php_fopen_wrapper.c


示例4: php_stream_input_read

static size_t php_stream_input_read(php_stream *stream, char *buf, size_t count) /* {{{ */
{
	php_stream_input_t *input = stream->abstract;
	size_t read;

	if (!SG(post_read) && SG(read_post_bytes) < (int64_t)(input->position + count)) {
		/* read requested data from SAPI */
		int read_bytes = sapi_read_post_block(buf, count);

		if (read_bytes > 0) {
			php_stream_seek(input->body, 0, SEEK_END);
			php_stream_write(input->body, buf, read_bytes);
		}
	}

	php_stream_seek(input->body, input->position, SEEK_SET);
	read = php_stream_read(input->body, buf, count);

	if (!read || read == (size_t) -1) {
		stream->eof = 1;
	} else {
		input->position += read;
	}

	return read;
}
开发者ID:mdesign83,项目名称:php-src,代码行数:26,代码来源:php_fopen_wrapper.c


示例5: real_php_log_buffer

static int real_php_log_buffer(zval *msg_buffer, char *opt, int opt_len TSRMLS_DC)
{
    php_stream *stream = NULL;
    HashTable *ht;

#if PHP_VERSION_ID >= 70000
    zend_ulong num_key;
    zend_string *str_key;
    zval *entry;
#else
    zval **log;
#endif

    stream = process_stream(opt,opt_len TSRMLS_CC);

    if (stream == NULL)
    {
        return FAILURE;
    }

#if PHP_VERSION_ID >= 70000

    ht = HASH_OF(msg_buffer);
    ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, str_key, entry)
    {
        zend_string *s = zval_get_string(entry);
        php_stream_write(stream, ZSTR_VAL(s), ZSTR_LEN(s));
        zend_string_release(s);
    }
开发者ID:SeasX,项目名称:SeasLog,代码行数:29,代码来源:Buffer.c


示例6: ftp_nb_continue_read

/* {{{ ftp_nb_continue_read
 */
int
ftp_nb_continue_read(ftpbuf_t *ftp)
{
	databuf_t	*data = NULL;
	char		*ptr;
	int		lastch;
	size_t		rcvd;
	ftptype_t	type;

	data = ftp->data;

	/* check if there is already more data */
	if (!data_available(ftp, data->fd)) {
		return PHP_FTP_MOREDATA;
	}

	type = ftp->type;

	lastch = ftp->lastch;
	if ((rcvd = my_recv(ftp, data->fd, data->buf, FTP_BUFSIZE))) {
		if (rcvd == -1) {
			goto bail;
		}

		if (type == FTPTYPE_ASCII) {
			for (ptr = data->buf; rcvd; rcvd--, ptr++) {
				if (lastch == '\r' && *ptr != '\n') {
					php_stream_putc(ftp->stream, '\r');
				}
				if (*ptr != '\r') {
					php_stream_putc(ftp->stream, *ptr);
				}
				lastch = *ptr;
			}
		} else if (rcvd != php_stream_write(ftp->stream, data->buf, rcvd)) {
			goto bail;
		}

		ftp->lastch = lastch;
		return PHP_FTP_MOREDATA;
	}

	if (type == FTPTYPE_ASCII && lastch == '\r') {
		php_stream_putc(ftp->stream, '\r');
	}

	ftp->data = data = data_close(ftp, data);

	if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) {
		goto bail;
	}

	ftp->nb = 0;
	return PHP_FTP_FINISHED;
bail:
	ftp->nb = 0;
	ftp->data = data_close(ftp, data);
	return PHP_FTP_FAILED;
}
开发者ID:AmesianX,项目名称:php-src,代码行数:61,代码来源:ftp.c


示例7: 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


示例8: MYSQLND_METHOD

/* {{{ mysqlnd_vio::network_write */
static size_t
MYSQLND_METHOD(mysqlnd_vio, network_write)(MYSQLND_VIO * const vio, const zend_uchar * const buffer, const size_t count,
											  MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info)
{
	size_t ret;
	DBG_ENTER("mysqlnd_vio::network_write");
	DBG_INF_FMT("sending %u bytes", count);
	ret = php_stream_write(vio->data->m.get_stream(vio), (char *)buffer, count);
	DBG_RETURN(ret);
}
开发者ID:MajorDeng,项目名称:php-src,代码行数:11,代码来源:mysqlnd_vio.c


示例9: php_curl_stream_write

static size_t php_curl_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
{
	php_curl_stream *curlstream = (php_curl_stream *) stream->abstract;

	if (curlstream->writebuffer.buf) {
		return php_stream_write(curlstream->writebuffer.buf, buf, count);
	}
	
	return 0;
}
开发者ID:Calado,项目名称:php-src,代码行数:10,代码来源:streams.c


示例10: php_mongo_io_stream_send

int php_mongo_io_stream_send(mongo_connection *con, mongo_server_options *options, void *data, int size, char **error_message)
{
	int retval;
	TSRMLS_FETCH();

	php_mongo_stream_notify_io(options, MONGO_STREAM_NOTIFY_IO_WRITE, 0, size TSRMLS_CC);

	retval = php_stream_write(con->socket, (char *) data, size);
	if (retval >= size) {
		php_mongo_stream_notify_io(options, MONGO_STREAM_NOTIFY_IO_COMPLETED, size, size TSRMLS_CC);
	}

	return retval;
}
开发者ID:johnpaulmedina,项目名称:mongo-php-driver,代码行数:14,代码来源:io_stream.c


示例11: stm_write

static HRESULT STDMETHODCALLTYPE stm_write(IStream *This, void const *pv, ULONG cb, ULONG *pcbWritten)
{
	ULONG nwrote;
	FETCH_STM();

	nwrote = (ULONG)php_stream_write(stm->stream, pv, cb);

	if (pcbWritten) {
		*pcbWritten = nwrote > 0 ? nwrote : 0;
	}
	if (nwrote > 0) {
		return S_OK;
	}
	return S_FALSE;
}
开发者ID:AxiosCros,项目名称:php-src,代码行数:15,代码来源:com_persist.c


示例12: php_mongo_io_stream_send

int php_mongo_io_stream_send(mongo_connection *con, mongo_server_options *options, void *data, int size, char **error_message)
{
	int retval;
	ERROR_HANDLER_DECLARATION(error_handler)
	TSRMLS_FETCH();

	php_mongo_stream_notify_io(options, MONGO_STREAM_NOTIFY_IO_WRITE, 0, size TSRMLS_CC);

	ERROR_HANDLER_REPLACE(error_handler, mongo_ce_ConnectionException);
	retval = php_stream_write(con->socket, (char *) data, size);
	ERROR_HANDLER_RESTORE(error_handler);
	if (retval >= size) {
		php_mongo_stream_notify_io(options, MONGO_STREAM_NOTIFY_IO_COMPLETED, size, size TSRMLS_CC);
	}

	return retval;
}
开发者ID:LTD-Beget,项目名称:mongo-php-driver,代码行数:17,代码来源:io_stream.c


示例13: SAPI_POST_READER_FUNC

SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
{
	if ((SG(post_max_size) > 0) && (SG(request_info).content_length > SG(post_max_size))) {
		php_error_docref(NULL, E_WARNING, "POST Content-Length of " ZEND_LONG_FMT " bytes exceeds the limit of " ZEND_LONG_FMT " bytes",
					SG(request_info).content_length, SG(post_max_size));
		return;
	}


	SG(request_info).request_body = php_stream_temp_create_ex(TEMP_STREAM_DEFAULT, SAPI_POST_BLOCK_SIZE, PG(upload_tmp_dir));

	if (sapi_module.read_post) {
		size_t read_bytes;

		for (;;) {
			char buffer[SAPI_POST_BLOCK_SIZE];

			read_bytes = sapi_read_post_block(buffer, SAPI_POST_BLOCK_SIZE);

			if (read_bytes > 0) {
				if (php_stream_write(SG(request_info).request_body, buffer, read_bytes) != read_bytes) {
					/* if parts of the stream can't be written, purge it completely */
					php_stream_truncate_set_size(SG(request_info).request_body, 0);
					php_error_docref(NULL, E_WARNING, "POST data can't be buffered; all data discarded");
					break;
				}
			}

			if ((SG(post_max_size) > 0) && (SG(read_post_bytes) > SG(post_max_size))) {
				php_error_docref(NULL, E_WARNING, "Actual POST length does not match Content-Length, and exceeds " ZEND_LONG_FMT " bytes", SG(post_max_size));
				break;
			}

			if (read_bytes < SAPI_POST_BLOCK_SIZE) {
				/* done */
				break;
			}
		}
		php_stream_rewind(SG(request_info).request_body);
	}
}
开发者ID:LTD-Beget,项目名称:php-src,代码行数:41,代码来源:SAPI.c


示例14: assert

/* {{{ */
PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC)
{
	php_stream *stream;
	php_stream_memory_data *ms;

	if ((stream = php_stream_memory_create_rel(mode)) != NULL) {
		ms = (php_stream_memory_data*)stream->abstract;

		if (mode == TEMP_STREAM_READONLY || mode == TEMP_STREAM_TAKE_BUFFER) {
			/* use the buffer directly */
			ms->data = buf;
			ms->fsize = length;
		} else {
			if (length) {
				assert(buf != NULL);
				php_stream_write(stream, buf, length);
			}
		}
	}
	return stream;
}
开发者ID:PeeHaa,项目名称:php-src,代码行数:22,代码来源:memory.c


示例15: php_xz_compress

static int php_xz_compress(struct php_xz_stream_data_t *self)
{
  //this function will attempt to consume all bytes in lzma_stream->next_in
  // and write to underlying file
  lzma_stream *strm = &self->strm;
  lzma_action action = LZMA_RUN;
  int wrote = 0;
  int to_write = strm->avail_in;

  while (strm->avail_in > 0) {
    lzma_ret ret = lzma_code(strm, action);
    size_t write_size = self->out_buf_sz - strm->avail_out;
    php_stream_write(self->stream, self->out_buf, write_size);
    strm->next_out = self->out_buf;
    strm->avail_out = self->out_buf_sz;
  }

  strm->next_in = self->in_buf;

  return to_write;
}
开发者ID:chobie,项目名称:php-xz,代码行数:21,代码来源:xz_fopen_wrapper.c


示例16: zephir_fwrite

void zephir_fwrite(zval *return_value, zval *stream_zval, zval *data)
{

	int num_bytes;
	php_stream *stream;

	if (Z_TYPE_P(stream_zval) != IS_RESOURCE) {
		php_error_docref(NULL, E_WARNING, "Invalid arguments supplied for zephir_fwrite()");
		if (return_value) {
			RETVAL_FALSE;
		} else {
			return;
		}
	}

	if (Z_TYPE_P(data) != IS_STRING) {
		/* @todo convert data to string */
		php_error_docref(NULL, E_WARNING, "Invalid arguments supplied for zephir_fwrite()");
		if (return_value) {
			RETVAL_FALSE;
		} else {
			return;
		}
	}

	if (!Z_STRLEN_P(data)) {
		if (return_value) {
			RETURN_LONG(0);
		} else {
			return;
		}
	}

	PHP_STREAM_TO_ZVAL(stream, stream_zval);

	num_bytes = php_stream_write(stream, Z_STRVAL_P(data), Z_STRLEN_P(data));
	if (return_value) {
		RETURN_LONG(num_bytes);
	}
}
开发者ID:oscarmolinadev,项目名称:zephir,代码行数:40,代码来源:file.c


示例17: ZEND_METHOD

ZEND_METHOD(hprose_bytes_io, save) {
    php_stream *stream;
    char *filename;
    length_t len;
    int32_t numbytes = 0;
    HPROSE_THIS(bytes_io);
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &len) == FAILURE) {
        return;
    }
    stream = php_stream_open_wrapper(filename, "wb", REPORT_ERRORS, NULL);
    if (stream == NULL) {
        RETURN_FALSE;
    }
    if (HB_INITED_P(_this) && HB_LEN_P(_this)) {
        numbytes = php_stream_write(stream, HB_BUF_P(_this), HB_LEN_P(_this));
        if (numbytes != HB_LEN_P(_this)) {
            php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", numbytes, HB_LEN_P(_this));
            numbytes = -1;
        }
    }
    php_stream_close(stream);
    RETURN_LONG(numbytes);    
}
开发者ID:hakiu,项目名称:hprose-pecl,代码行数:23,代码来源:hprose_bytes_io.c


示例18: cdb_make_write

/* {{{ cdb_make_write */
static int cdb_make_write(struct cdb_make *c, char *buf, uint32 sz TSRMLS_DC) {
	return php_stream_write(c->fp, buf, sz) == sz ? 0 : -1;
}
开发者ID:ARYANJASHWAL,项目名称:php7,代码行数:4,代码来源:cdb_make.c


示例19: _php_image_stream_putbuf

static int _php_image_stream_putbuf(struct gdIOCtx *ctx, const void* buf, int l)
{
	php_stream * stream = (php_stream *)ctx->data;
	TSRMLS_FETCH();
	return php_stream_write(stream, (void *)buf, l);
}
开发者ID:1HLtd,项目名称:php-src,代码行数:6,代码来源:gd_ctx.c


示例20: php_error_docref


//.........这里部分代码省略.........
#endif

    if (context && php_stream_context_get_option(context, "http", "method", &tmpzval) == SUCCESS) {
        if (Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) {
            scratch_len = strlen(path) + 29 + Z_STRLEN_PP(tmpzval);
            scratch = (char *)emalloc(scratch_len);
            strlcpy(scratch, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval) + 1);
            strcat(scratch, " ");
        }
    }

    if (!scratch) {
        scratch_len = strlen(path) + 32;
        scratch = (char *)emalloc(scratch_len);
        strcpy(scratch, "GET ");
    }

    /* file */
    if (resource->path && *resource->path)
        strlcat(scratch, resource->path, scratch_len);
    else
        strlcat(scratch, "/", scratch_len);

    /* query string */
    if (resource->query)	{
        strlcat(scratch, "?", scratch_len);
        strlcat(scratch, resource->query, scratch_len);
    }

    /* protocol version we are speaking */
    strlcat(scratch, " HTTP/1.0\r\n", scratch_len);

    /* send it */
    php_stream_write(stream, scratch, strlen(scratch));

    if (context && php_stream_context_get_option(context, "http", "header", &tmpzval) == SUCCESS && Z_STRLEN_PP(tmpzval)) {
        /* Remove newlines and spaces from start and end, php_trim will estrndup() */
        tmp = php_trim(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval), NULL, 0, NULL, 3 TSRMLS_CC);
        if (strlen(tmp) > 0) {
            /* Output trimmed headers with \r\n at the end */
            php_stream_write(stream, tmp, strlen(tmp));
            php_stream_write(stream, "\r\n", sizeof("\r\n") - 1);

            /* Make lowercase for easy comparison against 'standard' headers */
            php_strtolower(tmp, strlen(tmp));
            if (strstr(tmp, "user-agent:")) {
                have_header |= HTTP_HEADER_USER_AGENT;
            }
            if (strstr(tmp, "host:")) {
                have_header |= HTTP_HEADER_HOST;
            }
            if (strstr(tmp, "from:")) {
                have_header |= HTTP_HEADER_FROM;
            }
            if (strstr(tmp, "authorization:")) {
                have_header |= HTTP_HEADER_AUTH;
            }
        }
        efree(tmp);
    }

    /* auth header if it was specified */
    if (((have_header & HTTP_HEADER_AUTH) == 0) && resource->user && resource->pass) {
        /* decode the strings first */
        php_url_decode(resource->user, strlen(resource->user));
        php_url_decode(resource->pass, strlen(resource->pass));
开发者ID:Ashod,项目名称:Phalanger,代码行数:67,代码来源:HttpWrapper.cpp



注:本文中的php_stream_write函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ phy_connect函数代码示例发布时间:2022-05-30
下一篇:
C++ php_stream_read函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap