void QxtScreenPrivate::init() { if (screen < 0) screen = qApp->desktop()->primaryScreen(); if (availResos.isEmpty() || !currReso.isValid() || availRates.isEmpty() || currRate < 0 || availDepths.isEmpty() || currDepth < 0) init_sys(); }
/* * Initialize variables. */ void tninit(void) { init_terminal(); init_network(); init_telnet(); init_sys(); }
int main(void){ FILE * fid, * finit; fid = fopen("data.dat", "w"); finit = fopen("init_data.dat", "w"); int N = 200; Vars U[N]; Flux F_HLL[N-1]; double T, t, dt, dx; T = .14; t = 0; dx = 1./(double)N; init_sys(N, U); Write_Cons(N, U, dx, finit); while(t<T){ dt = advance_system(N, U, F, F_HLL, dx); t += dt; } Write_Cons(N, U, dx, fid); }
/* * Initialize variables. */ void tninit() { init_terminal(); init_network(); init_telnet(); init_sys(); #if defined(TN3270) init_3270(); #endif }
int main(void) { unsigned char data = 0x00; unsigned short addr = 0x00; init_sys(); init_uart(); init_am27c(); wait_for_sequence(seq, seq_len); for (;;) { addr = get_short(); data = am27c_get_data(addr); UARTCharPut(UART0_BASE, data); } }
/* * Initialize variables. */ void tninit(void) { init_terminal(); init_network(); init_telnet(); init_sys(); #ifdef TN3270 init_3270(); #endif }
void main(int argc, char **argv) { Errcode err; int i; if(argc > 1) rex_name = argv[1]; if(init_sys() < 0) exit(-1); pj_set_rast(vl.screen,4); test_uscale(); /* do_testpull(); */ if(!yes_no_line("continue ??")) goto exitit; do_qnumber(); if(!yes_no_line("continue ??")) goto exitit; { char *choices[] = { "choice 1", "choice 2", "a very very big choice", }; err = qchoice(NULL, "header", choices, sizeof(choices)/sizeof(char *)); boxf("choice %d", err); } goto exitit; error: boxf("error %d", err); exitit: uninit_sys(); exit(-1); }
int main(int ac, char **av) { t_sys sys; set_opt(&sys, ac, av); init_sys(&sys, av[2]); if (test_solv(&sys)) { print_list(&sys, sys.open); printf("This Puzzle is not solvable\n"); exit(0); } if (sys.size > 3) run_ida_star(&sys); else run_a_star(&sys); printf("Time complexity: %d\n", sys.time_complexity); printf("Size complexity: %d\n", sys.size_complexity); return (0); }
int main(int ac, char **av, char **env) { t_system sys; (void)av; (void)ac; if (signal(SIGINT, &handle_sig) == SIG_ERR) return (EXIT_FAILURE); if (init_sys(&sys, &sys.history, env) == -1) return (EXIT_FAILURE); get_sys(&sys); process_conf_file(&sys); aff_prompt(&sys); get_cmd_line(&sys); unset_termcaps(&sys); free_all(&sys); if (sys.exit.exit == true) return (sys.exit.value); return (EXIT_SUCCESS); }
int main() { int e = 0; int i; TETO t[2]; int dll[2]; int wt=10; int cwt=0; int dp=0; init_sys(); initTETO(&t[0], NINGEN, 1, -4, 15,7 ); initTETO(&t[1], KIKAI, 27, -4, -4,7 ); // initTETO(&t[0], KIKAI, 1, -4, 15,7 ); initTETO(&t[1], KIKAI, 27, -4, -4,7 ); // initTETO(&t[0], NINGEN, 1, -4, 15,7 ); initTETO(&t[1], MUJINKUN,27, -4, -4,7 ); clr_scr(); prtP(&t[0].P); prtP(&t[1].P); prtNP(&t[0].NP, &t[0].P); prtNP(&t[1].NP,&t[1].P); prtMINO(&t[0].next_mino, &t[0].P); prtMINO(&t[1].next_mino, &t[0].P); do{ dll[0] = calcTETO(&t[0],PAD1,dp); dll[1] = calcTETO(&t[1],PAD2,dp); if( dll[0] >= 1 ){ t[1].ojl += dll[0]-1; } if( dll[1] >= 1 ){ t[0].ojl += dll[1]-1; } vsync(1); syncPAD(); dp=0;if(cwt++>=wt){dp=1;cwt=0;} } while((PAD1&PAD_START)==0); close_sys(); return(0); }
int UHD_SAFE_MAIN(int argc, char *argv[]){ size_t rx_cnt; rx_cnt = 0; uhd::set_thread_priority_safe(); uhd::time_spec_t refer; po::options_description desc("Allowed options"); desc.add_options() ("help", "help message") ("r0", po::value<string>(&usrp_ip)->default_value("addr=192.168.10.10" ), "usrp's IP") ("in", po::value<string>(&in_name)->default_value("wn_trace/src_data_1.bin"), "binary samples file") ("out", po::value<string>(&out_name)->default_value("wn_trace/recv_signal.bin"), "signal file") ("i", po::value<double>(&inter)->default_value(SAMPLE_P), "interval of two sampling") ("f", po::value<double>(&freq)->default_value(2.49), "RF center frequency in Hz") ("g", po::value<double>(&gain)->default_value(30.0), "gain for the RF chain") ("s", po::value<double>(&r_sec)->default_value(1), "recording seconds") ("c", po::value<size_t>(&r_cnt)->default_value(90), "round count"); po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); if (vm.count("help")){ cout << boost::format("UHD TX samples from file %s") % desc << endl; return ~0; } // Initial systems init_sys(); size_t cleaning, done_cleaning; done_cleaning = 0; cleaning = 0; while(cleaning < ANT_CNT) { if (!done_cleaning) { usrp->get_device()->recv(pkt, SYM_LEN, rx_md, C_FLOAT32, R_ONE_PKT); if(rx_md.time_spec.get_real_secs() >= time_start_recv.get_real_secs()) { done_cleaning = 1; cleaning++; } } // cout << cleaning << "-" << done_cleaning << " Clean ant" << i << " buff:" << rx_md.time_spec.get_real_secs() << endl; } // TODO: // Receive Signals // HINT: You have to receive signals here // How many signals you have to recv? Ans: s_cnt // using rx_cnt+=usrp->get_device()->recv(...) // using pkt to record the received samples // remove content of within while loop cout << endl << "# of recv samples: " << s_cnt << endl; gr_complex *current = pkt; while(rx_cnt < s_cnt) { size_t read_cnt = 80; //At last recv(), modify read_cnt to receive the remaining samples if (s_cnt - rx_cnt < read_cnt){ read_cnt = s_cnt - rx_cnt; } // what is the number of remaining samples? read_cnt = ...; rx_cnt += usrp->get_device()->recv(current, read_cnt, rx_md, C_FLOAT32, R_ONE_PKT); current = current + read_cnt; //rx_cnt is the total number you have received //cout << rx_cnt << " hello " << endl; cout<<abs(*pkt)<<endl<<endl; if (rx_cnt < 100) cout << "Ant" << " recving at " << rx_md.time_spec.get_real_secs() << endl; } stream_cmd.stream_mode = uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS; usrp->issue_stream_cmd(stream_cmd); boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for some setup time // End systems dump_signals(); end_sys(); cout << "Terminate systems ... " << endl << endl; return 0; }
/*### Mainloop ###*/ int main(void) { WDT_TRIGGERED(); //Watchdogreset? init_sys(); init_pwm(); init_timer(); dist_init(); uart_init(UART_BAUD_SELECT(UART_MCU_BAUD_RATE,F_CPU)); //Bluetooth comm_init(); init_adc(); mot.off = 0; //The higher the task_i of the task is, the higher is the priority MAIN_LED_OFF(); tasks[TASK_TIMER_ID].state = -1; tasks[TASK_TIMER_ID].period = TASK_PERIOD_TIMER; tasks[TASK_TIMER_ID].elapsedTime = 0; tasks[TASK_TIMER_ID].running = 0; tasks[TASK_TIMER_ID].task_fct = &task_timer; tasks[TASK_SPEEDREG_ID].state = -1; tasks[TASK_SPEEDREG_ID].period = TASK_PERIOD_SPEEDREG; tasks[TASK_SPEEDREG_ID].elapsedTime = 0; tasks[TASK_SPEEDREG_ID].running = 0; tasks[TASK_SPEEDREG_ID].task_fct = &task_speedreg; tasks[TASK_ANASENS_ID].state = -1; tasks[TASK_ANASENS_ID].period = TASK_PERIOD_ANASENS; tasks[TASK_ANASENS_ID].elapsedTime = 0; tasks[TASK_ANASENS_ID].running = 0; tasks[TASK_ANASENS_ID].task_fct = &task_anasens; if(get_incrOk()) debug = 1; else debug = 0; sei(); //Enable global interrupts. The Operating System and every task in it is running now and the cam already can regulate its initial aparture bt_putStr_P(PSTR("\r\n\n\n\n\n\n\n\n")); bt_putStr_P(PSTR("–––––––––––––––––––––––\r\n")); bt_putStr_P(PSTR("| RIOS Scheduler v1.0 |\r\n")); bt_putStr_P(PSTR("–––––––––––––––––––––––\r\n")); bt_putStr_P(PSTR("rcj2015 v2.0\r\n")); bt_putStr_P(PSTR("Subcontroller ATmega2560\r\n")); bt_putStr_P(PSTR("Baud rate: "));bt_putLong(UART_COMM_BAUD_RATE); bt_putStr_P(PSTR(" Baud.\r\n")); bt_putStr_P(PSTR("\r\n")); bt_putLong(timer); bt_putStr_P(PSTR(": System initialized, ")); bt_putLong(TASKS_NUM); bt_putStr_P(PSTR(" running tasks.\n\n")); if(check_res) { motor_activate(0); //Shut down motor driver if(debug > 0){bt_putStr_P(PSTR("\r\n")); bt_putLong(timer); bt_putStr(PSTR(": WARNING: RECOVERED AFTER AN UNEXPECTED SHUTDOWN!!!\n\n"));} _delay_ms(5000); } wdt_enable(WDTO_1S); //activate watchdog timer_get_tast = 120; while(1) { wdt_reset(); //////////////////////////////////////////////////////////////////////////// comm_handler(); //Handle and respond to comm requests. comm_reg_gateway(); //////////////////////////////////////////////////////////////////////////// if((timer_get_tast == 0) && (setup == 0)) { timer_get_tast = -1; mot.off = 0; } if(get_t1()) //Always reset... { mot.off = 1; timer_get_tast = 120; } ////////////////////LED etc...////////////////////////////////////// if(timer_mainloop == 0) { if(check_res || fatal_err) //Flashing of the Info LED when there is an error led_fault = 1; else if(timer_nocomm == 0) led_fault = 85; //Blink green if no communication/waiting for command else if(mot.off) led_fault = 30; else led_fault = 0; if(fatal_err) led_top = LED_TOP_FAT_ERR; else led_top = LED_TOP_NORMAL; if(check_res) { if(!(debug_err_sendOneTime & (1<<0))) { if(debug > 1){bt_putStr_P(PSTR("\n\r")); bt_putLong(timer); bt_putStr_P(PSTR(": ERROR: RESET"));} debug_err_sendOneTime |= (1<<0); } } else debug_err_sendOneTime &= ~(1<<0); //Batterie/Akku if(batt_raw > 0) { batt_mV = (batt_raw*15)-300; if(batt_mV < batt_mV_old) { batt_mV_old = batt_mV; batt_percent = (0.037*batt_mV) - 363; } if(batt_percent < 20) //Batterie led_heartbeatColor = batt_percent; } //////////////////////////////////////////////////////////////////////////// //LED heartbeat if(rgb_led_mode == 0) led_rgb(led_heartbeatColor, led_fault, led_top); else led_hsvToRgb(rgb_led_hue, rgb_led_sat, rgb_led_val); timer_mainloop = TIMER_MAINLOOP; } } return 0; }
int main(int argc, char *argv[]) { uid_t uid, euid; int portarg = 0, fd; #ifdef SAVE_MAXCLIENT_STATS FILE *mcsfp; #endif memset(&me, 0, sizeof(aClient)); if ((timeofday = time(NULL)) == -1) { (void) fprintf(stderr, "ERROR: Clock Failure (%d)\n", errno); exit(errno); } build_version(); Count.server = 1; /* us */ Count.oper = 0; Count.chan = 0; Count.local = 0; Count.total = 0; Count.invisi = 0; Count.unknown = 0; Count.max_loc = 0; Count.max_tot = 0; Count.today = 0; Count.weekly = 0; Count.monthly = 0; Count.yearly = 0; Count.start = NOW; Count.day = NOW; Count.week = NOW; Count.month = NOW; Count.year = NOW; #ifdef SAVE_MAXCLIENT_STATS mcsfp=fopen(DPATH "/.maxclients", "r"); if(mcsfp!=NULL) { fscanf(mcsfp, "%d %d %li %li %li %ld %ld %ld %ld", &Count.max_loc, &Count.max_tot, &Count.weekly, &Count.monthly, &Count.yearly, &Count.start, &Count.week, &Count.month, &Count.year); fclose(mcsfp); } #endif /* * this code by [email protected] * it is intended to keep the ircd from being swapped out. BSD * swapping criteria do not match the requirements of ircd */ #ifdef INITIAL_DBUFS dbuf_init(); /* set up some dbuf stuff to control paging */ #endif sbrk0 = (char *) sbrk((size_t) 0); uid = getuid(); euid = geteuid(); #ifdef PROFIL (void) monstartup(0, etext); (void) moncontrol(1); (void) signal(SIGUSR1, s_monitor); #endif myargv = argv; (void) umask(077); /* better safe than sorry --SRB */ memset((char *) &me, '\0', sizeof(me)); setup_signals(); /* * * All command line parameters have the syntax "-fstring" or "-f * string" (e.g. the space is optional). String may be empty. Flag * characters cannot be concatenated (like "-fxyz"), it would * conflict with the form "-fstring". */ while (--argc > 0 && (*++argv)[0] == '-') { char *p = argv[0] + 1; int flag = *p++; if (flag == '\0' || *p == '\0') { if (argc > 1 && argv[1][0] != '-') { p = *++argv; argc -= 1; } else p = ""; } switch (flag) { case 'a': bootopt |= BOOT_AUTODIE; break; case 'c': bootopt |= BOOT_CONSOLE; break; case 'q': bootopt |= BOOT_QUICK; break; case 'd': (void) setuid((uid_t) uid); dpath = p; break; case 'o': /* Per user local daemon... */ (void) setuid((uid_t) uid); bootopt |= BOOT_OPER; break; #ifdef CMDLINE_CONFIG case 'f': (void) setuid((uid_t) uid); configfile = p; break; # ifdef KPATH case 'k': (void) setuid((uid_t) uid); klinefile = p; break; # endif #endif case 'h': strncpyzt(me.name, p, sizeof(me.name)); break; case 'i': bootopt |= BOOT_INETD | BOOT_AUTODIE; break; case 'p': if ((portarg = atoi(p)) > 0) portnum = portarg; break; case 's': bootopt |= BOOT_STDERR; break; case 't': (void) setuid((uid_t) uid); bootopt |= BOOT_TTY; break; case 'v': (void) printf("ircd %s\n", version); exit(0); case 'x': #ifdef DEBUGMODE (void) setuid((uid_t) uid); debuglevel = atoi(p); debugmode = *p ? p : "0"; bootopt |= BOOT_DEBUG; break; #else (void) fprintf(stderr, "%s: DEBUGMODE must be defined for -x y\n", myargv[0]); exit(0); #endif default: bad_command(); break; } } if (chdir(dpath)) { perror("chdir"); exit(-1); } if ((uid != euid) && !euid) { (void) fprintf(stderr, "ERROR: do not run ircd setuid root. Make it setuid a normal user.\n"); exit(-1); } if (argc > 0) return bad_command(); /* This should exit out */ initialize_ssl(); motd = (aMotd *) NULL; helpfile = (aMotd *) NULL; motd_tm = NULL; #ifdef SHORT_MOTD shortmotd = NULL; #endif read_motd(MOTD); read_help(HELPFILE); #ifdef SHORT_MOTD read_shortmotd(SHORTMOTD); #endif clear_client_hash_table(); clear_channel_hash_table(); clear_scache_hash_table(); /* server cache name table */ clear_ip_hash_table(); /* client host ip hash table */ initlists(); initclass(); initwhowas(); initstats(); init_tree_parse(msgtab); init_send(); NOW = time(NULL); open_debugfile(); NOW = time(NULL); init_fdlist(&serv_fdlist); init_fdlist(&oper_fdlist); init_fdlist(&listen_fdlist); #ifndef NO_PRIORITY init_fdlist(&busycli_fdlist); #endif init_fdlist(&default_fdlist); { int i; for (i = MAXCONNECTIONS + 1; i > 0; i--) { default_fdlist.entry[i] = i - 1; } } if ((timeofday = time(NULL)) == -1) { #ifdef USE_SYSLOG syslog(LOG_WARNING, "Clock Failure (%d), TS can be corrupted", errno); #endif sendto_ops("Clock Failure (%d), TS can be corrupted", errno); } #ifdef WINGATE_NOTICE strcpy(ProxyMonURL, "http://"); strncpyzt((ProxyMonURL + 7), DEFAULT_PROXY_INFO_URL, (TOPICLEN + 1) - 7); strncpyzt(ProxyMonHost, MONITOR_HOST, (HOSTLEN + 1)); #endif if (portnum < 0) portnum = PORTNUM; me.port = portnum; (void) init_sys(); me.flags = FLAGS_LISTEN; #ifndef _WIN32 if (bootopt & BOOT_INETD) { me.fd = 0; local[0] = &me; me.flags = FLAGS_LISTEN; } else #endif me.fd = -1; #ifdef USE_SYSLOG # define SYSLOG_ME "ircd" openlog(SYSLOG_ME, LOG_PID | LOG_NDELAY, LOG_FACILITY); #endif if ((fd = openconf(configfile)) == -1) { Debug((DEBUG_FATAL, "Failed in reading configuration file %s", configfile)); (void) printf("Couldn't open configuration file %s\n", configfile); exit(-1); } (void) initconf(bootopt, fd); /* comstuds SEPARATE_QUOTE_KLINES_BY_DATE code */ #ifdef SEPARATE_QUOTE_KLINES_BY_DATE { struct tm *tmptr; char timebuffer[20], filename[200]; tmptr = localtime(&NOW); (void) strftime(timebuffer, 20, "%y%m%d", tmptr); ircsprintf(filename, "%s.%s", klinefile, timebuffer); if ((fd = openconf(filename)) == -1) { Debug((DEBUG_ERROR, "Failed reading kline file %s", filename)); (void) printf("Couldn't open kline file %s\n", filename); } else (void) initconf(0, fd); } #else # ifdef KPATH if ((fd = openconf(klinefile)) == -1) { Debug((DEBUG_ERROR, "Failed reading kline file %s", klinefile)); (void) printf("Couldn't open kline file %s\n", klinefile); } else (void) initconf(0, fd); # endif #endif if (!(bootopt & BOOT_INETD)) { static char star[] = "*"; aConfItem *aconf; u_long vaddr; if ((aconf = find_me()) && portarg <= 0 && aconf->port > 0) portnum = aconf->port; Debug((DEBUG_ERROR, "Port = %d", portnum)); if ((aconf->passwd[0] != '\0') && (aconf->passwd[0] != '*')) vaddr = inet_addr(aconf->passwd); else vaddr = (u_long) NULL; if (inetport(&me, star, portnum, vaddr)) { if (bootopt & BOOT_STDERR) fprintf(stderr, "Couldn't bind to primary port %d\n", portnum); #ifdef USE_SYSLOG (void) syslog(LOG_CRIT, "Couldn't bind to primary port %d\n", portnum); #endif exit(1); } } else if (inetport(&me, "*", 0, 0)) { if (bootopt & BOOT_STDERR) fprintf(stderr, "Couldn't bind to port passed from inetd\n"); #ifdef USE_SYSLOG (void) syslog(LOG_CRIT, "Couldn't bind to port passed from inetd\n"); #endif exit(1); } (void) get_my_name(&me, me.sockhost, sizeof(me.sockhost) - 1); if (me.name[0] == '\0') strncpyzt(me.name, me.sockhost, sizeof(me.name)); me.hopcount = 0; me.authfd = -1; me.confs = NULL; me.next = NULL; me.user = NULL; me.from = &me; SetMe(&me); make_server(&me); me.serv->up = me.name; me.lasttime = me.since = me.firsttime = NOW; (void) add_to_client_hash_table(me.name, &me); /* We don't want to calculate these every time they are used :) */ sprintf(REPORT_DO_DNS, REPORT_DO_DNS_, me.name); sprintf(REPORT_FIN_DNS, REPORT_FIN_DNS_, me.name); sprintf(REPORT_FIN_DNSC, REPORT_FIN_DNSC_, me.name); sprintf(REPORT_FAIL_DNS, REPORT_FAIL_DNS_, me.name); sprintf(REPORT_DO_ID, REPORT_DO_ID_, me.name); sprintf(REPORT_FIN_ID, REPORT_FIN_ID_, me.name); sprintf(REPORT_FAIL_ID, REPORT_FAIL_ID_, me.name); R_do_dns = strlen(REPORT_DO_DNS); R_fin_dns = strlen(REPORT_FIN_DNS); R_fin_dnsc = strlen(REPORT_FIN_DNSC); R_fail_dns = strlen(REPORT_FAIL_DNS); R_do_id = strlen(REPORT_DO_ID); R_fin_id = strlen(REPORT_FIN_ID); R_fail_id = strlen(REPORT_FAIL_ID); check_class(); if (bootopt & BOOT_OPER) { aClient *tmp = add_connection(&me, 0); if (!tmp) exit(1); SetMaster(tmp); } else write_pidfile(); Debug((DEBUG_NOTICE, "Server ready...")); #ifdef USE_SYSLOG syslog(LOG_NOTICE, "Server Ready"); #endif NOW = time(NULL); #ifndef NO_PRIORITY check_fdlists(); #endif if ((timeofday = time(NULL)) == -1) { #ifdef USE_SYSLOG syslog(LOG_WARNING, "Clock Failure (%d), TS can be corrupted", errno); #endif sendto_ops("Clock Failure (%d), TS can be corrupted", errno); } #ifdef DUMP_DEBUG dumpfp=fopen("dump.log", "w"); #endif io_loop(); return 0; }
int main() { init_sys(); while(1); return -1; }
int main(int argc, char *argv[]) { time_t delay = 0; aConfItem* aconf; if(geteuid() == 0) { fprintf(stderr, "ERROR: Don't run ircd as root!\n"); return -1; } /* * save server boot time right away, so getrusage works correctly */ if ((CurrentTime = time(0)) == -1) { fprintf(stderr, "ERROR: Clock Failure: %s\n", strerror(errno)); exit(errno); } /* * Setup corefile size immediately after boot */ setup_corefile(); /* * set initialVMTop before we allocate any memory */ initialVMTop = get_vm_top(); /* * Initialize the Blockheap allocator */ initBlockHeap(); ServerRunning = 0; memset(&me, 0, sizeof(me)); GlobalClientList = &me; /* Pointer to beginning of Client list */ cold_start = YES; /* set when server first starts up */ memset(&Count, 0, sizeof(Count)); Count.server = 1; /* us */ initialize_global_set_options(); #ifdef REJECT_HOLD reject_held_fds = 0; #endif ConfigFileEntry.dpath = DPATH; ConfigFileEntry.configfile = CPATH; /* Server configuration file */ #ifdef KPATH ConfigFileEntry.klinefile = KPATH; /* Server kline file */ #else ConfigFileEntry.klinefile = CPATH; #endif /* KPATH */ #ifdef DLPATH ConfigFileEntry.dlinefile = DLPATH; #else ConfigFileEntry.dlinefile = CPATH; #endif /* DLPATH */ #ifdef GLINES ConfigFileEntry.glinefile = GLINEFILE; #endif #ifdef ZIP_LINKS /* Make sure the include files match the library version number. */ /* configure takes care of looking for zlib and zlibVersion(). */ if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { fprintf(stderr, "WARNING: zlib include files differ from library.\n"); fprintf(stderr, "WARNING: ZIPLINKS may fail!\n"); fprintf(stderr, "WARNING: library %s, include files %s\n", zlibVersion(), ZLIB_VERSION); } #endif myargv = argv; umask(077); /* better safe than sorry --SRB */ parse_command_line(argc, argv); if (chdir(ConfigFileEntry.dpath)) { perror("chdir"); exit(-1); } /* * Check if daemon is already running */ check_pidfile(); init_sys(bootDaemon); init_log(logFileName); setup_signals(); initialize_message_files(); isupport = make_isupport(); dbuf_init(); /* set up some dbuf stuff to control paging */ init_hash(); clear_scache_hash_table(); /* server cache name table */ clear_ip_hash_table(); /* client host ip hash table */ clear_Dline_table(); /* d line tree */ initlists(); initclass(); initwhowas(); init_stats(); init_tree_parse(msgtab); /* tree parse code (orabidoo) */ fdlist_init(); init_netio(); read_conf_files(YES); /* cold start init conf files */ aconf = find_me(); if (EmptyString(me.name)) strncpy_irc(me.name, aconf->host, HOSTLEN); strncpy_irc(me.host, aconf->host, HOSTLEN); me.fd = -1; me.from = &me; me.servptr = &me; SetMe(&me); make_server(&me); me.serv->up = me.name; me.lasttime = me.since = me.firsttime = CurrentTime; add_to_client_hash_table(me.name, &me); check_class(); write_pidfile(); log(L_NOTICE, "Server Ready"); ServerRunning = 1; while (ServerRunning) { usleep(100000); do_adns_io(); delay = io_loop(delay); do_adns_io(); } 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; }
int main(int argc, char ** argv){ int my_id, root, ierr, num_procs; MPI_Status status; ierr = MPI_Init(&argc, &argv);//Creat processes ierr = MPI_Comm_rank(MPI_COMM_WORLD, &my_id); ierr = MPI_Comm_size(MPI_COMM_WORLD, &num_procs); /*Make MPI data type for Vars*/ const int nitems=5; int blocklengths[5] = {1, 1, 1, 1, 1}; MPI_Datatype types[5] = { MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE}; MPI_Datatype mpi_Vars; MPI_Aint offsets[5]; offsets[0] = offsetof(Vars, mass); offsets[1] = offsetof(Vars, xvelocity); offsets[2] = offsetof(Vars, yvelocity); offsets[3] = offsetof(Vars, energy); offsets[4] = offsetof(Vars, press); MPI_Type_create_struct(nitems, blocklengths, offsets, types, &mpi_Vars); MPI_Type_commit(&mpi_Vars); /*start the program*/ int N, type; N = num_procs*100; type = 1; int zones_to_do = N/num_procs; double dt; int count = 0;char str[80]; FILE *fid, *finit; double dx = 1./(double)N; double t, T; t = 0.; T = .2; int num = 30; Vars * U = malloc((N+4)*(N+4)*sizeof(Vars)); init_sys(N+4, N+4, U, dx, dx, 1); if(my_id == 0){ /*I am root*/ finit = fopen("2Dinit.dat","w"); Write_Cons(N+4, N+4, U, dx, dx, finit); fclose(finit); int count = 0; } while(t<T){ //printf("before\n"); dt = advance_system(N+4, N+4, U, dx, dx, my_id, zones_to_do, num_procs, mpi_Vars); t+=dt; //break; //printf("what time is it = %f\n", dt); /*Broadcast U*/ ierr = MPI_Bcast(U, (N+4)*(N+4), mpi_Vars, 0, MPI_COMM_WORLD); /* if(my_id == 0){ if( count % 1 == 0){ sprintf(str, "T_%d.dat", count); fid = fopen(str, "w"); Write_Cons(N+4, N+4, U, dx, dx, fid); fclose(fid); //printf("T=%f\n", t); } count += 1; }*/ } if(my_id == 0){ /*I am Root*/ printf("%d\n", count); fid = fopen("22data.dat","w"); Write_Cons(N+4, N+4, U, dx, dx, fid); fclose(fid); } free(U); MPI_Finalize(); }
void main(void) { motor_fan_con(0); buzzer_led(0); init_sys(); LcdInitiate(); //调用LCD初始化函数 Delay1ms(2); WriteInstruction(0x01);//清显示:清屏幕指令 DisMenuInit(); mo_forword_slow(); //调用慢速档 while(!CarTurnLeft) { //AB段行驶 if (DeviateLeftTrack) { mo_R_forword_slow(); } if(DeviateRightTrack) { mo_L_forword_slow(); } if (CHECK_COIN) { //检测硬币 Delay1ms(5); if (CHECK_COIN) { mo_stop(); buzzer_led(1); Delay1ms(500); mo_forword_slow(); buzzer_led(0); Delay1ms(130); //不能太小,不能太大,太小会冲出跑道,小了会多次检测! if (!CHECK_COIN) { count_coin++; } } } if (count_kk>=50&&count_kk<51) { //变量显示稳定控制 ClearVarData(); WriteVarData(0x05,mo_time); WriteVarData(0x0d,total_length); WriteVarData(0x45,count_coin); WriteVarData(0x4d,count_bottle); } } while(1){ if (DeviateLeftTrack) { mo_R_forword(); } if(DeviateRightTrack) { mo_L_forword(); } /*转角声控报警之奇淫巧技*/ if((total_length >= 80 && total_length <= 110) ||\ (total_length >= 190 && total_length <= 230) ||\ (total_length >= 300 && total_length <= 360)){ if(CarTurnLeft){ mo_left(); buzzer_led(1); Delay1ms(20); buzzer_led(0); } if (CarTurnRight) { mo_right(); buzzer_led(1); Delay1ms(20); buzzer_led(0); } } else { if(CarTurnLeft){ mo_left(); Delay1ms(20); buzzer_led(0); } if (CarTurnRight) { mo_right(); Delay1ms(20); buzzer_led(0); } } if (UpBottle) { //瓶子检测 motor_fan_con(0); buzzer_led(1); Delay1ms(200); buzzer_led(0); if (NoBottle) { count_bottle++; } } if (DownBottle) { Delay1ms(2); if (DownBottle) { mo_stop(); motor_fan_con(1); Delay1ms(250); mo_forword(); motor_fan_con(0); } if (NoBottle) { count_bottle++; motor_fan_con(0); } } if (total_length>=430||mo_time>=90) { //终点 mo_stop(); Delay1ms(20); ClearVarData(); WriteVarData(0x05,mo_time); WriteVarData(0x0d,total_length); WriteVarData(0x45,count_coin); WriteVarData(0x4d,count_bottle); EA = 0; while (1) { mo_stop(); } } if (count_kk>=50&&count_kk<51) { //变量显示稳定控制 ClearVarData(); WriteVarData(0x05,mo_time); WriteVarData(0x0d,total_length); WriteVarData(0x45,count_coin); WriteVarData(0x4d,count_bottle); } } }
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; dlinkAdd (&me, &me.node, &global_client_list); /* Pointer to beginning of Client list */ memset (&ServerInfo, 0, sizeof (ServerInfo)); /* 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.xlinefile = XPATH; /* Server xline file */ ConfigFileEntry.dlinefile = DLPATH; /* dline file */ ConfigFileEntry.cresvfile = CRESVPATH; /* channel resv file */ ConfigFileEntry.nresvfile = NRESVPATH; /* nick resv file */ myargv = argv; umask (077); /* better safe than sorry --SRB */ parseargs (&argc, &argv, myopts); build_version (); if (printVersion) { printf ("ircd: version %s\n", ircd_version); exit (EXIT_SUCCESS); } if (chdir (ConfigFileEntry.dpath)) { perror ("chdir"); exit (EXIT_FAILURE); } if (!server_state.foreground) make_daemon (); else print_startup (getpid ()); #ifdef HAVE_LIBCRYPTO dh_init(); fprintf(stderr, "SSL: Initialize\n"); SSL_load_error_strings(); SSLeay_add_ssl_algorithms(); ServerInfo.ctx = SSL_CTX_new(SSLv23_server_method()); if (!ServerInfo.ctx) { ERR_print_errors_fp(stderr); return 0; } fprintf(stderr, "SSL: Client based SSL connections are enabled.\n"); #endif setup_signals (); /* We need this to initialise the fd array before anything else */ fdlist_init (); if (!server_state.foreground) close_all_connections (); /* this needs to be before init_netio()! */ else check_can_use_v6 (); /* Done in close_all_connections normally */ init_log (logFileName); init_netio (); /* This needs to be setup early ! -- adrian */ /* Check if there is pidfile and daemon already running */ check_pidfile (pidFileName); /* Init the event subsystem */ eventInit (); init_sys (); #ifndef NOBALLOC initBlockHeap (); #endif init_dlink_nodes (); init_slink_nodes (); initialize_message_files (); dbuf_init (); init_hash (); init_ip_hash_table (); /* client host ip hash table */ init_host_hash (); /* Host-hashtable. */ clear_hash_parse (); init_client (); init_user (); init_channels (); init_class (); init_whowas (); init_stats (); init_hooks (); read_conf_files (1); /* cold start init conf files */ initServerMask (); init_uid (); init_auth (); /* Initialise the auth code */ init_resolver (); /* Needs to be setup before the io loop */ init_reject (); /* Set up the reject code. */ init_umodes (); /* Set up the usermode system. */ initialize_foundation_signals(); /* register things that modules need */ #ifdef HAVE_LIBCRYPTO bio_spare_fd = save_spare_fd ("SSL private key validation"); #endif /* HAVE_LIBCRYPTO */ 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_CRIT, "No server name specified in serverinfo block."); exit (EXIT_FAILURE); } strlcpy (me.name, ServerInfo.name, sizeof (me.name)); /* 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_CRIT, "ERROR: No server description specified in serverinfo block."); exit (EXIT_FAILURE); } strlcpy (me.info, ServerInfo.description, sizeof (me.info)); me.from = &me; me.servptr = &me; SetMe (&me); make_server (&me); strlcpy (me.serv->up, me.name, sizeof (me.serv->up)); me.lasttime = me.since = me.firsttime = CurrentTime; hash_add_client (&me); /* add ourselves to global_serv_list */ dlinkAdd (&me, make_dlink_node (), &global_serv_list); check_class (); #ifndef STATIC_MODULES if (chdir (MODPATH)) { ilog (L_CRIT, "Could not load core modules. Terminating!"); exit (EXIT_FAILURE); } mod_set_base (); load_all_modules (1); load_core_modules (1); /* Go back to DPATH after checking to see if we can chdir to MODPATH */ chdir (ConfigFileEntry.dpath); #else load_all_modules (1); #endif write_pidfile (pidFileName); ilog (L_NOTICE, "Server Ready"); eventAddIsh ("cleanup_tklines", cleanup_tklines, NULL, CLEANUP_TKLINES_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 */ eventAddIsh ("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME); 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 (splitmode) eventAddIsh ("check_splitmode", check_splitmode, NULL, 60); ServerRunning = 1; io_loop (); return (0); }