Exemple #1
0
int		main(int argc, char **argv)
{
	int fd;
	int ret;
	char buf[22];
	char **tab;
	char ***tetro_tab = NULL;
	char **map;
	int i;

	argc= argc+1;
	i = 0;
	tab = (char**)malloc(sizeof(char*) * 27);
	fd = open(argv[1], O_RDONLY);
	if (fd == -1)
	{
		ft_putstr("open() error\n");
		return (0);
	}

	while (((ret = read(fd, buf, 21)) > 20) && i < 27)
	{
		buf[ret] = '\0';
		tab[i] = (char*)malloc(sizeof(char) * (ft_strlen(buf) + 1));
		tab[i] = ft_strcpy(tab[i], buf);
		if (ft_verif_tetro(tab[i]) == 0 || ft_stick_verif(tab[i]) == 0)
		{
			ft_putnbr(i);
			ft_putstr("tetromino error");
			return (0);
		}
		i++;
	}
	buf[ret] = '\0';
	tab[i] = (char*)malloc(sizeof(char) * (ft_strlen(buf) + 1));
	tab[i] = ft_strcpy(tab[i], buf);
	tab[i + 1] = NULL;
	if (ft_verif_tetro(tab[i]) == 1 && ft_stick_verif(tab[i]) == 1 && i < 27)
	{
	up_left_pieces(tab);
	ft_to_letters(tab, i);
	i++;
	tetro_tab = ft_bigger_tab(tab, i);
	// printf("\n\n\n\n");
	ft_print_grid(ft_sqrt_rounded_up(i * 4));
	map = ft_print_grid(ft_sqrt_rounded_up(i * 4));
	while (!backtracking(map, tetro_tab, 0))
	{
		ft_putstr("COUCOU JE SUIS ENTRE");
		ft_puttab(map);
		ft_putchar(10);
		map = up_map(map);
		ft_puttab(map);
	}
	printf("COUCOU JE SUIS SORTI\n");
	ft_puttab(map);
		ft_putchar(10);
	return (1);
	}
	return (0);
}
FT_GetFile_From_Mac_Name( char*     fontName,
                          FSSpec*   pathSpec,
                          FT_Long*  face_index )
{
    OptionBits            options = kFMUseGlobalScopeOption;

    FMFontFamilyIterator  famIter;
    OSStatus              status = FMCreateFontFamilyIterator( NULL, NULL,
                                   options,
                                   &famIter );
    FMFont                the_font = NULL;
    FMFontFamily          family   = NULL;


    *face_index = 0;
    while ( status == 0 && !the_font )
    {
        status = FMGetNextFontFamily( &famIter, &family );
        if ( status == 0 )
        {
            int                           stat2;
            FMFontFamilyInstanceIterator  instIter;
            Str255                        famNameStr;
            char                          famName[256];


            /* get the family name */
            FMGetFontFamilyName( family, famNameStr );
            CopyPascalStringToC( famNameStr, famName );

            /* iterate through the styles */
            FMCreateFontFamilyInstanceIterator( family, &instIter );

            *face_index = 0;
            stat2 = 0;
            while ( stat2 == 0 && !the_font )
            {
                FMFontStyle  style;
                FMFontSize   size;
                FMFont       font;


                stat2 = FMGetNextFontFamilyInstance( &instIter, &font,
                                                     &style, &size );
                if ( stat2 == 0 && size == 0 )
                {
                    char  fullName[256];


                    /* build up a complete face name */
                    ft_strcpy( fullName, famName );
                    if ( style & bold )
                        strcat( fullName, " Bold" );
                    if ( style & italic )
                        strcat( fullName, " Italic" );

                    /* compare with the name we are looking for */
                    if ( ft_strcmp( fullName, fontName ) == 0 )
                    {
                        /* found it! */
                        the_font = font;
                    }
                    else
                        ++(*face_index);
                }
            }

            FMDisposeFontFamilyInstanceIterator( &instIter );
        }
    }

    FMDisposeFontFamilyIterator( &famIter );

    if ( the_font )
    {
        FMGetFontContainer( the_font, pathSpec );
        return FT_Err_Ok;
    }
    else
        return FT_Err_Unknown_File_Format;
}
Exemple #3
0
static int		ft_is_new_line(char **line, char *buf, int i)
{
	ft_strncat(*line, buf, i);
	ft_strcpy(buf, ft_strsub(buf, i + 1, BUFF_SIZE - i - 1));
	return (1);
}
int		main(int argc, char **argv)
{
	ft_putstr(ft_strcpy(argv[1], argv[2]));
}
Exemple #5
0
char		*ft_strcat(char *s1, const char *s2)
{
	(void)ft_strcpy(ft_strchr(s1, '\0'), s2);
	s1[ft_strlen(s1)] = '\0';
	return (s1);
}
Exemple #6
0
int		main(void)
{
	char	str[256];

	printf("\n>--------------------------------------------------------------------<\n\n");
	printf("function: ");
	scanf("%s", str);
	ft_putchar('\n');
/*
**	STRLEN
*/
	if (strcmp(str, "strlen") == 0)
	{
		char	s[256];
		char	*s2;

		printf("size_t	strlen(const char *s);\n");
		printf("s = ");
		scanf("%s", s);
		s2 = strdup(s);
		printf("\nstrlen(\"%s\") :\n", s);
		printf("%d\n", (int)strlen(s));
		printf("s = %s\n", s);
		printf("\nft_strlen(\"%s\") :\n", s2);
		printf("%d\n", (int)ft_strlen(s2));
		printf("s = %s\n", s2);
		free(s2);
	}
/*
**	STRDUP
*/
	else if (strcmp(str, "strdup") == 0)
	{
		char	s1[256];
		char	*s12;
		char	*sdup;

		printf("char	*strdup(const char *s1);\n");
		printf("s1 = ");
		scanf("%s", s1);
		s12 = strdup(s1);
		printf("\nstrdup(\"%s\") :\n", s1);
		printf("%s\n", sdup = strdup(s1));
		free(sdup);
		printf("\nft_strdup(\"%s\") :\n", s12);
		printf("%s\n", sdup = strdup(s12));
		free(sdup);
	}
/*
**	STRCPY
*/
	else if (strcmp(str, "strcpy") == 0)
	{
		char	s1[256];
		char	*s12;
		char	s2[256];
		char	*s22;

		printf("char	*strcpy(char *s1, const char *s2);\n");
		printf("s1 = ");
		scanf("%s", s1);
		printf("s2 = ");
		scanf("%s", s2);
		s12 = strdup(s1);
		s22 = strdup(s2);
		printf("\nstrcpy(\"%s\", \"%s\") :\n", s1, s2);
		printf("%s\n", strcpy(s1, s2));
		printf("s1 = %s\n", s1);
		printf("s2 = %s\n", s2);
		printf("\nft_strcpy(\"%s\", \"%s\") :\n", s12, s22);
		printf("%s\n", ft_strcpy(s12, s22));
		printf("s1 = %s\n", s12);
		printf("s2 = %s\n", s22);
		free(s12);
		free(s22);
	}
/*
**	STRNCPY
*/
	else if (strcmp(str, "strncpy") == 0)
	{
		char	s1[256];
		char	*s12;
		char	s2[256];
		char	*s22;
		int		n;
		int		n2;

		printf("char	*strncpy(char *s1, const char *s2, size_t n);\n");
		printf("s1 = ");
		scanf("%s", s1);
		printf("s2 = ");
		scanf("%s", s2);
		printf("n = ");
		scanf("%d", &n);
		s12 = strdup(s1);
		s22 = strdup(s2);
		n2 = n;
		printf("\nstrncpy(\"%s\", \"%s\") :\n", s1, s2);
		printf("%s\n", strncpy(s1, s2, n));
		printf("s1 = %s\n", s1);
		printf("s2 = %s\n", s2);
		printf("\nft_strncpy(\"%s\", \"%s\") :\n", s12, s22);
		printf("%s\n", ft_strncpy(s12, s22, n2));
		printf("s1 = %s\n", s12);
		printf("s2 = %s\n", s22);
		free(s12);
		free(s22);
	}
/*
**	ATOI
*/
	else if (strcmp(str, "atoi") == 0)
	{
		char			s[256];
		char			*s2;

		printf("int	atoi(const char *str);\n");
		printf("s = ");
		scanf("%s", s);
		s2 = strdup(s);
		printf("\natoi(\"%s\") :\n", s);
		printf("%d\n", atoi(s));
		printf("\nft_atoi(\"%s\") :\n", s2);
		printf("%d\n", ft_atoi(s2));
	}
	else
		printf("This function does not exist.\n");
	main();
	return (0);
}
Exemple #7
0
  static  FT_Error
  lookup_lwfn_by_fond( const UInt8*      path_fond,
                       ConstStr255Param  base_lwfn,
                       UInt8*            path_lwfn,
                       int               path_size )
  {

#if HAVE_FSREF

    FSRef  ref, par_ref;
    int    dirname_len;


    /* Pathname for FSRef can be in various formats: HFS, HFS+, and POSIX. */
    /* We should not extract parent directory by string manipulation.      */

    if ( noErr != FSPathMakeRef( path_fond, &ref, FALSE ) )
      return FT_Err_Invalid_Argument;

    if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
                                    NULL, NULL, NULL, &par_ref ) )
      return FT_Err_Invalid_Argument;

    if ( noErr != FSRefMakePath( &par_ref, path_lwfn, path_size ) )
      return FT_Err_Invalid_Argument;

    if ( ft_strlen( (char *)path_lwfn ) + 1 + base_lwfn[0] > path_size )
      return FT_Err_Invalid_Argument;

    /* now we have absolute dirname in path_lwfn */
    if ( path_lwfn[0] == '/' )
      ft_strcat( (char *)path_lwfn, "/" );
    else
      ft_strcat( (char *)path_lwfn, ":" );

    dirname_len = ft_strlen( (char *)path_lwfn );
    ft_strcat( (char *)path_lwfn, (char *)base_lwfn + 1 );
    path_lwfn[dirname_len + base_lwfn[0]] = '\0';

    if ( noErr != FSPathMakeRef( path_lwfn, &ref, FALSE ) )
      return FT_Err_Cannot_Open_Resource;

    if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
                                    NULL, NULL, NULL, NULL ) )
      return FT_Err_Cannot_Open_Resource;

    return FT_Err_Ok;

