Example #1
0
File: game.c Project: kyri33/filler
void	begin_game(t_env *e)
{
	if (e->my_turn)
	{
		gnl_until("0123456");
		populate_map(e);
	}
	else
	{
		e->my_turn = 1;
		gnl_until("01234");
		populate_map(e);
	}
	malloc_piece(e);
	populate_piece(e);
	if (!make_move(e))
	{
		print_move(0, 0);
		ft_freemap(e);
		exit(0);
	}
	free_piece(e);
	e->my_turn = 0;
	gnl_until("Plateau");
	begin_game(e);
}
bool AlarmTableDefs::initialize(std::string& path)
{
  std::map<unsigned int, unsigned int> dup_check;
  _key_to_def.clear();

  bool rc = true;
  boost::filesystem::path p(path);

  if ((boost::filesystem::exists(p)) && (boost::filesystem::is_directory(p)))
  {
    boost::filesystem::directory_iterator dir_it(p);
    boost::filesystem::directory_iterator end_it;

    while ((dir_it != end_it) && (rc))
    {
      if ((boost::filesystem::is_regular_file(dir_it->status())) &&
          (dir_it->path().extension() == ".json"))
      {
        rc = populate_map(dir_it->path().c_str(), dup_check);
      }

      dir_it++;
    }
  }
  else
  {
    TRC_ERROR("Unable to open directory at %s", path.c_str());
    rc = false;
  }

  return rc;
}
static void test_map_in_map(void)
{
	struct sockaddr_in6 in6 = { .sin6_family = AF_INET6 };
	uint32_t result_key = 0, port_key;
	int result, inline_result;
	int magic_result = 0xfaceb00c;
	int ret;
	int i;

	port_key = rand() & 0x00FF;
	populate_map(port_key, magic_result);

	in6.sin6_addr.s6_addr16[0] = 0xdead;
	in6.sin6_addr.s6_addr16[1] = 0xbeef;
	in6.sin6_port = port_key;

	for (i = 0; i < NR_TESTS; i++) {
		printf("%s: ", test_names[i]);

		in6.sin6_addr.s6_addr16[7] = i;
		ret = connect(-1, (struct sockaddr *)&in6, sizeof(in6));
		assert(ret == -1 && errno == EBADF);

		ret = bpf_map_lookup_elem(REG_RESULT_H, &result_key, &result);
		assert(!ret);

		ret = bpf_map_lookup_elem(INLINE_RESULT_H, &result_key,
					  &inline_result);
		assert(!ret);

		if (result != magic_result || inline_result != magic_result) {
			printf("Error. result:%d inline_result:%d\n",
			       result, inline_result);
			exit(1);
		}

		bpf_map_delete_elem(REG_RESULT_H, &result_key);
		bpf_map_delete_elem(INLINE_RESULT_H, &result_key);

		printf("Pass\n");
	}
}