Exemple #1
0
void			replace_char(t_it *it, char cmd[2])
{
	int		size;
	char	*tmp2;
	char	*tmp3;
	char	*tmp;
	int		j;

	j = 0;
	tmp = ft_memalloc(sizeof(char) * (it->i + 3));
	ft_strncpy(tmp, it->line, it->i);
	tmp[it->i + 1] = '\0';
	tmp = ft_strcat(tmp, cmd);
	tmp3 = copy_end_line(j, it->i, it->line);
	tmp2 = ft_strjoin(tmp, tmp3);
	ft_memdel((void**)&it->line);
	it->line = ft_strdup(tmp2);
	multi_line_text(it);
	size = ((it->len + 1) + it->offset) + 1;
	if (!(size % (it->ws_col)))
		tputs(tgetstr(RIGHT, NULL), 0, my_putchar);
	free_elements(tmp, tmp2, tmp3, NULL);
}
Exemple #2
0
char	*ft_strjoin(char const *s1, char const *s2)
{
	size_t		len;
	char		*dst;

	if (!s1 && !s2)
		return (NULL);
	if (!s1)
		len = ft_strlen(s2);
	else if (!s2)
		len = ft_strlen(s1);
	else
		len = ft_strlen(s1) + ft_strlen(s2);
	if (!(dst = (char *)malloc(sizeof(char) * len + 1)))
		return (NULL);
	if (!s1)
		return (ft_strcpy(dst, s2));
	else if (!s2)
		return (ft_strcpy(dst, s1));
	else
		ft_strcpy(dst, s1);
	return (ft_strcat(dst, s2));
}
Exemple #3
0
int			get_all(int fd, char **a)
{
	int		i;
	char	*buf;

	buf = ft_strnew(BUFF_SIZE);
	if (!buf)
		check_errors(MALLOC, "buf", "get_all.c");
	if (!a || fd < 0)
		return (0);
	if (!*a)
		*a = ft_strnew(1);
	while ((i = (int)read(fd, (void*)buf, (size_t)BUFF_SIZE)) > 0)
	{
		buf[i] = '\0';
		*a = ft_realloc(*a, ft_strlen(*a), ft_strlen(*a) + i);
		ft_strcat(*a, buf);
	}
	free(buf);
	if (!*a || i < 0)
		return (0);
	return (1);
}
Exemple #4
0
void	user_receive(t_who *group, t_who *user)
{
	int		response;
	char	str[1024];

	(void)group;
	ft_bzero(str, 1024);
	response = recv(user->fd, str, BUF_SIZE, 0);
	ft_strcat(user->buffer, str);
	if (response && ft_strchr(user->buffer, '\n') != NULL)
	{
		if (user->buffer[0] == '/')
			user_command(group, user);
		else
			send_channel(group, user);
		ft_bzero(user->buffer, sizeof(user->buffer));
	}
	else if (response == 0)
	{
		sprintf(str, MSG_USER_QUIT, user->user.name);
		close_connection(user);
		send_broadcast(group, str);
	}
}
Exemple #5
0
char	*ft_add_in(char *buffer, char *toadd, int oct, int i)
{
	int			new_len;
	char		*tmp;

	if (!buffer || buffer == NULL)
		buffer = (char*)malloc(sizeof(char));
	new_len = (ft_strlen(buffer) + ft_strlen(toadd));
	if (!(tmp = (char*)malloc(sizeof(char) * (ft_strlen(buffer) + 1))))
		return (NULL);
	while (buffer[i])
	{
		tmp[i] = buffer[i];
		i++;
	}
	tmp[i] = '\0';
	i = 0;
	if (!(buffer = (char*)malloc(sizeof(char) * (new_len + 1))))
		return (NULL);
	buffer = ft_strcat(buffer, tmp);
	buffer = ft_strncat(buffer, toadd, oct);
	free(tmp);
	return (buffer);
}
Exemple #6
0
int main()
{
	check_isupper();

	check_isLower();


	puts("--------\nTest ft_puts:\n");
	check_puts("great succes !");
	check_puts(0);

	check_isDigit();

	check_isAlpha();


	check_isAlnum();

	check_isAscii();

	check_isprint();

	check_tolower();

	check_toupper();

	int i = 0;
	srand( 42 );


	printf( "--------\nTest ft_bzero:\n" );
	char	str_bezro[STR_MAX_SIZE];
	char	str_ft_bezro[STR_MAX_SIZE];
	size_t	len_bzero;

	for ( i = MIN; i < MAX; i++ )
	{
		len_bzero = random_str( str_bezro );
		len_bzero -= random( 0, len_bzero );
		strcpy( str_ft_bezro, str_bezro );

		ft_bzero( str_ft_bezro, len_bzero );
		bzero( str_bezro, len_bzero );
		if ( memcmp( str_ft_bezro, str_bezro, len_bzero ) != 0 )
		{
			printf("result: \n%s\nexpected result: \n%s\n", str_ft_bezro, str_bezro );
			exit( 0 );
		}
	}
	printf("\033[32mOk\n\033[0m");

	printf( "--------\nTest ft_strcat:\n" );
	char	str_strcat[STR_MAX_SIZE * 2];
	char	str_ft_strcat[STR_MAX_SIZE * 2];
	char	str_strcat_s2[STR_MAX_SIZE];
	char	*ret_strcat;
	char	*ret_ft_strcat;
	size_t	len_strcat;
	size_t	len_strcat_s2;

	for ( i = MIN; i < MAX; i++ )
	{
		len_strcat_s2 = random_str( str_strcat_s2 );
		len_strcat = random_str( str_strcat );
		strcpy( str_ft_strcat, str_strcat );

		ret_ft_strcat = ft_strcat( str_ft_strcat, str_strcat_s2 );
		ret_strcat = strcat( str_strcat, str_strcat_s2 );
		if ( memcmp( str_strcat, str_ft_strcat, len_strcat + len_strcat_s2 ) != 0 )
		{
			printmem( str_strcat, len_strcat );
			printmem( str_ft_strcat, len_strcat );
			printf("result: \n%s\nexpected result: \n%s\n", str_strcat, str_ft_strcat );
			exit( 0 );
		}
		if ( memcmp( ret_strcat, ret_ft_strcat, len_strcat + len_strcat_s2 ) != 0 )
		{
			printmem( ret_strcat, len_strcat );
			printmem( ret_ft_strcat, len_strcat );
			printf("result: \n%s\nexpected result: \n%s\n", ret_strcat, ret_ft_strcat );
			exit( 0 );
		}
	}
	printf("\033[32mOk\n\033[0m");

	check_strlen();
	check_strchr();
	check_strrchr();

	printf( "--------\nTest ft_memset:\n" );
	char	str_memset[STR_MAX_SIZE];
	char	str_ft_memset[STR_MAX_SIZE];
	size_t	len_memset;

	for ( i = MIN; i < MAX; i++ )
	{
		len_memset = random_str( str_memset );
		len_memset -= random( 0, len_memset );
		strcpy( str_ft_memset, str_memset );

		ft_memset( str_ft_memset, i, len_memset );
		memset( str_memset, i, len_memset );
		if ( memcmp( str_ft_memset, str_memset, len_bzero ) != 0 )
		{
			printf("result: \n%s\nexpected result: \n%s\n", str_ft_memset, str_memset );
			exit( 0 );
		}
	}
	printf("\033[32mOk\n\033[0m");

	printf( "--------\nTest ft_memcpy:\n" );
	char	str_memcpy[STR_MAX_SIZE];
	char	str_ft_memcpy[STR_MAX_SIZE];
	char	str_memcpy_s2[STR_MAX_SIZE];
	size_t	len_memcpy;
	void	*ret_memcpy;
	void	*ret_ft_memcpy;

	for ( i = MIN; i < MAX; i++ )
	{
		len_memcpy = random_str( str_memcpy_s2 );

		ret_ft_memcpy = ft_memcpy( str_ft_memcpy, str_memcpy_s2, len_memcpy );
		ret_memcpy = memcpy( str_memcpy, str_memcpy_s2, len_memcpy );
		if ( memcmp( str_ft_memcpy, str_memcpy, len_memcpy ) != 0 )
		{
			printf("result: \n%s\nexpected result: \n%s\n", str_ft_memcpy, str_memcpy );
			exit( 0 );
		}
		if ( ret_ft_memcpy != str_ft_memcpy )
		{
			printf("result: \n%d\nexpected result: \n%d\n", (size_t)ret_ft_memcpy, (size_t)str_ft_memcpy );
			exit( 0 );
		}
	}
	printf("\033[32mOk\n\033[0m");

	printf( "--------\nTest ft_strdup:\n" );
	char	str_strdup[STR_MAX_SIZE];
	size_t	len_strdup;
	char	*ret_ft_strdup;
	char	*ret_strdup;


	for ( i = MIN; i < MAX; i++ )
	{
		len_strdup = random_str( str_strdup );

		ret_ft_strdup = ft_strdup( str_strdup );
		ret_strdup = strdup( str_strdup );
		if ( memcmp( ret_ft_strdup, ret_strdup, len_strdup ) != 0 )
		{
			printf("result: \n%s\nexpected result: \n%s\n", ret_ft_strdup, ret_strdup );
			exit( 0 );
		}
	}
	printf("\033[32mOk\n\033[0m");

	printf( "--------\nTest ft_strcpy:\n" );
	char	str_ft_strcpy[STR_MAX_SIZE];
	char	str_strcpy[STR_MAX_SIZE];
	char	str_strcpy_s2[STR_MAX_SIZE];
	char	*ret_strcpy;
	char	*ret_ft_strcpy;
	int		len_strcpy;

	for ( i = MIN; i < MAX; i++ )
	{
		len_strcpy = random_str( str_strcpy_s2 );

		ret_strcpy = strcpy( str_strcpy, str_strcpy_s2 );
		ret_ft_strcpy = ft_strcpy( str_ft_strcpy, str_strcpy_s2 );

		if ( memcmp( str_ft_strcpy, str_strcpy, len_strcpy ) != 0 )
		{
			printf("result: \n%s\n, expected result: \n%s\n", str_ft_strcpy, str_strcpy );
			exit( 0 );
		}
		if ( memcmp( ret_strcpy, ret_ft_strcpy, len_strcpy ) != 0 )
		{
			printf("result: \n%s\n, expected result: \n%s\n", ret_strcpy, ret_ft_strcpy );
			exit( 0 );
		}
	}
	printf("\033[32mOk\n\033[0m");

	printf( "--------\nTest ft_cat:\n" );
	ft_cat( 4 );
	ft_cat( 8 );
	ft_cat( -4 );
	ft_cat( open( "ft_bzero.s", O_RDONLY ) );
	ft_cat( open( "Makefile", O_RDONLY ) );
	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_THROW( Invalid_Argument );

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

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

    if ( ft_strlen( (char *)path_lwfn ) + 1 + base_lwfn[0] > path_size )
      return FT_THROW( 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_THROW( Cannot_Open_Resource );

    if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
                                    NULL, NULL, NULL, NULL ) )
      return FT_THROW( 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_THROW( 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_THROW( 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_THROW( Cannot_Open_Resource );

    return FT_Err_Ok;

#endif /* HAVE_FSREF */

  }
Exemple #8
0
  FT_GetFile_From_Mac_Name( const char*  fontName,
                            FSSpec*      pathSpec,
                            FT_Long*     face_index )
  {
    OptionBits            options = kFMUseGlobalScopeOption;

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


    if ( !fontName || !face_index )
      return FT_THROW( Invalid_Argument );

    *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 )
              ft_strcat( fullName, " Bold" );
            if ( style & italic )
              ft_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_THROW( Unknown_File_Format );
  }
Exemple #9
0
static void		putvariable(char *dst, const char *name, const char *value)
{
	ft_strcpy(dst, name);
	ft_strcat(dst, "=");
	ft_strcat(dst, value);
}
Exemple #10
0
int		main()
{
	int			fd;
	int			a = 0;
	int			b = 0;
	char		c = 0;
	char		src[] = "The unterzee does not forgive";
	char		dst1[100] = {0};
	char		dst2[100] = {0};
	char		strputs[] = "Hello";
	const char	*srcdup = "Hello";
	char		*dstdup1 = NULL;
	char		*dstdup2 = NULL;

	strcat(dst1, "");
	strcat(dst2, "");
	strcat(dst1, src);
	ft_strcat(dst2, src);
	printf("strcat    : %s\n", dst1);
	printf("ft_strcat : %s\n", dst2);
	dstdup1 = strdup(srcdup);
	printf("strdup    : %s\n", dst1);
	free(dstdup1);
	dstdup1 = NULL;
	dstdup2 = ft_strdup(srcdup);
	printf("ft_strdup : %s\n", dst2);
	free(dstdup2);
	dstdup2 = NULL;
	memset((void*)dst1, 'a', 0);
	ft_memset((void*)dst2, 'a', 0);
	printf("memset    : %s\n", dst1);
	printf("ft_memset : %s\n", dst2);
	bzero((void*)dst1, 15);
	ft_bzero((void*)dst2, 15);
	printf("bzero     : ");
	write(1, dst1, 20);
	printf("\n");
	printf("ft_bzero  : ");
	write(1, dst2, 20);
	printf("\n");
	memcpy((void*)dst1, (void*)src, 0);
	ft_memcpy((void*)dst2, (void*)src, 0);
	printf("memcpy    : %s\n", dst1);
	printf("ft_memcpy : %s\n", dst2);
	a = ft_isalpha('p');
	printf("ft_isalpha: ");
	printf("%d\n", a);
	a = ft_isascii(127);
	printf("ft_isascii: ");
	printf("%d\n", a);
	a = ft_isdigit('p');
	printf("ft_isdigit: ");
	printf("%d\n", a);
	a = ft_isprint(' ');
	printf("ft_isprint: ");
	printf("%d\n", a);
	a = ft_isalnum('P');
	printf("ft_isalnum: ");
	printf("%d\n", a);
	c = ft_tolower('A');
	printf("ft_tolower: ");
	printf("%c\n", c);
	c = ft_toupper('P');
	printf("ft_toupper: ");
	printf("%c\n", c);
	fd = open("test1.txt", O_RDONLY);
	ft_cat(fd);
	a = puts(strputs);
	b = ft_puts(strputs);
	printf("puts      : ");
	printf("%d\n", a);
	printf("ft_puts   : ");
	printf("%d\n", b);

	return (0);
}
Exemple #11
0
int	main(int ac, char **av)
{
	/*
	 * 							Test ft_puts
	 */
	(void)ac;
	ft_putchar(10);
	puts("hello");
	ft_putchar(10);
	puts(NULL);
	ft_putchar(10);
	ft_puts("hello");
	ft_putchar(10);
	ft_puts(NULL);
	ft_putchar(10);

	/*
	 * 							Test ft_puts
	 */	
	/*
	 * 							Test ft_bzero
	 */

	char	str[] = "hello";
	char	str2[] = "hello";
	printf("\n ft_bzero \n");
	printf("Test 1 \n ft_bzero et bzero n = 1	et str : %s\n",str);
	bzero(str, 1);
	printf("Avec bzero et str[0] : %c\n",str[0]);
	ft_bzero(str2, 1);
	printf("Avec ft_bzero et str2[0] : %c\n",str2[0]);
	printf("Avec bzero et str[3] : %c\n",str[3]);
	printf("Avec ft_bzero et str[3] : %c\n\n",str[3]);

	char	str3[] = "hello";
	char	str4[] = "hello";
	printf("Test 2 \n ft_bzero et bzero n = 4	et str : %s\n",str3);
	bzero(str3, 4);
	printf("Avec bzero et str[0] : %c\n",str3[0]);
	ft_bzero(str4, 4);
	printf("Avec ft_bzero et str2[0] : %c\n",str4[0]);
	printf("Avec bzero et str[3] : %c\n",str3[3]);
	printf("Avec ft_bzero et str[3] : %c\n",str4[3]);
	printf("Avec bzero et str[4] : %c\n",str3[4]);
	printf("Avec ft_bzero et str[4] : %c\n\n",str4[4]);

	char	str5[] = "hello";
	char	str6[] = "hello";
	printf("Test 3 \n ft_bzero et bzero n = 9	et str : %s\n",str5);
	bzero(str5, 9);
	printf("Avec bzero et str[4] : %c\n",str5[4]);
	ft_bzero(str6, 9);
	printf("Avec ft_bzero et str2[4] : %c\n",str6[4]);


	/*
	 *							Fin ft_bzero
	 */

	/*
	 *							ft_strcat
	 */
	char		*src;
	char		*src2;
	char		*src3;
	char		*src4;
	char		dest[40] = "Please Cat";
	char		dest2[40] = "Please Cat";

	src = "_meEeeeEeeE";
	src2 = "_meEeeeEeeE";	
	printf("\n Test 1 ft_strcat\n");
	printf("Dest : %s\nSize Dest: 40\nSrc : %s .\n", dest, src);
	src3 = strcat(dest, src);
	printf("strcat Dest : %s\n", src3);
	src4 = ft_strcat(dest2, src2);
	printf("ft_strcat Dest : %s\n", src4);

	printf("\n And Re - ft_strcat\n");
	strcat(dest, src);
	printf("strcat Dest : %s\n", dest);
	src3 = ft_strcat(dest2, src2);
	printf("ft_strcat Dest : %s\n", src3);




	/*
	 *							Fin ft_strcat
	 */

	/*
	 *							 ft_isascii
	 */
	int		a;
	int		z;
	int		nbr;
	int		weird;
	int		neg;

	neg = -500;
	a = 'a';
	z = 'Z';
	nbr = 57;
	weird = 173;
	printf("\n\nTest ascii\n");
	printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",a ,z, nbr, weird, neg);
	printf("ft_isascii       isascii\n");
	printf("%d                %d\n",ft_isascii(a), isascii(a));
	printf("%d                %d\n",ft_isascii(z), isascii(z));
	printf("%d                %d\n",ft_isascii(nbr), isascii(nbr));
	printf("%d                %d\n",ft_isascii(weird), isascii(weird));
	printf("%d                %d\n",ft_isascii(neg), isascii(neg));
	/*while (neg < 500)
	  {
	  neg++;
	  ft_putchar(ft_isascii(neg) + 48);

	  }*/


	/*
	 *							Fin ft_isascii
	 */
	/*
	 *							 ft_isalpha
	 */
	int		b;
	int		y;
	int		nb;
	int		weir;

	b = 'a';
	y = 94;
	nb = 'Z';
	weir = 173;
	neg = -1;
	printf("\n\nTest isalpha\n");
	printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",b ,y, nb, weir,neg);
	printf("ft_isalpha       isalpha\n");
	printf("%d                %d\n",ft_isalpha(b), isalpha(b));
	printf("%d                %d\n",ft_isalpha(y), isalpha(y));
	printf("%d                %d\n",ft_isalpha(nb), isalpha(nb));
	printf("%d                %d\n",ft_isalpha(weir), isalpha(weir));
	printf("%d                %d\n",ft_isalpha(neg), isalpha(neg));
	/*
	 *							Fin ft_isalpha
	 */
	/*
	 *							 ft_isdigit
	 */
	int		c;
	int		x;
	int		nbt;
	int		weira;

	c = 47;
	x = 48;
	nbt = 57;
	weira = 58;
	printf("\n\nTest isdigit\n");
	printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",c ,x, nbt, weira, neg);
	printf("ft_isdigit       isdigit\n");
	printf("%d                %d\n",ft_isdigit(c), isdigit(c));
	printf("%d                %d\n",ft_isdigit(x), isdigit(x));
	printf("%d                %d\n",ft_isdigit(nbt), isdigit(nbt));
	printf("%d                %d\n",ft_isdigit(weira), isdigit(weira));
	printf("%d                %d\n",ft_isdigit(neg), isdigit(neg));
	/*
	 *							Fin ft_isdigit
	 */
	/*
	 *							 ft_isalnum
	 */
	int		d;
	int		w;
	int		nbq;
	int		weirb;

	d = 69;
	w = 48;
	nbq = 57;
	weirb = 92;
	printf("\n\nTest isalnum\n");
	printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",d ,w, nbq, weirb, neg);
	printf("ft_isalnum       isalnum\n");
	printf("%d                %d\n",ft_isalnum(d), isalnum(d));
	printf("%d                %d\n",ft_isalnum(w), isalnum(w));
	printf("%d                %d\n",ft_isalnum(nbq), isalnum(nbq));
	printf("%d                %d\n",ft_isalnum(weirb), isalnum(weirb));
	printf("%d                %d\n",ft_isalnum(neg), isalnum(neg));
	/*
	 *							Fin ft_isalnum
	 */
	/*
	 *							 ft_isprint
	 */
	int		e;
	int		v;
	int		nbs;
	int		weirc;

	e = 32;
	v = 126;
	nbs = 12;
	weirc = 380;
	printf("\n\nTest isprint\n");
	printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",e ,v, nbs, weirc, neg);
	printf("ft_isprint       isprint\n");
	printf("%d                %d\n",ft_isprint(e), isprint(e));
	printf("%d                %d\n",ft_isprint(v), isprint(v));
	printf("%d                %d\n",ft_isprint(nbs), isprint(nbs));
	printf("%d                %d\n",ft_isprint(weirc), isprint(weirc));
	printf("%d                %d\n",ft_isprint(neg), isdigit(neg));
	/*
	 *							Fin ft_isprint
	 */
	/*
	 *							 ft_touppper
	 */
	e = 97;
	v = 122;
	nbs = 69;
	weirc = 36;
	printf("\n\nTest ft_toupper\n");
	printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",e ,v, nbs, weirc, neg);
	printf("ft_toupper       toupper\n");
	printf("%c                %c\n",ft_toupper((UC)e), toupper((UC)e));
	printf("%c                %c\n",ft_toupper(v), toupper(v));
	printf("%c                %c\n",ft_toupper(nbs), toupper(nbs));
	printf("%c                %c\n",ft_toupper(weirc), toupper(weirc));
	printf("%c                %c\n",ft_toupper(neg), toupper(neg));
	/*
	 *							Fin ft_toupper
	 */
	/*
	 *							 ft_tolower
	 */
	e = 65;
	v = 90;
	nbs = 122;
	weirc = 36;
	printf("\n\nTest ft_tolower\n");
	printf("un = %c\ndeux = %c\ntrois = %c\nweird = %c\nneg = %d\n",e ,v, nbs, weirc, neg);
	printf("ft_tolower       tolower\n");
	printf("%c                %c\n",ft_tolower((UC)e), tolower((UC)e));
	printf("%c                %c\n",ft_tolower(v), tolower(v));
	printf("%c                %c\n",ft_tolower(nbs), tolower(nbs));
	printf("%c                %c\n",ft_tolower(weirc), tolower(weirc));
	printf("%c                %c\n",ft_tolower(neg), tolower(neg));
	/*
	 *							Fin ft_tolower
	 */
	ft_putchar('\n');

	int		l1;
	int		l2;

	/*
	 *						ft_strlen
	 */
	l1 = ft_strlen("yo Mamaa");
	ft_putstr("yo Mamaa ft_strlen: ");
	ft_putchar(l1 + 48);
	ft_putchar('\n');
	l2 = strlen("yo Mamaa");
	ft_putstr("yo Mamaa strlen: ");
	ft_putchar(l2 + 48);
	ft_putchar('\n');
	//	l2 = strlen(NULL);
	//	ft_putchar(l2 + 48);
	//	ft_putchar('\n');
	l1 = ft_strlen("\n");
	ft_putstr(" ft_strlen: ");
	ft_putchar(l1 + 48);
	ft_putchar('\n');
	l2 = strlen("\n");
	ft_putstr(" strlen: ");
	ft_putchar(l2 + 48);
	ft_putchar('\n');
	/*
	 *						Fin ft_strlen
	 */						


	/*
	 *						debut ft_memset
	 */						
	char	*memtmp;
	char	*memtmporg;
	char	*vide;
	char	*videe;

	printf("\nTEST ft_memset\n");
	vide = malloc(sizeof(char *) * 5);
	memtmporg = malloc(sizeof(char *) * 5);
	videe = malloc(sizeof(char *) * 5);
	memtmp = malloc(sizeof(char *) * 5);
	ft_putstr(memtmporg);
	ft_putchar('\n');
	memset(memtmporg, 'A', 4);
	ft_putstr(memtmporg);
	ft_putchar('\n');
	ft_memset(memtmp, 'B', 4);
	ft_putstr(memtmp);
	ft_putchar('\n');
	/*
	 *						Fin ft_memset
	 */						


	
	/*
	 *						debut ft_memcpy
	 */						
	
	
	printf("\nTEST ft_memcpy\n");
	
	memcpy(vide, memtmporg, 2);
	ft_putstr(vide);
	ft_putchar('\n');
	ft_memcpy(videe, memtmp, 2);
	ft_putstr(videe);
	ft_putchar('\n');



	/*
	 *						fin ft_memcpy
	 */



	 /*						debut ft_strdup
	 *						
	*/
	char		*isdup;
	char		*todup;
	char		*mydup;

	printf("\nTEST ft_strdup\n");
	todup = "Dupme";
	isdup = strdup(todup);
	ft_putstr(isdup);
	ft_putchar('\n');
	mydup = ft_strdup(todup);
	ft_putstr(mydup);
	ft_putchar('\n');


	 /*	[M@ft_putchar:					debut ft_strdup
	 *						
	*/


	 /*						debut ft_cat
	 *						
	*/
	int			fd;

	printf("\nTEST ft_cat\n");
	printf("\n sur 0\n");
	ft_cat(0);
	printf("\n sur ./src/ft_cat.s\n");
	fd = open("./src/ft_cat.s", O_RDONLY);
	ft_cat(fd);
	close(fd);
	printf("\n sur -42\n");
	ft_cat(-42);
	printf("\n sur __FILE__\n");
	ft_cat(open(__FILE__, O_RDONLY));
	printf("\n sur av[0]\n");
	ft_cat(open(av[0], O_RDONLY));
	 /*						fin ft_cat
	 *						
	*/

	return (0);
}
Exemple #12
0
int		main(int argc, char **argv)
{
	int		i;
	char *str;
	char *str2;

	printf("\n-------------------- PART 1 ----------------------------\n");

	printf("ft_bzero(str, 2):\n");
	str = strdup("coucou");
	printf("str avant : %s\n", str);
	ft_bzero(str, 2);
	printf("str apres : %s\n", str);

	printf("\nft_strcat(str1, str2) :\n");
	str = malloc(50);
	ft_bzero(str, 50);
	ft_strcat(str, "123456789");
	printf("str1 : %s\n", str);
	printf("str2 : coucou \n");
	ft_strcat(str, strdup("coucou"));
	printf("str1 : %s\n", str);

	printf("\nft_isalpha :\n");
	i = ft_isalpha('a');
	printf("a : %d\n", i);
	i = ft_isalpha('^');
	printf("^ : %d\n", i);

	printf("\nft_isdigit :\n");
	i = ft_isdigit('2');
	printf("2 : %d\n", i);
	i = ft_isdigit('a');
	printf("a : %d\n", i);

	printf("\nft_isalnum :\n");
	i = ft_isalnum('2');
	printf("2 : %d\n", i);
	i = ft_isalnum('a');
	printf("a : %d\n", i);
	i = ft_isalnum(32);
	printf("' ' : %d\n", i);
	i = ft_isalnum(59);
	printf("';' : %d\n", i);
	i = ft_isalnum(93);
	printf("']' : %d\n", i);

	printf("\nft_isascii :\n");
	i = ft_isascii('a');
	printf("a : %d\n", i);
	i = ft_isascii(130);
	printf("%c : %d\n", 130, i);

	printf("\nft_isprint :\n");
	i = ft_isprint(' ');
	printf("' ' : %d\n", i);
	i = ft_isprint('\t');
	printf("'\t' : %d\n", i);

	printf("\nft_toupper : \n");
	i = ft_toupper('a');
	printf("a : %c\n", i);
	i = ft_toupper('S');
	printf("S : %c\n", i);

	printf("\nft_tolower : \n");
	i = ft_tolower('Y');
	printf("Y : %c\n", i);
	i = ft_tolower('b');
	printf("b : %c\n", i);

	printf("\nft_puts : \n");
	str = strdup("coucou");
	ft_putstr("coucou : ");
	ft_puts(str);
	ft_putstr("J'aime bien les chats. : ");
	str = strdup("J'aime bien les chats.");
	ft_puts(str);
	ft_putstr("NULL : ");
	ft_puts(NULL);

	printf("\n-------------------- PART 2 ----------------------------\n");

	printf("\nft_strlen : \n");
	str = strdup("coucou");
	i = ft_strlen(str);
	printf("coucou : %d\n", i);
	str = strdup("La vie est belle.");
	i = ft_strlen(str);
	printf("La vie est belle. : %d\n", i);
	i = ft_strlen(NULL);
	printf("NULL : %d\n", i);

	printf("\nft_memset(str, x, 3) : \n");
	str = strdup("coucou");
	printf("str avant: %s\n", str);
	str = ft_memset(str, 'x', 3);
	printf("str apres: %s\n", str);

	printf("\nft_memcpy(dest, src, size) :\n");
	str = strdup("chatschats chats");
	printf("dest : %s\n",str);
	str2 = strdup("j'aime les frites.");
	printf("src : %s\n", str2);
	i = 10;
	printf("size : %d\n", i);
	str = ft_memcpy(str, str2, i);
	printf("dest : %s\n", str);

	printf("\nft_strdup :\n");
	str = ft_strdup("424242");
	printf("424242 : %s\n", str);

	printf("\n-------------------- Bonus  ----------------------------\n");

	printf("\nft_strndup :\n");
	str = ft_strndup("424242", 2);
	printf("424242, size = 2 : %s\n", str);

	printf("\nft_isspace :\n");
	i = ft_isspace(' ');
	printf("' ' : %d\n", i);
	i = ft_isspace('a');
	printf("a : %d\n", i);

	printf("\nft_strncat(str1, str2, size) :\n");
	str = malloc(50);
	ft_bzero(str, 50);
	ft_strcat(str, "123456789");
	printf("str1 : %s\n", str);
	printf("str2 : coucou \n");
	ft_strncat(str, strdup("coucou"), 3);
	printf("str1 : %s\n", str);

	printf("\n-------------------- ft_cat(fd) ------------------------\n");
	if (argc == 2)
		i = open(argv[1], O_RDONLY);
	else
		i = 0;
	ft_cat(i);
	return (0);
}