Esempio n. 1
0
File: put.c Progetto: Mpounta/augeas
static void regexp_match_error(struct state *state, struct lens *lens,
                               int count, struct split *split) {
    // FIXME: Split the regexp and encoding back
    // into something resembling a tree level
    char *text = NULL;
    char *pat = NULL;

    lns_format_atype(lens, &pat);
    text = enc_format(split->enc + split->start, split->end - split->start);

    if (count == -1) {
        put_error(state, lens,
                  "Failed to match \n    %s\n  with tree\n   %s",
                  pat, text);
    } else if (count == -2) {
        put_error(state, lens,
                  "Internal error matching\n    %s\n  with tree\n   %s",
                  pat, text);
    } else if (count == -3) {
        /* Should have been caught by the typechecker */
        put_error(state, lens, "Syntax error in tree schema\n    %s", pat);
    }
    free(pat);
    free(text);
}
int		db_weapon(t_engine *e, t_db_ind *ind)
{
  int		i;
  char		*buf;
  int		n;

  if (!xml_next("weapons"))
    return (put_error("Weapons not found in xml"));
  for (i = 0; i < ind->nb[TYPE_WEAPONS]; i++)
    {
      if (!xml_next("weapon"))
	return (put_error("Not enough weapon in xml"));
      if (!(e->db.weapons[i].name = xml_getstr("name")))
	return (put_error("Weapon without name !"));
      e->db.weapons[i].dmg = xml_getint("damage");
      e->db.weapons[i].rof = xml_getint("rof");
      e->db.weapons[i].range = xml_getint("range");
      buf = xml_getstr("projectile");
      for (n = 0; n < e->db.nb_instants; n++)
	if (!strcmp(e->db.instants[n].name, buf))
	  break;
      free(buf);
      if (n && n >= e->db.nb_instants)
	return (put_error("Weapon with Projectile not found"));
      e->db.weapons[i].projectile = &e->db.instants[n];
      if (!xml_next("types"))
	return (put_error("Weapon without type was found"));
      e->db.weapons[i].allowed = db_get_types(e);
      xml_out();
      xml_out();
    }
  xml_out();
  return (0);
}
Esempio n. 3
0
static void	init_img(t_glob *glob, t_img *image, int sizex, int sizey)
{
    if ((image->img = mlx_new_image(glob->graph->mlx_ptr, sizex, sizey)) == 0)
        put_error("Cannot create image\n", 1);
    image->data = mlx_get_data_addr(image->img, &(image->bpp),
                                    &(image->sizeline), &(glob->graph->endian));
    if (image->data == NULL)
        put_error("Cannot create image container\n", 1);
}
Esempio n. 4
0
int				is_doable(t_nest *nest)
{
	if (!nest->rooms)
		put_error(1);
	if (check_star_end(nest))
		put_error(1);
	if (!nest->pipes)
		put_error(1);
	if (startend_pipe(nest))
		put_error(1);
	return (1);
}
Esempio n. 5
0
static void	init(t_glob *glob)
{
    if ((glob->graph->mlx_ptr = mlx_init()) == 0)
        put_error("Cannot init mlx\n", 1);
    init_img(glob, &(glob->graph->aff_img), AFF_SIZEX, AFF_SIZEY);
    init_img(glob, &(glob->graph->calc_img), CALC_SIZEX, CALC_SIZEY);
    init_img(glob, &(glob->graph->loader), 60, 60);
    if ((glob->graph->win_ptr = mlx_new_window(glob->graph->mlx_ptr,
                                AFF_SIZEX, AFF_SIZEY,
                                "Raytracer")) == 0)
        put_error("Cannot create window\n", 1);
}
Esempio n. 6
0
File: cmenu.c Progetto: jkkm/xfsdump
/*ARGSUSED*/
int
menu_import(WINDOW *win, node_t *current, node_t *list)
{
    char inv_path[MAXPATHLEN];
    struct stat s;
    char *fstabname;
    data_t *d;

    for(;;) {
	inv_path[0] = '\0';

	if(get_string(win, "Path to inventory to be imported: ", inv_path, MAXPATHLEN) == ERR) {
	    put_error("Error: invalid input");
	    continue;
	}
	if(strlen(inv_path) == 0) {
	    clear_line(stdscr, LINES - 1);
	    return BOOL_FALSE;
	}
	if(stat(inv_path, &s) < 0 || !S_ISDIR(s.st_mode)) {
	    put_error("Error: invalid path");
	    continue;
	}
	clear_line(stdscr, LINES - 1);

	fstabname = GetFstabFullPath(inv_path);
	if(fstabname == NULL) {
	    put_footer("internal memory error: import inventory", ALIGN_LEFT);
	    exit(1);
	}

	while(current->next != NULL) {
	    current = current->next;
	}
	generate_fstab_menu(inv_path, current, 0, fstabname);
	free(fstabname);

	while(current->next != NULL) {
	    current = current->next;
	    d = current->data;
	    d->text[1] = 'I';
	    d->imported = BOOL_TRUE;
	}
	redraw_screen = BOOL_TRUE;
	break;
    }

    return BOOL_FALSE;
}
Esempio n. 7
0
File: cd.c Progetto: pciavald/42
int			sh_cd(char **argv, char ***envp)
{
	char	*dest_path;
	char	option;
	int		i;

	option = 'L';
	i = 0;
	while (argv[++i] && argv[i][0] == '-' && argv[i][1])
	{
		if ((option = get_option(argv[i])) == -1)
			return (-1);
	}
	if (!(dest_path = get_path(argv + i, envp, option)) || !dest_path[0])
		return (-1);
	if (!chdir(dest_path))
	{
		free(dest_path);
		return (pwd_update(envp));
	}
	else
	{
		put_error("cd", argv[i]);
		free(dest_path);
		return (-1);
	}
}
Esempio n. 8
0
int	my_loop(const char *format, int (**fptr)(va_list), va_list ap,
		char *tab)
{
  int	i;
  int	j;
  int	retour;

  i = 0;
  while (format[i] != '\0')
    {
      if (format[i] == '%')
	{
	  j = 0;
	  while (j != 10)
	    {
	      if (tab[j] == format[i + 1])
		retour = fptr[j](ap);
	      j = j + 1;
	    }
	  if (j == 10)
	    i = put_error(format, i, tab);
	  i = i +  1;
	}
      else
	my_putchar(format[i]);
      i = i + 1;
    }
  return (retour);
}
Esempio n. 9
0
File: key.c Progetto: HARM67/Fdf
int	key_mode(int key, t_app *app)
{
	if (key == 14)
	{
		if (app->maj)
			app->show_depth = !app->show_depth;
		else
			app->a_depth = !app->a_depth;
	}
	else if (key == 15)
		app->a_light = !app->a_light;
	else if (key == 12)
		app->a_culling = !app->a_culling;
	else if (key == 13)
		app->rem_no_visible = !app->rem_no_visible;
	else if (key == 17)
		app->a_picking = !app->a_picking;
	else if (key == 16)
		app->a_prof = !app->a_prof;
	else if (key == 53)
		put_error();
	else
		return (0);
	render(app);
	return (1);
}
Esempio n. 10
0
void				loop_client(t_client *client)
{
	int				type;
	int				i;
	static int		type_enum[TYPE_SIZE] = TYPE_ENUM;
	static char		*(*type_funct[TYPE_SIZE])(t_client *) = TYPE_FUNCT;
	char			*error;

	while (42)
	{
		print_prompt(client);
		while ((type = ft_select(client)) == -1)
			;
		refresh();
		if (type == QUIT)
			break ;
		error = NULL;
		i = 0;
		while (i < TYPE_SIZE)
		{
			if (type == type_enum[i])
				error = type_funct[i](client);
			i++;
		}
		put_error(client, error);
	}
}
int	args_h(char **cmd, t_history **history)
{
  t_history *list;
  int	i;

  i = -1;
  list = advance_history(*history, cmd[1]);
  if (!cmd[1])
    while (list != NULL)
      {
	printf("%s\n", list->command);
	list = list->next;
      }
  else
    {
      if (put_error(cmd[1], 1))
	return (EXIT_FAILURE);
      while (list &&  ++i < atoi(cmd[1]))
	{
	  printf("%s\n", list->command);
	  list = list->next;
	}
    }
  return (EXIT_SUCCESS);
}
int	args_r(char **cmd, t_history **history)
{
  t_history *list;
  int	i;

  i = -1;
  list = *history;
  if (!cmd[1])
    while (list != NULL)
      {
	show_param_history(list);
	list = list->prev;
      }
  else
    {
      if (put_error(cmd[1], 1))
	return (EXIT_FAILURE);
      while (list &&  ++i < atoi(cmd[1]))
	{
	  show_param_history(list);
	  list = list->prev;
	}
    }
  return (EXIT_SUCCESS);
}
Esempio n. 13
0
/**
  Cmd pong
  Used when you need to ping the service, and see if its up
  Responds with "pong" if available.
  */
