static int my_source_udp_close(my_port_t *port) { int rc; my_core_event_handler_del(port->core, MY_SOURCE(port)->fd); MY_DEBUG("core/%s: leaving mcast group", port->conf->name); rc = my_net_mcast_leave(MY_SOURCE(port)->fd, MY_SOURCE(port)->sa_local, MY_SOURCE(port)->sa_group); if (rc < 0) { my_log(MY_LOG_ERROR, "core/%s: error leaving mcast group (%d: %s)", port->conf->name, errno, strerror(errno)); goto _MY_ERR_mcast_leave; } MY_DEBUG("core/%s: closing socket", port->conf->name); rc = my_sock_close(MY_SOURCE(port)->fd); if (rc < 0) { my_log(MY_LOG_ERROR, "core/%s: error closing file (%d: %s)", port->conf->name, errno, strerror(errno)); goto _MY_ERR_sock_close; } return 0; _MY_ERR_sock_close: _MY_ERR_mcast_leave: return rc; }
static int my_control_sock_open(my_port_t *port) { struct sockaddr_un sa; MY_DEBUG("core/%s: creating unix socket '%s'", port->conf->name, MY_CONTROL(port)->path); MY_CONTROL(port)->sock = socket(AF_UNIX, SOCK_DGRAM, 0); if (MY_CONTROL(port)->sock == -1) { my_log(MY_LOG_ERROR, "core/%s: error creating socket '%s' (%d: %s)", port->conf->name, MY_CONTROL(port)->path, errno, strerror(errno)); goto _MY_ERR_create_sock; } my_mem_zero(&sa, sizeof(sa)); sa.sun_family = AF_UNIX; strncpy(sa.sun_path, MY_CONTROL(port)->path, sizeof(sa.sun_path)); MY_DEBUG("core/%s: binding unix socket '%s'", port->conf->name, MY_CONTROL(port)->path); if (bind(MY_CONTROL(port)->sock, (struct sockaddr *)&sa, sizeof(sa)) == -1) { my_log(MY_LOG_ERROR, "core/%s: error binding unix socket '%s' (%d: %s)", port->conf->name, MY_CONTROL(port)->path, errno, strerror(errno)); goto _MY_ERR_bind_sock; } return 0; _MY_ERR_bind_sock: close(MY_CONTROL(port)->sock); _MY_ERR_create_sock: return -1; }
void SwTmrMgr_Dump(handle_t handle) { struct SWTMR_NODE_ITEM *head, *entry; struct SWTMR_MGR_CTRL *pCtrl = (struct SWTMR_MGR_CTRL *)handle; u_int32 i = 0; if (0 == pCtrl) { return; } if (NULL == pCtrl->current) { MY_DEBUG("\nNo any timer to dump\n"); return; } head = pCtrl->current; entry = head; MY_DEBUG("\ndump[%X]\n", head); i = 0; do { i++; MY_DEBUG("\t%03d,Tmr[%d]: interval=%d, \texpire=%d, \t%x\n", i, entry->tmr_id, entry->timeoutTenths, entry->timeToExpiry, entry->flags); entry = entry->next; }while(entry != head); }
void my_source_dump_all(void) { MY_DEBUG("# registered sources"); MY_DEBUG("sources = ("); my_list_iter(&my_sources, my_source_dump_fn, NULL); MY_DEBUG(");"); }
void my_target_dump_all(void) { MY_DEBUG("# registered targets"); MY_DEBUG("targets = ("); my_list_iter(&my_targets, my_target_dump_fn, NULL); MY_DEBUG(");"); }
int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_TRACE ("main"); MY_DEBUG (ACE_TEXT ("Hi Mom\n")); foo (); MY_DEBUG (ACE_TEXT ("Goodnight\n")); return 0; }
static int my_source_dump_fn(void *data, void *user, int flags) { my_port_impl_t *impl = MY_PORT_IMPL(data); MY_DEBUG("\t{"); MY_DEBUG("\t\tname=\"%s\";", impl->name); MY_DEBUG("\t\tdescription=\"%s\";", impl->desc); MY_DEBUG("\t}%s", flags & MY_LIST_ITER_FLAG_LAST ? "" : ","); return 0; }
static int my_control_sock_close(my_port_t *port) { MY_DEBUG("core/%s: closing unix socket '%s'", port->conf->name, MY_CONTROL(port)->path); if (close(MY_CONTROL(port)->sock) == -1) { my_log(MY_LOG_ERROR, "core/%s: error closing unix socket '%s' (%d: %s)", port->conf->name, MY_CONTROL(port)->path, errno, strerror(errno)); } MY_DEBUG("core/%s: removing unix socket '%s'", port->conf->name, MY_CONTROL(port)->path); if (unlink(MY_CONTROL(port)->path) == -1) { my_log(MY_LOG_ERROR, "core/%s: error removing unix socket '%s' (%d: %s)", port->conf->name, MY_CONTROL(port)->path, errno, strerror(errno)); } return 0; }
void GenBase::closeFile (int index) { if (index >= 0 && index < files_.size()) files_[index].reset(); else MY_DEBUG("Invalid file index: %d", index); }
int put_comment(char *classn,char *func,char *filename,char *comment,int beg_line,int beg_char) { register unsigned char *p; if (!comment_database || !comment || !cross_ref_fp) { return 0; } /* We use cross_ref_fp because the comments should be inserted * only during the second phase with the cross reference together. */ for (p = (unsigned char *)comment; *p; p++) { if (*p == '\n') { *p = 0xff; } } MY_DEBUG((Output, "put comment into file <%s>\n", filename)); fprintf(cross_ref_fp, "%d%c%s%c%06d.%03d%c%s%c%s%c%s\n", PAF_COMMENT_DEF, KEY_DATA_SEP_CHR, filename, DB_FLDSEP_CHR, beg_line, beg_char, DB_FLDSEP_CHR, classn && *classn ? classn : "#", DB_FLDSEP_CHR, func && *func ? func : "#", KEY_DATA_SEP_CHR, comment); return 0; }
CIAsyncIO *CreateAsyncIO(INT iId ) { if( iId == 0 ) { MY_DEBUG(_GSTX("GSP 网络库 使用 Select 模型...\n" ) ); } return new CAIOSelect(iId); }
static int read_socket(struct stream *stream, void *buf, size_t len) { int n; assert(stream->chan.sock != -1); // return (recv(stream->chan.sock, buf, len, 0)); n = recv(stream->chan.sock, buf, len, 0); MY_DEBUG("n=%d\n", n); return n; }
static int write_socket(struct stream *stream, const void *buf, size_t len) { int n; assert(stream->chan.sock != -1); // return (send(stream->chan.sock, buf, len, 0)); n = send(stream->chan.sock, buf, len, 0); MY_DEBUG("n=%d\n", n); return n; }
void _shttpd_do_cgi(struct conn *c) { MY_DEBUG("%s(%s)\n", __func__, c->uri); assert(c->loc.io.size > CGI_REPLY_LEN); memcpy(c->loc.io.buf, CGI_REPLY, CGI_REPLY_LEN); c->loc.io.head = c->loc.io.tail = c->loc.io.total = CGI_REPLY_LEN; c->loc.io_class = &_shttpd_io_cgi; c->loc.flags = FLAG_R; if (c->method == METHOD_POST) c->loc.flags |= FLAG_W; }
static int my_source_udp_open(my_port_t *port) { int rc; MY_DEBUG("core/%s: opening socket", port->conf->name); MY_SOURCE(port)->fd = my_sock_create(PF_INET, SOCK_DGRAM); if (MY_SOURCE(port)->fd < 0) { my_log(MY_LOG_ERROR, "core/%s: error opening socket' (%d: %s)", port->conf->name, errno, strerror(errno)); goto _MY_ERR_sock_create; } MY_DEBUG("core/%s: binding socket", port->conf->name); rc = my_sock_bind(MY_SOURCE(port)->fd, MY_SOURCE(port)->sa_local); if (rc < 0) { my_log(MY_LOG_ERROR, "core/%s: error binding socket socket (%d: %s)", port->conf->name, errno, strerror(errno)); goto _MY_ERR_sock_bind; } MY_DEBUG("core/%s: setting socket receive buffer to %d", port->conf->name, 65535); rc = my_sock_set_rcv_buffer_size(MY_SOURCE(port)->fd, 65535); if (rc < 0) { my_log(MY_LOG_ERROR, "core/%s: error setting socket receive buffer (%d: %s)", port->conf->name, errno, strerror(errno)); goto _MY_ERR_set_rcv_buffer_size; } MY_DEBUG("core/%s: putting socket in non-blocking mode", port->conf->name); rc = my_sock_set_nonblock(MY_SOURCE(port)->fd); if (rc < 0) { my_log(MY_LOG_ERROR, "core/%s: error putting socket in non-blocking mode (%d: %s)", port->conf->name, errno, strerror(errno)); goto _MY_ERR_set_nonblock; } MY_DEBUG("core/%s: reusing socket addr", port->conf->name); rc = my_sock_set_reuseaddr(MY_SOURCE(port)->fd); if (rc < 0) { my_log(MY_LOG_ERROR, "core/%s: error reusing socket addr (%d: %s)", port->conf->name, errno, strerror(errno)); goto _MY_ERR_set_reuseaddr; } MY_DEBUG("core/%s: joining mcast group", port->conf->name); rc = my_net_mcast_join(MY_SOURCE(port)->fd, MY_SOURCE(port)->sa_local, MY_SOURCE(port)->sa_group); if (rc < 0) { my_log(MY_LOG_ERROR, "core/%s: error joining mcast group (%d: %s)", port->conf->name, errno, strerror(errno)); goto _MY_ERR_mcast_join; } my_core_event_handler_add(port->core, MY_SOURCE(port)->fd, my_source_udp_event_handler, port); return 0; _MY_ERR_mcast_join: _MY_ERR_set_reuseaddr: _MY_ERR_set_nonblock: _MY_ERR_set_rcv_buffer_size: _MY_ERR_sock_bind: _MY_ERR_sock_create: return -1; }
int _shttpd_run_cgi(struct conn *c, const char *prog) { struct env_block blk; char dir[FILENAME_MAX], *p; int ret, pair[2]; MY_DEBUG("%s(%s)\n", __func__, c->uri); prepare_environment(c, prog, &blk); pair[0] = pair[1] = -1; MY_DEBUG("%s(%s)\n", __func__, c->uri); /* CGI must be executed in its own directory */ (void) _shttpd_snprintf(dir, sizeof(dir), "%s", prog); for (p = dir + strlen(dir) - 1; p > dir; p--) if (*p == '/') { *p++ = '\0'; break; } MY_DEBUG("%s(%s)\n", __func__, c->uri); if (shttpd_socketpair(pair) != 0) { ret = -1; } else if (_shttpd_spawn_process(c, prog, blk.buf, blk.vars, pair[1], dir)) { MY_DEBUG("%s(%s)\n", __func__, c->uri); ret = -1; (void) closesocket(pair[0]); (void) closesocket(pair[1]); } else { MY_DEBUG("%s(%s)\n", __func__, c->uri); ret = 0; c->loc.chan.sock = pair[0]; } return (ret); }
void gmenu_content_list_changefocus(struct GMENU_CONTENT_LIST *list, u_int8 focus) { if (list) { if (focus < list->len) { if (focus != list->curFocus) { gmenu_content_list_cell_clear(list, list->curFocus, 1); gmenu_content_list_cell_draw(list, list->curFocus, UICOM_STATUS_NORMAL); } MY_DEBUG("MoveFocus %d->%d\n", list->curFocus, focus); list->curFocus = focus; gmenu_content_list_cell_clear(list, list->curFocus, 1); gmenu_content_list_cell_draw(list, list->curFocus, UICOM_STATUS_SELECTED); } } }
int main() { av_register_all(); avdevice_register_all(); do { AVFormatContext *pFormatCtx = NULL; AVInputFormat *ifmt=av_find_input_format("alsa"); if(avformat_open_input(&pFormatCtx,"hw:0",ifmt,NULL)!=0){ MY_DEBUG("Couldn't open input stream.\n"); break; } if(avformat_find_stream_info(pFormatCtx, NULL)<0) break; av_dump_format(pFormatCtx, 0, NULL, 0); int audiostream = -1; for(int i=0; i<pFormatCtx->nb_streams; i++) if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO) { audiostream=i; break; } if(audiostream==-1) break; // Get a pointer to the codec context for the video stream AVCodecContext *pCodecCtx=pFormatCtx->streams[audiostream]->codec; printf("video codec pixfmt:%d\n",pCodecCtx->pix_fmt); // Find the decoder for the video stream AVCodec *pCodec=avcodec_find_decoder(pCodecCtx->codec_id); if(pCodec==NULL) { fprintf(stderr, "Unsupported codec!\n"); break; } // Open codec if(avcodec_open2(pCodecCtx, pCodec, NULL)<0) break; }while (0); }
static int my_source_udp_get(my_port_t *port, void *buf, int len) { int n; n = read(MY_SOURCE(port)->fd, buf, len); if (n < 0) { if ((errno == EWOULDBLOCK) || (errno == EINTR)) { n = 0; goto out; } my_log(MY_LOG_ERROR, "core/%s: error reading from socket (%d: %s)", port->conf->name, errno, strerror(errno)); return n; } out: MY_DEBUG("core/%s: read %d bytes from socket", port->conf->name, n); return n; }
int my_source_close_all(my_core_t *core) { MY_DEBUG("core/sources: closing all"); return my_port_close_all(core->sources); }
int my_source_create_all(my_core_t *core, my_conf_t *conf) { MY_DEBUG("core/sources: creating all"); return my_list_iter(conf->sources, my_source_create_fn, core); }
int my_source_destroy_all(my_core_t *core) { MY_DEBUG("core/sources: destroying all"); return my_port_destroy_all(core->sources); }
int my_target_destroy_all(my_core_t *core) { MY_DEBUG("core/targets: destroying all"); return my_port_destroy_all(core->targets); }
void foo (void) { ACE_TRACE ("foo"); MY_DEBUG (ACE_TEXT ("Howdy Pardner\n")); }
int my_target_open_all(my_core_t *core) { MY_DEBUG("core/targets: opening all"); return my_port_open_all(core->targets); }
int my_target_close_all(my_core_t *core) { MY_DEBUG("core/targets: closing all"); return my_port_close_all(core->targets); }
static void prepare_environment(const struct conn *c, const char *prog, struct env_block *blk) { const struct headers *h = &c->ch; const char *s, *fname, *root = c->ctx->options[OPT_ROOT]; size_t len; blk->len = blk->nvars = 0; /* SCRIPT_FILENAME */ fname = prog; if ((s = strrchr(prog, '/'))) fname = s + 1; /* Prepare the environment block */ addenv(blk, "%s", "GATEWAY_INTERFACE=CGI/1.1"); addenv(blk, "%s", "SERVER_PROTOCOL=HTTP/1.1"); addenv(blk, "%s", "REDIRECT_STATUS=200"); /* PHP */ addenv(blk, "SERVER_PORT=%d", c->loc_port); addenv(blk, "SERVER_NAME=%s", c->ctx->options[OPT_AUTH_REALM]); addenv(blk, "SERVER_ROOT=%s", root); addenv(blk, "DOCUMENT_ROOT=%s", root); addenv(blk, "REQUEST_METHOD=%s", _shttpd_known_http_methods[c->method].ptr); addenv(blk, "REMOTE_ADDR=%s", inet_ntoa(c->sa.u.sin.sin_addr)); addenv(blk, "REMOTE_PORT=%hu", ntohs(c->sa.u.sin.sin_port)); addenv(blk, "REQUEST_URI=%s", c->uri); addenv(blk, "SCRIPT_NAME=%s", prog + strlen(root)); addenv(blk, "SCRIPT_FILENAME=%s", fname); /* PHP */ addenv(blk, "PATH_TRANSLATED=%s", prog); if (h->ct.v_vec.len > 0) addenv(blk, "CONTENT_TYPE=%.*s", h->ct.v_vec.len, h->ct.v_vec.ptr); if (c->query != NULL) addenv(blk, "QUERY_STRING=%s", c->query); if (c->path_info != NULL) addenv(blk, "PATH_INFO=/%s", c->path_info); if (h->cl.v_big_int > 0) addenv(blk, "CONTENT_LENGTH=%lu", h->cl.v_big_int); if ((s = getenv("PATH")) != NULL) addenv(blk, "PATH=%s", s); #ifdef _WIN32 if ((s = getenv("COMSPEC")) != NULL) addenv(blk, "COMSPEC=%s", s); if ((s = getenv("SYSTEMROOT")) != NULL) addenv(blk, "SYSTEMROOT=%s", s); #else if ((s = getenv("LD_LIBRARY_PATH")) != NULL) addenv(blk, "LD_LIBRARY_PATH=%s", s); #endif /* _WIN32 */ if ((s = getenv("PERLLIB")) != NULL) addenv(blk, "PERLLIB=%s", s); if (h->user.v_vec.len > 0) { addenv(blk, "REMOTE_USER=%.*s", h->user.v_vec.len, h->user.v_vec.ptr); addenv(blk, "%s", "AUTH_TYPE=Digest"); } /* Add user-specified variables */ s = c->ctx->options[OPT_CGI_ENVIRONMENT]; FOR_EACH_WORD_IN_LIST(s, len) addenv(blk, "%.*s", len, s); /* Add all headers as HTTP_* variables */ add_http_headers_to_env(blk, c->headers, c->request + c->rem.headers_len - c->headers); blk->vars[blk->nvars++] = NULL; blk->buf[blk->len++] = '\0'; assert(blk->nvars < CGI_ENV_VARS); assert(blk->len > 0); assert(blk->len < (int) sizeof(blk->buf)); /* Debug stuff to view passed environment */ MY_DEBUG("%s: %d vars, %d env size\n", prog, blk->nvars, blk->len); #if 0 { int i; for (i = 0 ; i < blk->nvars; i++) MY_DEBUG("[%s]\n", blk->vars[i] ? blk->vars[i] : "null"); } #endif }
int my_source_open_all(my_core_t *core) { MY_DEBUG("core/sources: opening all"); return my_port_open_all(core->sources); }
int my_target_create_all(my_core_t *core, my_conf_t *conf) { MY_DEBUG("core/targets: creating all"); return my_list_iter(conf->targets, my_target_create_fn, core); }