int monitor(t_init *data) { t_player_lst *tmp; int ret; struct timeval tv; int stay; init_monitor(data, &tv, &ret, &tmp); if ((select(max(data) + 1, &(data->read), &(data->write), NULL, &tv)) == -1) return (merror("select")); if (FD_ISSET(data->socket, &(data->read))) ret = do_server(data); else { stay = 1; while (stay && tmp != NULL) { if (ret == 0 && FD_ISSET(tmp->player.fd, &(data->read))) stay = do_client(tmp->player.fd, &tmp, data); else ret = 0; tmp = tmp->next; } } check_timer(data); test_end(data); return (0); }
int main() { monitor_t m; init_monitor(&m); pthread_create(&m.id, NULL, monitor_thread, &m); send_file(&m); pthread_join(m.id, NULL); return 0; }
int main(int argc, char **argv){ int init_status; if((init_status = init_monitor())){ fprintf(stderr, "Xevent-monitor failed to init, aborting...\n"); return init_status; } start_monitor(); endLogger(); return EXIT_SUCCESS; }
static rtems_task gui_task(rtems_task_argument argument) { init_fb_mtk(sysconfig_get_autostart_mode() == SC_AUTOSTART_FILE); sysconfig_set_mtk_language(); sysconfig_set_mtk_wallpaper(); init_input(); input_add_callback(mtk_input); init_shortcuts(); init_osc(); init_messagebox(); init_performance(); init_renderer(); init_cp(); init_keyboard(); init_ir(); init_audio(); init_midi(); init_oscsettings(); init_dmxspy(); init_dmxdesk(); init_dmx(); init_videoin(); init_rsswall(); init_patcheditor(); init_monitor(); init_firstpatch(); init_filemanager(); #ifdef WITH_PDF init_pdfreader(); #endif init_sysettings(); init_about(); init_flash(); init_shutdown(); cp_autostart(); if(sysconfig_is_rescue()) messagebox("Rescue mode", "You have booted in rescue mode.\n" "Your system will function as usual, using back-up software.\n" "From there, you can update the main software or perform\nother actions to fix the problem.\n"); /* FIXME: work around "black screen" bug in MTK */ mtk_cmd(1, "screen.refresh()"); input_eventloop(); }
int main() { int clk = 0; void *state = initAndResetChip(); /* set up memory for user program */ init_monitor(); /* emulate the 6502! */ for (;;) { step(state); clk = !clk; if (clk) handle_monitor(state); // chipStatus(state); //if (!(cycle % 1000)) printf("%d\n", cycle); }; }
int command_read_unprotect(int fd) { int res; res = send_command(fd, CMD_RU, NULL, 0, NULL, 0, 1); if (res < 0) return -EIO; /* Wait for the ACK */ if (wait_for_ack(fd) < 0) { fprintf(stderr, "Failed to get read-protect ACK\n"); return -EINVAL; } printf("Flash read unprotected.\n"); /* This commands triggers a reset */ if (init_monitor(fd) < 0) { fprintf(stderr, "Cannot recover after RP reset\n"); return -EIO; } return 0; }
int main(int argc,char* argv[]) { char* response; char* token; gtk_init(&argc,&argv); process_args(argc,argv); while(receiver==-1) { GtkDialog* dialog=(GtkDialog*)configure(TRUE); gtk_dialog_run(dialog); frequency=configure_get_frequency(); configure_destroy(); } /* sprintf(property_path,".ghpsdr.rx%d.properties",receiver); properties_load(property_path); token=property_get("window.x"); if(token) window_x=atoi(token); token=property_get("window.y"); if(token) window_y=atoi(token); token=property_get("fps"); if(token) fps=atoi(token); token=property_get("frequency"); if(token) frequency=atol(token); token=property_get("waterfall.high"); if(token) waterfall_high=atof(token); token=property_get("waterfall.low"); if(token) waterfall_low=atof(token); */ init_command(server); init_monitor(); sprintf(command,"attach %d",receiver); response=send_command(command); token=strtok(response," "); if(token==NULL) { fprintf(stderr,"null response to attach command!\n"); exit(1); } if(strcmp(token,"OK")==0) { token=strtok(NULL," "); if(token==NULL) { fprintf(stderr,"expected sample rate in response to attach command!\n"); exit(1); } else { sample_rate=atoi(token); } } else { fprintf(stderr,"Error: %s!\n",response); exit(1); } sprintf(command,"frequency %ld",frequency); send_command(command); build_ui(); init_iq_thread(receiver); start_iq_thread((void*)process_iq_samples); sprintf(command,"start iq %d",get_iq_port()); send_command(command); timer_id=gtk_timeout_add(1000/fps,process_samples,NULL); gtk_main(); close_command(); return 0; }
int main(int argc, char **argv) { int ser; struct stm32_def *chip; int ret = 1; int flags; /* Parse command line options */ flags = parse_parameters(argc, argv); if (i2c_adapter == INVALID_I2C_ADAPTER) { /* Open the serial port tty */ ser = open_serial(serial_port); } else { ser = open_i2c(i2c_adapter); } if (ser < 0) return 1; /* Trigger embedded monitor detection */ if (init_monitor(ser) < 0) goto terminate; chip = command_get_id(ser); if (!chip) goto terminate; command_get_commands(ser, chip); if (flags & FLAG_READ_UNPROTECT) command_read_unprotect(ser); if (flags & FLAG_UNPROTECT) command_write_unprotect(ser); if (flags & FLAG_ERASE || output_filename) { if (!strcmp("STM32L15", chip->name)) { /* Mass erase is not supported on STM32L15xx */ /* command_ext_erase(ser, ERASE_ALL, 0); */ int i, page_count = chip->flash_size / chip->page_size; for (i = 0; i < page_count; i += 128) { int count = MIN(128, page_count - i); ret = erase(ser, count, i); if (ret) goto terminate; } } else { ret = erase(ser, 0xFFFF, 0); if (ret) goto terminate; } } if (input_filename) { ret = read_flash(ser, chip, input_filename, 0, chip->flash_size); if (ret) goto terminate; } if (output_filename) { ret = write_flash(ser, chip, output_filename, 0); if (ret) goto terminate; } /* Run the program from flash */ if (flags & FLAG_GO) command_go(ser, chip->flash_start); /* Normal exit */ ret = 0; terminate: /* Close serial port */ close(ser); return ret; }
/** * Initialize this driver, by calling init monitor. */ int InitTerminalDriver(){ init_monitor(); return 0; }
int main(int argc, char *argv[]) { /* Check to see if the user is running us as root, which is a nono */ if(geteuid() == 0) { fprintf(stderr, "Don't run ircd as root!!!\n"); return -1; } /* * save server boot time right away, so getrusage works correctly */ set_time(); /* * Setup corefile size immediately after boot -kre */ setup_corefile(); /* * set initialVMTop before we allocate any memory */ initialVMTop = get_vm_top(); ServerRunning = 0; /* It ain't random, but it ought to be a little harder to guess */ srand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20))); memset(&me, 0, sizeof(me)); memset(&meLocalUser, 0, sizeof(meLocalUser)); me.localClient = &meLocalUser; /* Make sure all lists are zeroed */ memset(&unknown_list, 0, sizeof(unknown_list)); memset(&lclient_list, 0, sizeof(lclient_list)); memset(&serv_list, 0, sizeof(serv_list)); memset(&global_serv_list, 0, sizeof(global_serv_list)); memset(&oper_list, 0, sizeof(oper_list)); dlinkAddTail(&me, &me.node, &global_client_list); memset((void *) &Count, 0, sizeof(Count)); memset((void *) &ServerInfo, 0, sizeof(ServerInfo)); memset((void *) &AdminInfo, 0, sizeof(AdminInfo)); /* Initialise the channel capability usage counts... */ init_chcap_usage_counts(); ConfigFileEntry.dpath = DPATH; ConfigFileEntry.configfile = CPATH; /* Server configuration file */ ConfigFileEntry.klinefile = KPATH; /* Server kline file */ ConfigFileEntry.dlinefile = DLPATH; /* dline file */ ConfigFileEntry.xlinefile = XPATH; ConfigFileEntry.resvfile = RESVPATH; ConfigFileEntry.connect_timeout = 30; /* Default to 30 */ myargv = argv; umask(077); /* better safe than sorry --SRB */ parseargs(&argc, &argv, myopts); if(printVersion) { printf("ircd: version %s\n", ircd_version); exit(EXIT_SUCCESS); } if(chdir(ConfigFileEntry.dpath)) { fprintf(stderr, "Unable to chdir to %s: %s\n", ConfigFileEntry.dpath, strerror(errno)); exit(EXIT_FAILURE); } setup_signals(); #ifdef __CYGWIN__ server_state_foreground = 1; #endif if (testing_conf) server_state_foreground = 1; /* We need this to initialise the fd array before anything else */ fdlist_init(); if(!server_state_foreground) { comm_close_all(); } /* Check if there is pidfile and daemon already running */ if(!testing_conf) { check_pidfile(pidFileName); if(!server_state_foreground) make_daemon(); else print_startup(getpid()); } init_netio(); /* This needs to be setup early ! -- adrian */ /* Init the event subsystem */ eventInit(); init_sys(); init_main_logfile(); initBlockHeap(); init_dlink_nodes(); init_patricia(); newconf_init(); init_s_conf(); init_s_newconf(); linebuf_init(); /* set up some linebuf stuff to control paging */ init_hash(); clear_scache_hash_table(); /* server cache name table */ init_host_hash(); clear_hash_parse(); init_client(); initUser(); init_channels(); initclass(); initwhowas(); init_stats(); init_hook(); init_reject(); init_cache(); init_monitor(); load_all_modules(1); #ifndef STATIC_MODULES load_core_modules(1); #endif init_auth(); /* Initialise the auth code */ init_resolver(); /* Needs to be setup before the io loop */ if (testing_conf) fprintf(stderr, "\nBeginning config test\n"); read_conf_files(YES); /* cold start init conf files */ rehash_bans(0); #ifndef STATIC_MODULES mod_add_path(MODULE_DIR); mod_add_path(MODULE_DIR "/autoload"); #endif initialize_server_capabs(); /* Set up default_server_capabs */ initialize_global_set_options(); if(ServerInfo.name == NULL) { fprintf(stderr, "ERROR: No server name specified in serverinfo block.\n"); ilog(L_MAIN, "No server name specified in serverinfo block."); exit(EXIT_FAILURE); } strlcpy(me.name, ServerInfo.name, sizeof(me.name)); if(ServerInfo.sid[0] == '\0') { fprintf(stderr, "ERROR: No server sid specified in serverinfo block.\n"); ilog(L_MAIN, "No server sid specified in serverinfo block."); exit(EXIT_FAILURE); } strcpy(me.id, ServerInfo.sid); init_uid(); /* serverinfo{} description must exist. If not, error out. */ if(ServerInfo.description == NULL) { fprintf(stderr, "ERROR: No server description specified in serverinfo block.\n"); ilog(L_MAIN, "ERROR: No server description specified in serverinfo block."); exit(EXIT_FAILURE); } strlcpy(me.info, ServerInfo.description, sizeof(me.info)); if (testing_conf) { fprintf(stderr, "\nConfig testing complete.\n"); fflush(stderr); exit(EXIT_SUCCESS); } me.from = &me; me.servptr = &me; SetMe(&me); make_server(&me); me.serv->up = me.name; startup_time = CurrentTime; add_to_client_hash(me.name, &me); add_to_id_hash(me.id, &me); dlinkAddAlloc(&me, &global_serv_list); check_class(); write_pidfile(pidFileName); load_help(); open_logfiles(); ilog(L_MAIN, "Server Ready"); eventAddIsh("cleanup_glines", cleanup_glines, NULL, CLEANUP_GLINES_TIME); /* We want try_connections to be called as soon as possible now! -- adrian */ /* No, 'cause after a restart it would cause all sorts of nick collides */ /* um. by waiting even longer, that just means we have even *more* * nick collisions. what a stupid idea. set an event for the IO loop --fl */ eventAddIsh("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME); eventAddOnce("try_connections_startup", try_connections, NULL, 0); eventAddIsh("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME); /* Setup the timeout check. I'll shift it later :) -- adrian */ eventAddIsh("comm_checktimeouts", comm_checktimeouts, NULL, 1); if(ConfigServerHide.links_delay > 0) eventAddIsh("cache_links", cache_links, NULL, ConfigServerHide.links_delay); else ConfigServerHide.links_disabled = 1; if(splitmode) eventAdd("check_splitmode", check_splitmode, NULL, 2); ServerRunning = 1; io_loop(); return 0; }