您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ FG函数代码示例

51自学网 2021-06-01 20:41:11
  C++
这篇教程C++ FG函数代码示例写得很实用,希望能帮到您。

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

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

示例1: resize

static voidresize(void){	/* Get terminal dimensions */	ioctl(0, TIOCGWINSZ, &w);	/* Clear, move to top separator and set color */	printf(CLEAR_FULL MOVE(2, 1) FG(239));	/* Draw upper separator */	for (int i = 0; i < w.ws_col; i++)		printf("—");	/* Draw bottom bar, set color back to default */	printf(MOVE(%d, 1) " >>> " FG(250), w.ws_row);	/* Mark all buffers as resized for next draw */	rirc->resized = 1;	channel *c = ccur;	do {		c->resized = 1;	} while ((c = channel_switch(c, 1)) != ccur);	/* Draw everything else */	draw(D_FULL);}
开发者ID:shaggytwodope,项目名称:rirc,代码行数:27,


示例2: php_stream_filter_register_factory_volatile

/* API for registering VOLATILE wrappers */PHPAPI int php_stream_filter_register_factory_volatile(const char *filterpattern, php_stream_filter_factory *factory){	if (!FG(stream_filters)) {		ALLOC_HASHTABLE(FG(stream_filters));		zend_hash_init(FG(stream_filters), zend_hash_num_elements(&stream_filters_hash), NULL, NULL, 1);		zend_hash_copy(FG(stream_filters), &stream_filters_hash, NULL);	}	return zend_hash_str_add_ptr(FG(stream_filters), (char*)filterpattern, strlen(filterpattern), factory) ? SUCCESS : FAILURE;}
开发者ID:PeeHaa,项目名称:php-src,代码行数:11,


示例3: resize

voidresize(void){	/* Get terminal dimensions */	ioctl(0, TIOCGWINSZ, &w);	/* Clear, set separator color, move to top separator */	printf(CLEAR_FULL  FG(239)  MOVE(2, 1));	/* Draw upper separator */	for (i = 0; i < w.ws_col; i++)		printf("—");	/* Draw bottom bar, set color back to default */	printf(MOVE(%d, 1)" >>> " FG(250), w.ws_row);	/* Draw everything else */	draw(D_FULL);}
开发者ID:sirpengi,项目名称:rirc,代码行数:19,


示例4: drawmenu

voiddrawmenu(void) {	int curpos;	Item *item;	dc->x = 0;	dc->y = 0;	dc->h = bh;	drawrect(dc, 0, 0, mw, mh, True, BG(dc, normcol));	if(prompt && *prompt) {		dc->w = promptw;		drawtext(dc, prompt, selcol);		dc->x = dc->w;	}	/* draw input field */	dc->w = (lines > 0 || !matches) ? mw - dc->x : inputw;	drawtext(dc, text, normcol);	if((curpos = textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w)		drawrect(dc, curpos, 2, 1, dc->h - 4, True, FG(dc, normcol));    /* // Draw hits */    dc->w = textw(dc, hitstxt);    dc->x = mw - dc->w;    drawtext(dc, hitstxt, selcol);    dc->x = 0;	if(lines > 0) {		/* draw vertical list */		dc->w = mw - dc->x;		for(item = curr; item != next; item = item->right) {			dc->y += dc->h;			drawtext(dc, item->text, (item == sel) ? selcol :			                         (item->out)   ? outcol : normcol);		}	}	else if(matches) {		/* draw horizontal list */		dc->x += inputw;		dc->w = textw(dc, "<");		if(curr->left)			drawtext(dc, "<", normcol);		for(item = curr; item != next; item = item->right) {			dc->x += dc->w;			dc->w = MIN(textw(dc, item->text), mw - dc->x - textw(dc, ">"));			drawtext(dc, item->text, (item == sel) ? selcol :			                         (item->out)   ? outcol : normcol);		}		dc->w = textw(dc, ">");		dc->x = mw - dc->w;		if(next)			drawtext(dc, ">", normcol);	}	mapdc(dc, win, mw, mh);}
开发者ID:israellevin,项目名称:dmenu,代码行数:55,


示例5: FG

/* We allow very simple pattern matching for filter factories: * if "convert.charset.utf-8/sjis" is requested, we search first for an exact * match. If that fails, we try "convert.charset.*", then "convert.*" * This means that we don't need to clog up the hashtable with a zillion * charsets (for example) but still be able to provide them all as filters */PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval *filterparams, uint8_t persistent){	HashTable *filter_hash = (FG(stream_filters) ? FG(stream_filters) : &stream_filters_hash);	php_stream_filter_factory *factory = NULL;	php_stream_filter *filter = NULL;	size_t n;	char *period;	n = strlen(filtername);	if (NULL != (factory = zend_hash_str_find_ptr(filter_hash, filtername, n))) {		filter = factory->create_filter(filtername, filterparams, persistent);	} else if ((period = strrchr(filtername, '.'))) {		/* try a wildcard */		char *wildname;		wildname = emalloc(n+3);		memcpy(wildname, filtername, n+1);		period = wildname + (period - filtername);		while (period && !filter) {			*period = '/0';			strncat(wildname, ".*", 2);			if (NULL != (factory = zend_hash_str_find_ptr(filter_hash, wildname, strlen(wildname)))) {				filter = factory->create_filter(filtername, filterparams, persistent);			}			*period = '/0';			period = strrchr(wildname, '.');		}		efree(wildname);	}	if (filter == NULL) {		/* TODO: these need correct docrefs */		if (factory == NULL)			php_error_docref(NULL, E_WARNING, "unable to locate filter /"%s/"", filtername);		else			php_error_docref(NULL, E_WARNING, "unable to create or locate filter /"%s/"", filtername);	}	return filter;}
开发者ID:PeeHaa,项目名称:php-src,代码行数:47,


示例6: drawtextn

voiddrawtextn(DC *dc, const char *text, size_t n, unsigned long col[ColLast]) {	int x = dc->x + dc->font.height/2;	int y = dc->y + dc->font.ascent+1;	XSetForeground(dc->dpy, dc->gc, FG(dc, col));	if(dc->font.set)		XmbDrawString(dc->dpy, dc->canvas, dc->font.set, dc->gc, x, y, text, n);	else {		XSetFont(dc->dpy, dc->gc, dc->font.xfont->fid);		XDrawString(dc->dpy, dc->canvas, dc->gc, x, y, text, n);	}}
开发者ID:Yomin,项目名称:dmenu,代码行数:13,


示例7: print_line

