/* Lookup a header in the mapping and return the value as if it's an integer * and otherwise return the default. */ INLINE static int lookup_integer_header(char *headername, int default_value) { struct svalue *head = NULL; THREAD_SAFE_RUN(head = lookup_header(headername), "header lookup"); if(!head || head->type != PIKE_T_INT) return default_value; return head->u.integer; }
/* Lookup a header in the mapping and return the value as a string, or * return the default if it's missing */ INLINE static char *lookup_string_header(char *headername, char *default_value) { struct svalue *head = NULL; THREAD_SAFE_RUN(head = lookup_header(headername), "header lookup"); if(!head || head->type != PIKE_T_STRING) return default_value; return head->u.string->str; }
static int php_roxen_sapi_ub_write(const char *str, uint str_length) { #ifdef ZTS PLS_FETCH(); #endif #ifdef ROXEN_USE_ZTS GET_THIS(); #endif int sent_bytes = 0, fd = MY_FD; if(fd) { for(sent_bytes=0;sent_bytes < str_length;) { int written; written = fd_write(fd, str + sent_bytes, str_length - sent_bytes); if(written < 0) { switch(errno) { default: /* This means the connection is closed. Dead. Gone. *sniff* */ PG(connection_status) = PHP_CONNECTION_ABORTED; zend_bailout(); return sent_bytes; case EINTR: case EWOULDBLOCK: continue; } } else { sent_bytes += written; } } } else { THREAD_SAFE_RUN(sent_bytes = php_roxen_low_ub_write(str, str_length), "write"); } return sent_bytes; }
static int php_caudium_sapi_ub_write(const char *str, uint str_length TSRMLS_DC) { GET_THIS(); int sent_bytes = 0, fd = MY_FD; if(fd) { for(sent_bytes=0;sent_bytes < str_length;) { int written; written = fd_write(fd, str + sent_bytes, str_length - sent_bytes); if(written < 0) { switch(errno) { default: /* This means the connection is closed. Dead. Gone. *sniff* */ PG(connection_status) = PHP_CONNECTION_ABORTED; zend_bailout(); THIS->written += sent_bytes; return sent_bytes; case EINTR: case EWOULDBLOCK: continue; } } else { sent_bytes += written; } } THIS->written += sent_bytes; } else { THREAD_SAFE_RUN(sent_bytes = php_caudium_low_ub_write(str, str_length TSRMLS_CC), "write"); } return sent_bytes; }