Exemple #1
0
static BOOL init_registry(BOOL init)
{
    return init_key("TestScript\\CLSID", TESTSCRIPT_CLSID, init)
        && init_key("CLSID\\"TESTSCRIPT_CLSID"\\Implemented Categories\\{F0B7A1A1-9847-11CF-8F20-00805F2CD064}",
                    NULL, init)
        && init_key("CLSID\\"TESTSCRIPT_CLSID"\\Implemented Categories\\{F0B7A1A2-9847-11CF-8F20-00805F2CD064}",
                    NULL, init);
}
Service& service_registry::use_service(io_service& owner)
{
  execution_context::service::key key;
  init_key(key, Service::id);
  factory_type factory = &service_registry::create<Service, io_service>;
  return *static_cast<Service*>(do_use_service(key, factory, &owner));
}
Exemple #3
0
/** Init WMFS
*/
void
init(void)
{
     /* Init lists heads */
     SLIST_INIT(&bwhead);
     SLIST_INIT(&clients);
     SLIST_INIT(&trayicons);

     /* First init */
     ewmh_init_hints();
     init_conf();
     init_gc();
     init_font();
     init_cursor();
     init_key();
     init_root();
     screen_init_geo();
     event_make_array();
     infobar_init();
     systray_acquire();
     ewmh_update_current_tag_prop();
     grabkeys();

     return;
}
Service& service_registry::use_service()
{
  lslboost::asio::io_service::service::key key;
  init_key(key, Service::id);
  factory_type factory = &service_registry::create<Service>;
  return *static_cast<Service*>(do_use_service(key, factory));
}
Exemple #5
0
int main(int argc, char **argv) {
    (void)argc;
    (void)argv;

    /* open connection with the server */
    nil_.con = xcb_connect(0, 0);
    if (xcb_connection_has_error(nil_.con)) {
        NIL_ERR("xcb_connect %p", (void *)nil_.con);
        exit(1);
    }
    /* 1st stage */
    if ((init_screen() != 0) || (init_key() != 0) || (init_mouse() != 0)) {
        xcb_disconnect(nil_.con);
        exit(1);
    }
    /* 2nd stage */
    if ((init_cursor() != 0) || (init_color() != 0) != (init_font() != 0)
        || (init_bar() != 0) || (init_wm() != 0))  {
        cleanup();
        exit(1);
    }
    xcb_flush(nil_.con);
    recv_events();
    cleanup();
    return 0;
}
int			detect_keys(int argc, char **argv, t_slt *slt)
{
  int			tab_int[argc];

  slt->underline =  (init_tab(argc, tab_int));
  while (1)
    {
      tputs(tgetstr("cl", NULL), 0, my_putint);
      aff_params(argc, argv, slt, tab_int);
      init_key(slt);
      if (slt->key[0] == 27 && slt->key[1] == 0 && slt->key[2] == 0)
        return (0);
      else if (slt->key[0] == 27 && slt->key[1] == 91 && slt->key[2] == 65)
        slt->underline = slt->underline - 1;
      else if (slt->key[0] == 27 && slt->key[1] == 91 && slt->key[2] == 66)
        slt->underline = slt->underline + 1;
      else if (slt->key[0] == 32 && slt->key[1] == 0 && slt->key[2] == 0)
        gere_space(tab_int, slt);
      else if (slt->key[0] == 10 && slt->key[1] == 0 && slt->key[2] == 0)
        return (0);
      else if ((slt->key[0] == 127 && slt->key[1] == 0 && slt->key[2] == 0) ||
               (slt->key[0] == 27 && slt->key[1] == 91 && slt->key[2] == 51))
        return (0);
      circle(argc, slt);
    }
}
Exemple #7
0
int main()
{
	char key[9];
	int i;
	int pos = 0;

	init_key(key, ARRAY_SIZE(key));
	for (i = 0; i < HASHTABLE_SIZE; i++) {
		void *unchanged = NULL + 1234;
		void *actual = unchanged;
		void *value = NULL + i;
		assert(!find_next_collision(pos, key, strlen(key)));
		assert(hashtable_get(key, &actual) == 1);
		assert(actual == unchanged);
		assert(!hashtable_set(key, value));
		assert(hashtable_test_key_at_pos(key, pos + i % HASHTABLE_SIZE));
	}

	assert(!find_next_collision(pos, key, strlen(key)));
	/* table is full */
	assert(hashtable_set(key, NULL) == 1);

	init_key(key, ARRAY_SIZE(key));
	for (i = 0; i < HASHTABLE_SIZE; i++) {
		void *expect = NULL + i;
		void *actual;
		assert(!find_next_collision(pos, key, strlen(key)));
		assert(!hashtable_get(key, &actual));
		assert(actual == expect);
	}

	assert(hashtable_remove("asdf"));
	assert(hashtable_remove(""));
	init_key(key, ARRAY_SIZE(key));
	for (i = 0; i < HASHTABLE_SIZE; i++) {
		assert(!find_next_collision(pos, key, strlen(key)));
		assert(!hashtable_remove(key));
		assert(hashtable_remove(key));
	}
	init_key(key, ARRAY_SIZE(key));
	assert(hashtable_remove(key));

	return 0;
}
static el_file_ptr file_open(const char* file_name, const char* extra_path)
{
	char str[1024];
	el_zip_file_entry_t key;
	el_file_ptr result;
	Sint32 i, count;

	if (!file_name || !*file_name)
		return NULL;

	if (extra_path)
	{
		if (do_file_exists(file_name, extra_path, sizeof(str), str) == 1)
		{
			return xz_gz_file_open(str);
		}
	}

	if (do_file_exists(file_name, get_path_updates(), sizeof(str), str) == 1)
	{
		return xz_gz_file_open(str);
	}

	init_key(file_name, &key, sizeof(str), str);

	CHECK_AND_LOCK_MUTEX(zip_mutex);

	count = num_zip_files - 1;

	CHECK_AND_UNLOCK_MUTEX(zip_mutex);

	for (i = count; i >= 0; i--)
	{
		CHECK_AND_LOCK_MUTEX(zip_files[i].mutex);

		if (locate_in_zip(&zip_files[i], &key) == 1)
		{
			result = zip_file_open(zip_files[i].file);

			CHECK_AND_UNLOCK_MUTEX(zip_files[i].mutex);

			return result;
		}

		CHECK_AND_UNLOCK_MUTEX(zip_files[i].mutex);
	}

	if (do_file_exists(file_name, datadir, sizeof(str), str) == 1)
	{
		return xz_gz_file_open(str);
	}

	LOG_ERROR("Can't open file '%s'.", file_name);

	return NULL;
}
service_registry::service_registry(
    lslboost::asio::io_service& o, Service*, Arg arg)
  : owner_(o),
    first_service_(new Service(o, arg))
{
  lslboost::asio::io_service::service::key key;
  init_key(key, Service::id);
  first_service_->key_ = key;
  first_service_->next_ = 0;
}
Exemple #10
0
void save()
{
  write_cmd_12864(0x01);
  write_Chinese_12864("请按  键保存,按  键取消!",0,0,12);
  write_Chinese_12864("1.",2,0,1);
  write_Chinese_12864("2.",8,0,1);
  unsigned char key=init_key();
  while((key!=1) && (key!=2))
  {
    delay_12864(10000);
    key=init_key();
  }
  if(key==1)
  {
    write_cmd_12864(0x01);
    write_sega(itswave,itsvol,itsfreq&0xff,itsfreq>>8);
    write_Chinese_12864("保存成功!",10,0,5);
    delay_s(5);
  }
static Uint32 file_exists_path(const char* file_name, const char* extra_path)
{
	char str[1024];
	el_zip_file_entry_t key;
	Sint32 i, count;

	if (file_name == 0)
	{
		return 0;
	}

	if (extra_path != 0)
	{
		if (do_file_exists(file_name, extra_path, sizeof(str), str) == 1)
		{
			return 1;
		}
	}

	if (do_file_exists(file_name, get_path_updates(), sizeof(str), str) == 1)
	{
		return 1;
	}

	init_key(file_name, &key, sizeof(str), str);

	CHECK_AND_LOCK_MUTEX(zip_mutex);

	count = num_zip_files - 1;

	CHECK_AND_UNLOCK_MUTEX(zip_mutex);

	for (i = count; i >= 0; i--)
	{
		CHECK_AND_LOCK_MUTEX(zip_files[i].mutex);

		if (find_in_zip(&zip_files[i], &key) == 1)
		{
			CHECK_AND_UNLOCK_MUTEX(zip_files[i].mutex);

			return 1;
		}

		CHECK_AND_UNLOCK_MUTEX(zip_files[i].mutex);
	}

	if (do_file_exists(file_name, datadir, sizeof(str), str) == 1)
	{
		return 1;
	}

	return 0;
}
int main(int argc, char* argv[], char* envp[]){
    setbuf(stdout, NULL); //stdout sans buffer
    int msg_id;
    struct _msg message;
    key_t key;
    /* Gestion arguments */
    if(argc!=3){
	fprintf(stderr,"Ce programme doit etre appele avec 2 arguments (%d) :\n\t%s int num_archiviste >0 int nb_theme >2\n",argc,argv[0]);
	exit(-1);
    }else if(atoi(argv[1])<1){
	fprintf(stderr,"Veuillez préciser un numero positif pour cet archiviste (%d).\n",atoi(argv[1]));
	exit(-1);
    }else if(atoi(argv[2])<2){
	fprintf(stderr,"Veuillez préciser un nombre de theme supérieur a 2.\n");
	exit(-1);
    }
    /* Gestion signal */
    struct sigaction sig1;
    sig1.sa_handler = sig_h;
    sigemptyset(&sig1.sa_mask);
    sig1.sa_flags=0;
    sigaction(SIGUSR1,&sig1,NULL);
    /* Init Clef */
    key = init_key((char)0);

    /* Initialisation file de messages */
    if ( (msg_id = msgget(key, IPC_EXCL|0666)) == -1 ){
        perror("Probleme a la recuperation de la pile.");
	exit(1);
    }

    int msgsz = sizeof(message)-sizeof(long); //taille d'un message
    while(!done){ //tant que pas fini (voir signal et handler plus bas)
	if(msgrcv(msg_id,&message,msgsz,0,0)!=-1){ // recevoir le prochain message (gestion des message de confirmation prevu par signal, mais comme cela ne fonctionne pas...)
	    if(message.mtype==1){//publication
		fprintf(stdout,"[A-%d] Publication : %d <- %s\n\n",(int)getpid(),message.theme,message.mtext); 
		publicate(message.theme,message.mtext);
	    }else if(message.mtype==2){//consultation
		fprintf(stdout,"[A-%d] Consultation : %d \n\n",(int)getpid(),message.theme); 
		printTheme(message.theme);
	    }else{//reste
		fprintf(stdout,"[A-%d] Message Received (%ld) : %s\n\n",(int)getpid(),message.mtype,message.mtext); 
	    }

	}else{//si erreur a la reception arreter la boucle
	    done = 1;
	}
    }
    exit(0);
}
Exemple #13
0
/***************************************************
 エントリ
 ***************************************************/
int
main (void)
{
  // ゲームパックウェイト&キャッシュ
  *((vu16 *) 0x04000204) = 0x4317;

  // BG初期化
  init_bg ();
  // スプライト初期化
  init_sprite ();
  // キー初期化
  init_key ();
  // サウンド初期化
  DirectSoundInitialize ();

  // キャラクタ初期化
  init_sprite_chr ();

  // ハイスコア初期化
  init_hiscore ();

  // ゲーム初期化
  init_game ();

  // タイトル
  init_title ();

  // 割り込み初期化
  irqInit ();
  // サウンド用ハンドラ MUSIC / SE
  irqSet (IRQ_TIMER0, IRQ_Music);
  irqSet (IRQ_TIMER1, IRQ_Sound);
  irqEnable (IRQ_VBLANK | IRQ_TIMER0 | IRQ_TIMER1);

  // タイトル
  PlayMusic (MUSIC_TITLE, PLAY_LOOP_ON);

  // メインループ
  while (1)
  {
    // キー入力
    scanKeys ();

    // ゲーム本体
    game ();

    // 割り込み待ち
    VBlankIntrWait ();
  }
}
Exemple #14
0
/** Init MWM
*/
void
init(void)
{
     /* First init */
     ewmh_init_hints();
     init_conf();
     init_gc();
     init_font();
     init_cursor();
     init_key();
     init_root();
     screen_init_geo();
     infobar_init();
     systray_acquire();
     init_status();
     ewmh_update_current_tag_prop();
     grabkeys();

     return;
}
Exemple #15
0
int	main(int ac, char **av)
{
  int	nb;
  int	key = 0;

  if (ac != 3 && ac != 4)
    return (display_usage(av[0]));
  if (is_correct_param(av[2]) != 1)
    return (display_usage(av[0]));
  nb = atoi(av[2]);
  if (ac == 4)
    {
      if ((key = init_key(av[3])) == -1)
	return (EXIT_FAILURE);
    }
  if (nb == 0)
    crypt(av[1]);
  else
    decrypt(av[1]);
  return (EXIT_SUCCESS);
}
Exemple #16
0
int main()
{
	init_led();
	init_beep();
	init_key();

	led_off_all();
	int i;

	while(1)
	{
		if(i= key_press()){
			led_on(i);
			beep_on();
		}else{
			led_off_all();
			beep_off();
		}
	}
	 return 0;
}
Exemple #17
0
int main()
{
    int i;
    trienode *root = NULL;
    key *newkey;
    entry *value;
    for (i = 0; i < 4; i++) {
        value = (entry *) malloc(sizeof(entry));
        memset(value, sizeof(entry), 0);
        sprintf(value->name, "%s%d", "bart", i);
        value->id = i;
        newkey = (key *) malloc(sizeof(key));
        init_key(newkey, 1+i);
        root = trinsert(root, newkey, value);
    }
    trshow(root, 0);
    //sprintf(newkey, "%s%d", "bart", 2);
    trsearch(root, newkey);
    trdelete(root, newkey);
    trsearch(root, newkey);
}
Exemple #18
0
void paillier_pubkey::init_key(unsigned int _bits, char* rawKey) {
  int init_s_;
  bits = _bits;

  init_key();
  
  mpz_import(nj[1], _bits / 8, 1, sizeof(char), 0, 0, rawKey);
  mpz_add_ui(g, nj[1], 1);
  memcpy(&init_s_, rawKey+_bits/8, sizeof(int));
  
  // The client should not be using s above MAX_S
  if (init_s_ >= MAX_S)
  {
    std::cout << "PaillierKeys: WARNING. The client tries to use s>=MAX_S. Setting s=MAX_S-1."<<std::endl;
    init_s = MAX_S-1;
  } 
  else init_s = init_s_;

  for (int i = 2; i <= init_s+1; i++)
  {
    mpz_pow_ui(nj[i], nj[1], i);
  }
}
Exemple #19
0
void build_mainwindow(void) {
    mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    gtk_widget_set_app_paintable(mainwindow, TRUE);
    gtk_widget_set_size_request(mainwindow, conf_get_width(), conf_get_height());
    gtk_window_set_decorated(GTK_WINDOW(mainwindow), FALSE);
    gtk_window_set_skip_taskbar_hint(GTK_WINDOW(mainwindow), TRUE);
    gtk_window_set_skip_pager_hint(GTK_WINDOW(mainwindow), TRUE);
    gtk_window_set_resizable(GTK_WINDOW(mainwindow), TRUE);
    mainwindow_reset_position();

    fullscreen = FALSE;
    toggled = FALSE;
    
    GtkAccelGroup* accel_group;
    GClosure *new_tab, *delete_tab, *next_tab, *prev_tab, *delete_all,
        *maximize, *copy, *paste;

    accel_group = gtk_accel_group_new();
    gtk_window_add_accel_group(GTK_WINDOW(mainwindow), accel_group);

    maximize = g_cclosure_new_swap(G_CALLBACK(mainwindow_toggle_fullscreen),
            NULL, NULL);
    gtk_accel_group_connect(accel_group, GDK_F11, 0,
            GTK_ACCEL_VISIBLE, maximize);
    
    new_tab = g_cclosure_new_swap(G_CALLBACK(mainwindow_new_tab), 
            NULL, NULL);
    gtk_accel_group_connect(accel_group, 't', conf_get_key_mod(),
            GTK_ACCEL_VISIBLE, new_tab);

    delete_tab = g_cclosure_new_swap(G_CALLBACK(mainwindow_delete_tab), 
            NULL, NULL);
    gtk_accel_group_connect(accel_group, 'w', conf_get_key_mod(),
            GTK_ACCEL_VISIBLE, delete_tab);

    next_tab = g_cclosure_new_swap(G_CALLBACK(mainwindow_next_tab), 
            NULL, NULL);
    gtk_accel_group_connect(accel_group, GDK_Page_Down, conf_get_key_mod(),
            GTK_ACCEL_VISIBLE, next_tab);

    prev_tab = g_cclosure_new_swap(G_CALLBACK(mainwindow_prev_tab), 
            NULL, NULL);
    gtk_accel_group_connect(accel_group, GDK_Page_Up, conf_get_key_mod(),
            GTK_ACCEL_VISIBLE, prev_tab);

    delete_all = g_cclosure_new_swap(G_CALLBACK(mainwindow_destroy), 
            NULL, NULL);
    gtk_accel_group_connect(accel_group, 'q', conf_get_key_mod(),
            GTK_ACCEL_VISIBLE, delete_all);
            
    copy = g_cclosure_new_swap(G_CALLBACK(mainwindow_copy), 
            NULL, NULL);
    gtk_accel_group_connect(accel_group, 'c', conf_get_key_mod(),
            GTK_ACCEL_VISIBLE, copy);
            
    paste = g_cclosure_new_swap(G_CALLBACK(mainwindow_paste), 
            NULL, NULL);
    gtk_accel_group_connect(accel_group, 'v', conf_get_key_mod(),
            GTK_ACCEL_VISIBLE, paste);

    activetab = -1;
    tabs = g_array_new(TRUE, FALSE, sizeof(VteTerminal*));
    tabcount = 0;
    GtkVBox* mainbox = GTK_VBOX(gtk_vbox_new(FALSE, 0));
    tabbar = GTK_NOTEBOOK(gtk_notebook_new());
    g_signal_connect(G_OBJECT(tabbar), "switch-page",
            G_CALLBACK(mainwindow_switch_tab), NULL);

    if (conf_get_opacity() < 100) {
        GdkScreen *screen = gdk_screen_get_default();
        GdkColormap *colormap = gdk_screen_get_rgba_colormap(screen);
        screen_is_composited = (colormap != NULL
                && gdk_screen_is_composited(screen));

        if (screen_is_composited) {
            gtk_widget_set_colormap(GTK_WIDGET(mainwindow), colormap);
            gdk_screen_set_default_colormap(screen, colormap);
        }
    }

    gtk_box_pack_start(GTK_BOX(mainbox), GTK_WIDGET(tabbar), TRUE, TRUE, 0);

    mainwindow_create_tab();

    gtk_widget_show_all(GTK_WIDGET(mainbox));
    gtk_container_add(GTK_CONTAINER(mainwindow), GTK_WIDGET(mainbox));

    int border = conf_get_border();
    if (border == BORDER_THIN)
        gtk_container_set_border_width(GTK_CONTAINER(mainwindow), 1);
    else if (border == BORDER_THICK)
        gtk_container_set_border_width(GTK_CONTAINER(mainwindow), 5);
    if (border != BORDER_NONE)
        g_signal_connect(G_OBJECT(mainwindow), "expose-event",
                G_CALLBACK(mainwindow_expose_event), NULL);
    /*
     * g_signal_connect connects a GCallback function to a signal for a 
     * particular object.  For example, when the 'focus-out-event' signal is
     * triggered (That is, when Stjerm loses focus), the 
     * 'mainwindow_focus_out_event' function will run.
     */
    if (conf_get_auto_hide())
        g_signal_connect(G_OBJECT(mainwindow), "focus-out-event",
                G_CALLBACK(mainwindow_focus_out_event), NULL);
    g_signal_connect(G_OBJECT(mainwindow), "show", G_CALLBACK(mainwindow_show), 
            NULL);
    g_signal_connect(G_OBJECT(mainwindow), "destroy",
            G_CALLBACK(mainwindow_destroy), NULL);

    gtk_notebook_set_show_border(tabbar, FALSE);
    gtk_notebook_set_scrollable(tabbar, TRUE);
    if (conf_get_show_tab() == TABS_ONE|| conf_get_show_tab() == TABS_NEVER)
        gtk_notebook_set_show_tabs(tabbar, FALSE);
    gtk_notebook_set_tab_pos(tabbar, conf_get_tab_pos());

    XSetErrorHandler(handle_x_error);
    init_key(); // init_key and grab_key are
    grab_key(); // defined globally in stjerm.h
    g_thread_create((GThreadFunc)wait_key, NULL, FALSE, NULL);
}
PROXY_API __bool PMC_API init_proxy(HWND hWnd, __uint flags)
{
	char * szWarning = "没有找到软件狗,进入演示状态,数据库最大规模32点";

	if(!_g_InitLock){
		_g_InitLock = new CLock;
	}
	
	g_InitLock.Lock();
	if(g_iInitCount){
		g_iInitCount++;
		g_InitLock.UnLock();
		return __true;
	}

	g_iInitCount++;

	g_iInitFlag = flags;
	
	_load_settings(__false);
	
	g_DBDispatchTable.OnAddNode = _on_add_node;
	g_DBDispatchTable.OnDropNode = _on_del_node;
	hook_rtdb_events(&g_DBDispatchTable);
	
	if(!(g_iInitFlag & PROXY_INIT_AS_SERVER)){
		unsigned char run, dev;
		int runLevel, devLevel;
		init_key();
		get_key(&run, &runLevel, &dev, &devLevel);
		if(!dev){
			/* no dog is attached*/
			/* create_group(0x12345678,xxx) is a loophole */
			create_group((RTK_CURSOR)0x12345678, (PRTK_GROUP)32);
			if(!(flags & PROXY_SILENT)){
				MessageBox(
					hWnd,
					szWarning,
					"PMC Error",
					MB_OK
					);
			}
		}else{
			/* yes, dog is attached, set database limit */
			create_group((RTK_CURSOR)0x12345678, (PRTK_GROUP)devLevel);
		}
	}
	init_powermgr();
	init_network(0);
	init_rtdb();
	connect_vbus(BUSID_RTDB, 0, _on_rtdb, default_client_filter);
	connect_vbus(BUSID_CONFIG, 0, _on_config, default_client_filter);
	connect_vbus(BUSID_ALARM, 0, _on_alarm, default_client_filter);
	connect_vbus(BUSID_SYSTEM, 0, _on_system, default_client_filter);
	connect_vbus(BUSID_OPERATION, 0, 0, default_client_filter);
	if(flags & PROXY_ENABLE_DISPATCHER){
		start_dispatcher();
	}	

	g_Worker = new CProxyWorker(flags);
	if(!g_Worker){
		g_InitLock.UnLock();
		return __false;		
	}
	g_Worker->start();

#if defined(_WIN32) && 1
	SetThreadPriority(g_Worker->handle(), THREAD_PRIORITY_BELOW_NORMAL);
#endif
		
	g_InitLock.UnLock();
	return __true;
}
bool service_registry::has_service() const
{
  execution_context::service::key key;
  init_key(key, Service::id);
  return do_has_service(key);
}
void service_registry::add_service(Service* new_service)
{
  execution_context::service::key key;
  init_key(key, Service::id);
  return do_add_service(key, new_service);
}
Exemple #23
0
Fichier : main.c Projet : V07D/mc
int
main (int argc, char *argv[])
{
    GError *mcerror = NULL;
    gboolean config_migrated = FALSE;
    char *config_migrate_msg;
    int exit_code = EXIT_FAILURE;

    mc_global.timer = mc_timer_new ();

    /* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */
#ifdef HAVE_SETLOCALE
    (void) setlocale (LC_ALL, "");
#endif
    (void) bindtextdomain (PACKAGE, LOCALEDIR);
    (void) textdomain (PACKAGE);

    /* do this before args parsing */
    str_init_strings (NULL);

    if (!mc_args_parse (&argc, &argv, "mc", &mcerror))
    {
      startup_exit_falure:
        fprintf (stderr, _("Failed to run:\n%s\n"), mcerror->message);
        g_error_free (mcerror);
        g_free (mc_global.tty.shell);
      startup_exit_ok:
        str_uninit_strings ();
        mc_timer_destroy (mc_global.timer);
        return exit_code;
    }

    /* do this before mc_args_show_info () to view paths in the --datadir-info output */
    OS_Setup ();

    if (!g_path_is_absolute (mc_config_get_home_dir ()))
    {
        mc_propagate_error (&mcerror, 0, "%s: %s", _("Home directory path is not absolute"),
                            mc_config_get_home_dir ());
        mc_event_deinit (NULL);
        goto startup_exit_falure;
    }

    if (!mc_args_show_info ())
    {
        exit_code = EXIT_SUCCESS;
        goto startup_exit_ok;
    }

    if (!events_init (&mcerror))
        goto startup_exit_falure;

    mc_config_init_config_paths (&mcerror);
    config_migrated = mc_config_migrate_from_old_place (&mcerror, &config_migrate_msg);
    if (mcerror != NULL)
    {
        mc_event_deinit (NULL);
        goto startup_exit_falure;
    }

    vfs_init ();
    vfs_plugins_init ();

    load_setup ();

    /* Must be done after load_setup because depends on mc_global.vfs.cd_symlinks */
    vfs_setup_work_dir ();

    /* Resolve the other_dir panel option. Must be done after vfs_setup_work_dir */
    {
        char *buffer;
        vfs_path_t *vpath;

        buffer = mc_config_get_string (mc_panels_config, "Dirs", "other_dir", ".");
        vpath = vfs_path_from_str (buffer);
        if (vfs_file_is_local (vpath))
            saved_other_dir = buffer;
        else
            g_free (buffer);
        vfs_path_free (vpath);
    }

    /* Set up temporary directory after VFS initialization */
    mc_tmpdir ();

    /* do this after vfs initialization and vfs working directory setup
       due to mc_setctl() and mcedit_arg_vpath_new() calls in mc_setup_by_args() */
    if (!mc_setup_by_args (argc, argv, &mcerror))
    {
        vfs_shut ();
        done_setup ();
        g_free (saved_other_dir);
        mc_event_deinit (NULL);
        goto startup_exit_falure;
    }

    /* check terminal type
     * $TEMR must be set and not empty
     * mc_global.tty.xterm_flag is used in init_key() and tty_init()
     * Do this after mc_args_handle() where mc_args__force_xterm is set up.
     */
    mc_global.tty.xterm_flag = tty_check_term (mc_args__force_xterm);

    /* NOTE: This has to be called before tty_init or whatever routine
       calls any define_sequence */
    init_key ();

    /* Must be done before installing the SIGCHLD handler [[FIXME]] */
    handle_console (CONSOLE_INIT);

#ifdef ENABLE_SUBSHELL
    /* Don't use subshell when invoked as viewer or editor */
    if (mc_global.mc_run_mode != MC_RUN_FULL)
        mc_global.tty.use_subshell = FALSE;

    if (mc_global.tty.use_subshell)
        subshell_get_console_attributes ();
#endif /* ENABLE_SUBSHELL */

    /* Install the SIGCHLD handler; must be done before init_subshell() */
    init_sigchld ();

    /* We need this, since ncurses endwin () doesn't restore the signals */
    save_stop_handler ();

    /* Must be done before init_subshell, to set up the terminal size: */
    /* FIXME: Should be removed and LINES and COLS computed on subshell */
    tty_init (!mc_args__nomouse, mc_global.tty.xterm_flag);

    /* start check mc_global.display_codepage and mc_global.source_codepage */
    check_codeset ();

    /* Removing this from the X code let's us type C-c */
    load_key_defs ();

    load_keymap_defs (!mc_args__nokeymap);

    macros_list = g_array_new (TRUE, FALSE, sizeof (macros_t));

    tty_init_colors (mc_global.tty.disable_colors, mc_args__force_colors);

    mc_skin_init (NULL, &mcerror);
    dlg_set_default_colors ();
    input_set_default_colors ();
    if (mc_global.mc_run_mode == MC_RUN_FULL)
        command_set_default_colors ();

    mc_error_message (&mcerror);

#ifdef ENABLE_SUBSHELL
    /* Done here to ensure that the subshell doesn't  */
    /* inherit the file descriptors opened below, etc */
    if (mc_global.tty.use_subshell)
        init_subshell ();
#endif /* ENABLE_SUBSHELL */

    /* Also done after init_subshell, to save any shell init file messages */
    if (mc_global.tty.console_flag != '\0')
        handle_console (CONSOLE_SAVE);

    if (mc_global.tty.alternate_plus_minus)
        application_keypad_mode ();

    /* Done after subshell initialization to allow select and paste text by mouse
       w/o Shift button in subshell in the native console */
    init_mouse ();

    /* Done after do_enter_ca_mode (tty_init) because in VTE bracketed mode is
       separate for the normal and alternate screens */
    enable_bracketed_paste ();

    /* subshell_prompt is NULL here */
    mc_prompt = (geteuid () == 0) ? "# " : "$ ";

    if (config_migrated)
    {
        message (D_ERROR, _("Warning"), "%s", config_migrate_msg);
        g_free (config_migrate_msg);
    }

    /* Program main loop */
    if (mc_global.midnight_shutdown)
        exit_code = EXIT_SUCCESS;
    else
        exit_code = do_nc ()? EXIT_SUCCESS : EXIT_FAILURE;

    /* Save the tree store */
    (void) tree_store_save ();

    free_keymap_defs ();

    /* Virtual File System shutdown */
    vfs_shut ();

    flush_extension_file ();    /* does only free memory */

    mc_skin_deinit ();
    tty_colors_done ();

    tty_shutdown ();

    done_setup ();

    if (mc_global.tty.console_flag != '\0' && (quit & SUBSHELL_EXIT) == 0)
        handle_console (CONSOLE_RESTORE);
    if (mc_global.tty.alternate_plus_minus)
        numeric_keypad_mode ();

    (void) signal (SIGCHLD, SIG_DFL);   /* Disable the SIGCHLD handler */

    if (mc_global.tty.console_flag != '\0')
        handle_console (CONSOLE_DONE);

    if (mc_global.mc_run_mode == MC_RUN_FULL && mc_args__last_wd_file != NULL
        && last_wd_string != NULL && !print_last_revert)
    {
        int last_wd_fd;

        last_wd_fd = open (mc_args__last_wd_file, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL,
                           S_IRUSR | S_IWUSR);
        if (last_wd_fd != -1)
        {
            ssize_t ret1;
            int ret2;
            ret1 = write (last_wd_fd, last_wd_string, strlen (last_wd_string));
            ret2 = close (last_wd_fd);
            (void) ret1;
            (void) ret2;
        }
    }
    g_free (last_wd_string);

    g_free (mc_global.tty.shell);

    done_key ();

    if (macros_list != NULL)
    {
        guint i;
        for (i = 0; i < macros_list->len; i++)
        {
            macros_t *macros;

            macros = &g_array_index (macros_list, struct macros_t, i);
            if (macros != NULL && macros->macro != NULL)
                (void) g_array_free (macros->macro, FALSE);
        }
        (void) g_array_free (macros_list, TRUE);
    }
Exemple #24
0
Fichier : main.c Projet : BrEacK/mc
int
main (int argc, char *argv[])
{
    GError *error = NULL;
    int exit_code = EXIT_FAILURE;

    /* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */
    (void) setlocale (LC_ALL, "");
    (void) bindtextdomain ("mc", LOCALEDIR);
    (void) textdomain ("mc");

    /* do this before args parsing */
    str_init_strings (NULL);

    if (!mc_args_parse (&argc, &argv, "mc", &error))
    {
      startup_exit_falure:
        fprintf (stderr, _("Failed to run:\n%s\n"), error->message);
        g_error_free (error);
        g_free (shell);
      startup_exit_ok:
        str_uninit_strings ();
        return exit_code;
    }

    /* do this before mc_args_show_info () to view paths in the --datadir-info output */
    OS_Setup ();

    if (!g_path_is_absolute (mc_config_get_home_dir ()))
    {
        error = g_error_new (MC_ERROR, 0, "%s: %s", _("Home directory path is not absolute"),
                             mc_config_get_home_dir ());
        mc_event_deinit (NULL);
        goto startup_exit_falure;
    }

    if (!mc_args_show_info ())
    {
        exit_code = EXIT_SUCCESS;
        goto startup_exit_ok;
    }

    if (!events_init (&error))
        goto startup_exit_falure;

    mc_config_init_config_paths (&error);
    if (error == NULL && mc_config_deprecated_dir_present ())
        mc_config_migrate_from_old_place (&error);
    if (error != NULL)
    {
        mc_event_deinit (NULL);
        goto startup_exit_falure;
    }

    vfs_init ();
    vfs_plugins_init ();
    vfs_setup_work_dir ();

    /* do this after vfs initialization due to mc_setctl() call in mc_setup_by_args() */
    if (!mc_setup_by_args (argc, argv, &error))
    {
        vfs_shut ();
        mc_event_deinit (NULL);
        goto startup_exit_falure;
    }

    /* check terminal type
     * $TEMR must be set and not empty
     * mc_global.tty.xterm_flag is used in init_key() and tty_init()
     * Do this after mc_args_handle() where mc_args__force_xterm is set up.
     */
    mc_global.tty.xterm_flag = tty_check_term (mc_args__force_xterm);

    /* NOTE: This has to be called before tty_init or whatever routine
       calls any define_sequence */
    init_key ();

    /* Must be done before installing the SIGCHLD handler [[FIXME]] */
    handle_console (CONSOLE_INIT);

#ifdef HAVE_SUBSHELL_SUPPORT
    /* Don't use subshell when invoked as viewer or editor */
    if (mc_global.mc_run_mode != MC_RUN_FULL)
        mc_global.tty.use_subshell = FALSE;

    if (mc_global.tty.use_subshell)
        subshell_get_console_attributes ();
#endif /* HAVE_SUBSHELL_SUPPORT */

    /* Install the SIGCHLD handler; must be done before init_subshell() */
    init_sigchld ();

    /* We need this, since ncurses endwin () doesn't restore the signals */
    save_stop_handler ();

    /* Must be done before init_subshell, to set up the terminal size: */
    /* FIXME: Should be removed and LINES and COLS computed on subshell */
    tty_init (!mc_args__nomouse, mc_global.tty.xterm_flag);

    load_setup ();

    /* start check mc_global.display_codepage and mc_global.source_codepage */
    check_codeset ();

    /* Removing this from the X code let's us type C-c */
    load_key_defs ();

    load_keymap_defs (!mc_args__nokeymap);

    macros_list = g_array_new (TRUE, FALSE, sizeof (macros_t));

    tty_init_colors (mc_global.tty.disable_colors, mc_args__force_colors);

    mc_skin_init (&error);
    if (error != NULL)
    {
        message (D_ERROR, _("Warning"), "%s", error->message);
        g_error_free (error);
        error = NULL;
    }

    mc_filehighlight = mc_fhl_new (TRUE);
    dlg_set_default_colors ();

#ifdef HAVE_SUBSHELL_SUPPORT
    /* Done here to ensure that the subshell doesn't  */
    /* inherit the file descriptors opened below, etc */
    if (mc_global.tty.use_subshell)
        init_subshell ();

#endif /* HAVE_SUBSHELL_SUPPORT */

    /* Also done after init_subshell, to save any shell init file messages */
    if (mc_global.tty.console_flag != '\0')
        handle_console (CONSOLE_SAVE);

    if (mc_global.tty.alternate_plus_minus)
        application_keypad_mode ();

#ifdef HAVE_SUBSHELL_SUPPORT
    if (mc_global.tty.use_subshell)
    {
        mc_prompt = strip_ctrl_codes (subshell_prompt);
        if (mc_prompt == NULL)
            mc_prompt = (geteuid () == 0) ? "# " : "$ ";
    }
    else
#endif /* HAVE_SUBSHELL_SUPPORT */
        mc_prompt = (geteuid () == 0) ? "# " : "$ ";

    /* Program main loop */
    if (mc_global.midnight_shutdown)
        exit_code = EXIT_SUCCESS;
    else
        exit_code = do_nc ()? EXIT_SUCCESS : EXIT_FAILURE;

    /* Save the tree store */
    (void) tree_store_save ();

    free_keymap_defs ();

    /* Virtual File System shutdown */
    vfs_shut ();

    flush_extension_file ();    /* does only free memory */

    mc_fhl_free (&mc_filehighlight);
    mc_skin_deinit ();
    tty_colors_done ();

    tty_shutdown ();

    done_setup ();

    if (mc_global.tty.console_flag != '\0' && (quit & SUBSHELL_EXIT) == 0)
        handle_console (CONSOLE_RESTORE);
    if (mc_global.tty.alternate_plus_minus)
        numeric_keypad_mode ();

    (void) signal (SIGCHLD, SIG_DFL);   /* Disable the SIGCHLD handler */

    if (mc_global.tty.console_flag != '\0')
        handle_console (CONSOLE_DONE);

    if (mc_global.mc_run_mode == MC_RUN_FULL && mc_args__last_wd_file != NULL
        && last_wd_string != NULL && !print_last_revert)
    {
        int last_wd_fd;

        last_wd_fd = open (mc_args__last_wd_file, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL,
                           S_IRUSR | S_IWUSR);
        if (last_wd_fd != -1)
        {
            ssize_t ret1;
            int ret2;
            ret1 = write (last_wd_fd, last_wd_string, strlen (last_wd_string));
            ret2 = close (last_wd_fd);
        }
    }
    g_free (last_wd_string);

    g_free (shell);

    done_key ();

    if (macros_list != NULL)
    {
        guint i;
        macros_t *macros;
        for (i = 0; i < macros_list->len; i++)
        {
            macros = &g_array_index (macros_list, struct macros_t, i);
            if (macros != NULL && macros->macro != NULL)
                (void) g_array_free (macros->macro, FALSE);
        }
        (void) g_array_free (macros_list, TRUE);
    }
Exemple #25
0
int main()
{
	characters_init();
	PORT_INIT();
	LCD_INIT();
	init_key();
	//设定mah 2580 为3000mah 4b00 为6000
	/*while(!ds_reset());
	ds_write_byte(CMD_ONEWIRE_SKIP_ROM);
	ds_write_byte(CMD_ONEWIRE_WRITE);
	ds_write_byte(CMD_ADDR_ACR);
	ds_write_byte(0X4b);
	ds_write_byte(0X00);*/
	int count = 5; 
	char key;
	while(1)
	{
		key = get_key();
		//switch mode and in edit edit.
		if(key==1)
		{	
			//in mode 1 go to next cursor 
			if(yes&&mode==1)
			{		
				//go back to the begining of the line
				if(pos_mode1==4){LCD_WR_COM(0X02);}
				else
				{
					//cursor to the next
					LCD_WR_COM(0X14);
				}
				//the position of mode1 add
				pos_mode1 = (pos_mode1+1)%5;
			}
			else if(yes&&mode==2)
			{
				//go to the begining of the first line
				if(pos_mode2==4){LCD_WR_COM(0X02);}
				else
				{
						LCD_WR_COM(0x14);
				}
				pos_mode2 = (pos_mode2+1)%5;
			}
			else
			{
				switch_mode(1);
				mode = (mode+1)%3;
			}
		}
		if(key==3)
		{
			yes = ~yes;
			switch_mode(3);
		}
		if(key==2)
		{
			if(mode==1&&yes)
			{
				res[pos_mode1]=(res[pos_mode1]+1-'0')%10+'0';
				LCD_WR_COM(0X80+pos_mode1);
				LCD_WR_DATA(res[pos_mode1]);
				LCD_WR_COM(0X10);
				
			}
			if(mode==2&&yes)
			{
				fullc[pos_mode2] = (fullc[pos_mode2]+1-'0')%10+'0';	
				LCD_WR_COM(0x80+pos_mode2);
				LCD_WR_DATA(fullc[pos_mode2]);
				LCD_WR_COM(0X10);
			}
		}
		if(mode==0)
		{
			if(count==0)
			{
				count=4;
				LCD_CLEAR();
			}
			count--;
		}
		update();
		mode_pro();
		_delay_ms(50);
	}

}
Exemple #26
0
void init()
{
	sigset_t sigmask;
	sigemptyset(&sigmask);
	sigaddset(&sigmask, SIGALRM);
	sigaddset(&sigmask, SIGUSR1);
	
	sigprocmask(SIG_BLOCK, &sigmask, NULL);

	console_print("Emergence Client " VERSION "\n");
	
	SDL_Init(SDL_INIT_AUDIO);
	
	init_user();
	init_network();
	init_timer();
	init_openssl();
	init_key();
	init_download();
	init_servers();

	create_cvars();
	init_console_cvars();
	init_render_cvars();
	init_map_cvars();
	create_control_cvars();
//	create_input_cvars();
	init_tick_cvars();

	init_console();
	create_colour_cvars();
	
	struct string_t *string = new_string_string(emergence_home_dir);
	string_cat_text(string, "/client.config");
	
	if(!exec_config_file(string->text))
	{
		exec_config_file(find_resource("default-controls.config"));
	}
	else
	{
		char *ver = get_cvar_string("version");
		
		if(*ver == '\0')
		{
			struct string_t *command = new_string_text("rm ");
			string_cat_string(command, emergence_home_dir);
			string_cat_text(command, "/skins/default.skin*");
			
			console_print("%s\n", command->text);
			system(command->text);
			
			vid_mode = -1;	// find a nice mode

			exec_config_file(find_resource("default-controls.config"));
		}
		
		free(ver);
	}
	
	free_string(string);
	
	
	set_cvar_string("version", VERSION);
	
	init_skin();
	init_input();
	init_control();
	

	init_render();
	init_rcon();
	init_ping();

	create_cvar_command("quit", client_shutdown_char);
	

	init_sound();
	init_game();
	
	init_alarm();
	
	render_frame();
	
	string = new_string_text("%s%s", emergence_home_dir->text, "/client.autoexec");
	if(!exec_config_file(string->text))
		exec_config_file(find_resource("default-client.autoexec"));
	free_string(string);
	
	start_server_discovery();
}
void service_registry::add_service(Service* new_service)
{
  lslboost::asio::io_service::service::key key;
  init_key(key, Service::id);
  return do_add_service(key, new_service);
}
Exemple #28
0
static BOOL init_registry(BOOL init)
{
    return init_key("Wine.Test\\CLSID", TESTOBJ_CLSID, init);
}
bool service_registry::has_service() const
{
  lslboost::asio::io_service::service::key key;
  init_key(key, Service::id);
  return do_has_service(key);
}
Exemple #30
0
void threadTest(uint64_t arg) {
    int maxtop          = 16;
    int top             = 16;
    int nbuckets        = hashsize(16);
//    uint64_t updates    = 160 * nbuckets;
    uint64_t updates    = 16;
    int i, t, cmd_type;
    int mm_size[4];
    void* buf[4];
    Reporter_t *rpt[4];
    char *recv          = plat_alloc(300*top);
    char *cmp_recv      = plat_alloc(300*top);
    
    for (int i = 0; i < 4; i++) {
        mm_size[i]   = calc_hotkey_memory(maxtop, nbuckets, i);
        buf[i] = plat_alloc(mm_size[i]);
        rpt[i] = hot_key_init(buf[i], mm_size[i], nbuckets, maxtop, i);
    }

    init_key(4);

    // case 0: 0x00 handler
    // keys are get/update, randomized ip, result should be
    // merged keys and 0 for ip

    // 16 keys with different ip
    for (i = 0; i < updates*2; i++) {
        t = i % KEY_NUM;
        int ip = rnd_ip(i);
        cmd_type = rnd_cmd(i % 2);
        printf("key_t=%s\n", keys[t].key_str);
        hot_key_update(rpt[0], keys[t].key_str, KEY_LEN+1,
                       keys[t].syndrome, keys[t].bucket, cmd_type, ip);
        cmd_type <= 2 ? (keys[t].get_count++): (keys[t].update_count++);
        keys[t].count++;
    }
    recv[0] = '\0';
    hot_key_report(rpt[0], top, recv, 300*top, 1, 0);
    printf("handle 0x00:get\n%s", recv);
    strcpy(cmp_recv, recv);

    recv[0] = '\0';
    hot_key_report(rpt[0], top, recv, 300*top, 2, 0);
    printf("handle 0x00:update\n%s", recv);

    if (strcmp(cmp_recv, recv)) {
        printf("error: get/update should be both access for 0x00 reporter\n");
        nfailed++;
    }

    recv[0] = '\0';
    hot_client_report(rpt[0], top, recv, 300*top);
    printf("handle 0x00: client\n%s", recv);
    hot_key_reset(rpt[0]);

    // case 1: 0x01 handler
    // keys are get/update, randomized ip, result should be
    // seperate keys and 0 for ip

    // each instance has 16 keys with different ip
    for (i = 0; i < updates*2; i++) {
        t = i % KEY_NUM;
        for (int j = 0; j < 2; j++) {
            int ip = rnd_ip(i);
            cmd_type = rnd_cmd(j);
            hot_key_update(rpt[1], keys[t].key_str, KEY_LEN+1,
                           keys[t].syndrome, keys[t].bucket, cmd_type, ip);
            cmd_type <= 2 ? (keys[t].get_count++):
                (keys[t].update_count++);
            keys[t].count++;
        }
    }

    recv[0] = '\0';
    hot_key_report(rpt[1], top, recv, 300*top, 1, 0);
    printf("handle 0x01:get\n%s", recv);
    strcpy(cmp_recv, recv);
    recv[0] = '\0';
    hot_key_report(rpt[1], top, recv, 300*top, 3, 0);
    printf("handle 0x01:update\n%s", recv);
    if (strcmp(cmp_recv, recv) != 0) {
        printf("error: get/update should be the same for 0x01 reporter\n");
        nfailed++;
    }

    recv[0] = '\0';
    hot_client_report(rpt[1], top, recv, 300*top);
    printf("handle 0x01: client\n%s", recv);
    hot_key_reset(rpt[1]);

    // case 2: 0x02 handler
    // keys are get/update, randomized ip, result should be
    // merged keys keys for get/set while different ip

    // 8 sets, and 8 gets, the winner is filled with 16 entries
    // with the same key but different ip
    for (i = 0; i < updates*4; i++) {
        int ip = rnd_ip(i);
        for (int j = 0; j < 2; j++) {
            t = j;
            int cmd_type = rnd_cmd(j);
            hot_key_update(rpt[2], keys[t].key_str, KEY_LEN+1,
                           keys[t].syndrome, keys[t].bucket, cmd_type, ip);
        }
    }

    recv[0] = '\0';
    hot_key_report(rpt[2], top, recv, 300*top, 1, 0);
    printf("handle 0x02:get\n%s", recv);
    strcpy(cmp_recv, recv);
    recv[0] = '\0';
    hot_key_report(rpt[2], top, recv, 300*top, 3, 0);
    printf("handle 0x02:update\n%s", recv);
    if (strcmp(cmp_recv, recv)) {
        printf("error: get/update should be same for 0x02 reporter\n");
        nfailed++;
    }

    recv[0] = '\0';
    hot_client_report(rpt[2], top, recv, 300*top);
    printf("handle 0x02: client\n%s", recv);
    hot_key_reset(rpt[2]);


    // case 3: 0x03 handler
    // keys are get/update, randomized ip, result should be
    // separated keys keys for get/set while different ip

    // 16 sets, and 16 gets, the winner is filled with 16 entries
    // with the same key but different ip
    for (i = 0; i < updates*4; i++) {
        t = 0;
        int ip = rnd_ip(i);
        for (int j = 0; j < 2; j++) {
            int cmd_type = rnd_cmd(j);
            hot_key_update(rpt[3], keys[t].key_str, KEY_LEN+1,
                           keys[t].syndrome, keys[t].bucket, cmd_type, ip);
        }
    }
    recv[0] = '\0';
    hot_key_report(rpt[3], top, recv, 300*top, 1, 0);
    printf("handle 0x03: get\n%s", recv);
    strcpy(cmp_recv, recv);
    recv[0] = '\0';
    hot_key_report(rpt[3], top, recv, 300*top, 3, 0);
    printf("handle 0x03: update\n%s", recv);
    if (strcmp(cmp_recv, recv) != 0) {
        printf("error: get/update should be the same for 0x03 reporter\n");
        nfailed++;
    }

    recv[0] = '\0';
    hot_client_report(rpt[3], top, recv, 300*top);
    printf("handle 0x03: client\n%s", recv);
    hot_key_reset(rpt[3]);

    plat_free(recv);
    plat_free(cmp_recv);

    printf("nfailed = %d\n", nfailed);
    done = 1;
}