intprint_line(int row, line *l){	if (l < ccur->chat)		l += SCROLLBACK_BUFFER;	if (!l->len || l == ccur->cur_line)		return 3;	int count = 1;	char *ptr1, *ptr2, *wrap;	ptr1 = l->text;	ptr2 = l->text + l->len;	while ((ptr1 = word_wrap(ptr1, ptr2)) != NULL && ptr1 != ptr2)		count++;	if (row - count > 2)		row = print_line(row - count, l - 1) + count - 1;	ptr1 = l->text;	if ((wrap = word_wrap(ptr1, ptr2)) != NULL)		row = print_more(wrap, ptr2, row);	else		wrap = ptr2;	int from_fg;	char *from_bg = "";	if (l->type == LINE_JOIN || l->type == LINE_PART || l->type == LINE_QUIT)		from_fg = 239;	else if (l->type == LINE_PINGED)		from_fg = 255, from_bg = BG(1);	else		from_fg = nick_col(l->from);	if (row > 2) {		printf("/x1b[%d;1H/x1b[2K", row);		printf(FG(239)" %02d:%02d  %*s"FG(%d)"%s%s"BG_R FG(239)" ~ "FG(250),				l->time_h, l->time_m,				(int)(ccur->nick_pad - strlen(l->from)), "",				from_fg, from_bg, l->from);		while (ptr1 < wrap)			putchar(*ptr1++);	}
开发者ID:sirpengi,项目名称:rirc,代码行数:46,


示例8: sapi_cli_select

static inline int sapi_cli_select(int fd){	fd_set wfd, dfd;	struct timeval tv;	int ret;	FD_ZERO(&wfd);	FD_ZERO(&dfd);	PHP_SAFE_FD_SET(fd, &wfd);	tv.tv_sec = (long)FG(default_socket_timeout);	tv.tv_usec = 0;	ret = php_select(fd+1, &dfd, &wfd, &dfd, &tv);	return ret != -1;}
开发者ID:EleTeam,项目名称:php-src,代码行数:18,


示例9: FG

/* {{{ php_ssh2_session_connect * Connect to an SSH server with requested methods */LIBSSH2_SESSION *php_ssh2_session_connect(char *host, int port, zval *methods, zval *callbacks){	LIBSSH2_SESSION *session;	int socket;	php_ssh2_session_data *data;	struct timeval tv;	zend_string *hash_lookup_zstring;	tv.tv_sec = FG(default_socket_timeout);	tv.tv_usec = 0;	socket = php_network_connect_socket_to_host(host, port, SOCK_STREAM, 0, &tv, NULL, NULL, NULL, 0, STREAM_SOCKOP_NONE);	if (socket <= 0) {		php_error_docref(NULL, E_WARNING, "Unable to connect to %s on port %d", host, port);		return NULL;	}	data = ecalloc(1, sizeof(php_ssh2_session_data));	data->socket = socket;	session = libssh2_session_init_ex(php_ssh2_alloc_cb, php_ssh2_free_cb, php_ssh2_realloc_cb, data);	if (!session) {		php_error_docref(NULL, E_WARNING, "Unable to initialize SSH2 session");		efree(data);		closesocket(socket);		return NULL;	}	libssh2_banner_set(session, LIBSSH2_SSH_DEFAULT_BANNER " PHP");	/* Override method preferences */	if (methods) {		zval *container;		if (php_ssh2_set_method(session, HASH_OF(methods), "kex", sizeof("kex") - 1, LIBSSH2_METHOD_KEX)) {			php_error_docref(NULL, E_WARNING, "Failed overriding KEX method");		}		if (php_ssh2_set_method(session, HASH_OF(methods), "hostkey", sizeof("hostkey") - 1, LIBSSH2_METHOD_HOSTKEY)) {			php_error_docref(NULL, E_WARNING, "Failed overriding HOSTKEY method");		}		hash_lookup_zstring = zend_string_init("client_to_server", sizeof("client_to_server") - 1, 0);		if ((container = zend_hash_find(HASH_OF(methods), hash_lookup_zstring)) != NULL && Z_TYPE_P(container) == IS_ARRAY) {			if (php_ssh2_set_method(session, HASH_OF(container), "crypt", sizeof("crypt") - 1, LIBSSH2_METHOD_CRYPT_CS)) {				php_error_docref(NULL, E_WARNING, "Failed overriding client to server CRYPT method");			}			if (php_ssh2_set_method(session, HASH_OF(container), "mac", sizeof("mac") - 1, LIBSSH2_METHOD_MAC_CS)) {				php_error_docref(NULL, E_WARNING, "Failed overriding client to server MAC method");			}			if (php_ssh2_set_method(session, HASH_OF(container), "comp", sizeof("comp") - 1, LIBSSH2_METHOD_COMP_CS)) {				php_error_docref(NULL, E_WARNING, "Failed overriding client to server COMP method");			}			if (php_ssh2_set_method(session, HASH_OF(container), "lang", sizeof("lang") - 1, LIBSSH2_METHOD_LANG_CS)) {				php_error_docref(NULL, E_WARNING, "Failed overriding client to server LANG method");			}		}		zend_string_release(hash_lookup_zstring);		hash_lookup_zstring = zend_string_init("server_to_client", sizeof("server_to_client") - 1, 0);		if ((container = zend_hash_find(HASH_OF(methods), hash_lookup_zstring)) != NULL && Z_TYPE_P(container) == IS_ARRAY) {			if (php_ssh2_set_method(session, HASH_OF(container), "crypt", sizeof("crypt") - 1, LIBSSH2_METHOD_CRYPT_SC)) {				php_error_docref(NULL, E_WARNING, "Failed overriding server to client CRYPT method");			}			if (php_ssh2_set_method(session, HASH_OF(container), "mac", sizeof("mac") - 1, LIBSSH2_METHOD_MAC_SC)) {				php_error_docref(NULL, E_WARNING, "Failed overriding server to client MAC method");			}			if (php_ssh2_set_method(session, HASH_OF(container), "comp", sizeof("comp") - 1, LIBSSH2_METHOD_COMP_SC)) {				php_error_docref(NULL, E_WARNING, "Failed overriding server to client COMP method");			}			if (php_ssh2_set_method(session, HASH_OF(container), "lang", sizeof("lang") - 1, LIBSSH2_METHOD_LANG_SC)) {				php_error_docref(NULL, E_WARNING, "Failed overriding server to client LANG method");			}		}		zend_string_release(hash_lookup_zstring);	}	/* Register Callbacks */	if (callbacks) {		/* ignore debug disconnect macerror */		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "ignore", sizeof("ignore") - 1, LIBSSH2_CALLBACK_IGNORE, data)) {			php_error_docref(NULL, E_WARNING, "Failed setting IGNORE callback");		}		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "debug", sizeof("debug") - 1, LIBSSH2_CALLBACK_DEBUG, data)) {			php_error_docref(NULL, E_WARNING, "Failed setting DEBUG callback");		}		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "macerror", sizeof("macerror") - 1, LIBSSH2_CALLBACK_MACERROR, data)) {			php_error_docref(NULL, E_WARNING, "Failed setting MACERROR callback");		}		if (php_ssh2_set_callback(session, HASH_OF(callbacks), "disconnect", sizeof("disconnect") - 1, LIBSSH2_CALLBACK_DISCONNECT, data)) {			php_error_docref(NULL, E_WARNING, "Failed setting DISCONNECT callback");		}	}//.........这里部分代码省略.........
开发者ID:Sean-Der,项目名称:pecl-networking-ssh2,代码行数:101,


示例10: php_stream_wrapper_log_error

