Esempio n. 1
0
int
rclose( RD rd )
{
clsvbuff.data.clsv_rclose.rd = rd;
send_rcv( &clsvbuff, RCLOSE, sizeof( CLSV_RCLOSE ) );
return clsvbuff.data.svcl_rclose.status;
}
Esempio n. 2
0
int			run_serveur(t_serv *serv)
{
  t_user		*user_list;
  fd_set		readfd;
  int			max;
  int			socks;
  char			*buff;

  max = serv->s;
  user_list = NULL;
  if ((buff = malloc(4096 * sizeof(char))) == NULL)
    return (EXIT_FAILURE);
  while (1)
    {
      reset_list(&readfd, user_list, serv, max);
      if (FD_ISSET(serv->s, &readfd))
	{
	  accept_connect(&socks, serv);
	  if (read_client(socks, buff) != 0)
	    {
	      client_connexion(&max, socks, &readfd);
	      add_user(&user_list, DEFAULT_USER, socks, NULL);
	    }
	}
      else
	send_rcv(&user_list, &readfd);
    }
}
Esempio n. 3
0
RD
ropen( const char *pathname, const char *mode )
{
CLSV_ROPEN *pc; SVCL_ROPEN *ps;

pc = &clsvbuff.data.clsv_ropen;
ps = &clsvbuff.data.svcl_ropen; strcpy( pc->pathname, pathname ); strcpy( pc->mode, mode );
send_rcv( &clsvbuff, ROPEN, sizeof( CLSV_ROPEN ) );

return ps->rd;
}
Esempio n. 4
0
int
rwrite( RD rd, const void *data, int qty )
{
CLSV_RWRITE *pc; SVCL_RWRITE *ps;

pc = &clsvbuff.data.clsv_rwrite;
ps = &clsvbuff.data.svcl_rwrite;

pc->rd = rd;
pc->qty = qty;
if( qty > 0 )
memcpy( pc->data, data, qty );
send_rcv( &clsvbuff, RWRITE, sizeof( CLSV_RWRITE ) );

return ps->status;
}
Esempio n. 5
0
File: clstub.c Progetto: Lelv/SO-TP1
int adoptar_pokemon(POKEMON * pokemon){
	CLSV_POKEMON_TRANSFER * ps;
	SVCL_POKEMON_TRANSFER * pr;
	
	ps = &p.data.clsv_pokemon_transfer;
	pr = &p.data.svcl_pokemon_transfer;

	ps->cant = 0;
	ps->id = getpid();

	send_rcv(ADOPTAR,sizeof(CLSV_POKEMON_TRANSFER));

	memcpy(pokemon, &(ps->pokemons[0]),sizeof(POKEMON));

	return 1;
}
Esempio n. 6
0
int
rread( RD rd, void *data, int qty )
{
CLSV_RREAD *pc; SVCL_RREAD *ps;

int status;

pc = &clsvbuff.data.clsv_rread;
ps = &clsvbuff.data.svcl_rread;

pc->rd = rd;
pc->qty = qty;
send_rcv( &clsvbuff, RREAD, sizeof( CLSV_RREAD ) );

status = ps->status;
if( status > 0 )
memcpy( data, ps->data, status );
return status;
}
Esempio n. 7
0
File: clstub.c Progetto: Lelv/SO-TP1
int regalar_pokemon(POKEMON *pokemones, int index){

	CLSV_POKEMON_TRANSFER * ps;
	SVCL_POKEMON_TRANSFER * pr;
	
	ps = &p.data.clsv_pokemon_transfer;
	pr = &p.data.svcl_pokemon_transfer;

	memcpy(&(ps->pokemons[0]),&(pokemones[index]),sizeof(POKEMON));

	ps->cant = 1;
	ps->id = getpid();

	send_rcv(REGALAR,sizeof(CLSV_POKEMON_TRANSFER));

	pokemones[index].life = -1;

	return 1;
}
Esempio n. 8
0
File: clstub.c Progetto: Lelv/SO-TP1
int curar_pokemones(POKEMON* pokemones,int cant) {

	CLSV_POKEMON_TRANSFER * ps;
	SVCL_POKEMON_TRANSFER * pr;
	
	ps = &p.data.clsv_pokemon_transfer;
	pr = &p.data.svcl_pokemon_transfer;

	memcpy(ps->pokemons,pokemones,cant*sizeof(POKEMON));
	ps->cant=cant;
	ps->id=getpid();

	
	send_rcv(CURAR,sizeof(CLSV_POKEMON_TRANSFER));

  	memcpy(pokemones,ps->pokemons, cant*sizeof(POKEMON));

  	return 1;


}