Esempio n. 1
0
int main()
{
  //printf("Some random hashes:\n");
  //printf("\tBazinga: %d\n", map_hash_key("Bazinga"));
  //printf("\tFlabagoobie: %d\n", map_hash_key("Flabagoobie"));
  //printf("\tScooby: %d\n", map_hash_key("Scooby"));
  //printf("\tMcDooby: %d\n", map_hash_key("McDooby"));
  //printf("\tagnizaB: %d\n", map_hash_key("agnizaB"));

  Map map;
  map_init(&map);

  map_set(&map, "bazinga", "bazonga");
  map_set(&map, "zabinga", "zabonga");
  map_set(&map, "zabniga", "maponya");
  map_set(&map, "kabanooga", "daboogawoofa");

  MapItem *item;

  print_map(&map);
  map_get(&map, "abzinga");

  printf("================================\n");

  print_map(&map);
  map_free(&map);
}
Esempio n. 2
0
int
ikev2_pld_eap(struct iked *env, struct ikev2_payload *pld,
    struct iked_message *msg, size_t offset, size_t left)
{
	struct eap_header		 hdr;
	struct eap_message		*eap = NULL;
	struct iked_sa			*sa = msg->msg_sa;
	size_t				 len;

	if (ikev2_validate_eap(msg, offset, left, pld, &hdr))
		return (-1);
	len = betoh16(hdr.eap_length);

	if (len < sizeof(*eap)) {
		log_info("%s: %s id %d length %d", __func__,
		    print_map(hdr.eap_code, eap_code_map),
		    hdr.eap_id, betoh16(hdr.eap_length));
	} else {
		/* Now try to get the indicated length */
		if ((eap = ibuf_seek(msg->msg_data, offset, len)) == NULL) {
			log_debug("%s: invalid EAP length", __func__);
			return (-1);
		}

		log_info("%s: %s id %d length %d EAP-%s", __func__,
		    print_map(eap->eap_code, eap_code_map),
		    eap->eap_id, betoh16(eap->eap_length),
		    print_map(eap->eap_type, eap_type_map));
	}

	if (eap_parse(env, sa, &hdr, msg->msg_response) == -1)
		return (-1);

	return (0);
}
int main(int argc, char* argv[]) {
    //Set
    std::cout << "Set:" << std::endl;
    std::set<int> std_set;
    std_set.insert(20);
    std_set.insert(20);
    std_set.insert(10);
    print_container(std_set);
    
    //MultiSet
    std::cout << "MultiSet:" << std::endl;
    std::multiset<int> std_multiset;
    std_multiset.insert(20);
    std_multiset.insert(20);
    std_multiset.insert(10);
    print_container(std_multiset);
    
    //Map
    std::cout << "Map:" << std::endl;
    std::map<std::string, int> std_map;
    std_map.insert(std::pair<std::string ,int>("Hello", 10));
    std_map["World"]=20;
    std_map.insert(std::pair<std::string ,int>("Hello", 20));
    print_map(std_map);
    
    //MultiMap
    std::cout << "MultiMap:" << std::endl;
    std::multimap<std::string, int> std_multimap;
    std_multimap.insert(std::pair<std::string ,int>("Hello", 10));
    std_multimap.insert(std::pair<std::string ,int>("World", 20));
    std_multimap.insert(std::pair<std::string ,int>("Hello", 20));
    print_map(std_multimap);
}
Esempio n. 4
0
int
ikev2_pld_parse(struct iked *env, struct ike_header *hdr,
    struct iked_message *msg, off_t offset)
{
	log_debug("%s: header ispi %s rspi %s"
	    " nextpayload %s version 0x%02x exchange %s flags 0x%02x"
	    " msgid %d length %d response %d", __func__,
	    print_spi(betoh64(hdr->ike_ispi), 8),
	    print_spi(betoh64(hdr->ike_rspi), 8),
	    print_map(hdr->ike_nextpayload, ikev2_payload_map),
	    hdr->ike_version,
	    print_map(hdr->ike_exchange, ikev2_exchange_map),
	    hdr->ike_flags,
	    betoh32(hdr->ike_msgid),
	    betoh32(hdr->ike_length),
	    msg->msg_response);

