本文整理汇总了C++中FG函数的典型用法代码示例。如果您正苦于以下问题:C++ FG函数的具体用法?C++ FG怎么用?C++ FG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: resize
static void
resize(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,代码来源:draw.c
示例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,代码来源:filter.c
示例3: resize
void
resize(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,代码来源:draw.c
示例4: drawmenu
void
drawmenu(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,代码来源:dmenu.c
示例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,代码来源:filter.c
示例6: drawtextn
void
drawtextn(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,代码来源:draw.c
示例7: print_line
int
print_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,代码来源:draw.c
示例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,代码来源:php_cli.c
示例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,代码来源:ssh2.c
示例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,代码来源:http_fopen_wrapper.c
示例11: get
VT get(const V& v) const
{
return FG()(v);
}
开发者ID:migashko,项目名称:faslib-sandbox,代码行数:4,代码来源:getset.hpp
示例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,代码来源:http_fopen_wrapper.c
示例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,代码来源:hash.c
示例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,代码来源:hash.c
示例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,代码来源:xp_socket.c
示例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,代码来源:draw.c
示例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,代码来源:fcgi_client.c
示例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,代码来源:specialmonitors.cpp
示例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,代码来源:specialmonitors.cpp
|
请发表评论