php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, 		const char *path, const char *mode, int options, char **opened_path, 		php_stream_context *context, int redirect_max, int flags STREAMS_DC TSRMLS_DC) /* {{{ */{	php_stream *stream = NULL;	php_url *resource = NULL;	int use_ssl;	int use_proxy = 0;	char *scratch = NULL;	char *tmp = NULL;	char *ua_str = NULL;	zval **ua_zval = NULL, **tmpzval = NULL, *ssl_proxy_peer_name = NULL;	int scratch_len = 0;	int body = 0;	char location[HTTP_HEADER_BLOCK_SIZE];	zval *response_header = NULL;	int reqok = 0;	char *http_header_line = NULL;	char tmp_line[128];	size_t chunk_size = 0, file_size = 0;	int eol_detect = 0;	char *transport_string, *errstr = NULL;	int transport_len, have_header = 0, request_fulluri = 0, ignore_errors = 0;	char *protocol_version = NULL;	int protocol_version_len = 3; /* Default: "1.0" */	struct timeval timeout;	char *user_headers = NULL;	int header_init = ((flags & HTTP_WRAPPER_HEADER_INIT) != 0);	int redirected = ((flags & HTTP_WRAPPER_REDIRECTED) != 0);	int follow_location = 1;	php_stream_filter *transfer_encoding = NULL;	int response_code;	tmp_line[0] = '/0';	if (redirect_max < 1) {		php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Redirection limit reached, aborting");		return NULL;	}	resource = php_url_parse(path);	if (resource == NULL) {		return NULL;	}	if (strncasecmp(resource->scheme, "http", sizeof("http")) && strncasecmp(resource->scheme, "https", sizeof("https"))) {		if (!context || 			php_stream_context_get_option(context, wrapper->wops->label, "proxy", &tmpzval) == FAILURE ||			Z_TYPE_PP(tmpzval) != IS_STRING ||			Z_STRLEN_PP(tmpzval) <= 0) {			php_url_free(resource);			return php_stream_open_wrapper_ex(path, mode, REPORT_ERRORS, NULL, context);		}		/* Called from a non-http wrapper with http proxying requested (i.e. ftp) */		request_fulluri = 1;		use_ssl = 0;		use_proxy = 1;		transport_len = Z_STRLEN_PP(tmpzval);		transport_string = estrndup(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval));	} else {		/* Normal http request (possibly with proxy) */			if (strpbrk(mode, "awx+")) {			php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP wrapper does not support writeable connections");			php_url_free(resource);			return NULL;		}		use_ssl = resource->scheme && (strlen(resource->scheme) > 4) && resource->scheme[4] == 's';		/* choose default ports */		if (use_ssl && resource->port == 0)			resource->port = 443;		else if (resource->port == 0)			resource->port = 80;		if (context &&			php_stream_context_get_option(context, wrapper->wops->label, "proxy", &tmpzval) == SUCCESS &&			Z_TYPE_PP(tmpzval) == IS_STRING &&			Z_STRLEN_PP(tmpzval) > 0) {			use_proxy = 1;			transport_len = Z_STRLEN_PP(tmpzval);			transport_string = estrndup(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval));		} else {			transport_len = spprintf(&transport_string, 0, "%s://%s:%d", use_ssl ? "ssl" : "tcp", resource->host, resource->port);		}	}	if (context && php_stream_context_get_option(context, wrapper->wops->label, "timeout", &tmpzval) == SUCCESS) {		SEPARATE_ZVAL(tmpzval);		convert_to_double_ex(tmpzval);		timeout.tv_sec = (time_t) Z_DVAL_PP(tmpzval);		timeout.tv_usec = (size_t) ((Z_DVAL_PP(tmpzval) - timeout.tv_sec) * 1000000);	} else {		timeout.tv_sec = FG(default_socket_timeout);		timeout.tv_usec = 0;	}	stream = php_stream_xport_create(transport_string, transport_len, options,			STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT,//.........这里部分代码省略.........
开发者ID:90youth,项目名称:php-src,代码行数:101,


示例11: get

 VT get(const V& v) const {   return FG()(v); }
开发者ID:migashko,项目名称:faslib-sandbox,代码行数:4,


示例12: ZVAL_UNDEF

//.........这里部分代码省略.........			return NULL;		}		use_ssl = resource->scheme && (strlen(resource->scheme) > 4) && resource->scheme[4] == 's';		/* choose default ports */		if (use_ssl && resource->port == 0)			resource->port = 443;		else if (resource->port == 0)			resource->port = 80;		if (context &&			(tmpzval = php_stream_context_get_option(context, wrapper->wops->label, "proxy")) != NULL &&			Z_TYPE_P(tmpzval) == IS_STRING &&			Z_STRLEN_P(tmpzval) > 0) {			use_proxy = 1;			transport_len = Z_STRLEN_P(tmpzval);			transport_string = estrndup(Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval));		} else {			transport_len = spprintf(&transport_string, 0, "%s://%s:%d", use_ssl ? "ssl" : "tcp", resource->host, resource->port);		}	}	if (context && (tmpzval = php_stream_context_get_option(context, wrapper->wops->label, "timeout")) != NULL) {		double d = zval_get_double(tmpzval);#ifndef PHP_WIN32		timeout.tv_sec = (time_t) d;		timeout.tv_usec = (size_t) ((d - timeout.tv_sec) * 1000000);#else		timeout.tv_sec = (long) d;		timeout.tv_usec = (long) ((d - timeout.tv_sec) * 1000000);#endif	} else {#ifndef PHP_WIN32		timeout.tv_sec = FG(default_socket_timeout);#else		timeout.tv_sec = (long)FG(default_socket_timeout);#endif		timeout.tv_usec = 0;	}	stream = php_stream_xport_create(transport_string, transport_len, options,			STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT,			NULL, &timeout, context, &errstr, NULL);	if (stream) {		php_stream_set_option(stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &timeout);	}	if (errstr) {		php_stream_wrapper_log_error(wrapper, options, "%s", ZSTR_VAL(errstr));		zend_string_release(errstr);		errstr = NULL;	}	efree(transport_string);	if (stream && use_proxy && use_ssl) {		smart_str header = {0};		/* Set peer_name or name verification will try to use the proxy server name */		if (!context || (tmpzval = php_stream_context_get_option(context, "ssl", "peer_name")) == NULL) {			ZVAL_STRING(&ssl_proxy_peer_name, resource->host);			php_stream_context_set_option(PHP_STREAM_CONTEXT(stream), "ssl", "peer_name", &ssl_proxy_peer_name);			zval_ptr_dtor(&ssl_proxy_peer_name);		}
开发者ID:20uf,项目名称:php-src,代码行数:66,


示例13: php_hash_do_hash_hmac

static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_bool raw_output_default) /* {{{ */{	char *algo, *data, *digest, *key, *K;	int algo_len, data_len, key_len, i;	zend_uchar data_type = IS_STRING, key_type = IS_STRING;	zend_bool raw_output = raw_output_default;	const php_hash_ops *ops;	void *context;	php_stream *stream = NULL;#if PHP_MAJOR_VERSION >= 6	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "stt|b", &algo, &algo_len, &data, &data_len, &data_type, &key, &key_len, &key_type, &raw_output) == FAILURE) {		return;	}	if (data_type == IS_UNICODE) {		if (isfilename) {			if (php_stream_path_encode(NULL, &data, &data_len, (UChar *)data, data_len, REPORT_ERRORS, FG(default_context)) == FAILURE) {				RETURN_FALSE;			}		} else {			data = zend_unicode_to_ascii((UChar*)data, data_len TSRMLS_CC);			if (!data) {				/* Non-ASCII Unicode string passed for raw hashing */				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received");				RETURN_FALSE;			}		}	}	if (key_type == IS_UNICODE) {		key = zend_unicode_to_ascii((UChar*)key, key_len TSRMLS_CC);		if (!key) {			/* Non-ASCII Unicode key passed for raw hashing */			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Binary or ASCII-Unicode key expected, non-ASCII-Unicode key received");			if (data_type == IS_UNICODE) {				efree(data);			}			RETURN_FALSE;		}	}#else	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|b", &algo, &algo_len, &data, &data_len, &key, &key_len, &raw_output) == FAILURE) {		return;	}#endif	/* Assume failure */	RETVAL_FALSE;	ops = php_hash_fetch_ops(algo, algo_len);	if (!ops) {		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown hashing algorithm: %s", algo);		goto hmac_done;	}	if (isfilename) {		stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);		if (!stream) {			/* Stream will report errors opening file */			goto hmac_done;		}	}	context = emalloc(ops->context_size);	ops->hash_init(context);	K = emalloc(ops->block_size);	memset(K, 0, ops->block_size);	if (key_len > ops->block_size) {		/* Reduce the key first */		ops->hash_update(context, (unsigned char *) key, key_len);		ops->hash_final((unsigned char *) K, context);		/* Make the context ready to start over */		ops->hash_init(context);	} else {		memcpy(K, key, key_len);	}				/* XOR ipad */	for(i=0; i < ops->block_size; i++) {		K[i] ^= 0x36;	}	ops->hash_update(context, (unsigned char *) K, ops->block_size);	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);	/* Convert K to opad -- 0x6A = 0x36 ^ 0x5C *///.........这里部分代码省略.........
开发者ID:browniebraun,项目名称:php-src,代码行数:101,


示例14: php_hash_do_hash

static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_bool raw_output_default) /* {{{ */{	zend_string *digest;	char *algo, *data;	size_t 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(), "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, E_WARNING, "Unknown hashing algorithm: %s", algo);		RETURN_FALSE;	}	if (isfilename) {		if (CHECK_NULL_PATH(data, data_len)) {			php_error_docref(NULL, E_WARNING, "Invalid path");			RETURN_FALSE;		}		stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, FG(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];		size_t 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 = zend_string_alloc(ops->digest_size, 0);	ops->hash_final((unsigned char *) ZSTR_VAL(digest), context);	efree(context);	if (raw_output) {		ZSTR_VAL(digest)[ops->digest_size] = 0;		RETURN_NEW_STR(digest);	} else {		zend_string *hex_digest = zend_string_safe_alloc(ops->digest_size, 2, 0, 0);		php_hash_bin2hex(ZSTR_VAL(hex_digest), (unsigned char *) ZSTR_VAL(digest), ops->digest_size);		ZSTR_VAL(hex_digest)[2 * ops->digest_size] = 0;		zend_string_release(digest);		RETURN_NEW_STR(hex_digest);	}}
开发者ID:Bharath2796,项目名称:php-src,代码行数:62,


示例15: php_sockop_set_option

static int php_sockop_set_option(php_stream *stream, int option, int value, void *ptrparam){	int oldmode, flags;	php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;	php_stream_xport_param *xparam;	if (!sock) {		return PHP_STREAM_OPTION_RETURN_NOTIMPL;	}	switch(option) {		case PHP_STREAM_OPTION_CHECK_LIVENESS:			{				struct timeval tv;				char buf;				int alive = 1;				if (value == -1) {					if (sock->timeout.tv_sec == -1) {						tv.tv_sec = FG(default_socket_timeout);						tv.tv_usec = 0;					} else {						tv = sock->timeout;					}				} else {					tv.tv_sec = value;					tv.tv_usec = 0;				}				if (sock->socket == -1) {					alive = 0;				} else if (php_pollfd_for(sock->socket, PHP_POLLREADABLE|POLLPRI, &tv) > 0) {#ifdef PHP_WIN32					int ret;#else					ssize_t ret;#endif					int err;					ret = recv(sock->socket, &buf, sizeof(buf), MSG_PEEK);					err = php_socket_errno();					if (0 == ret || /* the counterpart did properly shutdown*/						(0 > ret && err != EWOULDBLOCK && err != EAGAIN)) { /* there was an unrecoverable error */						alive = 0;					}				}				return alive ? PHP_STREAM_OPTION_RETURN_OK : PHP_STREAM_OPTION_RETURN_ERR;			}		case PHP_STREAM_OPTION_BLOCKING:			oldmode = sock->is_blocked;			if (SUCCESS == php_set_sock_blocking(sock->socket, value)) {				sock->is_blocked = value;				return oldmode;			}			return PHP_STREAM_OPTION_RETURN_ERR;		case PHP_STREAM_OPTION_READ_TIMEOUT:			sock->timeout = *(struct timeval*)ptrparam;			sock->timeout_event = 0;			return PHP_STREAM_OPTION_RETURN_OK;		case PHP_STREAM_OPTION_META_DATA_API:			add_assoc_bool((zval *)ptrparam, "timed_out", sock->timeout_event);			add_assoc_bool((zval *)ptrparam, "blocked", sock->is_blocked);			add_assoc_bool((zval *)ptrparam, "eof", stream->eof);			return PHP_STREAM_OPTION_RETURN_OK;		case PHP_STREAM_OPTION_XPORT_API:			xparam = (php_stream_xport_param *)ptrparam;			switch (xparam->op) {				case STREAM_XPORT_OP_LISTEN:					xparam->outputs.returncode = (listen(sock->socket, xparam->inputs.backlog) == 0) ?  0: -1;					return PHP_STREAM_OPTION_RETURN_OK;				case STREAM_XPORT_OP_GET_NAME:					xparam->outputs.returncode = php_network_get_sock_name(sock->socket,							xparam->want_textaddr ? &xparam->outputs.textaddr : NULL,							xparam->want_addr ? &xparam->outputs.addr : NULL,							xparam->want_addr ? &xparam->outputs.addrlen : NULL							);					return PHP_STREAM_OPTION_RETURN_OK;				case STREAM_XPORT_OP_GET_PEER_NAME:					xparam->outputs.returncode = php_network_get_peer_name(sock->socket,							xparam->want_textaddr ? &xparam->outputs.textaddr : NULL,							xparam->want_addr ? &xparam->outputs.addr : NULL,							xparam->want_addr ? &xparam->outputs.addrlen : NULL							);					return PHP_STREAM_OPTION_RETURN_OK;				case STREAM_XPORT_OP_SEND:					flags = 0;					if ((xparam->inputs.flags & STREAM_OOB) == STREAM_OOB) {						flags |= MSG_OOB;					}					xparam->outputs.returncode = sock_sendto(sock,							xparam->inputs.buf, xparam->inputs.buflen,							flags,//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:php-src,代码行数:101,


示例16: draw_buffer

//.........这里部分代码省略.........	 *	 * So the general steps for drawing are:	 *	 * 1. Starting from line L = scrollback, traverse backwards through the	 *    buffer summing the rows required to draw lines, until the sum	 *    exceeds the number of rows available	 *	 * 2. L now points to the top-most line to be drawn. L might not be able	 *    to draw in full, so discard the excessive word-wrapped segments and	 *    draw the remainder	 *	 * 3. Traverse forward through the buffer, drawing lines until buffer_head	 *    is encountered	 *	 * 4. Clear any remaining rows that might exist in the case where the lines	 *    in the channel's buffer are insufficient to fill all rows	 */	printf(CURSOR_SAVE);	/* Establish current, min and max row for drawing */	int buffer_start = 3, buffer_end = w.ws_row - 2;	int print_row = buffer_start;	int max_row = buffer_end - buffer_start + 1;	int count_row = 0;	/* Insufficient rows for drawing */	if (buffer_end < buffer_start)		return;	/* (#terminal columns) - strlen((widest nick in c)) - strlen(" HH:MM   ~ ") */	int text_cols = w.ws_col - c->draw.nick_pad - 11;	/* Insufficient columns for drawing */	if (text_cols < 1)		goto clear_remainder;	line *tmp, *l = c->draw.scrollback;	/* Empty buffer */	if (l->text == NULL)		goto clear_remainder;	/* If the window has been resized, force all cached line rows to be recalculated */	if (c->resized) {		for (tmp = c->buffer; tmp < &c->buffer[SCROLLBACK_BUFFER]; tmp++)			tmp->rows = 0;		c->resized = 0;	}	/* 1. Find top-most drawable line */	for (;;) {		/* Store the number of rows until a resize */		if (l->rows == 0)			l->rows = count_line_rows(text_cols, l);		count_row += l->rows;		if (count_row >= max_row)			break;		tmp = (l == c->buffer) ? &c->buffer[SCROLLBACK_BUFFER - 1] : l - 1;		if (tmp->text == NULL || tmp == c->buffer_head)			break;		l = tmp;	}	/* 2. Handle top-most line if it can't draw in full */	if (count_row > max_row) {		char *ptr1 = l->text;		char *ptr2 = l->text + l->len;		while (count_row-- > max_row)			word_wrap(text_cols, &ptr1, ptr2);		do {			printf(MOVE(%d, %d) CLEAR_LINE, print_row++, (int)c->draw.nick_pad + 10);			printf(FG(239) "~" FG(250) " ");			char *print = ptr1;			char *wrap = word_wrap(text_cols, &ptr1, ptr2);			while (print < wrap)				putchar(*print++);		} while (*ptr1);		if (l == c->buffer_head)			goto clear_remainder;		l = (l == &c->buffer[SCROLLBACK_BUFFER - 1]) ? c->buffer : l + 1;		if (l->text == NULL)			goto clear_remainder;	}
开发者ID:shaggytwodope,项目名称:rirc,代码行数:101,


示例17: php_fsockopen_stream

static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent){    char *host;    int host_len;    long port = -1;    zval *zerrno = NULL, *zerrstr = NULL;    double timeout = FG(default_socket_timeout);    unsigned long conv;    struct timeval tv;    char *hashkey = NULL;    php_stream *stream = NULL;    int err;    char *hostname = NULL;    long hostname_len;    char *errstr = NULL;    RETVAL_FALSE;        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lzzd", &host, &host_len, &port, &zerrno, &zerrstr, &timeout) == FAILURE) {        RETURN_FALSE;    }    if (persistent) {        spprintf(&hashkey, 0, "fcgi_sockopen__%s:%ld", host, port);    }    if (port > 0) {        hostname_len = spprintf(&hostname, 0, "%s:%ld", host, port);    } else {        hostname_len = host_len;        hostname = host;    }        /* prepare the timeout value for use */    conv = (unsigned long) (timeout * 1000000.0);    tv.tv_sec = conv / 1000000;    tv.tv_usec = conv % 1000000;    if (zerrno) {        zval_dtor(zerrno);        ZVAL_LONG(zerrno, 0);    }    if (zerrstr) {        zval_dtor(zerrstr);        ZVAL_STRING(zerrstr, "", 1);    }    stream = php_stream_xport_create(hostname, hostname_len, REPORT_ERRORS,            STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, hashkey, &tv, NULL, &errstr, &err);    if (port > 0) {        efree(hostname);    }    if (stream == NULL) {        php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to connect to %s:%ld (%s)", host, port, errstr == NULL ? "Unknown error" : errstr);    }    if (hashkey) {        efree(hashkey);    }        if (stream == NULL) {        if (zerrno) {            zval_dtor(zerrno);            ZVAL_LONG(zerrno, err);        }        if (zerrstr && errstr) {            /* no need to dup; we need to efree buf anyway */            zval_dtor(zerrstr);            ZVAL_STRING(zerrstr, errstr, 0);        }        else if (!zerrstr && errstr) {            efree(errstr);        }         RETURN_FALSE;    }    if (errstr) {        efree(errstr);    }            php_stream_to_zval(stream, return_value);}
开发者ID:sdgdsffdsfff,项目名称:fcgi_client,代码行数:84,


示例18: graffiti

static bool graffiti(struct vidbuffer *src, struct vidbuffer *dst){	int y, x;	int ystart, yend, isntsc;	int xstart, xend;	uae_u8 *srcbuf, *srcend;	uae_u8 *dstbuf;	bool command, hires, found;	int xadd, xpixadd, extrapix;	int waitline = 0, dbl;	uae_u8 read_mask = 0xff, color = 0, color2 = 0;	if (!(bplcon0 & 0x0100)) // GAUD		return false;	command = true;	found = false;	isntsc = (beamcon0 & 0x20) ? 0 : 1;	if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))		isntsc = currprefs.ntscmode ? 1 : 0;	dbl = gfxvidinfo.ychange == 1 ? 2 : 1;	ystart = isntsc ? VBLANK_ENDLINE_NTSC : VBLANK_ENDLINE_PAL;	yend = isntsc ? MAXVPOS_NTSC : MAXVPOS_PAL;	if (src->yoffset >= (ystart << VRES_MAX))		ystart = src->yoffset >> VRES_MAX;	xadd = gfxvidinfo.xchange == 1 ? src->pixbytes * 2 : src->pixbytes;	xpixadd = gfxvidinfo.xchange == 1 ? 4 : 2;	xstart = 0x1c * 2 + 1;	xend = 0xf0 * 2 + 1;	srcbuf = src->bufmem + (((ystart << VRES_MAX) - src->yoffset) / gfxvidinfo.ychange) * src->rowbytes + (((xstart << RES_MAX) - src->xoffset) / gfxvidinfo.xchange) * src->pixbytes;	srcend = src->bufmem + (((yend << VRES_MAX) - src->yoffset) / gfxvidinfo.ychange) * src->rowbytes;	extrapix = 0;	dstbuf = dst->bufmem + (((ystart << VRES_MAX) - src->yoffset) / gfxvidinfo.ychange) * dst->rowbytes + (((xstart << RES_MAX) - src->xoffset) / gfxvidinfo.xchange) * dst->pixbytes;	y = 0;	while (srcend > srcbuf && dst->bufmemend > dstbuf) {		uae_u8 *srcp = srcbuf + extrapix;		uae_u8 *dstp = dstbuf;		x = xstart;		while (x < xend) {						uae_u8 mask = 0x80;			uae_u8 chunky[4] = { 0, 0, 0, 0 };			while (mask) {				if (FR(src, srcp)) // R					chunky[3] |= mask;				if (FG(src, srcp)) // G					chunky[2] |= mask;				if (FB(src, srcp)) // B					chunky[1] |= mask;				if (FI(src, srcp)) // I					chunky[0] |= mask;				srcp += xadd;				mask >>= 1;			}			if (command) {				if (chunky[0] || chunky[1] || chunky[2] || chunky[3] || found) {					for (int pix = 0; pix < 2; pix++) {						uae_u8 cmd = chunky[pix * 2 + 0];						uae_u8 parm = chunky[pix * 2 + 1];#if 0						//if (cmd != 0)							write_log(_T("X=%d Y=%d %02x = %02x (%d %d)/n"), x, y, cmd, parm, color, color2);#endif						if (automatic && cmd >= 0x40)							return false;						if (cmd != 0)							found = true;						if (cmd & 8) {							command = false;							dbl = 1;							waitline = 2;							if (cmd & 16) {								hires = true;								xadd /= 2;								xpixadd /= 2;								extrapix = -4 * src->pixbytes;							} else {								hires = false;							}							if (xpixadd == 0) // shres needed								return false;							if (monitor != MONITOREMU_GRAFFITI)								clearmonitor(dst);						} else if (cmd & 4) {							if ((cmd & 3) == 1) {								read_mask = parm;							} else if ((cmd & 3) == 2) {								graffiti_palette[color * 4 + color2] = (parm << 2) | (parm & 3);								color2++;//.........这里部分代码省略.........
开发者ID:ApolloniaUK,项目名称:PUAE,代码行数:101,


示例19: a2024

static bool a2024(struct vidbuffer *src, struct vidbuffer *dst){	int y;	uae_u8 *srcbuf, *dstbuf;	uae_u8 *dataline;	int px, py, doff, pxcnt, dbl;	int panel_width, panel_width_draw, panel_height, srcxoffset;	bool f64, interlace, expand, wpb, less16;	uae_u8 enp, dpl;	bool hires, ntsc, found;	int idline;	int total_width, total_height;		dbl = gfxvidinfo.ychange == 1 ? 2 : 1;	doff = (128 * 2 / gfxvidinfo.xchange) * src->pixbytes;	found = false;	for (idline = 21; idline <= 29; idline += 8) {		if (src->yoffset > (idline << VRES_MAX))			continue;		// min 178 max 234		dataline = src->bufmem + (((idline << VRES_MAX) - src->yoffset) / gfxvidinfo.ychange) * src->rowbytes + (((200 << RES_MAX) - src->xoffset) / gfxvidinfo.xchange) * src->pixbytes;#if 0		write_log (_T("%02x%02x%02x %02x%02x%02x %02x%02x%02x %02x%02x%02x/n"),			dataline[0 * doff + 0], dataline[0 * doff + 1], dataline[0 * doff + 2],			dataline[1 * doff + 0], dataline[1 * doff + 1], dataline[1 * doff + 2],			dataline[2 * doff + 0], dataline[2 * doff + 1], dataline[2 * doff + 2],			dataline[3 * doff + 0], dataline[3 * doff + 1], dataline[3 * doff + 2]);#endif		if (FB(src, &dataline[0 * doff]))			// 0:B = 0			continue;		if (!FI(src, &dataline[0 * doff]))			// 0:I = 1			continue;		if (FI(src, &dataline[2 * doff]))			// 2:I = 0			continue;		if (!FI(src, &dataline[3 * doff]))			// 3:I = 1			continue;		ntsc = idline < 26;		found = true;		break;	}	if (!found)		return false;	px = py = 0;	if (FB(src, &dataline[1 * doff])) // 1:B FN2		px |= 2;	if (FG(src, &dataline[1 * doff])) // 1:G FN1		px |= 1;	if (FR(src, &dataline[1 * doff])) // 1:R FN0		py |= 1;	f64 = FR(src, &dataline[0 * doff]) != 0;		// 0:R	interlace = FG(src, &dataline[0 * doff]) != 0;	// 0:G (*Always zero)	expand = FI(src, &dataline[1 * doff]) != 0;		// 1:I (*Always set)	enp = FR(src, &dataline[2 * doff]) ? 1 : 0;		// 2:R (*ENP=3)	enp |= FG(src, &dataline[2 * doff]) ? 2 : 0;	// 2:G	wpb = FB(src, &dataline[2 * doff]) != 0;		// 2:B (*Always zero)	dpl = FR(src, &dataline[3 * doff]) ? 1 : 0;		// 3:R (*DPL=3)	dpl |= FG(src, &dataline[3 * doff]) ? 2 : 0;	// 3:G	less16 = FB(src, &dataline[3 * doff]) != 0;		// 3:B	/* (*) = AOS A2024 driver static bits. Not yet implemented in emulation. */	if (f64) {		panel_width = 336;		panel_width_draw = px == 2 ? 352 : 336;		pxcnt = 3;		hires = false;		srcxoffset = 113;		if (px > 2)			return false;		total_width = 336 + 336 + 352;	} else {		panel_width = 512;		panel_width_draw = 512;		pxcnt = 2;		hires = true;		srcxoffset = 129;		if (px > 1)			return false;		total_width = 512 + 512;	}	panel_height = ntsc ? 400 : 512;	if (monitor != MONITOREMU_A2024) {		clearmonitor(dst);	}#if 0	write_log (_T("0 = F6-4:%d INTERLACE:%d/n"), f64, interlace);	write_log (_T("1 = FN:%d EXPAND:%d/n"), py + px *2, expand);	write_log (_T("2 = ENP:%d WPB=%d/n"), enp, wpb);	write_log (_T("3 = DPL:%d LESS16=%d/n"), dpl, less16);#endif#if 0//.........这里部分代码省略.........
开发者ID:ApolloniaUK,项目名称:PUAE,代码行数:101,


示例20: FG

		int flags, const char *persistent_id,		struct timeval *timeout,		php_stream_context *context,		zend_string **error_string,		int *error_code		STREAMS_DC){	php_stream *stream = NULL;	php_stream_transport_factory factory = NULL;	const char *p, *protocol = NULL;	size_t n = 0;	int failed = 0;	zend_string *error_text = NULL;	struct timeval default_timeout = { 0, 0 };	default_timeout.tv_sec = FG(default_socket_timeout);	if (timeout == NULL) {		timeout = &default_timeout;	}	/* check for a cached persistent socket */	if (persistent_id) {		switch(php_stream_from_persistent_id(persistent_id, &stream)) {			case PHP_STREAM_PERSISTENT_SUCCESS:				/* use a 0 second timeout when checking if the socket				 * has already died */				if (PHP_STREAM_OPTION_RETURN_OK == php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS, 0, NULL)) {					return stream;				}				/* dead - kill it */
开发者ID:dzuelke,项目名称:php-src,代码行数:31,


示例21: 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_uchar data_type = IS_STRING;	zend_bool raw_output = raw_output_default;	const php_hash_ops *ops;	void *context;	php_stream *stream = NULL;#if PHP_MAJOR_VERSION >= 6	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "st|b", &algo, &algo_len, &data, &data_len, &data_type, &raw_output) == FAILURE) {		return;	}	if (data_type == IS_UNICODE) {		if (isfilename) {			if (php_stream_path_encode(NULL, &data, &data_len, (UChar *)data, data_len, REPORT_ERRORS, FG(default_context)) == FAILURE) {				RETURN_FALSE;			}		} else {			data = zend_unicode_to_ascii((UChar*)data, data_len TSRMLS_CC);			if (!data) {				/* Non-ASCII Unicode string passed for raw hashing */				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received");				RETURN_FALSE;			}		}	}#else	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &algo, &algo_len, &data, &data_len, &raw_output) == FAILURE) {		return;	}#endif	/* Assume failure */	RETVAL_FALSE;	ops = php_hash_fetch_ops(algo, algo_len);	if (!ops) {		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown hashing algorithm: %s", algo);		goto hash_done;	}	if (isfilename) {		stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);		if (!stream) {			/* Stream will report errors opening file */			goto hash_done;		}	}	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;		/* Raw output is binary only */		RETVAL_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);		/* hexits can be binary or unicode */#if PHP_MAJOR_VERSION >= 6		RETVAL_RT_STRINGL(hex_digest, 2 * ops->digest_size, ZSTR_AUTOFREE);#else		RETVAL_STRINGL(hex_digest, 2 * ops->digest_size, 0);#endif	}hash_done:	if (data_type != IS_STRING) {		efree(data);	}}
开发者ID:browniebraun,项目名称:php-src,代码行数:94,


示例22: php_fsockopen_stream

static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent){	char *host;	size_t host_len;	zend_long port = -1;	zval *zerrno = NULL, *zerrstr = NULL;	double timeout = (double)FG(default_socket_timeout);#ifndef PHP_WIN32	time_t conv;#else	long conv;#endif	struct timeval tv;	char *hashkey = NULL;	php_stream *stream = NULL;	int err;	char *hostname = NULL;	size_t hostname_len;	zend_string *errstr = NULL;	RETVAL_FALSE;	ZEND_PARSE_PARAMETERS_START(1, 5)		Z_PARAM_STRING(host, host_len)		Z_PARAM_OPTIONAL		Z_PARAM_LONG(port)		Z_PARAM_ZVAL(zerrno)		Z_PARAM_ZVAL(zerrstr)		Z_PARAM_DOUBLE(timeout)	ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);	if (persistent) {		spprintf(&hashkey, 0, "pfsockopen__%s:" ZEND_LONG_FMT, host, port);	}	if (port > 0) {		hostname_len = spprintf(&hostname, 0, "%s:" ZEND_LONG_FMT, host, port);	} else {		hostname_len = host_len;		hostname = host;	}	/* prepare the timeout value for use */#ifndef PHP_WIN32	conv = (time_t) (timeout * 1000000.0);	tv.tv_sec = conv / 1000000;#else	conv = (long) (timeout * 1000000.0);	tv.tv_sec = conv / 1000000;#endif	tv.tv_usec = conv % 1000000;	stream = php_stream_xport_create(hostname, hostname_len, REPORT_ERRORS,			STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, hashkey, &tv, NULL, &errstr, &err);	if (port > 0) {		efree(hostname);	}	if (stream == NULL) {		php_error_docref(NULL, E_WARNING, "unable to connect to %s:" ZEND_LONG_FMT " (%s)", host, port, errstr == NULL ? "Unknown error" : ZSTR_VAL(errstr));	}	if (hashkey) {		efree(hashkey);	}	if (stream == NULL) {		if (zerrno) {			ZEND_TRY_ASSIGN_LONG(zerrno, err);		}		if (errstr) {			if (zerrstr) {				ZEND_TRY_ASSIGN_STR(zerrstr, errstr);			} else {				zend_string_release(errstr);			}		}		RETURN_FALSE;	}	if (zerrno) {		ZEND_TRY_ASSIGN_LONG(zerrno, 0);	}	if (zerrstr) {		ZEND_TRY_ASSIGN_EMPTY_STRING(zerrstr);	}	if (errstr) {		zend_string_release_ex(errstr, 0);	}	php_stream_to_zval(stream, return_value);}
开发者ID:SammyK,项目名称:php-src,代码行数:94,


示例23: return

/* Normal hash selection/retrieval call */PHPAPI HashTable *_php_get_stream_filters_hash(TSRMLS_D){	return (FG(stream_filters) ? FG(stream_filters) : &stream_filters_hash);}
开发者ID:899,项目名称:php-src,代码行数:5,


示例24: md5_hash_block

/* Hash a single block, 64 bytes long and 4-byte aligned. */static void md5_hash_block(const void *buffer, md5_ctx_t *ctx){	uint32_t correct_words[16];	const uint32_t *words = buffer;# if MD5_SIZE_VS_SPEED > 0	static const uint32_t C_array[] = {		/* round 1 */		0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,		0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,		0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,		0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,		/* round 2 */		0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,		0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8,		0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,		0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,		/* round 3 */		0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,		0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,		0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05,		0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,		/* round 4 */		0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,		0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,		0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,		0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391	};	static const char P_array[] ALIGN1 = {#  if MD5_SIZE_VS_SPEED > 1		0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,	/* 1 */#  endif	/* MD5_SIZE_VS_SPEED > 1 */		1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12,	/* 2 */		5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2,	/* 3 */		0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9	/* 4 */	};#  if MD5_SIZE_VS_SPEED > 1	static const char S_array[] ALIGN1 = {		7, 12, 17, 22,		5, 9, 14, 20,		4, 11, 16, 23,		6, 10, 15, 21	};#  endif	/* MD5_SIZE_VS_SPEED > 1 */# endif	uint32_t A = ctx->A;	uint32_t B = ctx->B;	uint32_t C = ctx->C;	uint32_t D = ctx->D;	/* Process all bytes in the buffer with 64 bytes in each round of	   the loop.  */		uint32_t *cwp = correct_words;		uint32_t A_save = A;		uint32_t B_save = B;		uint32_t C_save = C;		uint32_t D_save = D;# if MD5_SIZE_VS_SPEED > 1#  define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))		const uint32_t *pc;		const char *pp;		const char *ps;		int i;		uint32_t temp;		for (i = 0; i < 16; i++) {			cwp[i] = SWAP_LE32(words[i]);		}		words += 16;#  if MD5_SIZE_VS_SPEED > 2		pc = C_array;		pp = P_array;		ps = S_array - 4;		for (i = 0; i < 64; i++) {			if ((i & 0x0f) == 0)				ps += 4;			temp = A;			switch (i >> 4) {			case 0:				temp += FF(B, C, D);				break;			case 1:				temp += FG(B, C, D);				break;			case 2:				temp += FH(B, C, D);				break;			case 3:				temp += FI(B, C, D);			}			temp += cwp[(int) (*pp++)] + *pc++;			CYCLIC(temp, ps[i & 3]);//.........这里部分代码省略.........
开发者ID:Jeanlst,项目名称:Onlive-Source-Backup,代码行数:101,


示例25: pemalloc

	ret = (php_stream*) pemalloc(sizeof(php_stream), persistent_id ? 1 : 0);	memset(ret, 0, sizeof(php_stream));	ret->readfilters.stream = ret;	ret->writefilters.stream = ret;#if STREAM_DEBUGfprintf(stderr, "stream_alloc: %s:%p persistent=%s/n", ops->label, ret, persistent_id);#endif	ret->ops = ops;	ret->abstract = abstract;	ret->is_persistent = persistent_id ? 1 : 0;	ret->chunk_size = FG(def_chunk_size);	if (FG(auto_detect_line_endings)) {		ret->flags |= PHP_STREAM_FLAG_DETECT_EOL;	}	if (persistent_id) {		zend_rsrc_list_entry le;		le.type = le_pstream;		le.ptr = ret;		le.refcount = 0;		if (FAILURE == zend_hash_update(&EG(persistent_list), (char *)persistent_id,					strlen(persistent_id) + 1,					(void *)&le, sizeof(le), NULL)) {
开发者ID:Jasonudoo,项目名称:hhvm,代码行数:30,


示例26: php_url_parse

//.........这里部分代码省略.........				/* set data connection protection level */#if FTPS_ENCRYPT_DATA		php_stream_write_string(stream, "PROT P/r/n");		/* get the response */		result = GET_FTP_RESULT(stream);		use_ssl_on_data = (result >= 200 && result<=299) || reuseid;#else		php_stream_write_string(stream, "PROT C/r/n");		/* get the response */		result = GET_FTP_RESULT(stream);#endif	}#define PHP_FTP_CNTRL_CHK(val, val_len, err_msg) {	/	unsigned char *s = val, *e = s + val_len;	/	while (s < e) {	/		if (iscntrl(*s)) {	/			php_stream_wrapper_log_error(wrapper, options, err_msg, val);	/			goto connect_errexit;	/		}	/		s++;	/	}	/} 	/* send the user name */	if (resource->user != NULL) {		tmp_len = (int)php_raw_url_decode(resource->user, (int)strlen(resource->user));		PHP_FTP_CNTRL_CHK(resource->user, tmp_len, "Invalid login %s")		php_stream_printf(stream, "USER %s/r/n", resource->user);	} else {		php_stream_write_string(stream, "USER anonymous/r/n");	}		/* get the response */	result = GET_FTP_RESULT(stream);		/* if a password is required, send it */	if (result >= 300 && result <= 399) {		php_stream_notify_info(context, PHP_STREAM_NOTIFY_AUTH_REQUIRED, tmp_line, 0);		if (resource->pass != NULL) {			tmp_len = (int)php_raw_url_decode(resource->pass, (int)strlen(resource->pass));			PHP_FTP_CNTRL_CHK(resource->pass, tmp_len, "Invalid password %s")			php_stream_printf(stream, "PASS %s/r/n", resource->pass);		} else {			/* if the user has configured who they are,			   send that as the password */			if (FG(from_address)) {				php_stream_printf(stream, "PASS %s/r/n", FG(from_address));			} else {				php_stream_write_string(stream, "PASS anonymous/r/n");			}		}		/* read the response */		result = GET_FTP_RESULT(stream);		if (result > 299 || result < 200) {			php_stream_notify_error(context, PHP_STREAM_NOTIFY_AUTH_RESULT, tmp_line, result);		} else {			php_stream_notify_info(context, PHP_STREAM_NOTIFY_AUTH_RESULT, tmp_line, result);		}	}	if (result > 299 || result < 200) {		goto connect_errexit;	}	if (puse_ssl) {		*puse_ssl = use_ssl;	}	if (puse_ssl_on_data) {		*puse_ssl_on_data = use_ssl_on_data;	}	if (preuseid) {		*preuseid = reuseid;	}	if (presource) {		*presource = resource;	}	return stream;connect_errexit:	if (resource) {		php_url_free(resource);		}	if (stream) {		php_stream_close(stream);	}	return NULL;}
开发者ID:AmesianX,项目名称:php-src,代码行数:101,


示例27: md5_process_block64

static void md5_process_block64(md5_ctx_t *ctx){	/* Before we start, one word to the strange constants.	   They are defined in RFC 1321 as	   T[i] = (int)(4294967296.0 * fabs(sin(i))), i=1..64	 */	static const uint32_t C_array[] = {		/* round 1 */		0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,		0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,		0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,		0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,		/* round 2 */		0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,		0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,		0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,		0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,		/* round 3 */		0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,		0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,		0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05,		0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,		/* round 4 */		0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,		0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,		0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,		0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391	};	static const char P_array[] = {		0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 1 */		1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, /* 2 */		5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, /* 3 */		0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9  /* 4 */	};	uint32_t *words = (void*) ctx->wbuffer;	uint32_t A = ctx->hash[0];	uint32_t B = ctx->hash[1];	uint32_t C = ctx->hash[2];	uint32_t D = ctx->hash[3]; /* 2 or 3 */	static const char S_array[] = {		7, 12, 17, 22,		5, 9, 14, 20,		4, 11, 16, 23,		6, 10, 15, 21	};	const uint32_t *pc;	const char *pp;	const char *ps;	int i;	uint32_t temp; /* MD5_SIZE_VS_SPEED == 2 */	pc = C_array;	pp = P_array;	ps = S_array;	for (i = 0; i < 16; i++) {		temp = A + FF(B, C, D) + words[(int) (*pp++)] + *pc++;		temp = rotl32(temp, ps[i & 3]);		temp += B;		A = D;		D = C;		C = B;		B = temp;	}	ps += 4;	for (i = 0; i < 16; i++) {		temp = A + FG(B, C, D) + words[(int) (*pp++)] + *pc++;		temp = rotl32(temp, ps[i & 3]);		temp += B;		A = D;		D = C;		C = B;		B = temp;	}	ps += 4;	for (i = 0; i < 16; i++) {		temp = A + FH(B, C, D) + words[(int) (*pp++)] + *pc++;		temp = rotl32(temp, ps[i & 3]);		temp += B;		A = D;		D = C;		C = B;		B = temp;	}	ps += 4;	for (i = 0; i < 16; i++) {		temp = A + FI(B, C, D) + words[(int) (*pp++)] + *pc++;		temp = rotl32(temp, ps[i & 3]);		temp += B;		A = D;		D = C;		C = B;		B = temp;	}//.........这里部分代码省略.........
开发者ID:ShawnOfMisfit,项目名称:ambarella,代码行数:101,


示例28: php_fsockopen_stream

static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent){	char *host;	int host_len;	long port = -1;	zval *zerrno = NULL, *zerrstr = NULL, *zcontext = NULL;	double timeout = FG(default_socket_timeout);	unsigned long conv;	struct timeval tv;	char *hashkey = NULL;	php_stream *stream = NULL;	php_stream_context *context = NULL;	int err;	RETVAL_FALSE;		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lzzdr", &host, &host_len, &port, &zerrno, &zerrstr, &timeout, &zcontext) == FAILURE) {		RETURN_FALSE;	}	if (zcontext) {		ZEND_FETCH_RESOURCE(context, php_stream_context*, &zcontext, -1, "stream-context", php_le_stream_context());	}	if (persistent) {		spprintf(&hashkey, 0, "pfsockopen__%s:%ld", host, port);		switch(php_stream_from_persistent_id(hashkey, &stream TSRMLS_CC)) {			case PHP_STREAM_PERSISTENT_SUCCESS:				if (_php_network_is_stream_alive(stream TSRMLS_CC)) {					php_stream_to_zval(stream, return_value);				} else {					/* it died; we need to replace it */					php_stream_pclose(stream);					break;				}								/* fall through */			case PHP_STREAM_PERSISTENT_FAILURE:				efree(hashkey);				return;		}	}	/* prepare the timeout value for use */	conv = (unsigned long) (timeout * 1000000.0);	tv.tv_sec = conv / 1000000;	tv.tv_usec = conv % 1000000;	if (zerrno)	{		zval_dtor(zerrno);		ZVAL_LONG(zerrno, 0);	}	if (zerrstr) {		zval_dtor(zerrstr);		ZVAL_STRING(zerrstr, "", 1);	}	if (port > 0)	{ /* connect to a host */		enum php_sslflags_t { php_ssl_none, php_ssl_v23, php_ssl_tls };		enum php_sslflags_t ssl_flags = php_ssl_none;		struct {			char *proto;			int protolen;			int socktype;			enum php_sslflags_t ssl_flags;			/* more flags to be added here */		} sockmodes[] = {			{ "udp://", 6, SOCK_DGRAM,	php_ssl_none },			{ "tcp://", 6, SOCK_STREAM,	php_ssl_none },			{ "ssl://", 6, SOCK_STREAM, php_ssl_v23 },			{ "tls://", 6, SOCK_STREAM, php_ssl_tls },			/* more modes to be added here */			{ NULL, 0, 0 }		};		int socktype = SOCK_STREAM;		int i;		for (i = 0; sockmodes[i].proto != NULL; i++) {			if (strncmp(host, sockmodes[i].proto, sockmodes[i].protolen) == 0) {				ssl_flags = sockmodes[i].ssl_flags;						socktype = sockmodes[i].socktype;				host += sockmodes[i].protolen;				break;			}		}#ifndef HAVE_OPENSSL_EXT		if (ssl_flags != php_ssl_none) {			php_error_docref(NULL TSRMLS_CC, E_WARNING, "no SSL support in this build");		}		else#endif		stream = php_stream_sock_open_host(host, (unsigned short)port, socktype, &tv, hashkey);		/* Preserve error */		err = php_socket_errno();		if (stream == NULL) {			php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to connect to %s:%ld", host, port);		} else if (context) {			php_stream_context_set(stream, context);//.........这里部分代码省略.........
开发者ID:AzerTyQsdF,项目名称:osx,代码行数:101,


示例29: php_error_docref

//.........这里部分代码省略.........        if (snprintf(scratch, scratch_len, "Authorization: Basic %s/r/n", tmp) > 0) {            php_stream_write(stream, scratch, strlen(scratch));            php_stream_notify_info(context, PHP_STREAM_NOTIFY_AUTH_REQUIRED, NULL, 0);        }        efree(tmp);        tmp = NULL;    }    /* if the user has configured who they are, send a From: line */    if (((have_header & HTTP_HEADER_FROM) == 0) && cfg_get_string("from", &tmp) == SUCCESS)	{        if (snprintf(scratch, scratch_len, "From: %s/r/n", tmp) > 0) {            php_stream_write(stream, scratch, strlen(scratch));        }    }    /* Send Host: header so name-based virtual hosts work */    if ((have_header & HTTP_HEADER_HOST) == 0) {        if ((use_ssl && resource->port != 443) || (!use_ssl && resource->port != 80))	{            if (snprintf(scratch, scratch_len, "Host: %s:%i/r/n", resource->host, resource->port) > 0) {                php_stream_write(stream, scratch, strlen(scratch));            }        } else {            if (snprintf(scratch, scratch_len, "Host: %s/r/n", resource->host) > 0) {                php_stream_write(stream, scratch, strlen(scratch));            }        }    }    if (context &&            php_stream_context_get_option(context, "http", "user_agent", &ua_zval) == SUCCESS) {        ua_str = Z_STRVAL_PP(ua_zval);    } else if (FG(user_agent)) {        ua_str = FG(user_agent);    }    if (ua_str) {#define _UA_HEADER "User-Agent: %s/r/n"        char *ua;        size_t ua_len;        ua_len = sizeof(_UA_HEADER) + strlen(ua_str);        /* ensure the header is only sent if user_agent is not blank */        if (ua_len > sizeof(_UA_HEADER)) {            ua = (char *)emalloc(ua_len + 1);            if ((ua_len = snprintf(ua, ua_len, _UA_HEADER, ua_str)) > 0) {                ua[ua_len] = 0;                php_stream_write(stream, ua, ua_len);            } else {                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot construct User-agent header");            }            if (ua) {                efree(ua);            }        }    }    php_stream_write(stream, "/r/n", sizeof("/r/n")-1);    /* Request content, such as for POST requests */    if (context && php_stream_context_get_option(context, "http", "content", &tmpzval) == SUCCESS && Z_STRLEN_PP(tmpzval) > 0) {        php_stream_write(stream, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval));        php_stream_write(stream, "/r/n/r/n", sizeof("/r/n/r/n")-1);
开发者ID:Ashod,项目名称:Phalanger,代码行数:67,


示例30: php_mongo_io_stream_read

/* Returns the bytes read on success * Returns -31 on unknown failure * Returns -80 on timeout * Returns -32 when remote server closes the connection */int php_mongo_io_stream_read(mongo_connection *con, mongo_server_options *options, int timeout, void *data, int size, char **error_message){	int num = 1, received = 0;	TSRMLS_FETCH();	int socketTimeoutMS = options->socketTimeoutMS ? options->socketTimeoutMS : FG(default_socket_timeout) * 1000;	/* Convert negative values to -1 second, which implies no timeout */	socketTimeoutMS = socketTimeoutMS < 0 ? -1000 : socketTimeoutMS;	timeout = timeout < 0 ? -1000 : timeout;	/* Socket timeout behavior varies based on the following:	 * - Negative => no timeout (i.e. block indefinitely)	 * - Zero => not specified (no changes to existing configuration)	 * - Positive => used specified timeout (revert to previous value later) */	if (timeout && timeout != socketTimeoutMS) {		struct timeval rtimeout = {0, 0};		rtimeout.tv_sec = timeout / 1000;		rtimeout.tv_usec = (timeout % 1000) * 1000;		php_stream_set_option(con->socket, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &rtimeout);		mongo_manager_log(MonGlo(manager), MLOG_CON, MLOG_FINE, "Setting the stream timeout to %d.%06d", rtimeout.tv_sec, rtimeout.tv_usec);	} else {		mongo_manager_log(MonGlo(manager), MLOG_CON, MLOG_FINE, "No timeout changes for %s", con->hash);	}	php_mongo_stream_notify_io(options, MONGO_STREAM_NOTIFY_IO_READ, 0, size TSRMLS_CC);	/* this can return FAILED if there is just no more data from db */	while (received < size && num > 0) {		int len = 4096 < (size - received) ? 4096 : size - received;		ERROR_HANDLER_DECLARATION(error_handler)		ERROR_HANDLER_REPLACE(error_handler, mongo_ce_ConnectionException);		num = php_stream_read(con->socket, (char *) data, len);		ERROR_HANDLER_RESTORE(error_handler);		if (num < 0) {			/* Doesn't look like this can happen, php_sockop_read overwrites			 * the failure from recv() to return 0 */			*error_message = strdup("Read from socket failed");			return -31;		}		/* It *may* have failed. It also may simply have no data */		if (num == 0) {			zval *metadata;			MAKE_STD_ZVAL(metadata);			array_init(metadata);			if (php_stream_populate_meta_data(con->socket, metadata)) {				zval **tmp;				if (zend_hash_find(Z_ARRVAL_P(metadata), "timed_out", sizeof("timed_out"), (void**)&tmp) == SUCCESS) {					convert_to_boolean_ex(tmp);					if (Z_BVAL_PP(tmp)) {						struct timeval rtimeout = {0, 0};						if (timeout > 0 && options->socketTimeoutMS != timeout) {							rtimeout.tv_sec = timeout / 1000;							rtimeout.tv_usec = (timeout % 1000) * 1000;						} else {							/* Convert timeout=-1 to -1second, which PHP interprets as no timeout */							int socketTimeoutMS = options->socketTimeoutMS == -1 ? -1000 : options->socketTimeoutMS;							rtimeout.tv_sec = socketTimeoutMS / 1000;							rtimeout.tv_usec = (socketTimeoutMS % 1000) * 1000;						}						*error_message = malloc(256);						snprintf(*error_message, 256, "Read timed out after reading %d bytes, waited for %d.%06d seconds", num, rtimeout.tv_sec, rtimeout.tv_usec);						zval_ptr_dtor(&metadata);						return -80;					}				}				if (zend_hash_find(Z_ARRVAL_P(metadata), "eof", sizeof("eof"), (void**)&tmp) == SUCCESS) {					convert_to_boolean_ex(tmp);					if (Z_BVAL_PP(tmp)) {						*error_message = strdup("Remote server has closed the connection");						zval_ptr_dtor(&metadata);						return -32;					}				}			}			zval_ptr_dtor(&metadata);		}		data = (char*)data + num;		received += num;	}	/* PHP may have sent notify-progress of *more then* 'received' in some	 * cases.	 * PHP will read 8192 byte chunks at a time, but if we request less data	 * then that PHP will just buffer the rest, which is fine.  It could	 * confuse users a little, why their progress update was higher then the	 * max-bytes-expected though... *///.........这里部分代码省略.........
开发者ID:LTD-Beget,项目名称:mongo-php-driver,代码行数:101,



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


C++ FIELD_OFFSET函数代码示例
C++ FF_CEIL_RSHIFT函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。