Example #1
0
void	voir(t_env *env, t_action *action)
{
  int	largeur;
  int	deep;

  if (difftime(time(NULL), action->time) >= 7 / env->time)
    {
      add_output(action->client, strdup("{"));
      deep = 0;
      while (deep <= action->client->player.lvl)
	{
	  largeur = -deep;
	  while (largeur < deep + 1)
	    {
	      if (deep != 0)
		add_output(action->client, strdup(","));
	      voir_case(env, action, largeur, deep);
	      ++largeur;
	    }
	  ++deep;
	}
      add_output(action->client, strdup("}\n"));
      delete_action(action);
    }
}
static void delete_rule(struct pa_policy_context_rule **rules,
                        struct pa_policy_context_rule  *rule)
{
    struct pa_policy_context_rule *last;

    for (last = (struct pa_policy_context_rule *)rules;
         last->next != NULL;
         last = last->next)
    {
        if (last->next == rule) {
            last->next = rule->next;

            match_cleanup(&rule->match);

            while (rule->actions != NULL)
                delete_action(&rule->actions, rule->actions);

            pa_xfree(rule);

            return;
        }
    } 

    pa_log("%s(): confused with data structures: can't find rule",
           __FUNCTION__);
}
Example #3
0
void	gauche(t_env *env, t_action *action)
{
  if (difftime(time(NULL), action->time) >= 7 / env->time)
    {
      action->client->player.dir = (action->client->player.dir + 1) % 4;
      add_output(action->client, strdup("ok\n"));
      ppo(env, action->client);
      delete_action(action);
    }
}
Example #4
0
void delete_action (action * current_action)
{
    //post fix iteration in a binary tree
    if (current_action->sibling!=NULL)
    {
        delete_action(current_action->sibling);
        current_action->sibling=NULL;
    }
    if (current_action->child!=NULL)
    {
        delete_action(current_action->child);
        current_action->child=NULL;
    }
    if ((current_action->sibling==NULL)&&(current_action->child==NULL))
    {
        free(current_action);
    }

}
Example #5
0
void
delete_action_list( action_list *list ) {
  assert( list != NULL );

  for ( dlist_element *element = get_first_element( list ); element != NULL; element = element->next ) {
    action *action = element->data;
    if ( action != NULL ) {
      delete_action( action );
    }
  }
  delete_dlist( list );
}
Example #6
0
void clear_tracepoints(void)
{
    int i;

    skyeye_ice.num_tps=0;

    for (i=0; i<MAX_TRACEPOINTS; i++)
    {
        if (skyeye_ice.tps[i].actions!=NULL)
            delete_action(skyeye_ice.tps[i].actions);
        skyeye_ice.tps[i].actions=NULL;
    }
}
Example #7
0
OFDPE
remove_action( action_list *list, action *action ) {
  assert( list != NULL );
  assert( action != NULL );
  
  dlist_element *element = find_element( get_first_element( list ), action );
  if ( element == NULL ) {
    return ERROR_NOT_FOUND;
  }
  delete_action( action );
  delete_dlist_element( element );

  return OFDPE_SUCCESS;
}
Example #8
0
void		fptr_ppo(t_env *env, t_action *action)
{
  int		id;
  char		*err;
  t_client	*client;

  err = NULL;
  if (action->input[1] == NULL)
    sbp(env);
  else
    {
      id = strtol(action->input[1], &err, 10);
      if (err[0] != '\0' || (client = find_by_id(env, id)) == NULL)
	sbp(env);
      else
	ppo(env, client);
    }
  delete_action(action);
}
Example #9
0
void	fptr_mct(t_env *env, t_action *action)
{
  bct(env, action->client->player.coor.y,
      action->client->player.coor.x++);

  if (action->client->player.coor.x >= (int)env->map.width)
    {
      action->client->player.coor.x = 0;
      action->client->player.coor.y++;
    }
  if (action->client->player.coor.y >= (int)env->map.height)
    {
      action->client->player.coor.y = 0;
      action->client->player.coor.x = 0;
      if (action->client->graphic_init == 1)
	init_graph_end(env, action);
      delete_action(action);
    }
}
Example #10
0
void	fptr_bct(t_env *env, t_action *action)
{
  int	x;
  int	y;
  char	*err1;
  char	*err2;

  err1 = NULL;
  err2 = NULL;
  if (action->input == NULL || action->input[0] == NULL
      || action->input[1] == NULL || action->input[2] == NULL)
    sbp(env);
  else
    {
      x = strtol(action->input[1], &err1, 10);
      y = strtol(action->input[2], &err2, 10);
      if (x < (int)env->map.height && y < (int)env->map.width
	  && err1[0] == '\0' && err2[0] == '\0')
	bct(env, y, x);
      else
	sbp(env);
    }
  delete_action(action);
}
Example #11
0
void	fptr_tna(t_env *env, t_action *action)
{
  tna(env);
  delete_action(action);
}
Example #12
0
int
main(int argc, char **argv)
{
	char *device;
	const char *filename;
	int ch, dryrun;
	enum main_action action;

	device = NULL;
	filename = NULL;
	dryrun = 0;
	action = NONE;

	while ((ch = getopt(argc, argv, "Cd:Df:nS")) != -1) {
		switch (ch) {
		case 'C':
			if (action != NONE) {
				warnx(
				   "Only one of -C, -D or -S may be specified");
				usage();
			}
			action = CONFIG;
			break;
		case 'd':
			device = strdup(optarg);
			break;
		case 'D':
			if (action != NONE) {
				warnx(
				   "Only one of -C, -D or -S may be specified");
				usage();
			}
			action = DELETE;
			break;
		case 'f':
			filename = optarg;
			break;
		case 'n':
			dryrun = 1;
			break;
		case 'S':
			if (action != NONE) {
				warnx(
				   "Only one of -C, -D or -S may be specified");
				usage();
			}
			action = PRINT_SCHEMA;
			break;
		case '?':
			warnx("Unrecognized argument '-%c'\n", optopt);
			usage();
			break;
		}
	}

	if (device != NULL && filename != NULL) {
		warnx("Only one of the -d and -f flags may be specified");
		usage();
	}

	if (device == NULL && filename == NULL) {
		warnx("Either the -d or -f flag must be specified");
		usage();
	}

	switch (action) {
	case CONFIG:
		if (filename == NULL) {
			warnx("-d flag cannot be used with the -C flag");
			usage();
		}
		config_action(filename, dryrun);
		break;
	case DELETE:
		if (device == NULL)
			device = find_device(filename);
		delete_action(device, dryrun);
		free(device);
		break;
	case PRINT_SCHEMA:
		if (dryrun) {
			warnx("-n flag cannot be used with the -S flag");
			usage();
		}
		if (device == NULL)
			device = find_device(filename);
		print_schema(device);
		free(device);
		break;
	default:
		usage();
		break;
	}

	exit(0);
}
Example #13
0
int
main(int argc, char** argv)
{
  cmdline_t options;
  exittype_t exit_type;
  parser_t* ctx = NULL;
  bool_t success = 0;

  // Parse the command line.
  fetchdeps_cmdline_init(&options, argc, argv);
  exit_type = fetchdeps_cmdline_parse(&options);
  if (exit_type == EXIT_FAIL)
    goto failure;
  if (exit_type == EXIT_OK) {
    fetchdeps_cmdline_cleanup(&options);
    exit(0);
  }

  // If no fname was given try to find the default deps file.
  if (!options.fname)
    options.fname = fetchdeps_filesys_default_deps_file();
  if (!options.fname) {
    fetchdeps_errors_set(ERR_NO_DEPS);
    goto failure;
  }

  switch (options.action) {
  case ACTION_HELP:
    success = help_action(&options);
    break;
  case ACTION_INIT:
    success = init_action(&options);
    break;
  case ACTION_GET:
    success = get_action(&options);
    break;
  case ACTION_LIST:
    success = list_action(&options);
    break;
  case ACTION_INSTALL:
    success = install_action(&options);
    break;
  case ACTION_UNINSTALL:
    success = uninstall_action(&options);
    break;
  case ACTION_DELETE:
    success = delete_action(&options);
    break;
  case ACTION_VARS:
    success = vars_action(&options);
    break;
  default:
    success = 0;
    break;
  }

  if (!success)
    goto failure;

  // Clean up.
  fetchdeps_cmdline_cleanup(&options);
  
  return 0;

failure:
  fetchdeps_errors_print(stderr);
  fetchdeps_cmdline_cleanup(&options);
  if (ctx)
    fetchdeps_parser_free(ctx);
  return 1;
}