#else

    int     i;
    FSSpec  spec;


    /* pathname for FSSpec is always HFS format */
    if ( ft_strlen( (char *)path_fond ) > path_size )
      return FT_Err_Invalid_Argument;

    ft_strcpy( (char *)path_lwfn, (char *)path_fond );

    i = ft_strlen( (char *)path_lwfn ) - 1;
    while ( i > 0 && ':' != path_lwfn[i] )
      i--;

    if ( i + 1 + base_lwfn[0] > path_size )
      return FT_Err_Invalid_Argument;

    if ( ':' == path_lwfn[i] )
    {
      ft_strcpy( (char *)path_lwfn + i + 1, (char *)base_lwfn + 1 );
      path_lwfn[i + 1 + base_lwfn[0]] = '\0';
    }
    else
    {
      ft_strcpy( (char *)path_lwfn, (char *)base_lwfn + 1 );
      path_lwfn[base_lwfn[0]] = '\0';
    }

    if ( noErr != FT_FSPathMakeSpec( path_lwfn, &spec, FALSE ) )
      return FT_Err_Cannot_Open_Resource;

    return FT_Err_Ok;

#endif /* HAVE_FSREF */

  }
Exemple #8
0
void	ft_weapons_and_maps(t_id *s)
{
	s->niveau[0] = ft_strcpy(s->niveau[0], "Maps/niveau1");
	s->niveau[1] = ft_strcpy(s->niveau[1], "Maps/niveau2");
	s->niveau[2] = ft_strcpy(s->niveau[2], "Maps/niveau3");
	s->niveau[3] = ft_strcpy(s->niveau[3], "Maps/niveau4");
	s->niveau[4] = ft_strcpy(s->niveau[4], "Maps/niveau5");
	s->weapon[0] = ft_strcpy(s->weapon[0], "Textures/weapon1.xpm");
	s->weapon[1] = ft_strcpy(s->weapon[1], "Textures/weapon2.xpm");
	s->weapon[2] = ft_strcpy(s->weapon[2], "Textures/weapon3.xpm");
	s->weapon[3] = ft_strcpy(s->weapon[3], "Textures/weapon4.xpm");
	s->weapon[4] = ft_strcpy(s->weapon[4], "Textures/weapon5.xpm");
	s->weapon[5] = ft_strcpy(s->weapon[5], "Textures/weapon6.xpm");
	s->weapon[6] = ft_strcpy(s->weapon[6], "Textures/weapon7.xpm");
}