	if (ibuf_size(msg->msg_data) < betoh32(hdr->ike_length)) {
		log_debug("%s: short message", __func__);
		return (-1);
	}

	offset += sizeof(*hdr);

	return (ikev2_pld_payloads(env, msg, offset,
	    betoh32(hdr->ike_length), hdr->ike_nextpayload, 0));
}
Esempio n. 5
0
int main()
{
	Stack s;
	init_stack(&s);
	int i = 0;
	sElemType start = {
		0,
		{
			1,
			1,
		}
	};
	sElemType curpos = start;
	welcome();
	printf("\n\n");
	print_map();
	printf("\n\nI'm going...........................\n\n");
	i = walk_maze(&curpos, s);
	printf("(@_@)\n\n");
	print_map();
	if(i == 1)
		printf("\n\nDone!\n\n");
	else
		printf("\n\nI'm missing!\n\n");

	return 0;
}
Esempio n. 6
0
struct map *
or_map(struct map *mp1, struct map *mp2)
{
#ifdef MAP_DEBUG
    if (Mflag) {
	printf("Oring maps");
	print_map(mp1);
	printf(" and");
	print_map(mp2);
    }
#endif
    if (POSMAP(mp1))
	if (POSMAP(mp2))
	    mp1 = (struct map *)or_bitmap((struct bitmap *) mp1,
		(struct bitmap *) mp2);
	else
	    mp1 = NOT_MAP(bic_bitmap(MAP(mp2), (struct bitmap *) mp1));
    else if (POSMAP(mp2))
	mp1 = NOT_MAP(bic_bitmap(MAP(mp1), (struct bitmap *) mp2));
    else
	mp1 = NOT_MAP(and_bitmap(MAP(mp1), MAP(mp2)));
#ifdef MAP_DEBUG
    if (Mflag) {
	printf(" ->");
	print_map(mp1);
	printf("\n");
    }
#endif
    return mp1;
}
Esempio n. 7
0
struct map *
add_map(struct map *parm, int node)
{
    struct bitmap *map;
    int bit;
    int x, page;

#ifdef MAP_DEBUG
    if (Aflag) {
	printf("add_map: adding %d to [", node);
	print_map(parm);
	printf(" ] ");
    }
#endif
    bit = NUMBERTOBIT(node);
    x = NUMBERTOINDEX(node);
    page = NUMBERTOPAGE(node);

    bit = 1L << bit;;

    for (map = MAP(parm); map; map = map->m_next)
	if (map->m_page == page)
	    break;
    if (!map) {
	map = (struct bitmap *)malloc(sizeof *map);
	if (!map) {
#ifdef PRINT_MAP_ERROR
	    printf("No memory!\n");
#endif
	    free_map((struct map *)map);
	    return 0;
	}
	map->m_page = page;
	memset( map->m_data, 0, sizeof map->m_data);
	if (NEGMAP(parm)) {
	    int i;
	    for (i = 0; i < MDATA; ++i)
		map->m_data[i] = ~0;
	}
	map->m_next = MAP(parm);
	if (POSMAP(parm))
	    parm = (struct map *)map;
	else
	    parm = NOT_MAP(map);
    }
    if (POSMAP(parm))
	map->m_data[x] |= bit;
    else
	map->m_data[x] &= ~bit;
#ifdef MAP_DEBUG
    if (Aflag) {
	printf(" ->");
	print_map(parm);
	printf("\n");
    }
#endif
    return (struct map *)parm;
}
Esempio n. 8
0
int main(int argc, const char *argv[])
{
	int i=0;
	for (i = 1; i < 8; i+=2) {
		print_map(i);
	}
	i=0;
	for (i = 5; i > 0; i-=2) {
	print_map(i);
	}
	return 0;
}
Esempio n. 9
0
void Drone_pick_up(void *self, int id){
	Drone *obj = self;
	setPosition((*obj).curr_y, (*obj).curr_x, id);
	print_map();
	printf("\x1b[32mDrone %d ready for pick up  \n\x1b[0m", id);
	sleep(1);
	print_map();
	printf("\x1b[33mDrone %d requesting payload \n\x1b[0m", id);
	sleep(1);
	print_map();
	printf("\x1b[32mDrone %d payload picked up \n\x1b[0m", id);

	Drone_return_home(self, id);
}
Esempio n. 10
0
/********************MAIN*****************/
int main(int argc, char **argv){
  srand(time(NULL));
  initialize("cyclotron.dat");
  print_map(map);
  max=0;RANGE=13; /* Set max and RANGE*/
  search(map); /* Searching*/
  show_result(optimum,max); /* Show result*/
  printf("\n");
  max=0; RANGE=13; /* Reset max and RANGE*/
  print_map(map1);
  search(map1);
  show_result(optimum,max);
  return 0;
}
Esempio n. 11
0
int main(int argc, char** argv) {
  madness::World& world = madness::initialize(argc,argv);

  std::size_t m = 20;
  std::size_t n = 10;
  std::size_t M = 200;
  std::size_t N = 100;

  std::shared_ptr<TiledArray::Pmap> blocked_pmap(new TiledArray::detail::BlockedPmap(world, m * n));
  std::vector<ProcessID> blocked_map = make_map(m, n, blocked_pmap);

  std::shared_ptr<TiledArray::Pmap> cyclic_pmap(new TiledArray::detail::CyclicPmap(world, m, n, M, N));
  std::vector<ProcessID> cyclic_map = make_map(m, n, cyclic_pmap);

  std::shared_ptr<TiledArray::Pmap> hash_pmap(new TiledArray::detail::HashPmap(world, m * n));
  std::vector<ProcessID> hash_map = make_map(m, n, hash_pmap);

  if(world.rank() == 0) {
    std::cout << "Block\n";
    print_map(m, n, blocked_map);
    std::cout << "\n";
  }

  print_local(world, blocked_pmap);

  world.gop.fence();

  if(world.rank() == 0) {

    std::cout << "\n\nCyclic\n";
    print_map(m, n, cyclic_map);
    std::cout << "\n";
  }

  print_local(world, cyclic_pmap);

  world.gop.fence();

  if(world.rank() == 0) {
    std::cout << "\n\nHash\n";
    print_map(m, n, hash_map);
    std::cout << "\n";
  }

  print_local(world, hash_pmap);
  madness::finalize();

  return 0;
}
Esempio n. 12
0
struct map *
copy_map(struct map *parm)
{
    struct bitmap *result, **mpp, *map;
#ifdef MAP_DEBUG
    if (Mflag) {
	printf("copymap:");
	print_map(parm);
	printf("\n");
    }
#endif
    map = MAP(parm);
    for (mpp = &result; (*mpp = 0), map; map = map->m_next) {
	*mpp = (struct bitmap *)malloc(sizeof **mpp);
	if (!*mpp) {
#ifdef MAP_DEBUG
	    if (Mflag)
		printf("copy_map: out of memory\n");
#endif
	    free_map((struct map *)result);
	    result = 0;
	    break;
	}
	**mpp = *map;
	mpp = &(*mpp)->m_next;
    }
    if (NEGMAP(parm))
	return NOT_MAP(result);
    else
	return (struct map *)result;
}
Esempio n. 13
0
File: main.c Progetto: jgan42/bsq
int	main(int ac, char **av)
{
	int		i;
	int		j;
	char	*tab;
	t_sq	sq;
	char	**map;

	(void)ac;
	j = 1;
	while (av[j])
	{
		i = 0;
		tab = read_file(av[j]);
		write(1, "lo1", 3);
		map = map_error(tab);
		write(1, "lo2", 3);
		sq = bsq(map);
		write(1, "lo3", 3);
		print_map(map, &sq);
		write(1, "lo4", 3);
		++j;
	}
	return(0);
}
Esempio n. 14
0
void MemAllocFree(MemAlloc *ma, void *addr)
{
  MemAllocChunk *c;
  assert(ma != NULL);
  if (addr == NULL) {
    return;
  }
  c = (MemAllocChunk *)(((int8_t *) addr) - sizeof (MemAllocChunk));
  c->id = MEMALLOC_CHUNK_ID_FREE;
  if (c->next != 0) {
    MemAllocChunk *nc = next_chunk(c);
    if (nc->id == MEMALLOC_CHUNK_ID_FREE) {
      c->size += sizeof (MemAllocChunk) + nc->size;
      c->next = nc->next;
    }
  }
  if (c->prev != 0) {
    MemAllocChunk *pc = prev_chunk(c);
    if (pc->id == MEMALLOC_CHUNK_ID_FREE) {
      pc->size += sizeof (MemAllocChunk) + c->size;
      pc->next = c->next;
    }
  }
#ifdef ENABLE_PRINT_MAP
  print_map(ma);
#endif
}
Esempio n. 15
0
void *MemAllocAllocate(MemAlloc *ma, size_t size)
{
  size_t sz;
  assert(ma != NULL);
  sz = (size + (MEMALLOC_ALIGN_SIZE - 1)) / MEMALLOC_ALIGN_SIZE * MEMALLOC_ALIGN_SIZE;
  MemAllocChunk *c = ma->top;
  while (!0) {
    if (c->id == MEMALLOC_CHUNK_ID_FREE && c->size >= sz) {
      break;
    }
    if (c->next == 0) {
      return NULL;
    }
    c = next_chunk(c);
  }
  if (c->size > sizeof (MemAllocChunk) + sz) {
    MemAllocChunk *c2 = (MemAllocChunk *)(((int8_t *) c) + sizeof (MemAllocChunk) + sz);
    c2->id = MEMALLOC_CHUNK_ID_FREE;
    c2->size = c->size - sizeof (MemAllocChunk) - sz;
    c2->prev = sizeof (MemAllocChunk) + sz;
    c2->next = c->next;
    c->next = c2->prev;
  }
  c->id = MEMALLOC_CHUNK_ID_USED;
  c->size = sz;
#ifdef ENABLE_PRINT_MAP
  print_map(ma);
#endif
  return ((int8_t *) c) + sizeof (MemAllocChunk);
}
Esempio n. 16
0
int
ikev2_msg_send(struct iked *env, struct iked_message *msg)
{
	struct ibuf		*buf = msg->msg_data;
	u_int32_t		 natt = 0x00000000;
	struct ike_header	*hdr;

	if (buf == NULL || (hdr = ibuf_seek(msg->msg_data,
	    msg->msg_offset, sizeof(*hdr))) == NULL)
		return (-1);

	log_info("%s: %s from %s to %s, %ld bytes", __func__,
	    print_map(hdr->ike_exchange, ikev2_exchange_map),
	    print_host(&msg->msg_local, NULL, 0),
	    print_host(&msg->msg_peer, NULL, 0),
	    ibuf_length(buf));

	if (msg->msg_natt || (msg->msg_sa && msg->msg_sa->sa_natt)) {
		if (ibuf_prepend(buf, &natt, sizeof(natt)) == -1) {
			log_debug("%s: failed to set NAT-T", __func__);
			return (-1);
		}
	}

	if ((sendto(msg->msg_fd, ibuf_data(buf), ibuf_size(buf), 0,
	    (struct sockaddr *)&msg->msg_peer, msg->msg_peerlen)) == -1) {
		log_warn("%s: sendto", __func__);
		return (-1);
	}

	return (0);
}
Esempio n. 17
0
int
count_map(struct map *parm)
{
    int nf;
    struct bitmap *map;
    int i, j;

    nf = 0;
    for (map = MAP(parm); map; map = map->m_next) {
	for (i = 0; i < MDATA; ++i) {
	    if (!map->m_data[i])
		;
	    else if (!~map->m_data[i])
		nf += (1 << LSHIFT);
	    else
		for (j = 0; j < (1L << LSHIFT); ++j)
		    if (map->m_data[i] & (1L << j))
			++nf;
	}
    }
    if (NEGMAP(parm))
	nf = ~nf;		/* note 1's complement */
#ifdef MAP_DEBUG
    if (Mflag) {
	printf("countmap:");
	print_map(parm);
	printf(" -> %d\n", nf);
    }
#endif
    return nf;
}
Esempio n. 18
0
int
ikev2_pld_ke(struct iked *env, struct ikev2_payload *pld,
    struct iked_message *msg, off_t offset)
{
	struct ikev2_keyexchange	 kex;
	u_int8_t			*buf;
	size_t				 len;
	u_int8_t			*msgbuf = ibuf_data(msg->msg_data);