int cmd_pong(int arc, char **argv){


#ifdef USE_MYSQL
            _mysql_updateStats(g_conn, "init");
#endif
            cmd_sendresponse(put_error(200,"Pong"), 200);
            cmd_done();
            return 1;
}
Esempio n. 14
0
size_t		xfwrite(void *ptr, size_t size,
			size_t nmemb, FILE *stream)
{
  size_t        ret;

  ret = fwrite(ptr, size, nmemb, stream);
  if (ret < 0)
    return (put_error("Write failed on file descriptor"));
  return (ret);
}
Esempio n. 15
0
SDL_Surface	*get_surf(t_info *info, unsigned int id)
{
    unsigned int	i;

    for (i = 0; i < NB_ITEMS; i++)
        if (gl_items[i].id == id)
            return (info->img[i]);
    printf("id %d\n", (int)id);
    put_error("pewt");
    return (0);
}
Esempio n. 16
0
t_vec4	*new_vec4(t_vec4 v)
{
	t_vec4 *rt;

	rt = (t_vec4*)ft_memalloc(sizeof(t_vec4));
	if (rt == 0)
		put_error();
	*rt = v;
	rt->next = 0;
	return (rt);
}
Esempio n. 17
0
static int	read_other(t_app *app, char *array)
{
	if (ft_strncmp(array, "##start", 7) == 0 && !app->read_mode)
	{
		if (app->have_start)
			put_error("Error : Il y a plusieur ##start");
		app->read_mode = 1;
	}
	else if (ft_strncmp(array, "##end", 5) == 0 && !app->read_mode)
	{
		if (app->have_end)
			put_error("Error : Il y a plusieur ##end");
		app->read_mode = 2;
	}
	else if (array[0] == '#' || array[0] == 'L')
		;
	else
		return (0);
	return (1);
}
int		update_sound_param(t_trame *req, t_cfg *cfg)
{
  int		param[2];

  if (req->len != sizeof(int) * 2)
    return (put_error("size missmatch of trame for change cfg."));
  memcpy((void*)param, req->msg, req->len);
  cfg->Sound[0] = param[0];
  cfg->Sound[1] = param[1];
  return (0);
}
Esempio n. 19
0
int		xSDL_BlitSurface(SDL_Surface *src,
				 SDL_Rect *srcrect,
				 SDL_Surface *dest,
				 SDL_Rect *destrect)
{
  if (SDL_BlitSurface(src, srcrect, dest, destrect) < 0)
    {
      put_error(SDL_GetError());
      return (-1);
    }
  return (0);
}
Esempio n. 20
0
FILE            *xfopen(char *s, char *mode)
{
  FILE          *fd;

  fd = fopen(s, mode);
  if (!fd)
    {
      put_error("Failed to open file'");
      return (0);
    }
  return (fd);
}
Esempio n. 21
0
Err		load_gamespace(t_info *info)
{
  info->game.gamespace = SDL_DisplayFormatAlpha(info->mysdl.screen);
  if (!info->game.gamespace)
    {
      put_error(SDL_GetError());
      exit(1);
    }
  info->game.pos_x = 0;
  info->game.pos_y = 0;
  return (update_gamespace(info));
}
Esempio n. 22
0
File: main.c Progetto: HARM67/Fdf
int	main(int ac, char **av)
{
	t_app	app;

	if (ac < 2)
		put_error();
	ft_bzero(&app, sizeof(t_app));
	app.ac = ac;
	app.av = av;
	app_init(&app);
	app_run(&app);
	return (0);
}
int	args_c(char **cmd, t_history **history)
{
  int	fd;

  if (cmd[1])
    if (put_error(cmd[1], 1))
      return (EXIT_FAILURE);
  if ((fd = open(".history", O_TRUNC, 0, NO)) == -1)
    return (EXIT_FAILURE);
  close(fd);
 *history = NULL;
  return (EXIT_SUCCESS);
}
Esempio n. 24
0
static void search_complete(sp_search *search, void *userdata)
{


        if (sp_search_error(search) == SP_ERROR_OK){
             get_search(search);
        }
        else cmd_sendresponse(put_error(400, sp_error_message(sp_search_error(search))), 400);

        sp_search_release(search);

        cmd_done();
}
int			recv_client_req(t_client *clt, t_trame *req)
{
  SDLNet_SocketSet	sset;

  sset = SDLNet_AllocSocketSet(1);
  SDLNet_TCP_AddSocket(sset, clt->sock);
  while (32)
    {
      if (SDLNet_CheckSockets(sset, (Uint32)-1) < 0)
	return (put_error("recv_client_req failed"));
      if (SDLNet_SocketReady(clt->sock) && get_msg(clt, req))
	return (0);
      else if (clt->loss > NET_MAXLOSS)
	return (1);
    }
  return (0);
}
Esempio n. 26
0
int	check_history(t_global *global, char **cmd)
{
  if (!cmd[1])
    show_history(global->hist, NULL);
  else if (cmd[1] && !put_error(cmd[1], 0) && !cmd[2])
    show_history(global->hist, cmd[1]);
  else if (cmd[1] && cmd[2] && cmd[3])
    {
      fprintf(stderr, "%s: Too many arguments.\n", cmd[0]);
      return (EXIT_FAILURE);
    }
  else if (cmd[1] || (cmd[1] && cmd[2]))
    {
      if (param_history(&global->hist, cmd))
	return (EXIT_FAILURE);
    }
  return (EXIT_SUCCESS);
}
Esempio n. 27
0
void			init_pixel_format(t_info *info)
{
  const SDL_VideoInfo	*VideoInfo;

  info->mysdl.video_flags = SDL_HWPALETTE;
  info->mysdl.video_flags |= SDL_RESIZABLE;
  if ((VideoInfo = SDL_GetVideoInfo()) == NULL)
    put_error(SDL_GetError());
  if (VideoInfo->hw_available)
    {
      info->mysdl.video_flags |= SDL_HWSURFACE;
      info->mysdl.video_flags |= SDL_DOUBLEBUF;
    }
  else
    info->mysdl.video_flags |= SDL_SWSURFACE;
  if (VideoInfo->blit_hw)
    info->mysdl.video_flags |= SDL_HWACCEL;
}
int		db_base_instant(t_engine *e, t_db_ind *ind)
{
  int		i;

  for (i = 0; i < ind->nb[TYPE_INSTANTS]; i++)
    {
      if (!xml_next("instant"))
	return (put_error("Not found instants in xml"));
      e->db.instants[i].name = xml_getstr("name");
      e->db.instants[i].idsprite = unpack_sprite(xml_getstr("sprite"));
      e->db.instants[i].idtaunt = unpack_taunt(xml_getstr("taunt"));
      e->db.instants[i].damage = xml_getint("damage");
      e->db.instants[i].splash = xml_getint("splash");
      e->db.instants[i].speed = xml_getint("speed");
      e->db.instants[i].time = xml_getint("time");
      xml_out();
    }
  return (0);
}
Esempio n. 29
0
Err		init_sdl(t_info *info)
{
  if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
    {
      put_error(SDL_GetError());
      return (-1);
    }
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
    info->mysdl.rmask = 0xff000000;
    info->mysdl.gmask = 0x00ff0000;
    info->mysdl.bmask = 0x0000ff00;
    info->mysdl.amask = 0x000000ff;
#else
    info->mysdl.rmask = 0x000000ff;
    info->mysdl.gmask = 0x0000ff00;
    info->mysdl.bmask = 0x00ff0000;
    info->mysdl.amask = 0xff000000;
#endif
  atexit(SDL_Quit);
  init_pixel_format(info);
  return (0);
}
Esempio n. 30
0
int	check_link_name_suite(char *buffer, int a, int b)
{
  char	t[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-";

  while (buffer[a] != '\n')
    {
      if (buffer[a] == '\0')
	return (0);
      if (buffer[a] == t[b])
	{
	  b = 0;
	  a++;
	}
      else if (t[b] == '\0')
	put_error("Invalid link name");
      else
	{
	  a = skip_comment_line(buffer, a);
	  b++;
	}
    }
  return (1);
}