int main (int argc, char **argv) { BASE_DIR = argv[1]; LOG_DIR = argv[2]; VERBOSITY = atoi(argv[3]); char *command = argv[4]; char *param = argv[5]; // Setup char *db = o_printf("%s/openDIAS.sqlite3", BASE_DIR); o_log(DEBUGM,"database file is %s",db); if(open_db (db)) { o_log(ERROR, "Could not connect to the database."); free(db); exit(EXIT_FAILURE); } free(db); locale_init( "en" ); // Let's do the work o_log( INFORMATION, "Worker started and ready to process: %s", command); sane_worker( command, param ); // Finish up now close_all(); exit(EXIT_SUCCESS); }
int main(void) { init(); // APP_LOG(APP_LOG_LEVEL_DEBUG, "Done initializing, pushed window: %p", window); locale_init(); app_event_loop(); deinit(); }
void handle_init(void) { status_bar_init(); #ifdef PBL_ROUND round_bottom_bar_init(); #endif settings_init(); locale_init(); stations_init(); favorites_init(); message_init(); ui_push_window(new_window_main_menu()); }
int main(void) { locale_init(); handle_init(); app_event_loop(); if(launch_reason() == APP_LAUNCH_TIMELINE_ACTION) { //lastIdFromAppLaunch = (int)launch_get_args(); // Start voice dictation UI //dictation_session_start(s_dictation_session); } handle_deinit(); }
int main(int argc, char **argv) { int err = 0; lua_State *L; setup_signal_handler(); /* parse args once to read config file location */ if (parse_args(argc, argv, &err) != 0) { return err; } /* ini file sets defaults for arguments*/ parse_config(inifile); if (!global.inifile) { log_error("could not open ini configuration %s\n", inifile); } /* parse arguments again, to override ini file */ parse_args(argc, argv, &err); log_open(logfile); locale_init(); #ifdef CRTDBG init_crtdbg(); #endif L = lua_init(); game_init(); bind_monsters(L); err = eressea_run(L, luafile); if (err) { log_error("script %s failed with code %d\n", luafile, err); return err; } #ifdef MSPACES malloc_stats(); #endif game_done(); lua_done(L); log_close(); if (global.inifile) { iniparser_freedict(global.inifile); } return 0; }
int main(int argc, char **argv) { int err, result = 0; lua_State *L; setup_signal_handler(); parse_config(inifile); log_open(logfile); err = parse_args(argc, argv, &result); if (err) { return result; } locale_init(); #ifdef CRTDBG init_crtdbg(); #endif L = lua_init(); game_init(); register_races(); register_borders(); register_spells(); bind_monsters(L); err = eressea_run(L, luafile); if (err) { log_error("server execution failed with code %d\n", err); return err; } #ifdef MSPACES malloc_stats(); #endif game_done(); lua_done(L); log_close(); if (global.inifile) { iniparser_free(global.inifile); } return 0; }
int main(int argc, char **argv) { int err = 0; lua_State *L; dictionary *d = 0; setup_signal_handler(); message_handle_missing(MESSAGE_MISSING_REPLACE); /* parse arguments again, to override ini file */ err = parse_args(argc, argv); if (err != 0) { return (err > 0) ? 0 : err; } d = parse_config(inifile); if (!d) { log_error("could not open ini configuration %s\n", inifile); } locale_init(); L = lua_init(d); game_init(); bind_monsters(L); err = eressea_run(L, luafile); if (err) { log_error("script %s failed with code %d\n", luafile, err); return err; } game_done(); lua_done(L); log_close(); stats_write(stdout, ""); stats_close(); if (d) { iniparser_freedict(d); } return 0; }
static void init(void) { config_load(); #ifdef ENABLE_LOCALIZE locale_init(); #endif heartrate_init(); s_gpsdata.heartrate = 255; // no data at startup bg_color_data_main = BG_COLOR_DATA_MAIN; #ifdef ENABLE_NAVIGATION_FULL for (uint16_t i = 0; i < NAV_NB_POINTS_STORAGE - 1; i++) { s_gpsdata.nav_xpos[i] = s_gpsdata.nav_ypos[i] = INT16_MAX; } #endif #ifdef ENABLE_DEBUG_FIELDS_SIZE strcpy(s_data.speed, "188.8"); strcpy(s_data.distance, "88.8"); strcpy(s_data.avgspeed, "888.8"); strcpy(s_data.altitude, "888.8"); strcpy(s_data.ascent, "1342"); strcpy(s_data.ascentrate, "548"); strcpy(s_data.slope, "5"); strcpy(s_data.accuracy, "9"); strcpy(s_data.bearing, "270"); strcpy(s_data.elapsedtime, "1:05:28"); strcpy(s_data.maxspeed, "25.3"); strcpy(s_data.heartrate, "128"); strcpy(s_data.cadence, "90"); #endif #ifdef ENABLE_DEMO strcpy(s_data.maxspeed, "26.1"); strcpy(s_data.distance, "2.0"); strcpy(s_data.avgspeed, "14.0"); strcpy(s_data.altitude, "1139"); strcpy(s_data.accuracy, "4"); strcpy(s_data.steps, "7548"); strcpy(s_data.elapsedtime, "1:15:28"); strcpy(s_data.heartrate, "154"); s_gpsdata.heartrate = 154; heartrate_new_data(s_gpsdata.heartrate); s_data.live = 1; s_data.state = STATE_START; s_gpsdata.nav_distance_to_destination100 = 12100; s_gpsdata.nav_next_distance1000 = 1345; s_gpsdata.nav_error1000 = 55; snprintf(s_data.nav_next_distance, sizeof(s_data.nav_next_distance), "%d", s_gpsdata.nav_next_distance1000); #else strcpy(s_data.speed, "0.0"); strcpy(s_data.distance, "-"); strcpy(s_data.avgspeed, "-"); strcpy(s_data.altitude, "-"); strcpy(s_data.ascent, "-"); strcpy(s_data.ascentrate, "-"); strcpy(s_data.slope, "-"); strcpy(s_data.accuracy, "-"); strcpy(s_data.bearing, "-"); strcpy(s_data.elapsedtime, "00:00:00"); strcpy(s_data.maxspeed, "-"); strcpy(s_data.heartrate, "-"); strcpy(s_data.cadence, "-"); strcpy(s_data.nav_next_distance, "-"); strcpy(s_data.nav_distance_to_destination, "-"); strcpy(s_data.nav_ttd, "-"); strcpy(s_data.nav_eta, "-"); #endif //strcpy(s_data.lat, "-"); //strcpy(s_data.lon, "-"); //strcpy(s_data.nbascent, "-"); s_data.phone_battery_level = -1; #ifdef PBL_PLATFORM_CHALK font_roboto_bold_16 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_16)); #endif font_roboto_bold_62 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_62)); // set default unit of measure change_units(UNITS_IMPERIAL, true); buttons_init(); s_data.window = window_create(); window_set_background_color(s_data.window, BG_COLOR_WINDOW); #ifdef PBL_SDK_2 window_set_fullscreen(s_data.window, true); #endif topbar_layer_init(s_data.window); screen_data_layer_init(s_data.window); //screen_altitude_layer_init(s_data.window); #ifdef ENABLE_FUNCTION_LIVE screen_live_layer_init(s_data.window); #endif screen_map_layer_init(s_data.window); #ifdef PRODUCTION #ifndef ENABLE_DEMO screen_reset_instant_data(); #endif #endif action_bar_init(s_data.window); menu_init(); // Reduce the sniff interval for more responsive messaging at the expense of // increased energy consumption by the Bluetooth module // The sniff interval will be restored by the system after the app has been // unloaded //app_comm_set_sniff_interval(SNIFF_INTERVAL_REDUCED); communication_init(); screen_data_update_config(true); //screen_altitude_update_config(); graph_init(); window_stack_push(s_data.window, true /* Animated */); tick_timer_service_subscribe(MINUTE_UNIT, handle_tick); bluetooth_connection_service_subscribe(bt_callback); send_version(true); }
/** Main function. Parses options and calls helper function for any heavy lifting. */ int main (int argc, char *argv[]) { int input_type=FILEDATA; int output_type=MIMETYPE; const char *mimetype; char *output=0; int i; hash_table_t launch_hash; locale_init(); /* Parse options */ while( 1 ) { static struct option long_options[] = { { "input-file-data", no_argument, 0, 't' } , { "input-filename", no_argument, 0, 'f' } , { "input-mime", no_argument, 0, 'i' } , { "output-mime", no_argument, 0, 'm' } , { "output-description", no_argument, 0, 'd' } , { "output-action", no_argument, 0, 'a' } , { "help", no_argument, 0, 'h' } , { "version", no_argument, 0, 'v' } , { "launch", no_argument, 0, 'l' } , { 0, 0, 0, 0 } } ; int opt_index = 0; int opt = getopt_long( argc, argv, GETOPT_STRING, long_options, &opt_index ); if( opt == -1 ) break; switch( opt ) { case 0: break; case 't': input_type=FILEDATA; break; case 'f': input_type=FILENAME; break; case 'i': input_type=MIMETYPE; break; case 'm': output_type=MIMETYPE; break; case 'd': output_type=DESCRIPTION; break; case 'a': output_type=ACTION; break; case 'l': output_type=LAUNCH; break; case 'h': print_help( argv[0], 1 ); exit(0); case 'v': printf( _("%s, version %s\n"), MIMEDB, PACKAGE_VERSION ); exit( 0 ); case '?': return 1; } } if( ( output_type == LAUNCH )&&(input_type==MIMETYPE)) { fprintf( stderr, _("%s: Can not launch a mimetype\n"), MIMEDB ); print_help( argv[0], 2 ); exit(1); } if( output_type == LAUNCH ) hash_init( &launch_hash, &hash_str_func, &hash_str_cmp ); /* Loop over all non option arguments and do the specified lookup */ //fprintf( stderr, "Input %d, output %d\n", input_type, output_type ); for (i = optind; (i < argc)&&(!error); i++) { /* Convert from filename to mimetype, if needed */ if( input_type == FILENAME ) { mimetype = xdg_mime_get_mime_type_from_file_name(argv[i]); } else if( input_type == FILEDATA ) { mimetype = xdg_mime_get_mime_type_for_file(argv[i]); } else mimetype = xdg_mime_is_valid_mime_type(argv[i])?argv[i]:0; mimetype = xdg_mime_unalias_mime_type (mimetype); if( !mimetype ) { fprintf( stderr, _( "%s: Could not parse mimetype from argument '%s'\n"), MIMEDB, argv[i] ); error=1; return 1; } /* Convert from mimetype to whatever, if needed */ switch( output_type ) { case MIMETYPE: { output = (char *)mimetype; break; } case DESCRIPTION: { output = get_description( mimetype ); if( !output ) output = strdup( _("Unknown") ); break; } case ACTION: { output = get_action( mimetype ); break; } case LAUNCH: { /* There may be more files using the same launcher, we add them all up in little array_list_ts and launched them together after all the arguments have been parsed. */ array_list_t *l= (array_list_t *)hash_get( &launch_hash, mimetype ); output = 0; if( !l ) { l = my_malloc( sizeof( array_list_t ) ); if( l == 0 ) { break; } al_init( l ); hash_put( &launch_hash, mimetype, l ); } al_push( l, argv[i] ); } } /* Print the glorious result */ if( output ) { printf( "%s\n", output ); if( output != mimetype ) free( output ); } output = 0; } /* Perform the actual launching */ if( output_type == LAUNCH && !error ) { int i; array_list_t mimes; al_init( &mimes ); hash_get_keys( &launch_hash, &mimes ); for( i=0; i<al_get_count( &mimes ); i++ ) { char *mimetype = (char *)al_get( &mimes, i ); array_list_t *files = (array_list_t *)hash_get( &launch_hash, mimetype ); if( !files ) { fprintf( stderr, _( "%s: Unknown error\n"), MIMEDB ); error=1; break; } char *launcher = get_action( mimetype ); if( launcher ) { launch( launcher, files, 0 ); free( launcher ); } } hash_foreach( &launch_hash, &clear_entry ); hash_destroy( &launch_hash ); al_destroy( &mimes ); } if( launch_buff ) free( launch_buff ); if( start_re ) { regfree( start_re ); regfree( stop_re ); free( start_re ); free( stop_re ); } xdg_mime_shutdown(); return error; }
/** Main function. Parses options and calls helper function for any heavy lifting. */ int main (int argc, char *argv[]) { int input_type=FILEDATA; int output_type=MIMETYPE; const char *mimetype; char *output=0; int i; typedef std::map<std::string, string_list_t> launch_hash_t; launch_hash_t launch_hash; locale_init(); /* Parse options */ while( 1 ) { static struct option long_options[] = { { "input-file-data", no_argument, 0, 't' } , { "input-filename", no_argument, 0, 'f' } , { "input-mime", no_argument, 0, 'i' } , { "output-mime", no_argument, 0, 'm' } , { "output-description", no_argument, 0, 'd' } , { "output-action", no_argument, 0, 'a' } , { "help", no_argument, 0, 'h' } , { "version", no_argument, 0, 'v' } , { "launch", no_argument, 0, 'l' } , { 0, 0, 0, 0 } } ; int opt_index = 0; int opt = getopt_long( argc, argv, GETOPT_STRING, long_options, &opt_index ); if( opt == -1 ) break; switch( opt ) { case 0: break; case 't': input_type=FILEDATA; break; case 'f': input_type=FILENAME; break; case 'i': input_type=MIMETYPE; break; case 'm': output_type=MIMETYPE; break; case 'd': output_type=DESCRIPTION; break; case 'a': output_type=ACTION; break; case 'l': output_type=LAUNCH; break; case 'h': print_help( argv[0], 1 ); exit(0); case 'v': printf( _("%s, version %s\n"), MIMEDB, PACKAGE_VERSION ); exit( 0 ); case '?': return 1; } } if( ( output_type == LAUNCH )&&(input_type==MIMETYPE)) { fprintf( stderr, _("%s: Can not launch a mimetype\n"), MIMEDB ); print_help( argv[0], 2 ); exit(1); } /* Loop over all non option arguments and do the specified lookup */ //fprintf( stderr, "Input %d, output %d\n", input_type, output_type ); for (i = optind; (i < argc)&&(!error); i++) { /* Convert from filename to mimetype, if needed */ if( input_type == FILENAME ) { mimetype = xdg_mime_get_mime_type_from_file_name(argv[i]); } else if( input_type == FILEDATA ) { mimetype = xdg_mime_get_mime_type_for_file(argv[i]); } else mimetype = xdg_mime_is_valid_mime_type(argv[i])?argv[i]:0; mimetype = xdg_mime_unalias_mime_type (mimetype); if( !mimetype ) { fprintf( stderr, _( "%s: Could not parse mimetype from argument '%s'\n"), MIMEDB, argv[i] ); error=1; return 1; } /* Convert from mimetype to whatever, if needed */ switch( output_type ) { case MIMETYPE: { output = (char *)mimetype; break; } case DESCRIPTION: { output = get_description( mimetype ); if( !output ) output = strdup( _("Unknown") ); break; } case ACTION: { output = get_action( mimetype ); break; } case LAUNCH: { /* There may be more files using the same launcher, we add them all up in little array_list_ts and launched them together after all the arguments have been parsed. */ output = 0; string_list_t &l = launch_hash[mimetype]; l.push_back(argv[i]); } } /* Print the glorious result */ if( output ) { printf( "%s\n", output ); if( output != mimetype ) free( output ); } output = 0; } /* Perform the actual launching */ if( output_type == LAUNCH && !error ) { for( launch_hash_t::iterator iter = launch_hash.begin(); iter != launch_hash.end(); ++iter) { const char *mimetype = iter->first.c_str(); string_list_t &files = iter->second; char *launcher = get_action( mimetype ); if( launcher ) { launch( launcher, files, 0 ); free( launcher ); } } } if( launch_buff ) free( launch_buff ); if( start_re ) { regfree( start_re ); regfree( stop_re ); free( start_re ); free( stop_re ); } xdg_mime_shutdown(); return error; }
int main(void) { locale_init(); handle_init(); app_event_loop(); handle_deinit(); }
int main (void) { locale_init("en"); return mu_run_tests(&all_tests, "Print status"); }