	memcpy(&kex, msgbuf + offset, sizeof(kex));

	log_debug("%s: dh group %s reserved %d", __func__,
	    print_map(betoh16(kex.kex_dhgroup), ikev2_xformdh_map),
	    betoh16(kex.kex_reserved));

	buf = msgbuf + offset + sizeof(kex);
	len = betoh16(pld->pld_length) - sizeof(*pld) - sizeof(kex);

	print_hex(buf, 0, len);

	if (ikev2_msg_frompeer(msg)) {
		ibuf_release(msg->msg_parent->msg_ke);
		if ((msg->msg_parent->msg_ke = ibuf_new(buf, len)) == NULL) {
			log_debug("%s: failed to get exchange", __func__);
			return (-1);
		}
	}

	return (0);
}
Esempio n. 19
0
int			main(void)
{
	char		*line;
	t_box		box;
	int			ret;
	int			i;

	ret = 0;
	ft_bzero(&box, (sizeof(box)));
	while ((ret = get_next_line(0, &line) != 0))
	{
		if ((i = -1) && box.b_play == 0)
			check_player(line, &box);
		else if ((ft_strnequ(line, "Plateau", 7)))
			create_grid(line, &box);
		else if ((ft_strnequ(line, "Piece", 5)))
		{
			get_piece(line, &box);
			print_map(&box);
			while (i < 69999999)
				i++;
			if (!try_rush(&box))
				return (0);
			reinitialise_box(&box);
		}
	}
	return (0);
}
Esempio n. 20
0
int main( int argc, char *argv[] )
{
	struct map_data *map;
	if ( init(&map, argc, argv) ) {
		exit( 0 );
	}
	
	int cur = '\0';
	
	point_t start = get_start_point( map );
	

	
	 do {
		clear();
		print_map( map );
		
		process_key( cur );
		switch ( cur ) {
			default: {
				point_t target = get_cursor();
				//mvprintw( 0, 0, "Cursor was at : (%d, %d)", target.x, target.y);
				path_t *path_to_target = search_path( start, target, map );
				print_path( path_to_target );
				refresh();
			}
		}
		
		refresh();
	 } while ( (cur = getch()) != 'q' );
	
	
	cleanup_all();
	return 0;
}
Esempio n. 21
0
int
ikev2_msg_send(struct iked *env, struct iked_message *msg)
{
	struct iked_sa		*sa = msg->msg_sa;
	struct ibuf		*buf = msg->msg_data;
	u_int32_t		 natt = 0x00000000;
	int			 isnatt = 0;
	struct ike_header	*hdr;
	struct iked_message	*m;

	if (buf == NULL || (hdr = ibuf_seek(msg->msg_data,
	    msg->msg_offset, sizeof(*hdr))) == NULL)
		return (-1);

	isnatt = (msg->msg_natt || (msg->msg_sa && msg->msg_sa->sa_natt));

	log_info("%s: %s from %s to %s, %ld bytes%s", __func__,
	    print_map(hdr->ike_exchange, ikev2_exchange_map),
	    print_host(&msg->msg_local, NULL, 0),
	    print_host(&msg->msg_peer, NULL, 0),
	    ibuf_length(buf), isnatt ? ", NAT-T" : "");

	if (isnatt) {
		if (ibuf_prepend(buf, &natt, sizeof(natt)) == -1) {
			log_debug("%s: failed to set NAT-T", __func__);
			return (-1);
		}
		msg->msg_offset += sizeof(natt);
	}

	if ((sendto(msg->msg_fd, ibuf_data(buf), ibuf_size(buf), 0,
	    (struct sockaddr *)&msg->msg_peer, msg->msg_peerlen)) == -1) {
		log_warn("%s: sendto", __func__);
		return (-1);
	}

	if (!sa)
		return (0);

	if ((m = ikev2_msg_copy(env, msg)) == NULL) {
		log_debug("%s: failed to copy a message", __func__);
		return (-1);
	}
	m->msg_exchange = hdr->ike_exchange;

	if (hdr->ike_flags & IKEV2_FLAG_RESPONSE) {
		TAILQ_INSERT_TAIL(&sa->sa_responses, m, msg_entry);
		timer_initialize(env, &m->msg_timer,
		    ikev2_msg_response_timeout, m);
		timer_register(env, &m->msg_timer, IKED_RESPONSE_TIMEOUT);
	} else {
		TAILQ_INSERT_TAIL(&sa->sa_requests, m, msg_entry);
		timer_initialize(env, &m->msg_timer,
		    ikev2_msg_retransmit_timeout, m);
		timer_register(env, &m->msg_timer, IKED_RETRANSMIT_TIMEOUT);
	}

	return (0);
}
Esempio n. 22
0
int list_report (List_of_maps * list) {

    int map_ctr, best_ctr;

    printf ("==========================================\n");
    printf ("maps allocated:   %4d   maps used : %4d   best used : %4d  \n",
	    list->no_maps_allocated, list->no_maps_used, list->best_array_used);


    if ( list->best_array_used ) {
	
	for ( best_ctr= 0; best_ctr<list->no_maps_used; best_ctr++) {

	    map_ctr = list->map_best[best_ctr];
	    
	    printf ("\n  %3d: %3d   %8.3lf %8.3lf %8.3lf %8.3lf \n",
		    best_ctr, map_ctr, 
		    list->map[map_ctr].q[0],
		    list->map[map_ctr].q[1],
		    list->map[map_ctr].q[2],
		    list->map[map_ctr].q[3]);

	    print_map (stdout, list->map+map_ctr, NULL, NULL, NULL, NULL, 2);
	}
 

    } else {
    
	for ( map_ctr= 0; map_ctr<list->no_maps_used; map_ctr++) {
	
	    printf ("  %3d   %8.3lf %8.3lf %8.3lf %8.3lf \n", map_ctr,
		    list->map[map_ctr].q[0],
		    list->map[map_ctr].q[1],
		    list->map[map_ctr].q[2],
		    list->map[map_ctr].q[3]);

	    print_map (stdout, list->map+map_ctr, NULL, NULL, NULL, NULL, 2);
	}
    }

 
    
    return 0;

}
Esempio n. 23
0
void print_response(struct _u_response * response) {
  if (response != NULL) {
    char * headers = print_map(response->map_header), * json_body = json_dumps(response->json_body, JSON_INDENT(2));
    printf("protocol is\n%s\n\n  headers are \n%s\n\n  json body is \n%s\n\n  string body is \n%s\n\n",
           response->protocol, headers, json_body, (char *)response->string_body);
    free(headers);
    free(json_body);
  }
}
Esempio n. 24
0
/**
 * Callback function that put "Hello World!" and all the data sent by the client in the response as string (http method, url, params, cookies, headers, post, json, and user specific data in the response
 */
