Exemple #1
0
char		*ft_getenv(char **ep, const char *key)
{
	while (*ep)
	{
		if (ft_strstr(*ep, key))
			return (ft_strchr(*ep, '=') + 1);
		ep++;
	}
	return (NULL);
}
Exemple #2
0
int main()
{
	char s1[] = "tata";
	char s2[] = "a";
	char *result;

	result = ft_strstr(s1, s2);
	ft_putstr(result);
	ft_putchar('\n');
	return (0);
}
Exemple #3
0
t_generror		*gen_scalar(float *a, t_ast *elem)
{
	int n;

	if (!ft_strstr(elem->tag, "|int") && !ft_strstr(elem->tag, "|float"))
		return (new_gerror(elem, "Expected scalable type, got: ", elem->tag));
	if (ft_strstr(elem->tag, "|int"))
		*a = ft_atoi(elem->value);
	else
	{
		n = elem->children[0]->value[0] == '-';
		*a = ft_atoi(elem->children[0]->value + n);
		*a += ((float)ft_atoi(elem->children[2]->value)) /
			pow(10, ft_strlen(elem->children[2]->value));
		*a = n ? -*a : *a;
	}
	if (*a <= -10000.0f || *a >= 10000.0f)
		return (new_gerror(elem, "Value out of range: ", elem->tag));
	return (0);
}
Exemple #4
0
Fichier : b_cd.c Projet : Selk/Dev
static void		cd(t_struct *val, char *type, int flag)
{
	int		i;
	char	*tmp;

	i = 0;
	while (val->env[i])
	{
		if (ft_strstr(val->env[i], type) && val->env[i][flag] == '=')
		{
			tmp = get_tmp(ft_strstr(val->env[i], type));
			if (ft_strcmp(type, "OLDPWD=") == 0)
				ft_printf("%s\n", tmp);
			chdir(tmp);
			put_oldpwd(put_pwd(tmp, val), val);
			free(tmp);
		}
		i++;
	}
}
Exemple #5
0
char	*get_rel_from_abs(char *abs, char *rel)
{
	char	*pos;

	if (rel && (pos = ft_strstr(abs, rel)))
	{
		abs[0] = '~';
		abs[1] = 0;
		ft_strcat(abs, pos + ft_strlen(rel));
	}
	return (abs);
}
Exemple #6
0
  static FT_Bool
  tt_check_trickyness_family( FT_String*  name )
  {

#define TRICK_NAMES_MAX_CHARACTERS  19
#define TRICK_NAMES_COUNT           18

    static const char trick_names[TRICK_NAMES_COUNT]
                                 [TRICK_NAMES_MAX_CHARACTERS + 1] =
    {
      /*
         PostScript names are given in brackets if they differ from the
         family name.  The version numbers, together with the copyright or
         release year data, are taken from fonts available to the
         developers.

         Note that later versions of the fonts might be no longer tricky;
         for example, `MingLiU' version 7.00 (file `mingliu.ttc' from
         Windows 7) is an ordinary TTC with non-tricky subfonts.
       */

      "cpop",               /* dftt-p7.ttf; version 1.00, 1992 [DLJGyShoMedium] */
      "DFGirl-W6-WIN-BF",   /* dftt-h6.ttf; version 1.00, 1993 */
      "DFKaiSho-SB",        /* dfkaisb.ttf */
      "DFKaiShu",
      "DFKai-SB",           /* kaiu.ttf; version 3.00, 1998 [DFKaiShu-SB-Estd-BF] */
      "DLC",                /* dftt-m7.ttf; version 1.00, 1993 [DLCMingBold] */
                            /* dftt-f5.ttf; version 1.00, 1993 [DLCFongSung] */
      "DLCHayMedium",       /* dftt-b5.ttf; version 1.00, 1993 */
      "DLCHayBold",         /* dftt-b7.ttf; version 1.00, 1993 */
      "DLCKaiMedium",       /* dftt-k5.ttf; version 1.00, 1992 */
      "DLCLiShu",           /* dftt-l5.ttf; version 1.00, 1992 */
      "DLCRoundBold",       /* dftt-r7.ttf; version 1.00, 1993 */
      "HuaTianKaiTi?",      /* htkt2.ttf */
      "HuaTianSongTi?",     /* htst3.ttf */
      "Ming(for ISO10646)", /* hkscsiic.ttf; version 0.12, 2007 [Ming] */
                            /* iicore.ttf; version 0.07, 2007 [Ming] */
      "MingLiU",            /* mingliu.ttf */
                            /* mingliu.ttc; version 3.21, 2001 */
      "MingMedium",         /* dftt-m5.ttf; version 1.00, 1993 [DLCMingMedium] */
      "PMingLiU",           /* mingliu.ttc; version 3.21, 2001 */
      "MingLi43",           /* mingli.ttf; version 1.00, 1992 */
    };

    int  nn;


    for ( nn = 0; nn < TRICK_NAMES_COUNT; nn++ )
      if ( ft_strstr( name, trick_names[nn] ) )
        return TRUE;

    return FALSE;
  }
