Пример #1
0
int			parse_room(t_env *env, t_parser *p, char **split)
{
	t_room_list	*lst;
	t_room		*room;

	if (!is_nbr(split[1]) || !is_nbr(split[2]) || p->link_part)
		return (0);
	lst = env->rooms;
	while (lst)
	{
		if (!ft_strcmp(lst->room->name, split[0]))
			return (0);
		lst = lst->next;
	}
	if (!(lst = malloc(sizeof(*lst))))
		error_quit("Failed to malloc room list");
	room = room_create();
	room->name = split[0];
	lst->room = room;
	lst->next = env->rooms;
	env->rooms = lst;
	if (!check_start_end(env, room, p))
		return (0);
	return (1);
}
Пример #2
0
static void select_attacker(uint8_t *appdata)
{

	//printf("Selecting attacker\n");
	int num,i,j,k; uip_ipaddr_t tempadd,temp2;
	MAPPER_GET_PACKETDATA(num,appdata);
	uint8_t a; unsigned char buf[5],buf2[5], *buf_p;

	for(i=0;i<num;i++)
	{
		
		MAPPER_GET_PACKETDATA(a,appdata);	
		//printf("nbr of %u chk for %u\n",UIP_IP_BUF->srcipaddr.u8[15],a);

		uip_ipaddr_copy(&temp2, &UIP_IP_BUF->srcipaddr);
		if(a!=1)
		if(UIP_IP_BUF->srcipaddr.u8[15]!=myip.u8[15])
		if(a!=myip.u8[15])
		if(!is_nbr(a))
		{	
  			
			k=3;j=9;
			buf_p=buf2;
			MAPPER_ADD_PACKETDATA(buf_p,j);
			MAPPER_ADD_PACKETDATA(buf_p,k);			
			//uip_ip6addr(&server_ipaddr, 0xfe80, 0, 0, 0,0x0212, 0x7401, 1, 0x0101);
			tempadd.u16[0]=0xaaaa; tempadd.u16[1]=0;tempadd.u16[2]=0; tempadd.u16[3]=0;
			tempadd.u16[4]=0x1202; tempadd.u8[10]=0x74;tempadd.u8[11]=a;tempadd.u8[12]=0;tempadd.u8[13]=a;tempadd.u8[14]=a;
			tempadd.u8[15]=a;
			uip_udp_packet_sendto(client_conn, buf2, sizeof(buf2), &tempadd, UIP_HTONS(10000+(int)tempadd.u8[15]));
			uip_create_unspecified(&client_conn->ripaddr);	
			printf("attacker 3 is %u\n",tempadd.u8[15]);

			
 			k=2;buf_p=buf;
			MAPPER_ADD_PACKETDATA(buf_p,j);
			MAPPER_ADD_PACKETDATA(buf_p,k);						
			//temp2.u16[0]=0xaaaa;                
			uip_udp_packet_sendto(client_conn, buf, sizeof(buf), &temp2, UIP_HTONS(10000+(int)temp2.u8[15]));
			uip_create_unspecified(&client_conn->ripaddr);	
			printf("attacker 2 is %u\n",temp2.u8[15]);

			
			attacker_set=1;
			attacker=1;		
			attack_flag=1;
			dis_output(NULL);
			setreg(17,0);
		}
	}
		
}
Пример #3
0
int		check_para(t_dlist *list)
{
  t_list	*tmp;

  tmp = list->begin;
  while (tmp)
    {
      if (is_nbr(tmp->arg) == 0)
	if (tmp == list->begin || (my_strcmp(tmp->prev->arg, "-dump") != 0 &&
				   my_strcmp(tmp->prev->arg, "-a") != 0 &&
				   my_strcmp(tmp->prev->arg, "-n") != 0))
	  {
	    my_putstr("Para error : ");
	    exit(0);
	  }
      tmp = tmp->next;
    }
  return (0);
}
Пример #4
0
t_bool	my_getnbr(const char *str, int *nb)
{
  int	sign;

  if (!(is_nbr(str)))
    return (FALSE);
  (*nb) = NULL_VALUE;
  sign = (*str == SIGN_CHAR) ? (-1) : (1);
  str += (*str == SIGN_CHAR) ? (1) : (0);
  while (*str)
    {
      if ((sign > 0) && (CAN_GO_UP(*nb, *str)))
	*nb = *nb * 10 + *(str++) - '0';
      else if ((sign < 0) && (CAN_GO_DOWN(*nb, *str)))
	*nb = *nb * 10 - *(str++) + '0';
      else
	{
	  *nb = (sign > 0) ? (INT_MAX) : (INT_MIN);
	  return (TRUE);
	}
    }
  return (TRUE);
}
Пример #5
0
int		check_paral(t_dlist *list)
{
  t_list	*tmp;

  tmp = list->begin;
  while (tmp)
    {
      if (is_nbr(tmp->arg) != 0)
	{
	  if (my_strcmp(is_cor(tmp->arg), ".cor") != 0
	      && my_strcmp(tmp->arg, "-dump") != 0
	      && my_strcmp(tmp->arg, "-a") != 0
	      && my_strcmp(tmp->arg, "-n") != 0)
	    {
	      my_putstr("Paral error : ");
	      my_putstr(tmp->arg);
	      write(1, "\n", 1);
	      exit(0);
	    }
	}
      tmp = tmp->next;
    }
  return (0);
}