static int __init mdacon_setup(char *str) { /* command line format: mdacon=<first>,<last> */ int ints[3]; str = get_options(str, ARRAY_SIZE(ints), ints); if (ints[0] < 2) return 0; if (ints[1] < 1 || ints[1] > MAX_NR_CONSOLES || ints[2] < 1 || ints[2] > MAX_NR_CONSOLES) return 0; mda_first_vc = ints[1]; mda_last_vc = ints[2]; return 1; }
static int __init setup_trix (char *str) { /* io, irq, dma, dma2, sb_io, sb_irq, sb_dma, mpu_io, mpu_irq */ int ints[9]; str = get_options(str, ARRAY_SIZE(ints), ints); io = ints[1]; irq = ints[2]; dma = ints[3]; dma2 = ints[4]; sb_io = ints[5]; sb_irq = ints[6]; sb_dma = ints[6]; mpu_io = ints[7]; mpu_irq = ints[8]; return 1; }
/* * kernel boot parameters * format: "nec_candy_mac=xx,xx,xx,xx,xx,xx [nec_candy_mac=xx,xx,xx,xx,xx,xx]" */ static int __init nec_candy_boot_setup(char *str) { int ints[10]; int i; static int index=0; str = get_options(str, ARRAY_SIZE(ints), ints); if (ints[0] != 6) return 0; if (index == MAX_NUM_DEVS) return 1; /* ignore params */ for (i=0; i< 6; i++) candy_boot_params[index].mac_addr[i] = (u_char)ints[i+1]; index++; return 1; }
static int __init applicom_setup(char *str) { int ints[4]; (void) get_options(str, 4, ints); if (ints[0] > 2) { printk(KERN_WARNING "Too many arguments to 'applicom=', expected mem,irq only.\n"); } if (ints[0] < 2) { printk(KERN_INFO"applicom numargs: %d\n", ints[0]); return 0; } mem = ints[1]; irq = ints[2]; return 1; }
/** * Retrieve and bounds-check the cbtmaxtimeouts consensus paramter. * * Effect: When this many timeouts happen in the last 'cbtrecentcount' * circuit attempts, the client should discard all of its history and * begin learning a fresh timeout value. */ static int32_t circuit_build_times_max_timeouts(void) { int32_t cbt_maxtimeouts; cbt_maxtimeouts = networkstatus_get_param(NULL, "cbtmaxtimeouts", CBT_DEFAULT_MAX_RECENT_TIMEOUT_COUNT, CBT_MIN_MAX_RECENT_TIMEOUT_COUNT, CBT_MAX_MAX_RECENT_TIMEOUT_COUNT); if (!(get_options()->LearnCircuitBuildTimeout)) { log_debug(LD_BUG, "circuit_build_times_max_timeouts() called, cbtmaxtimeouts is" " %d", cbt_maxtimeouts); } return cbt_maxtimeouts; }
/** Add <b>ri</b> to the nodelist. */ node_t * nodelist_add_routerinfo(routerinfo_t *ri) { node_t *node; init_nodelist(); node = node_get_or_create(ri->cache_info.identity_digest); node->ri = ri; if (node->country == -1) node_set_country(node); if (authdir_mode(get_options())) { const char *discard=NULL; uint32_t status = dirserv_router_get_status(ri, &discard); dirserv_set_node_flags_from_authoritative_status(node, status); } return node; }
static int __init sc1200wdt_setup(char *str) { int ints[4]; str = get_options (str, ARRAY_SIZE(ints), ints); if (ints[0] > 0) { io = ints[1]; if (ints[0] > 1) timeout = ints[2]; #if defined CONFIG_PNP if (ints[0] > 2) isapnp = ints[3]; #endif } return 1; }
int main(int argc, char *argv[]) { if (argc > 1) get_options(argc, argv); get_envvars(); unsigned long lasttick; lasttick = GetTickCount(); run_tests(my_tests); char cmd[128]; snprintf(cmd,128, "Run for time %dms\n", (GetTickCount() - lasttick) ); printf("%s",cmd); return(exit_status()); return 0; }
void Chimera::applyPlayerOptions() { typedef boost::optional<std::string> param_type; typedef const FB::variant& param_vtype; const vlc_player_options& opts = get_options(); param_vtype mute = getParamVariant( "mute" ); if( !mute.empty() && mute.can_be_type<bool>() ) { m_forceMute = mute.convert_cast<bool>( ); get_player().audio().set_mute( mute.convert_cast<bool>() ); } param_vtype loop = getParamVariant( "loop" ); param_vtype autoloop = getParamVariant( "autoloop" ); bool set_loop = false; if ( !loop.empty() && loop.can_be_type<bool>() ) set_loop = loop.convert_cast<bool>(); if ( !autoloop.empty() && autoloop.can_be_type<bool>() ) set_loop = autoloop.convert_cast<bool>(); get_player().set_playback_mode( set_loop ? vlc::mode_loop : vlc::mode_normal ); param_type target = getParam( "target" ); param_type mrl = getParam( "mrl" ); param_type filename = getParam( "filename" ); param_type src = getParam( "src" ); std::string set_mrl; if ( target ) set_mrl = *target; if ( mrl ) set_mrl = *mrl; if ( filename ) set_mrl = *filename; if ( src ) set_mrl = *src; if( !set_mrl.empty() ) { int item = addPlaylistItem( set_mrl.c_str() ); if ( opts.get_autoplay() ) get_player().play( item ); } }
/** Note that we've seen a client connect from the IP <b>addr</b> (host order) * at time <b>now</b>. Ignored by all but bridges. */ void geoip_note_client_seen(geoip_client_action_t action, uint32_t addr, time_t now) { or_options_t *options = get_options(); clientmap_entry_t lookup, *ent; if (action == GEOIP_CLIENT_CONNECT) { if (!(options->BridgeRelay && options->BridgeRecordUsageByCountry)) return; /* Did we recently switch from bridge to relay or back? */ if (client_history_starts > now) return; } else { #ifndef ENABLE_GEOIP_STATS return; #else if (options->BridgeRelay || options->BridgeAuthoritativeDir || !options->DirRecordUsageByCountry) return; #endif } /* Rotate the current request period. */ while (current_request_period_starts + REQUEST_HIST_PERIOD < now) { if (!geoip_countries) geoip_countries = smartlist_create(); if (!current_request_period_starts) { current_request_period_starts = now; break; } SMARTLIST_FOREACH(geoip_countries, geoip_country_t *, c, { memmove(&c->n_v2_ns_requests[0], &c->n_v2_ns_requests[1], sizeof(uint32_t)*(REQUEST_HIST_LEN-1)); memmove(&c->n_v3_ns_requests[0], &c->n_v3_ns_requests[1], sizeof(uint32_t)*(REQUEST_HIST_LEN-1)); c->n_v2_ns_requests[REQUEST_HIST_LEN-1] = 0; c->n_v3_ns_requests[REQUEST_HIST_LEN-1] = 0; }); current_request_period_starts += REQUEST_HIST_PERIOD; if (n_old_request_periods < REQUEST_HIST_LEN-1) ++n_old_request_periods; }
extern lzma_ret lzma_outq_init(lzma_outq *outq, const lzma_allocator *allocator, uint64_t buf_size_max, uint32_t threads) { uint64_t bufs_alloc_size; uint32_t bufs_count; // Set bufs_count and bufs_alloc_size. return_if_error(get_options(&bufs_alloc_size, &bufs_count, buf_size_max, threads)); // Allocate memory if needed. if (outq->buf_size_max != buf_size_max || outq->bufs_allocated != bufs_count) { lzma_outq_end(outq, allocator); #if SIZE_MAX < UINT64_MAX if (bufs_alloc_size > SIZE_MAX) return LZMA_MEM_ERROR; #endif outq->bufs = lzma_alloc(bufs_count * sizeof(lzma_outbuf), allocator); outq->bufs_mem = lzma_alloc((size_t)(bufs_alloc_size), allocator); if (outq->bufs == NULL || outq->bufs_mem == NULL) { lzma_outq_end(outq, allocator); return LZMA_MEM_ERROR; } } // Initialize the rest of the main structure. Initialization of // outq->bufs[] is done when they are actually needed. outq->buf_size_max = (size_t)(buf_size_max); outq->bufs_allocated = bufs_count; outq->bufs_pos = 0; outq->bufs_used = 0; outq->read_pos = 0; return LZMA_OK; }
static int __init get_temperature_params(char *str) { unsigned int tmu_temp[8] = { (int)NULL, (int)NULL, (int)NULL, (int)NULL, (int)NULL, (int)NULL, (int)NULL, (int)NULL }; get_options(str, 8, tmu_temp); tmu_test_on = tmu_temp[0]; printk(KERN_INFO "@@@ tmu_test enable = %d\n", tmu_test_on); if (tmu_temp[1] > 0) in.stop_1st_throttle = tmu_temp[1]; if (tmu_temp[2] > 0) in.start_1st_throttle = tmu_temp[2]; if (tmu_temp[3] > 0) in.stop_2nd_throttle = tmu_temp[3]; if (tmu_temp[4] > 0) in.start_2nd_throttle = tmu_temp[4]; if (tmu_temp[5] > 0) in.start_tripping = tmu_temp[5]; if (tmu_temp[6] > 0) in.start_mem_throttle = tmu_temp[6]; if (tmu_temp[7] > 0) in.start_emergency = tmu_temp[7]; /* output the input value */ pr_info("@@ 1st throttling temp: start = %d, stop = %d @@\n" "@@ 2nd throttling temp: start = %d, stop = %d @@\n" "@@ trpping temp = %d, start_tq0 temp = %d @@\n" "@@ emergency temp = %d\n", in.start_1st_throttle, in.stop_1st_throttle, in.start_2nd_throttle, in.stop_2nd_throttle, in.start_tripping, in.start_mem_throttle, in.start_emergency); return 0; }
/** If we aren't currently dormant, close all connections and become * dormant. */ static void hibernate_go_dormant(time_t now) { connection_t *conn; if (hibernate_state == HIBERNATE_STATE_DORMANT) return; else if (hibernate_state == HIBERNATE_STATE_LOWBANDWIDTH) hibernate_state = HIBERNATE_STATE_DORMANT; else hibernate_begin(HIBERNATE_STATE_DORMANT, now); log_notice(LD_ACCT,"Going dormant. Blowing away remaining connections."); /* Close all OR/AP/exit conns. Leave dir conns because we still want * to be able to upload server descriptors so people know we're still * running, and download directories so we can detect if we're obsolete. * Leave control conns because we still want to be controllable. */ while ((conn = connection_get_by_type(CONN_TYPE_OR)) || (conn = connection_get_by_type(CONN_TYPE_AP)) || (conn = connection_get_by_type(CONN_TYPE_EXIT))) { if (CONN_IS_EDGE(conn)) connection_edge_end(TO_EDGE_CONN(conn), END_STREAM_REASON_HIBERNATING); log_info(LD_NET,"Closing conn type %d", conn->type); if (conn->type == CONN_TYPE_AP) /* send socks failure if needed */ connection_mark_unattached_ap(TO_EDGE_CONN(conn), END_STREAM_REASON_HIBERNATING); else connection_mark_for_close(conn); } if (now < interval_wakeup_time) hibernate_end_time = interval_wakeup_time; else hibernate_end_time = interval_end_time; accounting_record_bandwidth_usage(now, get_or_state()); or_state_mark_dirty(get_or_state(), get_options()->AvoidDiskWrites ? now+600 : 0); }
/** Save all our bandwidth tracking information to disk. Return 0 on * success, -1 on failure. */ int accounting_record_bandwidth_usage(time_t now, or_state_t *state) { /* Just update the state */ state->AccountingIntervalStart = interval_start_time; state->AccountingBytesReadInInterval = ROUND_UP(n_bytes_read_in_interval); state->AccountingBytesWrittenInInterval = ROUND_UP(n_bytes_written_in_interval); state->AccountingSecondsActive = n_seconds_active_in_interval; state->AccountingExpectedUsage = expected_bandwidth_usage; state->AccountingSecondsToReachSoftLimit = n_seconds_to_hit_soft_limit; state->AccountingSoftLimitHitAt = soft_limit_hit_at; state->AccountingBytesAtSoftLimit = n_bytes_at_soft_limit; or_state_mark_dirty(state, now+(get_options()->AvoidDiskWrites ? 7200 : 60)); return 0; }
static int __init get_cpufreq_limit_param(char *str) { int tmu_temp[3] = { (int)NULL, (int)NULL, (int)NULL}; get_options(str, 3, tmu_temp); tmu_limit_on = tmu_temp[0]; printk(KERN_INFO "@@@ tmu_limit_on = %d\n", tmu_limit_on); if (tmu_temp[1] > 0) freq_limit_1st_throttle = tmu_temp[1]; if (tmu_temp[2] > 0) freq_limit_2nd_throttle = tmu_temp[2]; pr_info("@@ 1st throttling : cpu_level = %d, 2nd cpu_level = %d\n", freq_limit_1st_throttle, freq_limit_2nd_throttle); return 0; }
/** Helper for dirserv_compute_performance_thresholds(): Decide whether to * include a router in our calculations, and return true iff we should; the * require_mbw parameter is passed in by * dirserv_compute_performance_thresholds() and controls whether we ever * count routers with only advertised bandwidths */ static int router_counts_toward_thresholds(const node_t *node, time_t now, const digestmap_t *omit_as_sybil, int require_mbw) { /* Have measured bw? */ int have_mbw = dirserv_has_measured_bw(node->identity); uint64_t min_bw_kb = ABSOLUTE_MIN_BW_VALUE_TO_CONSIDER_KB; const or_options_t *options = get_options(); if (options->TestingTorNetwork) { min_bw_kb = (int64_t)options->TestingMinExitFlagThreshold / 1000; } return node->ri && router_is_active(node->ri, node, now) && !digestmap_get(omit_as_sybil, node->identity) && (dirserv_get_credible_bandwidth_kb(node->ri) >= min_bw_kb) && (have_mbw || !require_mbw); }
static int __init arcrimi_setup(char *s) { int ints[8]; s = get_options(s, 8, ints); if (!ints[0]) return 1; switch (ints[0]) { default: /* ERROR */ printk("arcrimi: Too many arguments.\n"); case 3: /* Node ID */ node = ints[3]; case 2: /* IRQ */ irq = ints[2]; case 1: /* IO address */ io = ints[1]; } if (*s) snprintf(device, sizeof(device), "%s", s); return 1; }
/** Note that we've rejected a client's request for a v2 or v3 network * status, encoded in <b>action</b> for reason <b>reason</b> at time * <b>now</b>. */ void geoip_note_ns_response(geoip_client_action_t action, geoip_ns_response_t response) { static int arrays_initialized = 0; if (!get_options()->DirReqStatistics) return; if (!arrays_initialized) { memset(ns_v2_responses, 0, sizeof(ns_v2_responses)); memset(ns_v3_responses, 0, sizeof(ns_v3_responses)); arrays_initialized = 1; } tor_assert(action == GEOIP_CLIENT_NETWORKSTATUS || action == GEOIP_CLIENT_NETWORKSTATUS_V2); tor_assert(response < GEOIP_NS_RESPONSE_NUM); if (action == GEOIP_CLIENT_NETWORKSTATUS) ns_v3_responses[response]++; else ns_v2_responses[response]++; }
/* Initialize the cookie-based authentication system of the * ControlPort. If <b>enabled</b> is 0, then disable the cookie * authentication system. */ int init_control_cookie_authentication(int enabled) { char *fname = NULL; int retval; if (!enabled) { authentication_cookie_is_set = 0; return 0; } fname = get_controller_cookie_file_name(); retval = init_cookie_authentication(fname, "", /* no header */ AUTHENTICATION_COOKIE_LEN, get_options()->CookieAuthFileGroupReadable, &authentication_cookie, &authentication_cookie_is_set); tor_free(fname); return retval; }
size_t database::backup(char *file) { // prepare for output if ( get_options()&&DBO_OVERWRITE ) unlink(file); if ( access(file,0x00)==0 ) exception("unable to backup of '%s' to '%s' - OVERWRITE not specified but file exists",get_schema(),file); // get list of tables MYSQL_RES *res = select("SHOW TABLES"); if ( res==NULL ) { gl_error("backup of '%s' failed - %s", file, mysql_error(mysql)); return -1; } size_t ntables = mysql_num_rows(res); char **tables = new char*[ntables]; int n; for ( n=0 ; n<ntables ; n++ ) { MYSQL_ROW row; row = mysql_fetch_row(res); unsigned long *len = mysql_fetch_lengths(res); tables[n] = new char[len==NULL?1024:(len[0]+1)]; strcpy(tables[n],row[0]); } mysql_free_result(res); // dump tables int nrows = 0; for ( n=0 ; n<ntables ; n++ ) { size_t nr = dump(tables[n],file,TD_APPEND|TD_BACKUP); if ( nr<0 ) { nrows=-1; break; } nrows += nr; } for ( n=0 ; n<ntables ; n++ ) delete [] tables[n]; delete[] tables; return nrows; }
//------------------------------------------------------------------------------ int main( int argc, char **argv ) //------------------------------------------------------------------------------ { // initialize the log (see log.h for details) logInit(); get_options (argc, argv); //Command-line options set_glog(glog_level, glog_verbosity); log_set_instance_type (LOG_INSTANCE_ENB); /* Read eNB configuration file */ enb_properties = enb_config_init(conf_config_file_name); itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file); itti_wait_ready(1); if (itti_create_task (TASK_SCTP, sctp_eNB_task, NULL) < 0) { LOG_E(SCTP, "Create task for SCTP failed\n"); return -1; } if (itti_create_task (TASK_S1AP, s1ap_eNB_task, NULL) < 0) { LOG_E(S1AP, "Create task for S1AP failed\n"); return -1; } if (itti_create_task (TASK_ENB_APP, eNB_app_task, NULL) < 0) { LOG_E(S1AP, "Create task for S1AP failed\n"); return -1; } itti_wait_ready(0); sleep(30); logClean(); return 0; }
/** Set expected_bandwidth_usage based on how much we sent/received * per minute last interval (if we were up for at least 30 minutes), * or based on our declared bandwidth otherwise. */ static void update_expected_bandwidth(void) { uint64_t expected; const or_options_t *options= get_options(); uint64_t max_configured = (options->RelayBandwidthRate > 0 ? options->RelayBandwidthRate : options->BandwidthRate) * 60; #define MIN_TIME_FOR_MEASUREMENT (1800) if (soft_limit_hit_at > interval_start_time && n_bytes_at_soft_limit && (soft_limit_hit_at - interval_start_time) > MIN_TIME_FOR_MEASUREMENT) { /* If we hit our soft limit last time, only count the bytes up to that * time. This is a better predictor of our actual bandwidth than * considering the entirety of the last interval, since we likely started * using bytes very slowly once we hit our soft limit. */ expected = n_bytes_at_soft_limit / (soft_limit_hit_at - interval_start_time); expected /= 60; } else if (n_seconds_active_in_interval >= MIN_TIME_FOR_MEASUREMENT) { /* Otherwise, we either measured enough time in the last interval but * never hit our soft limit, or we're using a state file from a Tor that * doesn't know to store soft-limit info. Just take rate at which * we were reading/writing in the last interval as our expected rate. */ uint64_t used = MAX(n_bytes_written_in_interval, n_bytes_read_in_interval); expected = used / (n_seconds_active_in_interval / 60); } else { /* If we haven't gotten enough data last interval, set 'expected' * to 0. This will set our wakeup to the start of the interval. * Next interval, we'll choose our starting time based on how much * we sent this interval. */ expected = 0; } if (expected > max_configured) expected = max_configured; expected_bandwidth_usage = expected; }
int main(int argc, char* argv[]) { char type = 'a'; int nrthr = get_options(argc, argv, &type); pthread_t threads[nrthr]; extern int optind; extern char *optarg; struct listnode *first_node = NULL; struct search_args *args = malloc(sizeof(struct search_args)); args->active_threads = nrthr; args->phrase = argv[argc - 1]; args->type = &type; args->first_node_ptr = &first_node; chdir("/home"); //Add all the paths to the list of search paths. for (int i = optind; i <= argc - 2; i++) { struct listnode *tmp_node = create_node(argv[i]); insert_node(&first_node, tmp_node); } //Create threads. for (int i = 0; i < nrthr - 1; i++) { pthread_create(&threads[i], NULL, thread_function, (void *)args); } //Main thread work. thread_function((void *)args); //Join threads. for (int i = 0; i < nrthr - 1; i++) { pthread_join(threads[i], NULL); } free(args); return 0; }
/** Note that we've seen a client connect from the IP <b>addr</b> * at time <b>now</b>. Ignored by all but bridges and directories if * configured accordingly. */ void geoip_note_client_seen(geoip_client_action_t action, const tor_addr_t *addr, time_t now) { const or_options_t *options = get_options(); clientmap_entry_t lookup, *ent; if (action == GEOIP_CLIENT_CONNECT) { /* Only remember statistics as entry guard or as bridge. */ if (!options->EntryStatistics && (!(options->BridgeRelay && options->BridgeRecordUsageByCountry))) return; } else { if (options->BridgeRelay || options->BridgeAuthoritativeDir || !options->DirReqStatistics) return; } tor_addr_copy(&lookup.addr, addr); lookup.action = (int)action; ent = HT_FIND(clientmap, &client_history, &lookup); if (! ent) { ent = tor_malloc_zero(sizeof(clientmap_entry_t)); tor_addr_copy(&ent->addr, addr); ent->action = (int)action; HT_INSERT(clientmap, &client_history, ent); } if (now / 60 <= (int)MAX_LAST_SEEN_IN_MINUTES && now >= 0) ent->last_seen_in_minutes = (unsigned)(now/60); else ent->last_seen_in_minutes = 0; if (action == GEOIP_CLIENT_NETWORKSTATUS) { int country_idx = geoip_get_country_by_addr(addr); if (country_idx < 0) country_idx = 0; /** unresolved requests are stored at index 0. */ if (country_idx >= 0 && country_idx < smartlist_len(geoip_countries)) { geoip_country_t *country = smartlist_get(geoip_countries, country_idx); ++country->n_v3_ns_requests; } } }
int main(int argc, char *argv[]) { MYSQL *mysql; int i; if (argc > 1) get_options(argc, argv); get_envvars(); for (i = 0; i < MAX_COUNT; ++i) { if (mysql_library_init(-1, NULL, NULL) != 0) { diag("mysql_library_init failed"); return 1; } mysql = mysql_init(NULL); if (!mysql) { diag("mysql_init failed"); return 1; } if (!mysql_real_connect(mysql, hostname, username, password, NULL, port, NULL, 0)) { diag("mysql_real_connect failed: %s", mysql_error(mysql)); return 1; } if (mysql_query(mysql, "SELECT NULL LIMIT 0") != 0) { diag("mysql_query failed: %s", mysql_error(mysql)); return 1; } mysql_close(mysql); mysql_library_end(); } return 0; }
static void _file(Request& r, MethodParams& params) { VXdoc& vdoc=GET_SELF(r, VXdoc); XDocOutputOptions oo(vdoc.output_options); oo.append(r, get_options(params, 0), true/* $.name[filename] could be specified by user */); String::C buf=xdoc2buf(r, vdoc, oo, 0/*file_name. not to file, to memory*/); VFile& vfile=*new VFile; VHash& vhcontent_type=*new VHash; vhcontent_type.hash().put( value_name, new VString(*oo.mediaType)); vhcontent_type.hash().put( String::Body("charset"), new VString(*oo.encoding)); vfile.set_binary(false/*not tainted*/, buf.str?buf.str:""/*to distinguish from stat-ed file*/, buf.length, oo.filename, &vhcontent_type); // write out result r.write_no_lang(vfile); }
void ft_base(t_dt *data) { static void (*func[])(t_dt *) = { PRINTF_FUNC1, PRINTF_FUNC2 }; char *ptr; while (*data->tail) { if (*data->tail == '%') { ptr = NULL; get_options(data); if (*data->tail) ptr = ft_strchr(PRINTF_ARGS, *data->tail); (ptr) ? func[ptr - PRINTF_ARGS](data) : print_flag(data); ft_memset(&data->flag, 0, sizeof(data->flag)); } else write_char(data, *data->tail); data->tail++; } }
int main(int argc, char *argv[]) { MY_INIT(argv[0]); { uint row_count; struct errors *error_head; struct languages *lang_head; DBUG_ENTER("main"); charsets_dir= DEFAULT_CHARSET_DIR; my_umask_dir= 0777; if (get_options(&argc, &argv)) DBUG_RETURN(1); if (!(row_count= parse_input_file(TXTFILE, &error_head, &lang_head))) { fprintf(stderr, "Failed to parse input file %s\n", TXTFILE); DBUG_RETURN(1); } if (lang_head == NULL || error_head == NULL) { fprintf(stderr, "Failed to parse input file %s\n", TXTFILE); DBUG_RETURN(1); } if (create_header_files(error_head)) { fprintf(stderr, "Failed to create header files\n"); DBUG_RETURN(1); } if (create_sys_files(lang_head, error_head, row_count)) { fprintf(stderr, "Failed to create sys files\n"); DBUG_RETURN(1); } clean_up(lang_head, error_head); DBUG_LEAVE; /* Can't use dbug after my_end() */ my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); return 0; } }
int main( int argc, char *argv[] ) { po::options_description description("Allowed options"); get_options( description ); po::variables_map vm; try { vm = create_cmd_params( argc, argv, description ); } catch ( const std::exception &ex ) { std::cerr << "Options error: " << ex.what( ) << "\n" << description; return 1; } if( vm.count( "help" ) ) { show_help( description ); return 0; } try { start( vm ); } catch( const vtrc::common::exception &ex ) { std::cerr << "Server start failed: " << ex.what( ); std::string add(ex.additional( )); if( !add.empty( ) ) { std::cerr << " '" << add << "'"; } std::cerr << "\n"; return 3; } catch( const std::exception &ex ) { std::cerr << "Server start failed: " << ex.what( ) << "\n"; return 3; } google::protobuf::ShutdownProtobufLibrary( ); return 0; }
/** * Output a histogram of current circuit build times to * the or_state_t state structure. */ void circuit_build_times_update_state(circuit_build_times_t *cbt, or_state_t *state) { uint32_t *histogram; build_time_t i = 0; build_time_t nbins = 0; config_line_t **next, *line; histogram = circuit_build_times_create_histogram(cbt, &nbins); // write to state config_free_lines(state->BuildtimeHistogram); next = &state->BuildtimeHistogram; *next = NULL; state->TotalBuildTimes = cbt->total_build_times; state->CircuitBuildAbandonedCount = 0; for (i = 0; i < CBT_NCIRCUITS_TO_OBSERVE; i++) { if (cbt->circuit_build_times[i] == CBT_BUILD_ABANDONED) state->CircuitBuildAbandonedCount++; } for (i = 0; i < nbins; i++) { // compress the histogram by skipping the blanks if (histogram[i] == 0) continue; *next = line = tor_malloc_zero(sizeof(config_line_t)); line->key = tor_strdup("CircuitBuildTimeBin"); tor_asprintf(&line->value, "%d %d", CBT_BIN_TO_MS(i), histogram[i]); next = &(line->next); } if (!unit_tests) { if (!get_options()->AvoidDiskWrites) or_state_mark_dirty(get_or_state(), 0); } tor_free(histogram); }