static guint mai_util_add_global_event_listener(GSignalEmissionHook listener, const gchar *event_type) { guint rc = 0; gchar **split_string; split_string = g_strsplit (event_type, ":", 3); if (split_string) { if (!strcmp ("window", split_string[0])) { guint gail_listenerid = 0; if (gail_add_global_event_listener) { // call gail's function to track gtk native window events gail_listenerid = gail_add_global_event_listener(listener, event_type); } rc = add_listener (listener, "MaiAtkObject", split_string[1], event_type, gail_listenerid); } else { rc = add_listener (listener, split_string[1], split_string[2], event_type); } g_strfreev(split_string); } return rc; }
void state_listener_controller_t::so_add_nondestroyable_listener( agent_state_listener_t & state_listener ) { add_listener( agent_state_listener_ref_t( new nondestroyable_listener_item_t( state_listener ) ) ); }
void *_Listen(void *arg) { acceptor_t a = create_acceptor(); add_listener(a,ip,port,accept_callback,arg); while(1) acceptor_run(a,100); return 0; }
void state_listener_controller_t::so_add_destroyable_listener( agent_state_listener_unique_ptr_t state_listener ) { add_listener( agent_state_listener_ref_t( new destroyable_listener_item_t( std::move( state_listener ) ) ) ); }
void init_timer() { listener_t tt_listener; tt_listener.call = &on_tick; add_listener(TIMER_TICK, tt_listener); }
void listeners_reload(struct Listener_head *existing_listeners, struct Listener_head *new_listeners, const struct Table_head *tables, struct ev_loop *loop) { struct Listener *iter_existing = SLIST_FIRST(existing_listeners); struct Listener *iter_new = SLIST_FIRST(new_listeners); while (iter_existing != NULL || iter_new != NULL) { int compare_result; char address[ADDRESS_BUFFER_SIZE]; if (iter_existing == NULL) compare_result = 1; else if (iter_new == NULL) compare_result = -1; else compare_result = address_compare(iter_existing->address, iter_new->address); if (compare_result > 0) { struct Listener *new_listener = iter_new; iter_new = SLIST_NEXT(iter_new, entries); notice("Listener %s added.", display_address(new_listener->address, address, sizeof(address))); SLIST_REMOVE(new_listeners, new_listener, Listener, entries); add_listener(existing_listeners, new_listener); init_listener(new_listener, tables, loop); /* -1 for removing from new_listeners */ listener_ref_put(new_listener); } else if (compare_result == 0) { notice ("Listener %s updated.", display_address(iter_existing->address, address, sizeof(address))); listener_update(iter_existing, iter_new, tables); iter_existing = SLIST_NEXT(iter_existing, entries); iter_new = SLIST_NEXT(iter_new, entries); } else { struct Listener *removed_listener = iter_existing; iter_existing = SLIST_NEXT(iter_existing, entries); notice("Listener %s removed.", display_address(removed_listener->address, address, sizeof(address))); SLIST_REMOVE(existing_listeners, removed_listener, Listener, entries); close_listener(loop, removed_listener); /* -1 for removing from existing_listeners */ listener_ref_put(removed_listener); } } }
static void xml_config_add_listeners(void) { struct gfs_listen *gfs = gfs_listen_list; int id_no; for (id_no = 1; gfs; gfs = gfs->next, id_no++) { if (gfs->address) add_listener(gfs->address, id_no); } }
static bool coreaudio_init_hooks(struct coreaudio_data *ca) { OSStatus stat; AURenderCallbackStruct callback_info = { .inputProc = input_callback, .inputProcRefCon = ca }; stat = add_listener(ca, kAudioDevicePropertyDeviceIsAlive); if (!ca_success(stat, ca, "coreaudio_init_hooks", "set disconnect callback")) return false; stat = add_listener(ca, PROPERTY_FORMATS); if (!ca_success(stat, ca, "coreaudio_init_hooks", "set format change callback")) return false; if (ca->default_device) { AudioObjectPropertyAddress addr = { PROPERTY_DEFAULT_DEVICE, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; stat = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &addr, notification_callback, ca); if (!ca_success(stat, ca, "coreaudio_init_hooks", "set device change callback")) return false; } stat = set_property(ca->unit, kAudioOutputUnitProperty_SetInputCallback, SCOPE_GLOBAL, 0, &callback_info, sizeof(callback_info)); if (!ca_success(stat, ca, "coreaudio_init_hooks", "set input callback")) return false; return true; }
void keystates_init() { int i; key_states = calloc(vektor_key_last, sizeof(*key_states)); // add a listener for every key for (i = 0; i < vektor_key_last; i++) { keybind_add(&key_states[i], &keystate_activate, &keystate_deactivate, i); } // make sure array gets freed add_listener(&keystates_remove, NULL, vektor_event_quit); }
int fix_cmd_listeners(void) { struct socket_id *si, *prev; for (si = cmd_listeners; si;) { if (si->proto == PROTO_NONE) si->proto = PROTO_UDP; if (add_listener(si, 0) < 0) LM_ERR("Cannot add socket <%s>, skipping...\n", si->name); prev = si; si = si->next; pkg_free(prev); } return 0; }
void *_Listen(void *arg) { /*struct listen_arg* args[2]; args[0] = (struct listen_arg*)calloc(1,sizeof(*args[0])); args[0]->ip = ip; args[0]->port = port; args[0]->accept_callback = &accept_callback; args[0]->ud = arg; args[1] = NULL;*/ acceptor_t a = create_acceptor(); add_listener(a,ip,port,accept_callback,arg); //free(args[0]); while(1) acceptor_run(a,100); return 0; }
static Chan* consopen(Chan *c, int omode) { c = devopen(c, omode, contab, nelem(contab), devgen); switch((ulong)c->qid.path) { case Qconsctl: incref(&kbd.ctl); break; case Qscancode: qlock(&kbd.gq); if(gkscanq != nil || gkscanid == nil) { qunlock(&kbd.q); c->flag &= ~COPEN; if(gkscanq) error(Einuse); else error("not supported"); } gkscanq = qopen(256, 0, nil, nil); qunlock(&kbd.gq); break; case Qkprint: wlock(&kprintq.l); if(waserror()){ wunlock(&kprintq.l); c->flag &= ~COPEN; nexterror(); } if(kprintq.q != nil) error(Einuse); kprintq.q = qopen(32*1024, Qcoalesce, nil, nil); if(kprintq.q == nil) error(Enomem); qnoblock(kprintq.q, 1); poperror(); wunlock(&kprintq.l); c->iounit = qiomaxatomic; break; case Qevents: c->aux = qopen(512, 0, nil, nil); add_listener(&event_listeners, c->aux); break; } return c; }
bool net::tcp_server::listen(const socket_address& addr, void* data) { for (unsigned i = 0; i < _M_nlisteners; i++) { if (addr == _M_listeners[i]->_M_addr) { // Already listening. return true; } } socket s; if (!s.listen(addr)) { return false; } if (!add_listener(s, addr, data)) { s.close(); return false; } return true; }
void SyslogDaemon::MessageReceived(BMessage *msg) { switch (msg->what) { case SYSLOG_ADD_LISTENER: { BMessenger messenger; if (msg->FindMessenger("target", &messenger) == B_OK) add_listener(&messenger); break; } case SYSLOG_REMOVE_LISTENER: { BMessenger messenger; if (msg->FindMessenger("target", &messenger) == B_OK) remove_listener(&messenger); break; } default: BApplication::MessageReceived(msg); } }
isc_result_t ns_controls_configure(ns_controls_t *cp, const cfg_obj_t *config, cfg_aclconfctx_t *aclconfctx) { controllistener_t *listener; controllistenerlist_t new_listeners; const cfg_obj_t *controlslist = NULL; const cfg_listelt_t *element, *element2; char socktext[ISC_SOCKADDR_FORMATSIZE]; ISC_LIST_INIT(new_listeners); /* * Get the list of named.conf 'controls' statements. */ (void)cfg_map_get(config, "controls", &controlslist); /* * Run through the new control channel list, noting sockets that * are already being listened on and moving them to the new list. * * Identifying duplicate addr/port combinations is left to either * the underlying config code, or to the bind attempt getting an * address-in-use error. */ if (controlslist != NULL) { for (element = cfg_list_first(controlslist); element != NULL; element = cfg_list_next(element)) { const cfg_obj_t *controls; const cfg_obj_t *inetcontrols = NULL; controls = cfg_listelt_value(element); (void)cfg_map_get(controls, "inet", &inetcontrols); if (inetcontrols == NULL) continue; for (element2 = cfg_list_first(inetcontrols); element2 != NULL; element2 = cfg_list_next(element2)) { const cfg_obj_t *control; const cfg_obj_t *obj; isc_sockaddr_t addr; /* * The parser handles BIND 8 configuration file * syntax, so it allows unix phrases as well * inet phrases with no keys{} clause. */ control = cfg_listelt_value(element2); obj = cfg_tuple_get(control, "address"); addr = *cfg_obj_assockaddr(obj); if (isc_sockaddr_getport(&addr) == 0) isc_sockaddr_setport(&addr, NS_CONTROL_PORT); isc_sockaddr_format(&addr, socktext, sizeof(socktext)); isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_CONTROL, ISC_LOG_DEBUG(9), "processing control channel %s", socktext); update_listener(cp, &listener, control, config, &addr, aclconfctx, socktext, isc_sockettype_tcp); if (listener != NULL) /* * Remove the listener from the old * list, so it won't be shut down. */ ISC_LIST_UNLINK(cp->listeners, listener, link); else /* * This is a new listener. */ add_listener(cp, &listener, control, config, &addr, aclconfctx, socktext, isc_sockettype_tcp); if (listener != NULL) ISC_LIST_APPEND(new_listeners, listener, link); } } for (element = cfg_list_first(controlslist); element != NULL; element = cfg_list_next(element)) { const cfg_obj_t *controls; const cfg_obj_t *unixcontrols = NULL; controls = cfg_listelt_value(element); (void)cfg_map_get(controls, "unix", &unixcontrols); if (unixcontrols == NULL) continue; for (element2 = cfg_list_first(unixcontrols); element2 != NULL; element2 = cfg_list_next(element2)) { const cfg_obj_t *control; const cfg_obj_t *path; isc_sockaddr_t addr; isc_result_t result; /* * The parser handles BIND 8 configuration file * syntax, so it allows unix phrases as well * inet phrases with no keys{} clause. */ control = cfg_listelt_value(element2); path = cfg_tuple_get(control, "path"); result = isc_sockaddr_frompath(&addr, cfg_obj_asstring(path)); if (result != ISC_R_SUCCESS) { isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_CONTROL, ISC_LOG_DEBUG(9), "control channel '%s': %s", cfg_obj_asstring(path), isc_result_totext(result)); continue; } isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_CONTROL, ISC_LOG_DEBUG(9), "processing control channel '%s'", cfg_obj_asstring(path)); update_listener(cp, &listener, control, config, &addr, aclconfctx, cfg_obj_asstring(path), isc_sockettype_unix); if (listener != NULL) /* * Remove the listener from the old * list, so it won't be shut down. */ ISC_LIST_UNLINK(cp->listeners, listener, link); else /* * This is a new listener. */ add_listener(cp, &listener, control, config, &addr, aclconfctx, cfg_obj_asstring(path), isc_sockettype_unix); if (listener != NULL) ISC_LIST_APPEND(new_listeners, listener, link); } } } else { int i; for (i = 0; i < 2; i++) { isc_sockaddr_t addr; if (i == 0) { struct in_addr localhost; if (isc_net_probeipv4() != ISC_R_SUCCESS) continue; localhost.s_addr = htonl(INADDR_LOOPBACK); isc_sockaddr_fromin(&addr, &localhost, 0); } else { if (isc_net_probeipv6() != ISC_R_SUCCESS) continue; isc_sockaddr_fromin6(&addr, &in6addr_loopback, 0); } isc_sockaddr_setport(&addr, NS_CONTROL_PORT); isc_sockaddr_format(&addr, socktext, sizeof(socktext)); update_listener(cp, &listener, NULL, NULL, &addr, NULL, socktext, isc_sockettype_tcp); if (listener != NULL) /* * Remove the listener from the old * list, so it won't be shut down. */ ISC_LIST_UNLINK(cp->listeners, listener, link); else /* * This is a new listener. */ add_listener(cp, &listener, NULL, NULL, &addr, NULL, socktext, isc_sockettype_tcp); if (listener != NULL) ISC_LIST_APPEND(new_listeners, listener, link); } } /* * ns_control_shutdown() will stop whatever is on the global * listeners list, which currently only has whatever sockaddrs * were in the previous configuration (if any) that do not * remain in the current configuration. */ controls_shutdown(cp); /* * Put all of the valid listeners on the listeners list. * Anything already on listeners in the process of shutting * down will be taken care of by listen_done(). */ ISC_LIST_APPENDLIST(cp->listeners, new_listeners, link); return (ISC_R_SUCCESS); }
void event_environment::add_listener(const char * event_id, lua_CFunction function) { lua_pushcfunction(m_state, function); add_listener(event_id); }
int check_options(int argc, char **argv) { int ret = 0, r; char *arg; yaz_log_init_level(yaz_log_mask_str(STAT_DEFAULT_LOG_LEVEL)); get_logbits(1); while ((ret = options("1a:iszSTl:v:u:c:w:t:k:d:A:p:DC:f:m:r:", argv, argc, &arg)) != -2) { switch (ret) { case 0: if (add_listener(arg, 0)) return 1; /* failed to create listener */ break; case '1': control_block.one_shot = 1; control_block.dynamic = 0; break; case 'z': control_block.default_proto = PROTO_Z3950; break; case 's': fprintf(stderr, "%s: SR protocol no longer supported\n", me); exit(1); break; case 'S': control_block.dynamic = 0; break; case 'T': #if YAZ_POSIX_THREADS control_block.dynamic = 0; control_block.threads = 1; #elif YAZ_GNU_THREADS control_block.dynamic = 0; control_block.threads = 1; #else fprintf(stderr, "%s: Threaded mode not available.\n", me); return 1; #endif break; case 'l': option_copy(control_block.logfile, arg); yaz_log_init_file(control_block.logfile); break; case 'm': if (!arg) { fprintf(stderr, "%s: Specify time format for log file.\n", me); return(1); } yaz_log_time_format(arg); break; case 'v': yaz_log_init_level(yaz_log_mask_str(arg)); get_logbits(1); break; case 'a': option_copy(control_block.apdufile, arg); break; case 'u': option_copy(control_block.setuid, arg); break; case 'c': option_copy(control_block.configname, arg); break; case 'C': option_copy(control_block.cert_fname, arg); break; case 'd': option_copy(control_block.daemon_name, arg); break; case 't': if (!arg || !(r = atoi(arg))) { fprintf(stderr, "%s: Specify positive timeout for -t.\n", me); return(1); } control_block.idle_timeout = r; break; case 'k': if (!arg || !(r = atoi(arg))) { fprintf(stderr, "%s: Specify positive size for -k.\n", me); return(1); } control_block.maxrecordsize = r * 1024; break; case 'i': control_block.inetd = 1; break; case 'w': if (chdir(arg)) { perror(arg); return 1; } break; case 'A': max_sessions = atoi(arg); break; case 'p': option_copy(control_block.pid_fname, arg); break; case 'f': #if YAZ_HAVE_XML2 option_copy(control_block.xml_config, arg); #else fprintf(stderr, "%s: Option -f unsupported since YAZ is compiled without Libxml2 support\n", me); exit(1); #endif break; case 'D': control_block.background = 1; break; case 'r': if (!arg || !(r = atoi(arg))) { fprintf(stderr, "%s: Specify positive size for -r.\n", me); return(1); } yaz_log_init_max_size(r * 1024); break; default: fprintf(stderr, "Usage: %s [ -a <pdufile> -v <loglevel>" " -l <logfile> -u <user> -c <config> -t <minutes>" " -k <kilobytes> -d <daemon> -p <pidfile> -C certfile" " -ziDST1 -m <time-format> -w <directory> <listener-addr>... ]\n", me); return 1; } } return 0; }
nexus::behavior_type nexus::make_behavior() { return { [=](const riac::node_info& ni) { if (ni.source_node == caf::invalid_node_id) { cerr << "node_info received with invalid source node" << endl; return; } cout << "received node_info " << endl; data_[ni.source_node].node = ni; auto& ls = current_sender(); probes_[ls] = ls.node(); monitor(ls); broadcast(); }, HANDLE_UPDATE(riac::ram_usage, ram), HANDLE_UPDATE(riac::work_load, load), [=](const riac::new_actor_published& msg) { CHECK_SOURCE(riac::actor_published, msg); auto addr = msg.published_actor; auto nid = msg.source_node; if (addr == invalid_actor_addr) { cerr << "received riac::actor_published " << "with invalid actor address" << endl; return; } if (data_[nid].known_actors.insert(addr).second) { monitor(addr); } data_[nid].published_actors.insert(std::make_pair(addr, msg.port)); broadcast(); }, [=](const riac::new_route& route) { CHECK_SOURCE(riac::new_route, route); if (route.is_direct && data_[route.source_node].direct_routes.insert(route.dest).second) { broadcast(); } }, [=](const riac::route_lost& route) { CHECK_SOURCE(riac::route_lost, route); if (data_[route.source_node].direct_routes.erase(route.dest) > 0) { cout << "new route" << endl; broadcast(); } }, [=](const riac::new_message& msg) { // TODO: reduce message size by avoiding the complete msg CHECK_SOURCE(riac::new_message, msg); cout << "new message" << endl; broadcast(); }, [=](const riac::add_listener& req) { //cout << "new listerner" << endl; add_listener(actor_cast<riac::listener_type>(req.listener)); }, [=](const riac::add_typed_listener& req) { add_listener(req.listener); }, [=](const down_msg& dm) { if (listeners_.erase(actor_cast<riac::listener_type>(dm.source)) > 0) { cout << format_down_msg("listener", dm) << endl; return; } auto probe_addr = probes_.find(dm.source); if (probe_addr != probes_.end()) { cout << format_down_msg("probe", dm) << endl; riac::node_disconnected nd{probe_addr->second}; send(this, nd); auto i = data_.find(probe_addr->second); if (i != data_.end() && i->second.known_actors.erase(probe_addr->first) > 0) { return; } } }, [=](const riac::node_disconnected& nd) { data_.erase(nd.source_node); broadcast(); } }; }
static result_t get_listeners(int32 mask, listener_t** header) { struct node_info *subnode = NULL; int32 subnode_num = 0; struct node_info *listener_subnode = NULL; struct node_info *listener_sub_node = NULL; int32 listener_subnode_num = 0; int32 i,j = 0; memdb_integer error_code = 0; int32 subscribe_mask = 0; int8 tmp_url[MAX_URL] = {0}; listener_dest_t listener = {}; int32 listener_count = 0; struct node_info *evt_type_nodes = NULL; result_t rc = RESULT_OK; /* get event root node */ subnode = libdb_list_node_by_type(DB_RMM, MC_REDFISH_EVENT, MC_REDFISH_EVENT, &subnode_num, NULL, LOCK_ID_NULL); if (subnode_num != 1) { rc = RESULT_NO_NODE; goto end; } /* get supported event type nodes */ subnode = libdb_list_subnode(DB_RMM, subnode[0].node_id, &subnode_num, NULL, LOCK_ID_NULL); if (subnode_num == 0) { rc = RESULT_NO_NODE; goto end; } evt_type_nodes = (struct node_info *)malloc(CMDBUFSIZ); if (evt_type_nodes == NULL) { rc = RESULT_MALLOC_ERR; goto end; } memcpy_s(evt_type_nodes, sizeof(struct node_info) * subnode_num, subnode, sizeof(struct node_info) * subnode_num); listener_sub_node = (struct node_info *)malloc(CMDBUFSIZ); if (listener_sub_node == NULL) { rc = RESULT_MALLOC_ERR; goto end; } for (i = 0; i < subnode_num; i++) { /* get listeners of each event type */ listener_subnode = libdb_list_subnode_by_type(DB_RMM, evt_type_nodes[i].node_id, MC_REDFISH_LISTENER, &listener_subnode_num, NULL, LOCK_ID_NULL); if (listener_subnode == NULL) goto end; bzero(listener_sub_node, CMDBUFSIZ); memcpy_s(listener_sub_node, sizeof(struct node_info) * listener_subnode_num, listener_subnode, sizeof(struct node_info) * listener_subnode_num); for (j = 0; j < listener_subnode_num; j++) { error_code = 0; /* get listener's mask */ error_code = libdb_attr_get_int(DB_RMM, listener_sub_node[j].node_id, RF_EVENT_LISTENER_INDEXES_STR, &subscribe_mask, LOCK_ID_NULL); if (error_code != 0) continue; if ((subscribe_mask & mask) != 0) { error_code = 0; error_code = libdb_attr_get_string(DB_RMM, listener_sub_node[j].node_id, RF_EVENT_LISTENER_DEST_STR, tmp_url, sizeof(tmp_url), LOCK_ID_NULL); if (error_code == 0) { if (libdb_attr_get_string(DB_RMM, listener_sub_node[j].node_id, RF_EVENT_LISTENER_CONTEXT_STR, listener.context, sizeof(listener.context), LOCK_ID_NULL) != 0) continue; if (libdb_attr_get_string(DB_RMM, listener_sub_node[j].node_id, RF_EVENT_LISTENER_PROTOCOL_STR, listener.protocol, sizeof(listener.protocol), LOCK_ID_NULL) != 0) continue; if (libdb_attr_get_string(DB_RMM, listener_sub_node[j].node_id, RF_EVENT_LISTENER_NAME_STR, listener.name, sizeof(listener.name), LOCK_ID_NULL) != 0) continue; if (libdb_attr_get_string(DB_RMM, listener_sub_node[j].node_id, RF_EVENT_LISTENER_DESC_STR, listener.description, sizeof(listener.description), LOCK_ID_NULL) != 0) continue; /* add matched listener into list */ add_listener(header, tmp_url, &listener, evt_type_nodes[i].type); } } } } end: libdb_free_node(listener_sub_node); libdb_free_node(evt_type_nodes); return rc; }
void server_work(engine_t * e) { create_acceptor(); add_listener(e, IP, PORT); }
static int statserv_sc_main(yaz_sc_t s, int argc, char **argv) { char sep; #ifdef WIN32 /* We need to initialize the thread list */ ThreadList_Initialize(); /* WIN32 */ #endif #ifdef WIN32 sep = '\\'; #else sep = '/'; #endif if ((me = strrchr(argv[0], sep))) me++; /* get the basename */ else me = argv[0]; programname = argv[0]; if (control_block.options_func(argc, argv)) return 1; xml_config_open(); xml_config_bend_start(); #ifdef WIN32 xml_config_add_listeners(); yaz_log(log_server, "Starting server %s", me); if (!pListener && *control_block.default_listen) add_listener(control_block.default_listen, 0); #else /* UNIX */ if (control_block.inetd) inetd_connection(control_block.default_proto); else { static int hand[2]; if (control_block.background) { /* create pipe so that parent waits until child has created PID (or failed) */ if (pipe(hand) < 0) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "pipe"); return 1; } switch (fork()) { case 0: break; case -1: return 1; default: close(hand[1]); while(1) { char dummy[1]; int res = read(hand[0], dummy, 1); if (res < 0 && yaz_errno() != EINTR) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "read fork handshake"); break; } else if (res >= 0) break; } close(hand[0]); _exit(0); } /* child */ close(hand[0]); if (setsid() < 0) return 1; close(0); close(1); close(2); open("/dev/null", O_RDWR); if (dup(0) == -1) return 1; if (dup(0) == -1) return 1; } xml_config_add_listeners(); if (!pListener && *control_block.default_listen) add_listener(control_block.default_listen, 0); if (!pListener) return 1; if (*control_block.pid_fname) { FILE *f = fopen(control_block.pid_fname, "w"); if (!f) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "Couldn't create %s", control_block.pid_fname); exit(0); } fprintf(f, "%ld", (long) getpid()); fclose(f); } if (control_block.background) close(hand[1]); yaz_log(log_server, "Starting server %s pid=%ld", programname, (long) getpid()); #if 0 sigset_t sigs_to_block; sigemptyset(&sigs_to_block); sigaddset(&sigs_to_block, SIGTERM); pthread_sigmask(SIG_BLOCK, &sigs_to_block, 0); /* missing... */ #endif if (control_block.dynamic) signal(SIGCHLD, catchchld); } signal(SIGPIPE, SIG_IGN); signal(SIGTERM, sigterm); if (*control_block.setuid) { struct passwd *pw; if (!(pw = getpwnam(control_block.setuid))) { yaz_log(YLOG_FATAL, "%s: Unknown user", control_block.setuid); return(1); } if (setuid(pw->pw_uid) < 0) { yaz_log(YLOG_FATAL|YLOG_ERRNO, "setuid"); exit(1); } } /* UNIX */ #endif if (pListener == NULL) return 1; if (s) yaz_sc_running(s); yaz_log(YLOG_DEBUG, "Entering event loop."); return iochan_event_loop(&pListener); }
console init_console(int x, int y, int w, int h) { console c; button console_btn, chat_btn, log_btn; window_load_textures(); console_load_textures(); add_texture("/usr/local/share/vektor/ui/ui_content.texture", &texture_cpane); add_texture("/usr/local/share/vektor/ui/ui_input_bar.texture", &texture_input_bar); // allocate and initialize a new console c = calloc(1, sizeof(*c)); c->x = x; c->y = y; c->w = w; c->h = h; c->active = 1; user = getenv("USER"); main_console = c; c->win = add_window((float)x,(float)y,w,h); hide_window(c->win); // add tab bar and buttons c->tabs = add_tabbar(10, -26, 502, 36); // add textboxes c->tb_out = textbox_new(25, -80, 57, 16, 500000); c->tb_in = textbox_new(25, -300, 59, 1, 1000); console_data = c->tb_out->data; chat_data = calloc(500000,1); set_input(c->tb_in->data, 1000); textbox_set_text(c->tb_in, "v$ "); // add textbox listeners add_listener(&console_return, c->tb_in, vektor_event_return); add_listener(&chat_recv, c->tb_out, vektor_event_net_recv); // add content pane //c->cpane = add_bitmap(10, -65, 502, 262, &texture_cpane); //c->in_bar = add_bitmap(20, -293, 482, 25, &texture_input_bar); // add buttons console_btn = add_button(x + 5, y + 5, 87, 26, &texture_btn_console); chat_btn = add_button(x + 10 + 87, y + 5, 87, 26, &texture_btn_chat); log_btn = add_button(x + 15 + 174, y + 5, 87, 26, &texture_btn_log); // set button actions console_btn->action = &set_console; chat_btn->action = &set_chat; log_btn->action = &set_log; // attach buttons to tab bar tabbar_add_tab(c->tabs, console_btn); tabbar_add_tab(c->tabs, chat_btn); tabbar_add_tab(c->tabs, log_btn); // attach objects to window window_addchild(c->win, c->tabs, c->tabs->draw, c->tabs->move, c->tabs->resize, c->tabs->remove); //window_addchild(c->win, c->cpane, c->cpane->draw, c->cpane->move, c->cpane->resize, c->cpane->remove); //window_addchild(c->win, c->in_bar, c->in_bar->draw, c->in_bar->move, c->in_bar->resize, c->in_bar->remove); window_addchild(c->win, c->tb_out, c->tb_out->scene_data.draw, c->tb_out->move, c->tb_out->resize, c->tb_out->scene_data.remove); window_addchild(c->win, c->tb_in, c->tb_in->scene_data.draw, c->tb_in->move, c->tb_in->resize, c->tb_in->scene_data.remove); //add_object_2d(c, NULL, &draw_console, NULL, &free_console); keybind_add(c, &toggle_console, NULL, vektor_key_f1); toggle_console(c); return c; }
isc_result_t ns_statschannels_configure(ns_server_t *server, const cfg_obj_t *config, cfg_aclconfctx_t *aclconfctx) { ns_statschannel_t *listener, *listener_next; ns_statschannellist_t new_listeners; const cfg_obj_t *statschannellist = NULL; const cfg_listelt_t *element, *element2; char socktext[ISC_SOCKADDR_FORMATSIZE]; RUNTIME_CHECK(isc_once_do(&once, init_desc) == ISC_R_SUCCESS); ISC_LIST_INIT(new_listeners); /* * Get the list of named.conf 'statistics-channels' statements. */ (void)cfg_map_get(config, "statistics-channels", &statschannellist); /* * Run through the new address/port list, noting sockets that are * already being listened on and moving them to the new list. * * Identifying duplicate addr/port combinations is left to either * the underlying config code, or to the bind attempt getting an * address-in-use error. */ if (statschannellist != NULL) { #ifndef HAVE_LIBXML2 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_WARNING, "statistics-channels specified but not effective " "due to missing XML library"); #endif for (element = cfg_list_first(statschannellist); element != NULL; element = cfg_list_next(element)) { const cfg_obj_t *statschannel; const cfg_obj_t *listenercfg = NULL; statschannel = cfg_listelt_value(element); (void)cfg_map_get(statschannel, "inet", &listenercfg); if (listenercfg == NULL) continue; for (element2 = cfg_list_first(listenercfg); element2 != NULL; element2 = cfg_list_next(element2)) { const cfg_obj_t *listen_params; const cfg_obj_t *obj; isc_sockaddr_t addr; listen_params = cfg_listelt_value(element2); obj = cfg_tuple_get(listen_params, "address"); addr = *cfg_obj_assockaddr(obj); if (isc_sockaddr_getport(&addr) == 0) isc_sockaddr_setport(&addr, NS_STATSCHANNEL_HTTPPORT); isc_sockaddr_format(&addr, socktext, sizeof(socktext)); isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_DEBUG(9), "processing statistics " "channel %s", socktext); update_listener(server, &listener, listen_params, config, &addr, aclconfctx, socktext); if (listener != NULL) { /* * Remove the listener from the old * list, so it won't be shut down. */ ISC_LIST_UNLINK(server->statschannels, listener, link); } else { /* * This is a new listener. */ isc_result_t r; r = add_listener(server, &listener, listen_params, config, &addr, aclconfctx, socktext); if (r != ISC_R_SUCCESS) { cfg_obj_log(listen_params, ns_g_lctx, ISC_LOG_WARNING, "couldn't allocate " "statistics channel" " %s: %s", socktext, isc_result_totext(r)); } } if (listener != NULL) ISC_LIST_APPEND(new_listeners, listener, link); } } } for (listener = ISC_LIST_HEAD(server->statschannels); listener != NULL; listener = listener_next) { listener_next = ISC_LIST_NEXT(listener, link); ISC_LIST_UNLINK(server->statschannels, listener, link); shutdown_listener(listener); } ISC_LIST_APPENDLIST(server->statschannels, new_listeners, link); return (ISC_R_SUCCESS); }