Ejemplo n.º 1
0
inline static int w_exec_msg(struct sip_msg* msg, char* cmd, char* foo)
{
	environment_t *backup;
	int ret;
	str command;
	
	if(msg==0 || cmd==0)
		return -1;

	backup=0;
	if (setvars) {
		backup=set_env(msg);
		if (!backup) {
			LM_ERR("no env created\n");
			return -1;
		}
	}
	
	if(fixup_get_svalue(msg, (gparam_p)cmd, &command)!=0)
	{
		LM_ERR("invalid command parameter");
		return -1;
	}
	
	LM_DBG("executing [%s]\n", command.s);
	
	ret=exec_msg(msg, command.s);
	if (setvars) {
		unset_env(backup);
	}
	return ret;
}
Ejemplo n.º 2
0
inline static int w_exec_msg(struct sip_msg* msg, char* p1, char* foo)
{
        str cmd;
	environment_t *backup;
	int ret;

	if (get_str_fparam(&cmd, msg, (fparam_t*)p1) < 0) {
	    ERR("Error while obtaining command name\n");
	    return -1;
	}

	backup=0;
	if (setvars) {
		backup=set_env(msg);
		if (!backup) {
			LOG(L_ERR, "ERROR: w_exec_msg: no env created\n");
			return -1;
		}
	}
	ret=exec_msg(msg, &cmd);
	if (setvars) {
		unset_env(backup);
	}
	return ret;
}
Ejemplo n.º 3
0
int		get_db_info(t_game_goodies *nfo)
{
  t_trame	trame;
  Uint32	ticks;
  int		ret;

  ticks = SDL_GetTicks();
  stock_msg(&cnt->clients[0], TAG_WELCOME, 0, NULL);
  fprintf(fd_log, "in\n");
  while (42)
    {
      if ((ret = check_select(100)))
	{
	  if (exec_msg(&cnt->clients[0], &trame))
	    {
	      if (is_valid_trame(&trame, TAG_WELCOME))
		{
			fprintf(fd_log, "AFirstChaos: Coucou from server\n");
		}
	      else if (is_valid_trame(&trame, TAG_INFO))
		{
		  memcpy((void*)nfo->db_info, trame.msg,
			 sizeof(*(nfo->db_info)));
		  free(trame.msg);
		  fprintf(fd_log, "out\n");
		  return (0);
		}
	      else
		fprintf(fd_log, "AFirstChaos: Trame unused: %d\n", trame.tag);
	    }
	  else
	    fprintf(fd_log, "Activity from ? (%d)\n", ret);
	}
	if (!cnt->clients[0].sock)
	  return (1);
      if ((SDL_GetTicks() - ticks) > (50000 * SEC_IN_MS))
	{
	  fprintf(fd_log, "drop out\n");
	  return (1);
	}
    }
  return (1);
}