int			parse_name_comment(t_bin *bin, t_parser *p)
{
	if (!bin->has_name && ft_strstr(p->line, NAME_CMD_STRING) == p->line)
	{
		p->i += ft_strlen(NAME_CMD_STRING);
		parse_name(bin, p);
		bin->has_name = 1;
		return (1);
	}
	else if (!bin->has_comment
			&& ft_strstr(p->line, COMMENT_CMD_STRING) == p->line)
	{
		p->i += ft_strlen(COMMENT_CMD_STRING);
		parse_comment(bin, p);
		bin->has_comment = 1;
		return (1);
	}
	else
		parse_error(p, "Expected file name or comment");
	return (0);
}
Exemple #8
0
void		trait_pov(char *here, t_obj *obj)
{
	char	*here2;
	char	*temp;

	temp = chaine(here);
	here[0] = 'W';
	if (temp == NULL)
		return ;
	if ((here2 = ft_strstr(temp, "pos(")) && here2 != NULL)
	{
		here2 = chaine2(here2);
		obj->pos = *vec3d(here2);
	}
	if ((here2 = ft_strstr(temp, "color(")) && here2 != NULL)
	{
		here2 = chaine2(here2);
		obj->color = *vec3d(here2);
	}
	cut_pov(temp, obj);
}
Exemple #9
0
Fichier : b_cd.c Projet : Selk/Dev
static char		*put_pwd(char *pwd, t_struct *val)
{
	int		i;
	char	*tmp1;
	char	*tmp2;

	i = 0;
	while (val->env[i])
	{
		if (ft_strstr(val->env[i], "PWD") && val->env[i][3] == '=')
		{
			tmp1 = ft_strstr(val->env[i], "PWD=");
			tmp2 = get_tmp(tmp1);
			val->env[i] = (char *)malloc(sizeof(char) * (ft_strlen(pwd) + 5));
			ft_strcpy(val->env[i], "PWD=");
			ft_strcat(val->env[i], pwd);
		}
		i++;
	}
	return (tmp2);
}
Exemple #10
0
static void		update_env(t_params *p, char *new_dir)
{
	char	*tmp;

	p->oldpwd = p->pwd;
	if (ft_strstr(new_dir, "/nfs/"))
		p->pwd = ft_strdup(ft_strstr(new_dir, "/nfs/"));
	else
		p->pwd = ft_strdup(new_dir);
	if (!(update_var(p, "PWD=", p->pwd)))
	{
		tmp = ft_strjoin("setenv PWD ", p->pwd);
		ft_add_env(tmp, p);
		ft_strdel(&tmp);
	}
	if (!(update_var(p, "OLDPWD=", p->oldpwd)))
	{
		tmp = ft_strjoin("setenv OLDPWD ", p->oldpwd);
		ft_add_env(tmp, p);
		ft_strdel(&tmp);
	}
}
Exemple #11
0
char	*ft_strtabfind(char **tab, char *needle)
{
	int		i;

	i = 0;
	while (tab[i])
	{
		if (ft_strstr(tab[i], needle))
			return (tab[i]);
		i++;
	}
	return (NULL);
}
Exemple #12
0
int		ft_strtabifind(char **tab, char *needle)
{
	int		i;

	i = 0;
	while (tab[i])
	{
		if (ft_strstr(tab[i], needle))
			return (i);
		i++;
	}
	return (-1);
}
Exemple #13
0
char	*ft_getenv(char *str, t_env *e)
{
	int	y;

	y = 0;
	while (e->environ[y] != 0)
	{
		if (ft_strstr(e->environ[y], str) != NULL)
			return (&e->environ[y][ft_strlen(str) + 1]);
		y++;
	}
	return (NULL);
}
Exemple #14
0
int	main(void)
{
	char str[] = "SalutCommentCaVa";
	char str1[] = "";
	char *str2;
	char *str3;

	str2 = strstr(str, str1);
	printf("%s\n", str2);
	str3 = ft_strstr(str, str1);
	printf("%s\n", str3);
	return (0);
}
Exemple #15
0
/* Numeros des options -R = 1, -a = 2, -r = 3, -t = 4, -l = 5
*/
int		*ft_detect_option(char *path)
{
	int *options;
	int i;

	i = 0;
	options = (int *)malloc(sizeof(int) * 6);
	while (i < 6)
		options[i++] = 0;
	i = 0;
	if (path[0] != '-')
	{
		options[5] = 2;
		return (options);
	}
	(ft_strstr(path, "R") != NULL) ? options[i++] = 1 : i++;
	(ft_strstr(path, "a") != NULL) ? options[i++] = 1 : i++;
	(ft_strstr(path, "r") != NULL) ? options[i++] = 1 : i++;
	(ft_strstr(path, "t") != NULL) ? options[i++] = 1 : i++;
	(ft_strstr(path, "l") != NULL) ? options[i++] = 1 : i++;
	return (options);
}
Exemple #16
0
t_generror		*gen_type(t_prim_type *ret, t_ast *elem)
{
	const char	*types[] = {"plane", "sphere", "cone", "cylinder", 0};
	int			i;

	if (!ft_strstr(elem->tag, "|string"))
		return (new_gerror(elem, "Expected string type, got: ", elem->tag));
	i = str_arr_find(types, elem->value);
	if (i == -1)
		return (new_gerror(elem, "Unknown primitive type: ", elem->value));
	*ret = i;
	return (0);
}
Exemple #17
0
int ft_str_is_numeric(char *str)
{
	int i;
	i = 0;
	char numbers[] = "0123456789";
	while (str[i] != '\0'){
		if (ft_strstr(numbers, &str[i]) != NULL)
			i++;
		else 
			return 0;	
	}
	return 1;
}
Exemple #18
0
void	display(GLFWwindow *win, t_env *e)
{
	char	*line;
	float	eom;
	char	**got;

	while (!glfwWindowShouldClose(win) && !glfwGetKey(win, 256))
	{
		glfwPollEvents();
		if (get_next_line(0, &line) > 0)
		{
			glClear(GL_COLOR_BUFFER_BIT);
			if (ft_strstr(line, "<got"))
				got = ft_strsplit(line, ' ');
			else if (ft_strstr(line, "Plateau"))
			{
				e->map_size = get_size_bonus(line, e);
				if (e->map_size && !e->sz)
					e->sz = get_square_size(e->map_size);
				get_next_line(0, &line);
				e->map = get_map(e, line);
				eom = disp_grid(e->map_size, -0.95, 0.95, e->sz);
				if (e->piece_size[0] > 0)
					disp_piece(e, eom);
				put_map_square(e);
				if (got != NULL)
					get_play(eom, got, e);
				glfwSwapBuffers(win);
			}
		}
		else
		{
			put_winner(e, eom);
			glfwSwapBuffers(win);
			glfwWaitEvents(); //TODO BETTER HOLD
		}
	}
}
Exemple #19
0
static int	star(char *tested, char *word)
{
	char	*buf;
	char	*ret;
	int		skip;

	buf = word + 1;
	while (*buf && *buf != '*' && *buf != '?' && *buf != '[')
		buf++;
	if ((skip = skip_to_glob(buf, tested, word)) == 1)
		return (1);
	else if (skip == -1)
		return (0);
	buf = ft_strsub(word + 1, 0, buf - (word + 1));
	ret = ft_strstr(tested, buf);
	while (ret != NULL &&
			(match(ret + ft_strlen(buf), word + ft_strlen(buf) + 1)) == 0)
		ret = ft_strstr(ret + ft_strlen(buf), buf);
	free(buf);
	if (ret == NULL)
		return (0);
	return (1);
}
Exemple #20
0
int					ft_is_opera(char *str)
{
	int			i;
	static char	*g_opera[3] = {"||", "&&", "|"};

	i = 0;
	while (i < 3)
	{
		if (ft_strstr(str, g_opera[i]))
			return (i);
		i++;
	}
	return (-1);
}
Exemple #21
0
char 	*match_from_end(char *s, char *m)
{
	char *cpy;

	cpy = ft_strdup(m);
	while (*cpy)
	{
		printf("cpy: %s\n", cpy);
		if (ft_strstr(s, cpy))
			return (cpy);
		cpy[ft_strlen(cpy) - 1] = 0;
	}
	return (cpy);
}
Exemple #22
0
int main(/*int ac, char **argv*/)
{
    char a[100] = "63d012345";
    char b[100] = "01234";
    char *c;
    char *d;
//    if (ac > 2)
//    {
        c = strstr(a, b);
        d = ft_strstr(a, b);
        printf("%s;%s", c, d);
//    }
    return(0);
}
Exemple #23
0
static void		ft_fill_cone(t_rtv1 *rtv1, char **tab, char **tri, int i)
{
	char	*hexa;

	rtv1->obj.cone[i].posx = ft_atoid(tri[0]);
	rtv1->obj.cone[i].posy = ft_atoid(tri[1]);
	rtv1->obj.cone[i].posz = ft_atoid(tri[2]);
	rtv1->obj.cone[i].base_size = ft_atoid(tab[1]);
	rtv1->obj.cone[i].height = ft_atoid(tab[2]);
	if ((hexa = ft_strstr(tab[3], "0x")))
		rtv1->obj.cone[i].color = ft_abs(ft_atoi_base(&hexa[2], 16));
	else
		rtv1->obj.cone[i].color = ft_abs(ft_atoi_base(tab[3], 16));

}
Exemple #24
0
void match_right(char *s1, char *s2)
{
	char *c1;

	c1 = ft_strdup(s1);
	while (*c1)
	{
		if (ft_strstr(s2, c1))
		{
			if (ft_strlen(c1) > ft_strlen(local_max))
				local_max = ft_strdup(c1);
		}
		c1[ft_strlen(c1) - 1] = 0;
	}
}
Exemple #25
0
int presence_occ(t_liaison *liaison, char *name)
{
  int i;
  t_liaison *tmp;

  tmp = liaison;
  i = 0;
  while (tmp)
    {
      if (ft_strstr(tmp->line, name))
	i++;
      tmp = tmp->next;
    }
  return (i);
}
Exemple #26
0
static void		detect_flags(t_check *check, int argc, char **argv)
{
	if (argc <= 1)
		return ;
	FT_INIT(int, line, 1);
	check->flags = ft_strdup("0000");
	while (argv[line])
	{
		if (ft_strchr(argv[line], '-'))
		{
			if (ft_strchr(argv[line], 'r'))
				(check->flags)[0] = 'r';
			if (ft_strchr(argv[line], 'c'))
				(check->flags)[1] = 'c';
			if (!ft_strstr(argv[line], "--name=") && ft_strchr(argv[line], 'm'))
				(check->flags)[2] = 'm';
			if (ft_strstr(argv[line], "--name="))
				if (ft_strlen(ft_strchr(argv[line], '=')) > 1)
					check->ant_name =
						ft_strdup((ft_strchr(argv[line], '=') + 1));
		}
		line++;
	}
}
Exemple #27
0
int		main(int argc, char **argv)
{
	char	*body;
	char	*part;

	body = argv[1];
	part = argv[2];
	if (argc > 2)
	{
		printf("In the string [%s] find [%s]\n", body, part);
		printf("In the string ft_strstr  [%s] \n", ft_strstr(body, part));
		printf("In the string find strstr[%s] \n", strstr(body, part));
	}
	return (0);
}
Exemple #28
0
static int	ft_check_len_modif(t_print *prnt)
{
	if (ft_strstr(prnt->len, "hh") && (prnt->type == 'd' || prnt->type == 'D'))
		return (1);
	if (ft_strstr(prnt->len, "hh") && (prnt->type == 'o' || prnt->type == 'O'))
		return (1);
	if (ft_strstr(prnt->len, "hh") && (prnt->type == 'u' || prnt->type == 'U'))
		return (1);
	if (ft_strstr(prnt->len, "hh") && (prnt->type == 'x' || prnt->type == 'X'))
		return (1);
	if (ft_strstr(prnt->len, "hh") && (prnt->type == 'n' || prnt->type == 'i'))
		return (1);
	if (ft_strstr(prnt->len, "ll") && (prnt->type == 'd' || prnt->type == 'D'))
		return (1);
	if (ft_strstr(prnt->len, "ll") && (prnt->type == 'o' || prnt->type == 'O'))
		return (1);
	if (ft_strstr(prnt->len, "ll") && (prnt->type == 'u' || prnt->type == 'U'))
		return (1);
	if (ft_strstr(prnt->len, "ll") && (prnt->type == 'x' || prnt->type == 'X'))
		return (1);
	if (ft_strstr(prnt->len, "ll") && (prnt->type == 'n' || prnt->type == 'i'))
		return (1);
	return (-1);
}
Exemple #29
0
int			parse_verif(char *line, int fd, t_env *e, int i)
{
	if (ft_strstr(line, "sphere"))
	{
		if (!ft_parse_sphere(fd, line, e->objects, i))
			return (0);
		e->types[i] = ft_strdup("sphere");
	}
	else if (ft_strstr(line, "cylinder"))
	{
		if (!ft_parse_sphere(fd, line, e->objects, i))
			return (0);
		if (!ft_parse_cylindre(fd, line, e->objects, i))
			return (0);
		e->types[i] = ft_strdup("cylindre");
	}
	else if (ft_strstr(line, "cone"))
		return (ft_parse_verif_3(fd, line, e, i));
	else if (ft_strstr(line, "plan"))
		return (ft_parse_verif_2(fd, line, e, i));
	else
		return (0);
	return (1);
}
int			ft_syntax_analysis(char **args)
{
	int		i;

	i = 0;
	if (args == NULL)
		return (1);
	while (args[i] != '\0')
	{
		if (ft_strchr(SEPARATORS, args[i][0]) != NULL)
		{
			if (ft_strlen(args[i]) > 2)
				return (ft_parse_error(args[i]));
			if (ft_strstr(args[i], "||") && ft_check_double_pipe(args, i))
				return (ft_parse_error(args[i]));
			else if (ft_strchr(args[i], ';') && ft_check_semi_colon(args, i))
				return (ft_parse_error(args[i]));
			else if (ft_strstr(args[i], "&&") && ft_check_double_and(args, i))
				return (ft_parse_error(args[i]));
		}
		i++;
	}
	return (ft_pipes_analysis(args));
}