Exemplo n.º 1
0
static void
init(void)
{
    GtkBuilder* builder = gtk_builder_new();
    gtk_builder_add_from_file(builder, UI_FILE, NULL);
    main_wnd = GTK_WIDGET(gtk_builder_get_object(builder, "settings_dialog"));

    RETRIEVE(trigger_ctrl_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(english_ctrl_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(trigger_shift_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(english_shift_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(trigger_combo, GTK_COMBO_BOX);
    RETRIEVE(english_combo, GTK_COMBO_BOX);
    RETRIEVE(background_color_btn, GTK_COLOR_BUTTON);
    RETRIEVE(font_btn, GTK_FONT_BUTTON);
    RETRIEVE(font_color_btn, GTK_COLOR_BUTTON);
    RETRIEVE(opacity_value, GTK_ADJUSTMENT);
    RETRIEVE(ncandidates, GTK_ADJUSTMENT);

    init_settings();
    
    gtk_builder_connect_signals(builder, NULL);
    
    g_object_unref(builder);
}
Exemplo n.º 2
0
login_dialog::login_dialog() : QDialog(0)
{
  QVBoxLayout* top_layout = new QVBoxLayout(this);
  QGridLayout* grid = new QGridLayout();
  top_layout->addLayout(grid);

  int row=0;
  grid->addWidget(new QLabel(tr("Database name:"), this), row, 0);
  m_dbname = new QComboBox(this);
  m_dbname->setEditable(true);
  grid->addWidget(m_dbname, row, 1);
  row++;

  grid->addWidget(new QLabel(tr("Login:"******"Password:"******"Host:"), this), row, 0);
  m_host = new QLineEdit(this);
  grid->addWidget(m_host, row, 1);
  row++;

  grid->addWidget(new QLabel(tr("More parameters:"), this), row, 0);
  m_params = new QLineEdit(this);
  grid->addWidget(m_params, row, 1);
  row++;

  QHBoxLayout* hbox = new QHBoxLayout();
  top_layout->addLayout(hbox);

  hbox->setMargin(10);
  hbox->setSpacing(20);
  QPushButton* wok = new QPushButton(tr("OK"), this);
  QPushButton* whelp = new QPushButton(tr("Help"), this);
  QPushButton* wcancel = new QPushButton(tr("Cancel"), this);
  hbox->addWidget(wok);
  hbox->addWidget(whelp);
  hbox->addWidget(wcancel);
  connect(wok, SIGNAL(clicked()), this, SLOT(ok()));
  connect(wcancel, SIGNAL(clicked()), this, SLOT(reject()));
  connect(whelp, SIGNAL(clicked()), this, SLOT(help()));

  setWindowTitle(tr("Connect to a manitou database"));
  setWindowIcon(UI_ICON(ICON16_DISCONNECT));

  init_settings();
  set_focus();
}
Exemplo n.º 3
0
/*!
 * \brief DialogSettings::DialogSettings
 * \param parent
 *
 * DialogSettings
 */
DialogSettings::DialogSettings(QWidget *parent) :
    QDialog(parent)
{
    if (DEBUG) cout << Q_FUNC_INFO << endl;

    init_var();
    init_win();
    init_sig();
    init_css();

    init_settings();
}
Exemplo n.º 4
0
void interface (gint argc, gchar *argv[])
{
  GtkWidget *MenuBar;
  GtkWidget *VBox;
  GtkWidget *HandleBox;

  gtk_set_locale();  
  gtk_init (&argc, &argv);
  Settings = init_settings ();
  MainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW(MainWindow), g_strconcat
			(WELCOME_MSG, " ", APP_NAME, " ",
			 VERSION_NUMBER, NULL));
  gtk_window_set_policy (GTK_WINDOW(MainWindow), TRUE, TRUE, FALSE);
  gtk_widget_set_usize (MainWindow, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT);
  gtk_signal_connect (GTK_OBJECT(MainWindow), "delete_event",
		      (GtkSignalFunc) quit, NULL); 
  gtk_signal_connect (GTK_OBJECT(MainWindow), "destroy",
		      (GtkSignalFunc) quit, NULL);
  FileProperties = g_array_new (TRUE, FALSE, sizeof(t_fprops));
  VBox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER(MainWindow), VBox);
  HandleBox = gtk_handle_box_new();
  gtk_container_set_border_width (GTK_CONTAINER(HandleBox), 2);
  gtk_box_pack_start (GTK_BOX(VBox), HandleBox, FALSE, FALSE, 0);
  init_toolbar (GTK_BOX(VBox));
  MainNotebook = gtk_notebook_new ();
  read_uedit_wordfile (WORDFILE);
  editor_init();
  MenuBar = menubar_new (MainWindow);
  gtk_container_add (GTK_CONTAINER(HandleBox), MenuBar);
  gtk_notebook_popup_enable (GTK_NOTEBOOK(MainNotebook));
  gtk_notebook_set_homogeneous_tabs (GTK_NOTEBOOK(MainNotebook), TRUE);
  gtk_notebook_set_scrollable (GTK_NOTEBOOK(MainNotebook), TRUE);
  gtk_box_pack_start (GTK_BOX(VBox), MainNotebook, TRUE, TRUE, 0);
  gtk_signal_connect (GTK_OBJECT(MainNotebook), "switch_page",
		      (GtkSignalFunc) set_title, NULL);
  init_msgbar (GTK_BOX(VBox));
  print_msg ("You're the welcome...");
  command_line (argc, argv);
  autosave (AUTOSAVE_DELAY);
  gtk_widget_show_all (MainWindow);
  if (!MSGBAR_DISPLAY) hide_msgbar ();
  if (!TOOLBAR_DISPLAY) hide_toolbar ();
  gtk_timeout_add (80, (GtkFunction)display_line_column, NULL);
  gtk_main ();
  set_preferences_to_disk (&Settings, NULL);
  gtk_item_factory_dump_rc (g_strconcat (g_get_home_dir (), PATH_SEP_STRING,
					 CONF_DIR, PATH_SEP_STRING,
					 "AccelRC", NULL), NULL, FALSE);
}
Exemplo n.º 5
0
int main(int argc, char **argv)
{
	run_as_emulator(argv[0]);
	init_settings();
	term_fd = open_tty();
	if (term_fd < 0) {
		printf("Unable to open I/O to terminal (/dev/tty), r=%d\n",
			term_fd);
		sleep(1);
		exit(1);
	}
	create_window(&argc, &argv);
	run_gui();
	close_serial_port();
	close(term_fd);
	return 0;
}
Exemplo n.º 6
0
void
loop_cli(struct taltos_conf *arg_conf, struct book *arg_book)
{
    trace(__func__);

    char *cmd;

    assert(arg_conf != NULL && arg_book != NULL);
    conf = arg_conf;
    book = arg_book;
    init_settings();

    setup_mutexes();

    while (true) {
        if (fgets(line, sizeof line, stdin) == NULL) {
            if (exit_on_done)
                wait_thinking();
            exit(EXIT_SUCCESS);
        }

        if (line[0] == '\0')
            continue;

        if (strlen(line) == sizeof(line) - 1)
            abort();

        line[strcspn(line, "\n\r")] = '\0';

        tracef("%s input: \"%s\"", __func__, line);

        bool is_it_move;

        if ((cmd = xstrtok_r(line, " \t\n", &line_lasts)) == NULL)
            continue;

        mtx_lock(&game_mutex);

        is_it_move = (try_read_move(cmd) == 0);

        mtx_unlock(&game_mutex);

        if (!is_it_move)
            dispatch_command(cmd);
    }
}
Exemplo n.º 7
0
/* returns the value of a setting */
int get_setting(char * setting_name, char * value)
{
	int index = -1, i, j, n, ctr;
	FILE * fp;
	char filename[BLOCK_SIZE],linestr[BLOCK_SIZE];

	value[0]=0;

	init_settings();
	settings_filename(filename);

	fp = fopen(filename,"r");
	if (!fp) return -1;
	ctr = 0;
	while (!feof(fp)) {
		if (fgets(linestr, BLOCK_SIZE-1, fp) != NULL) {
			if (strlen(linestr) == 0) continue;

			for (i = 0; i < strlen(linestr); i++) {
				if (linestr[i] == SETTINGS_SEPARATOR) {
					break;
				}
			}
			if (i < strlen(linestr)) {
				if (strncmp(linestr,setting_name,i)==0) {
					/* record the index within the file */
					index = ctr;
					/* extract the value */
					n = 0;
					for (j = i+1; j < strlen(linestr); j++) {
						if ((linestr[j] != 13) &&
							(linestr[j] != 10)) {
							value[n++] = linestr[j];
						}
					}
					value[n]=0;
					break;
				}
			}
			ctr++;
		}		
	}
	fclose(fp);
	return index;
}
Exemplo n.º 8
0
int corefs_main(int argc, char *argv[], const corefs_client_operations *op)
{

  // set all unused functions to null.
  memset(&corefs_oper, 0, sizeof(corefs_oper));
    
  // connect any functions supplied by the client.
  if (op->getattr)  corefs_oper.getattr =  op->getattr;
  if (op->read)     corefs_oper.read = op->read;
  if (op->write)    corefs_oper.write = op->write;
  if (op->readdir)  corefs_oper.readdir = op->readdir;
  if (op->mknod)    corefs_oper.mknod = op->mknod;
  if (op->truncate) corefs_oper.truncate = op->truncate;
  if (op->unlink)   corefs_oper.unlink = op->unlink;
  if (op->rename)   corefs_oper.rename = op->rename;
  if (op->symlink)  corefs_oper.symlink = op->symlink;
  if (op->readlink)  corefs_oper.readlink = op->readlink; 
  if (op->mkdir)  corefs_oper.mkdir = op->mkdir;
  if (op->rmdir)  corefs_oper.rmdir = op->rmdir;
  if (op->open)  corefs_oper.open = op->open;
  if (op->release)  corefs_oper.release = op->release;
  if (op->utime)  corefs_oper.utime = op->utime;
  if (op->chmod)  corefs_oper.chmod = op->chmod;
  if (op->link)  corefs_oper.link = op->link;
  if (op->flush)  corefs_oper.flush = op->flush;
  if (op->destroy) corefs_oper.destroy = op->destroy;
#ifdef HAVE_SETXATTR
  if (op->setxattr)  corefs_oper.setxattr = op->setxattr;
  if (op->getxattr)  corefs_oper.getxattr = op->getxattr;
  if (op->listxattr)  corefs_oper.listxattr = op->listxattr;
  if (op->removexattr)  corefs_oper.removexattr = op->removexattr;
#endif
    
  umask(0);
  init_settings(&g_ms);
  g_ms.spoof_uids = 1;
  g_ms.spoof_gids = 1;
  g_ms.cache_attr = 0; //1;
  g_ms.spoof_perms = 0; /* set to 1 to change default permission */
  g_ms.spoof_permbits = 00700;
  return fuse_main(argc, argv, &corefs_oper);
}
Exemplo n.º 9
0
static void
init(void)
{
    GtkBuilder* builder = gtk_builder_new();
    gtk_builder_add_from_file(builder, UI_FILE, NULL);
    main_wnd = GTK_WIDGET(gtk_builder_get_object(builder, "settings_dialog"));

    RETRIEVE(trigger_ctrl_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(english_ctrl_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(trigger_shift_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(english_shift_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(trigger_combo, GTK_COMBO_BOX);
    RETRIEVE(english_combo, GTK_COMBO_BOX);
    RETRIEVE(background_color_btn, GTK_COLOR_BUTTON);
    RETRIEVE(font_btn, GTK_FONT_BUTTON);
    RETRIEVE(font_color_btn, GTK_COLOR_BUTTON);
    RETRIEVE(opacity_value, GTK_ADJUSTMENT);
    RETRIEVE(ncandidates, GTK_ADJUSTMENT);
    RETRIEVE(minus_plus_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(comma_period_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(paren_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(fuzzy_seg_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(fuzzy_inner_seg_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(cancel_on_backspace_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(smart_punct_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(shuangpin_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(shuangpin_combo, GTK_COMBO_BOX);
    RETRIEVE(skin_combo, GTK_COMBO_BOX);
    RETRIEVE(hide_icbar_check, GTK_TOGGLE_BUTTON);
    RETRIEVE(punc_english_radio, GTK_TOGGLE_BUTTON);
    RETRIEVE(punc_chinese_radio, GTK_TOGGLE_BUTTON);
    RETRIEVE(half_width_radio, GTK_TOGGLE_BUTTON);
    RETRIEVE(full_width_radio, GTK_TOGGLE_BUTTON);
    RETRIEVE(lang_english_radio, GTK_TOGGLE_BUTTON);
    RETRIEVE(lang_chinese_radio, GTK_TOGGLE_BUTTON);

    init_settings();

    gtk_builder_connect_signals(builder, NULL);

    g_object_unref(builder);
}
Exemplo n.º 10
0
void load_settings(const char *filename)
{
    struct stat stat_p;
    int filehandle;
    char *buffer;
    long nread;
    XML_Parser myparse;
    
    init_settings();
    init_parsinginfo();
    
    
    myparse=XML_ParserCreate("UTF-8");
    XML_UseParserAsHandlerArg(myparse);
    XML_SetElementHandler(myparse,handlestart,handleend);
    XML_SetCharacterDataHandler(myparse,handlechar);
    
    
    
    
    filehandle=open(filename,O_RDONLY);
    if(filehandle == -1) {
        XML_ParserFree(myparse);
        return;
    }

    stat(filename,&stat_p);
    buffer=(char *)malloc(stat_p.st_size);
    nread=read(filehandle,(void *)buffer,stat_p.st_size);
    XML_Parse(myparse,buffer,nread,1);
    
    
    free(buffer);
    free_parsinginfo();
    close(filehandle);
    
    XML_ParserFree(myparse);

}
Exemplo n.º 11
0
void lutro_init()
{
   L = luaL_newstate();
   luaL_openlibs(L);

#ifdef HAVE_JIT
   luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC|LUAJIT_MODE_ON);
#endif

   lutro_checked_stack_begin();

   init_settings(L);

   lutro_preload(L, lutro_core_preload, "lutro");
   lutro_preload(L, lutro_graphics_preload, "lutro.graphics");
   lutro_preload(L, lutro_audio_preload, "lutro.audio");
   lutro_preload(L, lutro_input_preload, "lutro.input");
   lutro_preload(L, lutro_filesystem_preload, "lutro.filesystem");
   lutro_preload(L, lutro_timer_preload, "lutro.timer");
#ifdef HAVE_INOTIFY
   lutro_preload(L, lutro_live_preload, "lutro.live");
#endif

   // if any of these requires fail, the checked stack assertion at the end will
   // be triggered. remember that assertions are only avaialable in debug mode.
   lutro_require(L, "lutro", 1);
   lutro_require(L, "lutro.graphics", 1);
   lutro_require(L, "lutro.audio", 1);
   lutro_require(L, "lutro.input", 1);
   lutro_require(L, "lutro.filesystem", 1);
   lutro_require(L, "lutro.timer", 1);
#ifdef HAVE_INOTIFY
   lutro_require(L, "lutro.live", 1);
#endif

   lutro_checked_stack_assert(0);
}
Exemplo n.º 12
0
Arquivo: rqd.c Projeto: hyper/rqd
//-----------------------------------------------------------------------------
// Main... process command line parameters, and then setup our listening 
// sockets and event loop.
int main(int argc, char **argv) 
{
	system_data_t   sysdata;

///============================================================================
/// Initialization.
///============================================================================

	init_sysdata(&sysdata);
	init_settings(&sysdata);

	get_options(sysdata.settings, argc, argv);
	
	init_maxconns(&sysdata);
	init_daemon(&sysdata);
	init_events(&sysdata);
	init_logging(&sysdata);

	logger(sysdata.logging, 1, "System starting up");

	init_signals(&sysdata);
	init_buffers(&sysdata);
	init_servers(&sysdata);
	init_stats(&sysdata);
	init_risp(&sysdata);
	init_nodes(&sysdata);
	init_msglist(&sysdata);
	init_queues(&sysdata);
	init_controllers(&sysdata);


///============================================================================
/// Main Event Loop.
///============================================================================

	// enter the event loop.
	logger(sysdata.logging, 1, "Starting Event Loop");
	assert(sysdata.evbase);
	event_base_loop(sysdata.evbase, 0);
	logger(sysdata.logging, 1, "Shutdown preparations complete.  Shutting down now.");


///============================================================================
/// Shutdown
///============================================================================

	cleanup_events(&sysdata);
	cleanup_controllers(&sysdata);
	cleanup_queues(&sysdata);
	cleanup_msglist(&sysdata);
	cleanup_nodes(&sysdata);
	cleanup_risp(&sysdata);
	cleanup_stats(&sysdata);
	cleanup_servers(&sysdata);
	cleanup_buffers(&sysdata);
	cleanup_signals(&sysdata);
	
	logger(sysdata.logging, 1, "Shutdown complete.\n");

	cleanup_logging(&sysdata);
	cleanup_daemon(&sysdata);
	cleanup_maxconns(&sysdata);
	cleanup_settings(&sysdata);
	cleanup_sysdata(&sysdata);
	
	// good-bye.
	return 0;
}
Exemplo n.º 13
0
const char *
bot_get_password() {
	init_settings();
	return s.pass;
}
Exemplo n.º 14
0
int main(int argc, char *argv[])
{
    int ret;
#if defined(_XBOX)
    XINPUT_STATE state;

    get_environment_settings();

    XInputGetState(0, &state);

    if(state.Gamepad.wButtons & XINPUT_GAMEPAD_Y)
    {
        //override path, boot first executable in cores directory
        RARCH_LOG("Fallback - Will boot first executable in RetroArch cores directory.\n");
        find_and_set_first_file();
    }
    else
    {
        //normal executable loading path
        init_settings();
    }

    XLaunchNewImage(libretro_path, NULL);
    RARCH_LOG("Launch libretro core: [%s] (return code: %x]).\n", libretro_path, ret);
#elif defined(__CELLOS_LV2__)
    CellPadData pad_data;
    char spawn_data[256], spawn_data_size[16];
    SceNpDrmKey * k_licensee = NULL;

    cellSysutilRegisterCallback(0, callback_sysutil_exit, NULL);

    cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
    cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
    cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_GAME);
    cellSysmoduleLoadModule(CELL_SYSMODULE_NET);

    cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_NP);

    sys_net_initialize_network();

#ifdef HAVE_LOGGER
    logger_init();
#endif

    sceNpInit(NP_POOL_SIZE, np_pool);

    get_environment_settings();

    cellPadInit(7);

    cellPadGetData(0, &pad_data);

    if(pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE)
    {
        //override path, boot first executable in cores directory
        RARCH_LOG("Fallback - Will boot first executable in RetroArch cores/ directory.\n");
        find_and_set_first_file();
    }
    else
    {
        //normal executable loading path
        init_settings();
    }

    cellPadEnd();

#ifdef HAVE_LOGGER
    logger_shutdown();
#endif

    for(unsigned int i = 0; i < sizeof(spawn_data); ++i)
        spawn_data[i] = i & 0xff;

    snprintf(spawn_data_size, sizeof(spawn_data_size), "%d", 256);

    const char * const spawn_argv[] = {
        spawn_data_size,
        "test argv for",
        "sceNpDrmProcessExitSpawn2()",
        NULL
    };

    ret = sceNpDrmProcessExitSpawn2(k_licensee, libretro_path, (const char** const)spawn_argv, NULL, (sys_addr_t)spawn_data, 256, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M);
    RARCH_LOG("Launch libretro core: [%s] (return code: %x]).\n", libretro_path, ret);

    if(ret < 0)
    {
        RARCH_LOG("Executable file is not of NPDRM type, trying another approach to boot it...\n");
        sys_game_process_exitspawn2(libretro_path, NULL, NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M);
    }

    sceNpTerm();

    sys_net_finalize_network();

    cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_NP);

    cellSysmoduleUnloadModule(CELL_SYSMODULE_NET);
    cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME);
    cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
    cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
#endif

    return 1;
}
Exemplo n.º 15
0
/**
	Application main.
	Initializes internationalization, libosso, app and appview.
	Calls user interface creation functions and gtk_main.

	Follows the component initialization order of
	osso-filemanager main.
		
	@param argc Number of command line arguments
	@param argv Command line arguments
	@return 0 if successful; otherwise error code
*/
int
main(int argc, char *argv[])
{
    gboolean result;

    g_thread_init(NULL);
    dbus_g_thread_init();
    gdk_threads_init();

    mainThread = g_thread_self();


    /* Allocate application data structures */
    app_data = g_new0(AppData, 1);
    if (app_data == NULL)
    {
        OSSO_LOG_CRIT("Failed memory allocation: AppData");
        exit(1);
    }

    /* there was no low memory ind from HW yet. */
    app_data->low_memory = FALSE;

    app_data->app_ui_data = g_new0(AppUIData, 1);
    if (app_data->app_ui_data == NULL)
    {
        OSSO_LOG_CRIT("Failed memory allocation: AppUIData");
        // free_app_data();
        exit(1);
    }

    /* Add reference back to parent structure (AppData) */
    app_data->app_ui_data->app_data = app_data;

    /* init comapp_system */

    init_comapp_system(app_data);

    /* Initialize GnomeVFS */
    result = gnome_vfs_init();

    if (!result)
    {
        OSSO_LOG_CRIT("Failed initializing GnomeVFS");
        return OSSO_ERROR;
    }

    /* Initialize GConf and read application configuration */
    if (!init_settings(app_data))
    {
        OSSO_LOG_CRIT("Failed initializing GConf");
        return OSSO_ERROR;
    }
    
    if (!get_configuration(argc, argv, app_data))
    {
        OSSO_LOG_CRIT("Failed reading configuration");
        return OSSO_ERROR;
    }
#ifdef ENABLE_NLS
    /* Initialize localization */
    /* Gettext does not seem to work properly without the following function
     * call */
    setlocale(LC_ALL, "");

    bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
    textdomain(GETTEXT_PACKAGE);
#endif /* ENABLE_NLS */

    /* Initialize GTK */
    //gtk_init(&argc, &argv);
    
    /* Initialize GTK+ and Hildon */
    hildon_gtk_init(&argc, &argv);

    /* Create application UI */
    ui_create_main_window(app_data);

    /* Initialize engine */
    pdf_viewer_init(app_data->app_ui_data);

    app_data->app_ui_data->password_dialog = NULL;

    app_data->app_ui_data->replace_dialog = NULL;

    //hildon_gtk_window_take_screenshot(GTK_WINDOW(app_data->app_ui_data->app_view), TRUE);
    
    g_signal_connect(G_OBJECT(app_data->app_ui_data->app_view), "map-event",
		    	G_CALLBACK(game_get_screenshot), NULL);    //prasanna
    
    GDK_THR_ENTER;
    gtk_main();
    GDK_THR_LEAVE;
    
    if( !just_exit ) {
		g_debug( "Save configuration..." );
        save_configuration(app_data);

		g_debug( "Deinit engine..." );
        pdf_viewer_deinit();

		g_debug( "Deinit compapp systems..." );
        deinit_comapp_system(app_data);

		g_debug( "Deinit settings..." );
        deinit_settings();

		g_debug( "Deinit mime..." );
        free_mime_filters();
        free_application_mime_types();

		g_debug( "Deinit gnomevfs..." );
        if (gnome_vfs_initialized()) {
            gnome_vfs_shutdown();
        }
    }
    
    /* Exit successfully, regardless of any errors */
	g_debug( "Exit success" );    
    exit(EXIT_SUCCESS);
}
Exemplo n.º 16
0
int main (int argc, char *argv[]) {

    int		rv; 		/* return value for functionss */
    FILE		*file_in;	/* file for mem RW/addr input */
    settings_t	settings;	/* settings structure */
    char		line_buffer[64];/* buffer for reading in lines */
    mem_rw_t	parse_data;
    save_data_t	save_data;

    init_save(&save_data);	/* inits the stats  */

    init_settings(&settings);	/* inits the settings struct */

    /* parses the input arguements for the cache set up and run info */
    if ((rv = get_settings(&settings, argc, argv)) != RTN_SUCCESS) {
        if (rv == RTN_PARSE_ERR) {
            fprintf(stderr, "Error parsing input arguements"
                    "exiting\n");
            return rv;
        }
        else if (rv ==  RTN_NO_SET) {
            fprintf(stderr, "Not all of the settings were"
                    "present or set correctly, exiting\n");
            return rv;
        }
        else {
            fprintf(stderr, "Unknown error, exiting\n");
            return rv;
        }
    }


    /* sets up the cache array in memory */
    if (cache_setup(&settings) == RTN_FAIL) {
        fprintf(stderr, "Failed to malloc memory, exiting\n");
    }

    /* opens the input file */
    if ((file_in = fopen(settings.file_path, "r")) == NULL) {
        fprintf(stderr, "Can not open input file, exiting\n");
        return RTN_FILE_ERR;
    }


    /* reads one line from the  input */
    if(fgets(line_buffer, 64, file_in) == NULL) {
        fprintf(stderr, "The input file is empty, exiting\n");
        return 1;
    }
    parse_data.time = 0ull;

    do {
        if (sscanf(line_buffer, "%d %d %u", &parse_data.flags,
                   &parse_data.data_len, &parse_data.addr) != 3) {
            fprintf(stderr, "%llu: could not be parsed"
                    ", skipping\n", parse_data.time + 1ull);
            continue;		/* skip if the data isn't
						 * read correctly */
        }
        if (parse_data.flags == 0) { 		/* read */
            read_cache(&settings, &parse_data, &save_data);
            parse_data.time++;
        }
        else if (parse_data.flags == 1) { 	/* write */
            ;
        }
        else {					/* error */
            fprintf(stderr, "%llu: neither read nor write"
                    ", skipping\n", parse_data.time + 1ull);
        }
        fgets(line_buffer, 64, file_in);

    }
    while  (!feof(file_in));

    print_save(&save_data);

    return 0;
}
Exemplo n.º 17
0
int
main (int argc, char *argv[])
{
    GdkDisplay    *gdkdisplay;
    Display       *xdisplay;
    GdkScreen     *gdkscreen;
    WnckScreen    *screen;
    gint          i, j, status;
    gboolean      replace = FALSE;
    unsigned int  nchildren;
    Window        root_ret, parent_ret;
    Window        *children = NULL;
    GList	  *windows, *win;
    decor_frame_t *bare_p, *switcher_p;

    const char *option_meta_theme = NULL;
    gint       option_blur_type = 0;

    program_name = argv[0];

    gtk_init (&argc, &argv);

    bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);

    for (i = 0; i < argc; i++)
    {
	if (strcmp (argv[i], "--minimal") == 0)
	{
	    minimal = TRUE;
	}
	else if (strcmp (argv[i], "--replace") == 0)
	{
	    replace = TRUE;
	}
	else if (strcmp (argv[i], "--blur") == 0)
	{
	    if (argc > ++i)
	    {
		if (strcmp (argv[i], "titlebar") == 0)
		    option_blur_type = BLUR_TYPE_TITLEBAR;
		else if (strcmp (argv[i], "all") == 0)
		    option_blur_type = BLUR_TYPE_ALL;
	    }
	}

#ifdef USE_METACITY
	else if (strcmp (argv[i], "--metacity-theme") == 0)
	{
	    if (argc > ++i)
		option_meta_theme = argv[i];
	}
#endif

	else if (strcmp (argv[i], "--help") == 0)
	{
	    fprintf (stderr, "%s "
		     "[--minimal] "
		     "[--replace] "
		     "[--blur none|titlebar|all] "

#ifdef USE_METACITY
		     "[--metacity-theme THEME] "
#endif

		     "[--help]"

		     "\n", program_name);
	    return 0;
	}
    }

    gdkdisplay = gdk_display_get_default ();
    xdisplay   = gdk_x11_display_get_xdisplay (gdkdisplay);
    gdkscreen  = gdk_display_get_default_screen (gdkdisplay);

    frame_input_window_atom  = XInternAtom (xdisplay,
					    DECOR_INPUT_FRAME_ATOM_NAME, FALSE);
    frame_output_window_atom = XInternAtom (xdisplay,
					    DECOR_OUTPUT_FRAME_ATOM_NAME, FALSE);

    win_decor_atom	= XInternAtom (xdisplay, DECOR_WINDOW_ATOM_NAME, FALSE);
    win_blur_decor_atom	= XInternAtom (xdisplay, DECOR_BLUR_ATOM_NAME, FALSE);
    wm_move_resize_atom = XInternAtom (xdisplay, "_NET_WM_MOVERESIZE", FALSE);
    restack_window_atom = XInternAtom (xdisplay, "_NET_RESTACK_WINDOW", FALSE);
    select_window_atom	= XInternAtom (xdisplay, DECOR_SWITCH_WINDOW_ATOM_NAME,
				       FALSE);
    mwm_hints_atom	= XInternAtom (xdisplay, "_MOTIF_WM_HINTS", FALSE);
    switcher_fg_atom    = XInternAtom (xdisplay,
				       DECOR_SWITCH_FOREGROUND_COLOR_ATOM_NAME,
				       FALSE);
    
    compiz_shadow_info_atom  = XInternAtom (xdisplay, "_COMPIZ_NET_CM_SHADOW_PROPERTIES", FALSE);
    compiz_shadow_color_atom = XInternAtom (xdisplay, "_COMPIZ_NET_CM_SHADOW_COLOR", FALSE);

    toolkit_action_atom			  =
	XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION", FALSE);
    toolkit_action_window_menu_atom	  =
	XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_WINDOW_MENU", FALSE);
    toolkit_action_force_quit_dialog_atom =
	XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_FORCE_QUIT_DIALOG",
		     FALSE);

    net_wm_state_atom = XInternAtom (xdisplay,"_NET_WM_STATE", 0);
    net_wm_state_modal_atom = XInternAtom (xdisplay, "_NET_WM_STATE_MODAL", 0);

    decor_request_atom = XInternAtom (xdisplay, "_COMPIZ_DECOR_REQUEST", 0);
    decor_pending_atom = XInternAtom (xdisplay, "_COMPIZ_DECOR_PENDING", 0);
    decor_delete_pixmap_atom = XInternAtom (xdisplay, "_COMPIZ_DECOR_DELETE_PIXMAP", 0);

    status = decor_acquire_dm_session (xdisplay,
				       gdk_screen_get_number (gdkscreen),
				       "gwd", replace, &dm_sn_timestamp);
    if (status != DECOR_ACQUIRE_STATUS_SUCCESS)
    {
	if (status == DECOR_ACQUIRE_STATUS_FAILED)
	{
	    fprintf (stderr,
		     "%s: Could not acquire decoration manager "
		     "selection on screen %d display \"%s\"\n",
		     program_name, gdk_screen_get_number (gdkscreen),
		     DisplayString (xdisplay));
	}
	else if (status == DECOR_ACQUIRE_STATUS_OTHER_DM_RUNNING)
	{
	    fprintf (stderr,
		     "%s: Screen %d on display \"%s\" already "
		     "has a decoration manager; try using the "
		     "--replace option to replace the current "
		     "decoration manager.\n",
		     program_name, gdk_screen_get_number (gdkscreen),
		     DisplayString (xdisplay));
	}

	return 1;
    }

    screen = wnck_screen_get_default ();

    initialize_decorations ();

    notified = gwd_settings_notified_impl_new (screen);

    if (!notified)
	return 1;

    writable = GWD_SETTINGS_WRITABLE_INTERFACE (gwd_settings_impl_new (option_blur_type != BLUR_TYPE_NONE ? &option_blur_type : NULL,
								       option_meta_theme ? &option_meta_theme : NULL,
								       notified));

    if (!writable)
    {
	g_object_unref (notified);
	return 1;
    }

    settings = GWD_SETTINGS_INTERFACE (writable);

    gwd_settings_writable_freeze_updates (writable);

    if (!init_settings (writable,
			screen))
    {
	g_object_unref (writable);
	fprintf (stderr, "%s: Failed to get necessary gtk settings\n", argv[0]);
	return 1;
    }

    for (i = 0; i < 3; i++)
    {
	for (j = 0; j < 3; j++)
	{
	    if (cursor[i][j].shape != XC_left_ptr)
		cursor[i][j].cursor =
		    XCreateFontCursor (xdisplay, cursor[i][j].shape);
	}
    }

    xformat_rgba = XRenderFindStandardFormat (xdisplay, PictStandardARGB32);
    xformat_rgb  = XRenderFindStandardFormat (xdisplay, PictStandardRGB24);

    frame_table = g_hash_table_new (NULL, NULL);
    destroyed_pixmaps_table = g_hash_table_new (NULL, NULL);

    if (!create_tooltip_window ())
    {
	g_object_unref (writable);

	free (settings);
	fprintf (stderr, "%s, Couldn't create tooltip window\n", argv[0]);
	return 1;
    }

    wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);

    gdk_window_add_filter (NULL,
			   selection_event_filter_func,
			   NULL);

    if (!minimal)
    {
	GdkWindow *root = create_foreign_window (gdk_x11_get_default_root_xwindow ());

 	gdk_window_add_filter (NULL,
 			       event_filter_func,
 			       NULL);
			       
	XQueryTree (xdisplay, gdk_x11_get_default_root_xwindow (),
		    &root_ret, &parent_ret, &children, &nchildren);

	for (i = 0; i < nchildren; i++)
	{
	    GdkWindow *toplevel = create_foreign_window  (children[i]);

	    /* Need property notify on all windows */

	    gdk_window_set_events (toplevel,
				   gdk_window_get_events (toplevel) |
				   GDK_PROPERTY_CHANGE_MASK);
	}

	/* Need MapNotify on new windows */
	gdk_window_set_events (root, gdk_window_get_events (root) |
			       GDK_STRUCTURE_MASK |
			       GDK_PROPERTY_CHANGE_MASK |
			       GDK_VISIBILITY_NOTIFY_MASK |
			       GDK_SUBSTRUCTURE_MASK);
 
 	connect_screen (screen);
    }

    decor_set_dm_check_hint (xdisplay, gdk_screen_get_number (gdkscreen),
			     WINDOW_DECORATION_TYPE_PIXMAP |
			     WINDOW_DECORATION_TYPE_WINDOW);

    /* Update the decorations based on the settings */
    gwd_settings_writable_thaw_updates (writable);

    /* Keep the default, bare and switcher decorations around
     * since otherwise they will be spuriously recreated */

    bare_p = gwd_get_decor_frame ("bare");
    switcher_p = gwd_get_decor_frame ("switcher");

    update_default_decorations (gdkscreen);

    gtk_main ();

    win = windows = wnck_screen_get_windows (screen);

    while (win != NULL)
    {
	WnckWindow *w = (WnckWindow *) win->data;

	window_closed (screen, w);

	win = g_list_next (win);
    }

    g_list_free (windows);

    if (tip_label)
	gtk_widget_destroy (GTK_WIDGET (tip_label));

    if (tip_window)
	gtk_widget_destroy (GTK_WIDGET (tip_window));

    gwd_decor_frame_unref (bare_p);
    gwd_decor_frame_unref (switcher_p);

    fini_settings ();

    return 0;
}
Exemplo n.º 18
0
int main(int argc, char **argv)
{
	char *dicts_list = NULL;
	regimen_t regimen = usually_regimen; // GCC warning fix

	int opt;
	struct option long_options[] = {
		{OPT_SEARCH_USUALLY,			required_argument,	NULL,	'u'}, // +
		{OPT_SEARCH_FIRST_CONCURRENCE,		required_argument,	NULL,	'f'}, // +
		{OPT_SEARCH_WORD_COMBINATIONS,		required_argument,	NULL,	'c'}, // +
		{OPT_SEARCH_LIST,			required_argument,	NULL,	'l'}, // +
		{OPT_SEARCH_ILL_DEFINED,		required_argument,	NULL,	'i'}, // +
		{OPT_SEARCH_SOUND,			required_argument,	NULL,	's'}, // +

		{OPT_DICT_CONNECT,			required_argument,	NULL,	'0'}, // -
		{OPT_DICT_DISCONNECT,			required_argument,	NULL,	'1'}, // -
		{OPT_DICT_PRINT_DICTS_LIST,		no_argument,		NULL,	'2'}, // -
		{OPT_DICT_PRINT_DICT_INFO,		required_argument,	NULL,	'3'}, // -
		{OPT_DICT_USE_LIST,			required_argument,	NULL,	'5'}, // -
		{OPT_DICT_PRINT_INDEX,			required_argument,	NULL,	'6'}, // -

		{OPT_MISC_MAX_TRANSLATE_COUNT,		required_argument,	NULL,	'm'}, // +
		{OPT_MISC_ILL_DEFINED_SEARCH_PERCENT,	required_argument,	NULL,	'p'}, // +
		{OPT_MISC_SHOW_TIME,			no_argument,		NULL,	't'}, // +
		{OPT_SETTINGS_OUTPUT_FORMAT,		required_argument,	NULL,	'7'}, // -
		{OPT_SETTINGS_USE_ESCS,			required_argument,	NULL,	'8'}, // -
		{OPT_SETTINGS_USE_CSS,			required_argument,	NULL,	'9'}, // -

		{OPT_INFO_HELP,				no_argument,		NULL,	'h'}, // +
		{OPT_INFO_VERSION,			no_argument,		NULL,	'v'}, // +
		{OPT_INFO_DEBUG,			no_argument,		NULL,	'd'}, // +

		{0, 0, 0, 0}
	};

	int error_count = 0;

	clock_t begin_time_label, end_time_label;

	bool use_default_function_flag = true;
	bool show_time_flag = false;


	begin_time_label = clock();

	if ( init_settings() != 0 ) {
		fprintf(stderr, "Cannot initialize default \"%s\" settings\n", MYNAME);
		return 1;
	}

	while ( (opt = getopt_long(argc, argv, ":u:f:c:l:i:s:m:p:thvd", long_options, NULL)) != -1 ) {
		switch ( opt ) {
			case 'u' :
			case 'f' :
			case 'c' :
			case 'l' :
			case 'i' : {
				switch ( opt ) {
					case 'u' : regimen = usually_regimen; break;
					case 'f' : regimen = first_concurrence_regimen; break;
					case 'c' : regimen = word_combinations_regimen; break;
					case 'l' : regimen = list_regimen; break;
					case 'i' : regimen = ill_defined_regimen; break;
				}
				error_count += managed_find_word(optarg, regimen, dicts_list);
				use_default_function_flag = false;
				break;
			}

			case 's' : {
				error_count += find_sound(optarg);
				use_default_function_flag = false;
				break;
			}

			case '0' : {
				error_count += connect_dict(optarg);
				use_default_function_flag = false;
				break;
			}

			case '1' : {
				error_count += disconnect_dict(optarg);
				use_default_function_flag = false;
				break;
			}

			case '2' : {
				error_count += print_dicts_list();
				use_default_function_flag = false;
				break;
			}

			case '3' : {
				error_count += print_dict_info(optarg);
				use_default_function_flag = false;
				break;
			}

			case '5' : {
				dicts_list = optarg;
				use_default_function_flag = false;
				break;
			}

			case '6' : {
				error_count += build_linear_index(optarg);
				use_default_function_flag = false;
				break;
			}

			case 'm' : {
				set_settings_max_translate_count(optarg);
				use_default_function_flag = false;
				break;
			}

			case 'p' : {
				set_settings_ill_defined_search_percent(optarg);
				use_default_function_flag = false;
				break;
			}

			case '7' : {
				set_settings_output_format(optarg);
				use_default_function_flag = false;
				break;
			}

			case '8' : {
				set_settings_use_terminal_escapes_flag(optarg);
				use_default_function_flag = false;
				break;
			}

			case '9' : {
				set_settings_use_css_flag(optarg);
				use_default_function_flag = false;
				break;
			}

			case 't' : {
				show_time_flag = true;
				use_default_function_flag = false;
				break;
			}

			case 'h' : {
				help();
				use_default_function_flag = false;
				break;
			}

			case 'v' : {
				version();
				use_default_function_flag = false;
				break;
			}

			case 'd' : {
				debug();
				use_default_function_flag = false;
				break;
			}

			case ':' : {
				fprintf(stderr, "Option \"-%c\" requires an argument: ignored\n", optopt);
				--error_count;
				break;
			}

			case '?' :
			default : {
				fprintf(stderr, "Invalid option \"-%c\": ignored\n", optopt);
				use_default_function_flag = false;
				break;
			}
		}
	}

	if ( argc == 2 && use_default_function_flag ) {
		error_count += managed_find_word(argv[1], usually_regimen, NULL);
	}
	else if ( argc != 2 && use_default_function_flag ) {
		fprintf(stderr, "Bad options syntax, try \"%s --help\"\n", MYNAME);
		--error_count;
	}

	if ( close_settings() != 0 )
		fprintf(stderr, "Warning: cannot close \"%s\" settings\n", MYNAME);

	if ( show_time_flag ) {
		end_time_label = clock();

		if ( begin_time_label != -1 && end_time_label != -1 )
			fprintf(stderr, "Search time: %.2f sec\n", ((double) (end_time_label - begin_time_label)) / CLOCKS_PER_SEC);
	}

	return abs(error_count);
}
Exemplo n.º 19
0
/* adds or edits a setting */
int add_setting(char * setting_name, char * value)
{
	FILE * fp, * fp_temp;
	int ctr, retval, index=-1;
	char str[BLOCK_SIZE];
	char filename[BLOCK_SIZE], linestr[BLOCK_SIZE];
	char temp_filename[BLOCK_SIZE];
	char commandstr[BLOCK_SIZE];

	init_settings();
	settings_filename(filename);

	if (file_exists(filename) != 0) {
		str[0]=0;
		index = get_setting(setting_name, str);
	}

	if (index == -1) {
		if (file_exists(filename)==0) {
			/* the first entry in the settings file */
			fp = fopen(filename,"w");
			if (fp) {
				fprintf(fp,"%s%c%s\n",setting_name,SETTINGS_SEPARATOR,value);
				fclose(fp);
			}
			else {
				printf("Unable to write to file %s\n",filename);
			}
			return 0;
		}
		/* append a new entry to the settings file */
		fp = fopen(filename,"a");
		if (fp) {
			fprintf(fp,"%s%c%s\n",setting_name,SETTINGS_SEPARATOR,value);
			fclose(fp);
		}
		else {
			printf("Unable to append to file %s\n",filename);
		}
		return 0;
	}

	/* edit an existing entry in the settings file */
	sprintf(temp_filename,"%s.new",filename);
	fp_temp = fopen(temp_filename,"w");
	fp = fopen(filename,"r");
	if ((!fp) || (!fp_temp)) return -1;
	ctr = 0;
	while (!feof(fp)) {
		if (fgets(linestr, BLOCK_SIZE-1, fp) != NULL) {
			if (strlen(linestr) == 0) continue;
 
			if (ctr == index) {
				fprintf(fp_temp,"%s%c%s\n",setting_name,SETTINGS_SEPARATOR,value);
			}
			else {
				fprintf(fp_temp,"%s",linestr);
			}
			ctr++;
		}
	}
	fclose(fp);
	fclose(fp_temp);

	sprintf(commandstr, "%s %s %s", COMMAND_COPY, temp_filename, filename);
	retval = system(commandstr);
	sprintf(commandstr, "%s %s", COMMAND_DELETE, temp_filename);
	retval = system(commandstr);
	return retval;
}
Exemplo n.º 20
0
Arquivo: main.c Projeto: Df458/Halberd
int main(int argc, char** argv)
{
    if(!glfwInit()) {
        error("Failed to intialize GLFW.");
        return 1;
    }

    GLFWwindow* win;
	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    win = glfwCreateWindow(800, 600, "Halberd", NULL, NULL);
    if(!win) {
        error("Unable to create window.");
        return 1;
    }
    glfwSetFramebufferSizeCallback(win, sizeCallback);
    glfwMakeContextCurrent(win);

	glewExperimental = 1;
	if(glewInit() != GLEW_OK) {
        error("glewInit() failed.");
        glfwDestroyWindow(win);
        return 1;
    }
    glGetError(); // Because GLEW is silly. <http://stackoverflow.com/questions/20034615/why-does-glewinit-result-in-gl-invalid-enum-after-making-some-calls-to-glfwwin>
    GLuint VAO; // FIXME: Stupid Hack. <http://stackoverflow.com/questions/13403807/glvertexattribpointer-raising-gl-invalid-operation>
    glGenVertexArrays(1, &VAO);
    glBindVertexArray(VAO);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    init_graphics();
    update_camera(800, 600);
    init_input(win);
    init_player(0, 0);
    init_ui();
    init_settings();

    /*init_maps();*/
    // TODO: Figure out the correct way to start up
    /*get_tileset_id("Plains.png");*/
    /*load_maps("test");*/

    float delta = 0;
    glfwSetTime(0);
    do {
        delta = glfwGetTime();
        glfwSetTime(0);
        glfwPollEvents();

        if(!ui_present())
            update_player(delta);
        update_actors(delta);
        update_ui(delta);
        update_input_states(delta);

        render_game();

        glfwSwapBuffers(win);
    } while(!glfwWindowShouldClose(win) && get_input_state(4) != 2);

    destroy_player_actor();
    destroy_actors();
    /*destroy_maps();*/
    destroy_ui();
    destroy_graphics();
    cleanup_settings();

    glfwDestroyWindow(win);
    glfwTerminate();
    return 0;
}
Exemplo n.º 21
0
int main(int argc, char **argv)
{
    char c;

    init_settings();
    setbuf(stderr,NULL);

    if (argc < 2) {
        usage(argv[0]);
        exit(EXIT_FAILURE);
    }

    while (-1 != (c = getopt(argc, argv,
                             "F:"
                             "D:"
                             "T:"
                             "N:"
                             "W:"
                             "f:"
           ))) {

        switch(c) {
            case 'F':
                bench_desc.log_file_dir = optarg;
                break;
            case 'D':
                bench_desc.dir_path = optarg;
                break;
            case 'T':
                bench_desc.num_threads = atoi(optarg);
                if (bench_desc.num_threads < 1) {
                    fprintf(stderr, 
                            "Number of threads (T) must be greater than 0\n");
                    exit(EXIT_FAILURE);
                }
                if (bench_desc.num_threads > MAX_THREADS) {
                    fprintf(stderr, 
                            "WARNING: Number of threads (T) is too large. "
                            "This is not recommended and may lead to weird " 
                            "behavior.\n");
                }
                break;
            case 'N':
                bench_desc.num_files = atoi(optarg);
                break;
            case 'W':
                if (strcasecmp(optarg, "create") == 0)
                    bench_desc.workload_type = CREATE_WORKLOAD;
                else if (strcasecmp(optarg, "lookup") == 0)
                    bench_desc.workload_type = LOOKUP_WORKLOAD;
                else if (strcasecmp(optarg, "scan") == 0) {
                    bench_desc.workload_type = SCAN_WORKLOAD;
                    bench_desc.num_threads = 1;
                }
                else if (strcasecmp(optarg, "mixed") == 0)
                    bench_desc.workload_type = MIXED_WORKLOAD;
                else {
                    fprintf(stderr,
                            "Invalid workload (w): %s \n"
                            "We only support: create, lookup, scan or mixed."
                            "\n",optarg);
                    exit(EXIT_FAILURE);
                }
                break;
            case 'f':
                if (bench_desc.workload_type == MIXED_WORKLOAD) {
                    bench_desc.mixed_frac = atof(optarg);
                    if ((bench_desc.mixed_frac < 0.0) ||
                        (bench_desc.mixed_frac > 1.0))
                        fprintf(stderr,
                                "range of mixed_frac (f) is [0.0-1.0] \n");
                        exit(EXIT_FAILURE);
                }
                else 
                    fprintf(stderr,
                            "WARNING: mixed_frac (f) is valid only with "
                            "mixed workloads (-O m). We will default it to "
                            "an all create workload. \n");
            default:
                fprintf(stderr, "Illegal parameter: %c\n", c);
                break;
        }
    }

    print_settings();

    init_threads();
    
    return 1;
}
Exemplo n.º 22
0
const char *
bot_get_username() {
	init_settings();
	return s.user;
}