int callback_all_test_foo (const struct _u_request * request, struct _u_response * response, void * user_data) {
  char * url_params = print_map(request->map_url), * headers = print_map(request->map_header), * cookies = print_map(request->map_cookie), 
        * post_params = print_map(request->map_post_body), * json_params = json_dumps(request->json_body, JSON_INDENT(2));
  int len;
  len = snprintf(NULL, 0, "Hello World!\n\n  method is %s\n  url is %s\n\n  parameters from the url are \n%s\n\n  cookies are \n%s\n\n  headers are \n%s\n\n  post parameters are \n%s\n\n  json body parameters are \n%s\n\n  user data is %s\n\nclient address is %s\n\n",
                                  request->http_verb, request->http_url, url_params, cookies, headers, post_params, json_params, (char *)user_data, inet_ntoa(((struct sockaddr_in *)request->client_address)->sin_addr));
  response->string_body = malloc((len+1)*sizeof(char));
  snprintf(response->string_body, (len+1), "Hello World!\n\n  method is %s\n  url is %s\n\n  parameters from the url are \n%s\n\n  cookies are \n%s\n\n  headers are \n%s\n\n  post parameters are \n%s\n\n  json body parameters are \n%s\n\n  user data is %s\n\nclient address is %s\n\n",
                                  request->http_verb, request->http_url, url_params, cookies, headers, post_params, json_params, (char *)user_data, inet_ntoa(((struct sockaddr_in *)request->client_address)->sin_addr));
  response->status = 200;
  
  free(url_params);
  free(headers);
  free(cookies);
  free(post_params);
  free(json_params);
  return U_OK;
}
Esempio n. 25
0
int main()
{
  std::map<int, int> numcounts;

  int n;
  while(std::cin >> n) ++numcounts[n]; 

  print_map(numcounts);
}
Esempio n. 26
0
gamestate_t npc::take_turn(heap_t *h, cell_t *cell_arr, path_node_t *t_map,
			   path_node_t *n_t_map, character **c_arr, int t_char)
{
  int move_er;
  gamestate_t result;
  path_node_t *c_map;
  character *player;

  player = *(c_arr + 0);
  result = normal;
  move_er = 0;
  
  if(x_pos > 100)
	{
	  return normal;
	}

      if(traits & IS_TUNNELING || traits & IS_PASS)
	{
	  c_map = t_map;
	}
      else
	{
	  c_map = n_t_map;
	}

      if(traits & IS_ERATIC)
	{
	  move_er = random_number(1 , 100) > 50;
	}
      
      if(move_er)
	{
	  result = move_eratic(this, cell_arr, c_map);
	}
      else
	{

	  result = move_table[traits % 4](this, cell_arr, c_map,
	  					   player);
	}


      if(result == player_died)
	{
	  print_map(cell_arr);
	  return player_died;
	}
      else if(result == update_nt_map)
	{
	  update_non_tunn_map(n_t_map, cell_arr);
	}
  turn = turn + (100 / speed);
  heap_insert(h, this);

  return normal;
}
Esempio n. 27
0
int main(int argc, char const *argv[])
{

	generate();

	print_map();

	return 0;
}
Esempio n. 28
0
int main()
{ 
    map = map_data;

    print_map();
    generate_lasers();

    return 0;
}
Esempio n. 29
0
int sweep_map(char * p_mine, int rows,int cols ,int mine){

	int result = 0;
	int row = 0,col = 0,operator = 0;
	char * pt_mine = NULL;
	counts = rows*cols - mine;
	while(!result){
	
		printf("row,col,operator:1->open,2->flag,3->cancel\n");
		scanf("%*[^\n]%*c");
		scanf("%d,%d,%d",&row,&col,&operator);
		row--;col--;
		pt_mine = p_mine + cols * row + col;
		switch(operator){
		
			case 1:
			if(*pt_mine & 1){
			
				result = -1;
			}else{

				if(*pt_mine & 2)continue;
			
				*pt_mine |= 2;
				if((--counts) <= 0) result =  1;

				if(!(*pt_mine>>4)){
				
					if(open(row,col,p_mine,rows,cols)){
						result = 1;
					}
				
				}
			}
			break;

			case 2:
			*pt_mine |= 4;
			break;

			case 3:
			break;

			default:
			break;
		
		}//end switch

		printf("counts:%d\n",counts);
		print_map(p_mine,rows,cols,mine);

	}//end while


	return result;
}
Esempio n. 30
0
/**
 * Callback function that put a "Hello World!" and the post parameters send by the client in the response
 */
int callback_post_test (const struct _u_request * request, struct _u_response * response, void * user_data) {
  int len;
  char * post_params = print_map(request->map_post_body);
  len = snprintf(NULL, 0, "Hello World!\n%s", post_params);
  response->string_body = malloc((len+1)*sizeof(char));
  snprintf(response->string_body, (len+1), "Hello World!\n%s", post_params);
  free(post_params);
  response->status = 200;
  return U_OK;
}