Пример #1
0
int main()
{
    int result = 0;

    if (setup_destination()) {
        printf("Error initializing destination.\n");
        result = 1;
        goto done;
    }

    if (setup_source()) {
        printf("Done initializing source.\n");
        result = 1;
        goto done;
    }

    wait_ready();

    if (setup_map()) {
        printf("Error initializing map.\n");
        result = 1;
        goto done;
    }

    printf("SENDING UDP\n");
    loop();

    set_map_protocol(MAPPER_PROTO_TCP);
    printf("SENDING TCP\n");
    loop();

    set_map_protocol(MAPPER_PROTO_UDP);
    printf("SENDING UDP AGAIN\n");
    loop();

    if (sent != received) {
        printf("Not all sent messages were received.\n");
        printf("Updated value %d time%s, but received %d of them.\n",
               sent, sent == 1 ? "" : "s", received);
        result = 1;
    }

done:
    cleanup_destination();
    cleanup_source();
    printf("Test %s.\n", result ? "FAILED" : "PASSED");
    return result;
}
Пример #2
0
int		main(int ac, char **av)
{
	t_box	box;
	int		fd;

	ft_bzero(&box, sizeof(t_box));
	box.color = 0xFFFFFF;
	if (ac > 2)
		analyze_args(ac, av, &box);
	if (ac < 2)
		error_lem("NO ARGUMENT\n", &box);
	fd = open(av[ac - 1], O_RDONLY);
	setup_env(&box, fd);
	setup_map(&box);
	display_info();
	mlx_hook(box.win, 2, (1L << 0), command, &box);
	mlx_loop(box.mlx);
	return (0);
}
Пример #3
0
/**
 * Initialize permanent data in search table.
 */
static void
st_initialize(search_table_t *table)
{
	guchar cur_char = '\0';
	guint i;

	search_table_check(table);

	table->nentries = table->nchars = 0;
	setup_map();

	/*
	 * The indexing map is used to avoid having 256*256 bins.
	 */

	for (i = 0; i < G_N_ELEMENTS(table->index_map); i++) {
		guchar map_char = map[i];

		if (table->fold_map[map_char]) {
			table->index_map[i] = table->fold_map[map_char];
		} else {
			table->fold_map[map_char] = cur_char;
			table->index_map[i] = cur_char;
			cur_char++;
		}
	}

	table->nchars = cur_char;
	table->nbins = table->nchars * table->nchars;
	table->bins = NULL;
	table->all_entries.vals = 0;

	if (GNET_PROPERTY(matching_debug)) {
		static gboolean done;

		if (!done) {
			done = TRUE;
			g_debug("MATCH search tables will use %d bins max "
				"(%d indexing chars)", table->nbins, table->nchars);
		}
	}
}
Пример #4
0
OSErr AddToMasterFile(INTEGER from_file_rn, INTEGER master_file_rn)
{
  OSErr err;
  mapping_t mapping;
  INTEGER type_num, type_num_max;
  ResType type;
  Handle h;
  Str255 name;
  BOOLEAN save_resload;

  err = setup_map (from_file_rn, master_file_rn, &mapping);
  if (err == noEErr)
    {
      type_num_max = CountTypesRN (from_file_rn);
      save_resload = ResLoad;
      SetResLoad (false);
      for (type_num = 1; type_num <= type_num_max; ++type_num)
	{
	  GetIndTypeRN (from_file_rn, &type, type_num);
	  res_num_max = CountResourcesRN (from_file_rn, type);
	  for (res_num = 1; res_num <= res_num_max; ++res_num)
	    {
	      h = GetIndResourceRN (from_file_rn, type, res_num);
	      GetResInfo (h, &id, &t, name);
	      if (map_id (&id, from_file_rn, master_file_rn, &mapping))
		{
		  LoadResource(h);
		  DetachResource(h);
		  map_data (h, &mapping);
		  AddResourceRN (master_file_rn, h, type, id, name);
		}
	    }
	}
      SetResLoad (save_resload);
    }
}