/* * Main entry point */ int main(int argc, char **argv) { int opt_v = 0; char *opt_c = NULL; char *opt_s = NULL; int ch; /* check we're running as root */ if(getuid() != 0) { errno = EACCES; ERR("I must be run as root\n"); return -1; } /* handle command line arguments */ while ((ch = getopt(argc, argv, "hvc:s:")) != -1) { switch (ch) { case 'v': // enables verbose logging opt_v++; break; case 'c': // allows use to override location of config opt_c = strdup(optarg); break; case 's': // changes location of unix socket opt_s = strdup(optarg); break; case 'h': // help! default: usage(argc, argv); } } argc -= optind; argv += optind; /* set the logging level */ if (opt_v == 0) { opt_v = LOG_LEVEL_DEFAULT; } log_level(opt_v); INF("thermal manager starting...\n"); /* bring up "subsystems" */ sensor_init(); hwmon_init(); actions_init(); /* read and parse sensor config file */ if (opt_c == NULL) { opt_c = strdup(DEFAULT_CONFIG_FILE_PATH); if (opt_c == NULL) { ERR("unable to allocate memory\n"); return -1; } } INF("parsing thermal.conf...\n"); if (parse_config(opt_c) < 0) { ERR("failed to parse config file\n"); return -1; } /* discover HWMON sensors */ INF("discovering platform HWMON sensors...\n"); if (hwmon_find_sensors()) { ERR("failed to find platform HWMON sensors\n"); return -1; } /* startup client socket */ if (opt_s != NULL) { INF("overriding default socket path (%s)!\n", opt_s); socket_setunixsocket(opt_s); } INF("starting client communication socket...\n"); if (socket_init()) { ERR("unable to start socket communication\n"); return -1; } /* set sensor values & start monitoring */ INF("configuring initial sensor value...\n"); if (sensor_configure_all()) { ERR("Unable to configure HWMON sensors\n"); return -1; } /* finally stop and wait for the server thread to * shutdown (ie a catostrophic error has occured) */ socket_wait(); INF("thermal manager going down!\n"); free(opt_c); if (opt_s) { free(opt_s); } return 0; }
static void gui_restore_callback (Gimp *gimp, GimpInitStatusFunc status_callback) { GimpDisplayConfig *display_config = GIMP_DISPLAY_CONFIG (gimp->config); GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config); if (gimp->be_verbose) g_print ("INIT: %s\n", G_STRFUNC); gui_vtable_init (gimp); if (! gui_config->show_tooltips) gimp_help_disable_tooltips (); g_signal_connect (gui_config, "notify::show-tooltips", G_CALLBACK (gui_show_tooltips_notify), gimp); gimp_dialogs_show_help_button (gui_config->use_help && gui_config->show_help_button); g_signal_connect (gui_config, "notify::use-help", G_CALLBACK (gui_show_help_button_notify), gimp); g_signal_connect (gui_config, "notify::user-manual-online", G_CALLBACK (gui_user_manual_notify), gimp); g_signal_connect (gui_config, "notify::show-help-button", G_CALLBACK (gui_show_help_button_notify), gimp); g_signal_connect (gimp_get_user_context (gimp), "display-changed", G_CALLBACK (gui_display_changed), gimp); /* make sure the monitor resolution is valid */ if (display_config->monitor_res_from_gdk || display_config->monitor_xres < GIMP_MIN_RESOLUTION || display_config->monitor_yres < GIMP_MIN_RESOLUTION) { gdouble xres, yres; gimp_get_monitor_resolution (initial_screen, initial_monitor, &xres, &yres); g_object_set (gimp->config, "monitor-xresolution", xres, "monitor-yresolution", yres, "monitor-resolution-from-windowing-system", TRUE, NULL); } actions_init (gimp); menus_init (gimp, global_action_factory); gimp_render_init (gimp); dialogs_init (gimp, global_menu_factory); gimp_clipboard_init (gimp); gimp_clipboard_set_buffer (gimp, gimp->global_buffer); g_signal_connect (gimp, "buffer-changed", G_CALLBACK (gui_global_buffer_changed), NULL); gimp_devices_init (gimp); gimp_controllers_init (gimp); session_init (gimp); g_type_class_unref (g_type_class_ref (GIMP_TYPE_COLOR_SELECTOR_PALETTE)); status_callback (NULL, _("Tool Options"), 1.0); gimp_tools_restore (gimp); }
void server_init( char* conf_file_name, int map_szx, int map_szy, int tdepth, int speed_min, int speed_max, int apple_map_ratio, int apple_pl_ratio, int wall_map_ratio, int wall_pl_ratio, char* balname ) { int i; rand_seed = (unsigned int) time( NULL ); srand( (unsigned int) time( NULL ) ); conf_t* c = conf_create(); assert(c); conf_parse_file( c, conf_file_name ); /* server */ sv.port = conf_get_int( c, "server.port" ); //sv.num_threads = conf_get_int( c, "server.number_of_threads" ); sv.update_interval = conf_get_int( c, "server.update_interval" ); sv.stats_interval = conf_get_int( c, "server.stats_interval" ); assert( sv.port > 1023 ); assert( sv.num_threads > 0 && sv.num_threads <= MAX_THREADS ); assert( sv.update_interval > 0 ); assert( sv.stats_interval > 0 ); /* quests */ sv.quest_between = conf_get_int( c, "server.quest_between" ); sv.quest_length = conf_get_int( c, "server.quest_length" ); assert( sv.quest_between > 0 && sv.quest_length > 0 ); assert( sv.quest_between > sv.update_interval && sv.quest_length > sv.update_interval ); /* initialize clients array */ sv.n_clients = 0; sv.clients = new tm_p_tm_sv_client_t[MAX_ENTITIES]; assert( sv.clients ); /* initialize world */ server_traces_init(); actions_init( c ); server_init_multiple_actions(); entity_types_init( c ); // override the speed settings read from the config file entity_types[ ET_PLAYER ]->attr_types[ PL_SPEED ].min = speed_min; entity_types[ ET_PLAYER ]->attr_types[ PL_SPEED ].max = speed_max; // override the ratio settings read from the config file entity_types[ ET_APPLE ]->ratio = apple_map_ratio; entity_types[ ET_APPLE ]->pl_ratio = apple_pl_ratio; entity_types[ ET_WALL ]->ratio = wall_map_ratio; entity_types[ ET_WALL ]->pl_ratio = wall_pl_ratio; tm_worldmap_init( c, map_szx, map_szy, tdepth ); server_init_quests(); tm_worldmap_generate(); tm_worldmap_is_valid(); /* //burceam: if heuristic1 is turned on, allocate structures for feedback/info sv.h1_dbg_num_ent = NULL; sv.h1_dbg_num_set = NULL; //temporarily turned it always on, for potential study; //if (sv.heuristic1 != 0) { sv.h1_dbg_num_ent = (int *) malloc (sv.wl_cycles * sizeof (int)); sv.h1_dbg_num_set = (int *) malloc (sv.wl_cycles * sizeof (int)); assert ((sv.h1_dbg_num_ent != NULL) && (sv.h1_dbg_num_set != NULL)); int i; for (i = 0; i < sv.wl_cycles; i++) { sv.h1_dbg_num_ent [i] = 0; sv.h1_dbg_num_set [i] = 0; } } //burceam: for heuristic 2, hopefully temporary //note that this may need to be resized at some point: new players may join, //and existing players can drop out. //change_grain_to_entity_for_h3 is obviously meant to be used by heuristic h3. { sv.change_grain_to_entity = (unsigned char *) malloc (sv.wl_client_count * sizeof (unsigned char)); sv.change_grain_to_entity_for_h3 = (unsigned char *) malloc (sv.wl_client_count * sizeof (unsigned char)); int i; for (i = 0; i < sv.wl_client_count; i ++) { sv.change_grain_to_entity [i] = 0; sv.change_grain_to_entity_for_h3 [i] = 0; } } //burceam: this field is used for debugging sv.num_invocations_collision_detection [0] = 0; sv.num_invocations_collision_detection [1] = 0; sv.num_invocations_collision_detection [2] = 0; sv.num_invocations_collision_detection [3] = 0; //burceam: create and initialize the list of area node h_meta pointers. //this MUST be done after tm_worldmap_init(), where I think the area node tree is created //and initialized. We need the depth here. { int i, num_area_nodes = 1; //IMPORTANT: the _actual_ depth of the tree is tdepth+1 !! //root is level "depth", and they keep building until level reaches 0, including for 0! //(nodes at level 0 are the leaves). So for depth=8 entered on cmd line, we really have 9 levels. num_area_nodes = 1 << (tm_wm.depth + 1); sv.hmeta_list = (ptr_t *) malloc (num_area_nodes * sizeof (ptr_t)); for (i = 0; i < num_area_nodes; i++) sv.hmeta_list [i] = NULL; } */ /* initialize synthetic workload */ server_generate_workload(); tm_worldmap_is_valid(); loadb_init( balname ); /* initialize syncronization & server threads */ barrier_init( &sv.barrier, sv.num_threads ); server_stats_init(); sv.done = 0; svts = (server_thread_t*) malloc( sv.num_threads * sizeof(server_thread_t) ); for( i = 0; i < sv.num_threads; ++i ) server_thread_init( &svts[i], i ); log_info( "[I] Server init done.\n" ); }