예제 #1
0
파일: client.c 프로젝트: FMP196/ppnetwork
static int getIP(char *buf, int len, int *plen, struct in_addr *pinaddr) {

	int n, ris, newlen=*plen;
	char strIP[32];
	struct in_addr ina;

	/* cerco primo byte */
	ris=getInt(buf,len,&newlen, &n);
	if(ris!=1) return(ris);
	ris=getPunto(buf,len,&newlen);
	if(ris!=1) return(ris);
	/* cerco secondo byte */
	ris=getInt(buf,len,&newlen, &n);
	if(ris!=1) return(ris);
	ris=getPunto(buf,len,&newlen);
	if(ris!=1) return(ris);
	/* cerco terzo byte */
	ris=getInt(buf,len,&newlen, &n);
	if(ris!=1) return(ris);
	ris=getPunto(buf,len,&newlen);
	if(ris!=1) return(ris);
	/* cerco quarto byte */
	ris=getInt(buf,len,&newlen, &n);
	if(ris!=1) return(ris);
	/* ok, c'e' un indirizzo IP */
	memcpy(strIP,buf+(*plen), newlen-(*plen) );
	strIP[newlen-(*plen)]=0;
	ris=inet_aton(strIP,&ina);
	if(ris==0) {
		perror("inet_aton failed :");
		return(-1); /* no IP */
	}
	memcpy(pinaddr,&ina,sizeof(struct in_addr));
	*plen=newlen;
	return(1);
}
예제 #2
0
bool Cubo::esArista(int Xn, int Yn, int Zn){
	//Si es piso o techo, vuelve true

    if ( (Zn == 0) || (Zn == cantidadDePuntosEnAlto()) )
		return true;
	float* punto = getPunto(Xn, Yn, Zn);

	if ( ((punto[0] ==  lado/2.0) && (punto[1] ==  lado/2.0)) ||
		 ((punto[0] == -lado/2.0) && (punto[1] ==  lado/2.0)) ||
		 ((punto[0] == -lado/2.0) && (punto[1] == -lado/2.0)) ||
		 ((punto[0] ==  lado/2.0) && (punto[1] == -lado/2.0))){
			delete []punto;
			return true;
	}
	return false;
}