int main(int argc, char *argv[]) { static const struct option longopts[] = { { "colors", optional_argument, 0, 'c' }, { NULL, 0, 0, 0 } }; int c, mode = UL_COLORMODE_NEVER; /* default */ while ((c = getopt_long(argc, argv, "c::", longopts, NULL)) != -1) { switch (c) { case 'c': mode = UL_COLORMODE_AUTO; if (optarg) { mode = colormode_or_err(optarg, "unsupported color mode"); printf("%d\n", mode); } printf("%s\n", optarg); break; } } colors_init(mode); color_enable(UL_COLOR_RED); printf("Hello World!\n"); color_disable(); color_enable(UL_COLOR_GREEN); printf("Hello World!\n"); color_disable(); return EXIT_SUCCESS; }
void initializeModules(void) { frameSize frame; // Sets up the camera to 320x240 frame.imageWidth = DEFAULT_IMAGE_WIDTH; frame.imageHeight = DEFAULT_IMAGE_HEIGHT; init_heap(); io_initPeriphery(); // Initialise LED, GPIO, serial flow & lasers, srv_initRobotFunctions(); // motor PWM and IR receiver timers systemTime_init(); timer_init(); uart_uart0Init(UART0_BAUDRATE); uart_uart1Init(UART1_BAUDRATE); //uart_uart2Init(); clear_sdram(); // Clears from 0x00100000 to 0x02000000 camera_setup(frame); colors_init(); // Dependent on camera setup srv_initVariables(); // Dependent on camera setup }
static void sfdisk_init(struct sfdisk *sf) { fdisk_init_debug(0); sfdiskprog_init_debug(); colors_init(UL_COLORMODE_UNDEF, "sfdisk"); sf->cxt = fdisk_new_context(); if (!sf->cxt) err(EXIT_FAILURE, _("failed to allocate libfdisk context")); fdisk_set_ask(sf->cxt, ask_callback, (void *) sf); if (sf->label_nested) { struct fdisk_context *x = fdisk_new_nested_context(sf->cxt, sf->label_nested); if (!x) err(EXIT_FAILURE, _("failed to allocate nested libfdisk context")); /* the original context is available by fdisk_get_parent() */ sf->cxt = x; } }
int main(int argc, char *argv[]) { gchar *filename; gboolean default_used; GtkWidget *notebook; GtkActionGroup *action_group; GtkUIManager *ui_manager; GtkWidget *vbox; GtkWidget *menubar; GtkAccelGroup *accel_group; GError *error = NULL; gchar *icon_file; GOptionContext *context; default_game = g_build_filename(get_pioneers_dir(), "default.game", NULL); /* Gtk+ handles the locale, we must bind the translations */ setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); bind_textdomain_codeset(PACKAGE, "UTF-8"); GtkOSXApplication *theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL); context = /* Long description in the command line: --help */ g_option_context_new(_("- Editor for games of Pioneers")); g_option_context_add_main_entries(context, commandline_entries, GETTEXT_PACKAGE); g_option_context_add_group(context, gtk_get_option_group(TRUE)); g_option_context_parse(context, &argc, &argv, &error); if (error != NULL) { g_print("%s\n", error->message); g_error_free(error); return 1; } if (show_version) { g_print(_("Pioneers version:")); g_print(" "); g_print(FULL_VERSION); g_print("\n"); return 0; } if (filenames != NULL) filename = g_strdup(filenames[0]); else filename = NULL; toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(toplevel), "delete_event", G_CALLBACK(exit_cb), NULL); action_group = gtk_action_group_new("MenuActions"); gtk_action_group_set_translation_domain(action_group, PACKAGE); gtk_action_group_add_actions(action_group, entries, G_N_ELEMENTS(entries), toplevel); ui_manager = gtk_ui_manager_new(); gtk_ui_manager_insert_action_group(ui_manager, action_group, 0); accel_group = gtk_ui_manager_get_accel_group(ui_manager); gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_group); error = NULL; if (!gtk_ui_manager_add_ui_from_string(ui_manager, ui_description, -1, &error)) { g_message(_("Building menus failed: %s"), error->message); g_error_free(error); return 1; } config_init("pioneers-editor"); icon_file = g_build_filename(g_get_user_runtime_dir(), "pixmaps", MAINICON_FILE, NULL); if (g_file_test(icon_file, G_FILE_TEST_EXISTS)) { gtk_window_set_default_icon_from_file(icon_file, NULL); } else { /* Missing pixmap, main icon file */ g_warning("Pixmap not found: %s", icon_file); } g_free(icon_file); themes_init(); colors_init(); notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), build_map(), /* Tab page name */ gtk_label_new(_("Map"))); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), build_settings(GTK_WINDOW(toplevel)), /* Tab page name */ gtk_label_new(_("Settings"))); terrain_menu = build_terrain_menu(); roll_menu = build_roll_menu(); port_menu = build_port_menu(); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(toplevel), vbox); menubar = gtk_ui_manager_get_widget(ui_manager, "/MainMenu"); gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); if (filename == NULL) { filename = config_get_string("editor/last-game", &default_used); if (default_used || !g_file_test(filename, G_FILE_TEST_EXISTS)) { g_free(filename); filename = NULL; } } load_game(filename, FALSE); g_free(filename); if (params == NULL) return 1; gtk_widget_show_all(toplevel); gtk_accel_map_load(g_getenv("ACCEL_MAP")); gtk_widget_hide (menubar); gtk_osxapplication_set_menu_bar(theApp, GTK_MENU_SHELL(menubar)); gtk_osxapplication_ready(theApp); gtk_main(); config_finish(); guimap_delete(gmap); g_free(default_game); g_option_context_free(context); return 0; }
int main(int argc, char **argv) { int i, c, act = ACT_FDISK; int colormode = UL_COLORMODE_AUTO; struct fdisk_context *cxt; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); atexit(close_stdout); fdisk_init_debug(0); cxt = fdisk_new_context(); if (!cxt) err(EXIT_FAILURE, _("failed to allocate libfdisk context")); fdisk_context_set_ask(cxt, ask_callback, NULL); while ((c = getopt(argc, argv, "b:c::C:hH:lL::sS:t:u::vV")) != -1) { switch (c) { case 'b': { size_t sz = strtou32_or_err(optarg, _("invalid sector size argument")); if (sz != 512 && sz != 1024 && sz != 2048 && sz != 4096) usage(stderr); fdisk_save_user_sector_size(cxt, sz, sz); break; } case 'C': fdisk_save_user_geometry(cxt, strtou32_or_err(optarg, _("invalid cylinders argument")), 0, 0); break; case 'c': if (optarg) { /* this setting is independent on the current * actively used label */ struct fdisk_label *lb = fdisk_context_get_label(cxt, "dos"); if (!lb) err(EXIT_FAILURE, _("not found DOS label driver")); if (strcmp(optarg, "=dos") == 0) fdisk_dos_enable_compatible(lb, TRUE); else if (strcmp(optarg, "=nondos") == 0) fdisk_dos_enable_compatible(lb, FALSE); else usage(stderr); } /* use default if no optarg specified */ break; case 'H': fdisk_save_user_geometry(cxt, 0, strtou32_or_err(optarg, _("invalid heads argument")), 0); break; case 'S': fdisk_save_user_geometry(cxt, 0, 0, strtou32_or_err(optarg, _("invalid sectors argument"))); break; case 'l': act = ACT_LIST; break; case 'L': if (optarg) colormode = colormode_or_err(optarg, _("unsupported color mode")); break; case 's': act = ACT_SHOWSIZE; break; case 't': { struct fdisk_label *lb = NULL; while (fdisk_context_next_label(cxt, &lb) == 0) fdisk_label_set_disabled(lb, 1); lb = fdisk_context_get_label(cxt, optarg); if (!lb) errx(EXIT_FAILURE, _("unsupported disklabel: %s"), optarg); fdisk_label_set_disabled(lb, 0); } case 'u': if (optarg && *optarg == '=') optarg++; if (fdisk_context_set_unit(cxt, optarg) != 0) usage(stderr); break; case 'V': case 'v': printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': usage(stdout); default: usage(stderr); } } if (argc-optind != 1 && fdisk_has_user_device_properties(cxt)) warnx(_("The device properties (sector size and geometry) should" " be used with one specified device only.")); colors_init(colormode); switch (act) { case ACT_LIST: fdisk_context_enable_listonly(cxt, 1); if (argc > optind) { int k; for (k = optind; k < argc; k++) print_device_pt(cxt, argv[k]); } else print_all_devices_pt(cxt); break; case ACT_SHOWSIZE: /* deprecated */ if (argc - optind <= 0) usage(stderr); for (i = optind; i < argc; i++) { if (argc - optind == 1) printf("%llu\n", get_dev_blocks(argv[i])); else printf("%s: %llu\n", argv[i], get_dev_blocks(argv[i])); } break; case ACT_FDISK: if (argc-optind != 1) usage(stderr); if (fdisk_context_assign_device(cxt, argv[optind], 0) != 0) err(EXIT_FAILURE, _("cannot open %s"), argv[optind]); /* Here starts interactive mode, use fdisk_{warn,info,..} functions */ color_enable(UL_COLOR_GREEN); fdisk_info(cxt, _("Welcome to fdisk (%s)."), PACKAGE_STRING); color_disable(); fdisk_info(cxt, _("Changes will remain in memory only, until you decide to write them.\n" "Be careful before using the write command.\n")); fflush(stdout); if (!fdisk_dev_has_disklabel(cxt)) { fdisk_warnx(cxt, _("Device does not contain a recognized partition table.")); fdisk_create_disklabel(cxt, NULL); } while (1) process_fdisk_menu(&cxt); } fdisk_free_context(cxt); return EXIT_SUCCESS; }