/** * The main entry point. * * @param argc Number of program arguments. * @param argv The argument vector supplied to this program. * * @return The exit status of the program. */ int main (int argc, char *argv[]) { set_program_name (argv[0]); setlocale (LC_ALL, ""); #if ENABLE_NLS bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); #endif vars_init (); /* Initialize the version string. */ argp_version_setup (PACKAGE, authors); /* Initialize the help string. */ const char *totaldoc = NULL, **ptr; for (ptr = doc; *ptr != NULL; ptr++) EXTENDF (totaldoc, "%s", *ptr); struct argp args = { opts, arg_parse, N_("FILE"), totaldoc }; argp_parse (&args, argc, argv, 0, NULL, NULL); FREE (totaldoc); run_unit (); return 0; }
void init(t_env *e) { void *libre; cursor(e); e->map = ft_lecture(e->stage->str, e); libre = e->stage; if (e->check_x != 500) { e->posx = e->check_x; e->posy = e->check_y; delete_check(e); } else { e->posx = e->enter_x; e->posy = e->enter_y; } vars_init(e); fill_texture(e); fill_obj(e); level_image(e); e->stage = e->stage->next; free(libre); }
/* Create a a new session and assign it to frontend <fe>, listener <li>, * origin <origin>, set the current date and clear the stick counters pointers. * Returns the session upon success or NULL. The session may be released using * session_free(). */ struct session *session_new(struct proxy *fe, struct listener *li, enum obj_type *origin) { struct session *sess; sess = pool_alloc2(pool2_session); if (sess) { sess->listener = li; sess->fe = fe; sess->origin = origin; sess->accept_date = date; /* user-visible date for logging */ sess->tv_accept = now; /* corrected date for internal use */ memset(sess->stkctr, 0, sizeof(sess->stkctr)); vars_init(&sess->vars, SCOPE_SESS); } return sess; }
void driver_loop(void) { initial(); printf("initialed.\n"); while (1){ if (setjmp(jump_buffer) == 0){ printf("\n%s\n", input_prompt); reg = read_sexp(); //eval the expression with tail_context is a_false args_push(a_false); args_push(reg); reg = eval(); printf("\n%s\n", output_prompt); write(reg); newline(); }else { //error handler, initial some variables vars_init(); } } }
/* Create a a new session and assign it to frontend <fe>, listener <li>, * origin <origin>, set the current date and clear the stick counters pointers. * Returns the session upon success or NULL. The session may be released using * session_free(). Note: <li> may be NULL. */ struct session *session_new(struct proxy *fe, struct listener *li, enum obj_type *origin) { struct session *sess; sess = pool_alloc(pool_head_session); if (sess) { sess->listener = li; sess->fe = fe; sess->origin = origin; sess->accept_date = date; /* user-visible date for logging */ sess->tv_accept = now; /* corrected date for internal use */ memset(sess->stkctr, 0, sizeof(sess->stkctr)); vars_init(&sess->vars, SCOPE_SESS); sess->task = NULL; sess->t_handshake = -1; /* handshake not done yet */ HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.conn_max, HA_ATOMIC_ADD(&fe->feconn, 1)); if (li) proxy_inc_fe_conn_ctr(li, fe); HA_ATOMIC_ADD(&totalconn, 1); HA_ATOMIC_ADD(&jobs, 1); } return sess; }
int main(int argc, char **argv) { setlocale(LC_ALL, ""); // Early logging goes to stderr stderrlog = stderr; // parse commandline options GOptionContext *optx = g_option_context_new("- NCurses Direct Connect"); g_option_context_add_main_entries(optx, cli_options, NULL); GError *err = NULL; if(!g_option_context_parse(optx, &argc, &argv, &err)) { puts(err->message); exit(1); } g_option_context_free(optx); // check that the current locale is UTF-8. Things aren't going to work otherwise if(!g_get_charset(NULL)) { puts("WARNING: Your current locale is not set to UTF-8."); puts("Non-ASCII characters may not display correctly."); puts("Hit Ctrl+c to abort ncdc, or the return key to continue anyway."); getchar(); } // init stuff init_crypt(); g_thread_init(NULL); // Create main loop main_loop = g_main_loop_new(NULL, FALSE); // setup logging g_log_set_handler(NULL, G_LOG_FATAL_MASK | G_LOG_FLAG_FATAL | G_LOG_LEVEL_ERROR, log_fatal, NULL); g_log_set_default_handler(log_redirect, NULL); // Init database & variables db_init(); vars_init(); // open log file char *errlog = g_build_filename(db_dir, "stderr.log", NULL); if(!(stderrlog = fopen(errlog, "w"))) { fprintf(stderr, "ERROR: Couldn't open %s for writing: %s\n", errlog, strerror(errno)); exit(1); } g_free(errlog); // Init more stuff hub_init_global(); net_init_global(); listen_global_init(); cc_global_init(); dl_init_global(); ui_cmdhist_init("history"); ui_init(bracketed_paste); geoip_reinit(4); geoip_reinit(6); // setup SIGWINCH struct sigaction act; sigemptyset(&act.sa_mask); act.sa_flags = SA_RESTART; act.sa_handler = catch_sigwinch; if(sigaction(SIGWINCH, &act, NULL) < 0) g_error("Can't setup SIGWINCH: %s", g_strerror(errno)); // setup SIGTERM act.sa_handler = catch_sigterm; if(sigaction(SIGTERM, &act, NULL) < 0) g_error("Can't setup SIGTERM: %s", g_strerror(errno)); // setup SIGHUP act.sa_handler = catch_sighup; if(sigaction(SIGHUP, &act, NULL) < 0) g_error("Can't setup SIGHUP: %s", g_strerror(errno)); // setup SIGUSR1 act.sa_handler = catch_sigusr1; if(sigaction(SIGUSR1, &act, NULL) < 0) g_error("Can't setup SIGUSR1: %s", g_strerror(errno)); // setup SIGPIPE act.sa_handler = catch_sigpipe; if(sigaction(SIGPIPE, &act, NULL) < 0) g_error("Can't setup SIGPIPE: %s", g_strerror(errno)); fl_init(); if(auto_open) open_autoconnect(); // add some watches and start the main loop GIOChannel *in = g_io_channel_unix_new(STDIN_FILENO); g_io_add_watch(in, G_IO_IN, stdin_read, NULL); GSource *sighandle = g_source_new(&sighandle_funcs, sizeof(GSource)); g_source_set_priority(sighandle, G_PRIORITY_HIGH); g_source_set_callback(sighandle, sighandle_sourcefunc, NULL, NULL); g_source_attach(sighandle, NULL); g_source_unref(sighandle); g_timeout_add_seconds_full(G_PRIORITY_HIGH, 1, one_second_timer, NULL, NULL); g_timeout_add(100, screen_update_check, NULL); int maxage = var_get_int(0, VAR_filelist_maxage); g_timeout_add_seconds_full(G_PRIORITY_LOW, CLAMP(maxage, 3600, 24*3600), dl_fl_clean, NULL, NULL); g_main_loop_run(main_loop); // cleanup if(!main_noterm) { erase(); refresh(); endwin(); if(bracketed_paste) ui_set_bracketed_paste(0); printf("Flushing unsaved data to disk..."); fflush(stdout); } ui_cmdhist_close(); cc_global_close(); fl_flush(NULL); dl_close_global(); db_close(); gnutls_global_deinit(); if(!main_noterm) printf(" Done!\n"); g_debug("Clean shutdown."); return 0; }