本文整理汇总了C++中php_stream_write函数的典型用法代码示例。如果您正苦于以下问题:C++ php_stream_write函数的具体用法?C++ php_stream_write怎么用?C++ php_stream_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了php_stream_write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}