This commit is contained in:
Guy Baconniere committed 2021-08-20 10:02:38 +02:00
1 parent 5aa02c94b5
commit d30270c485
354 files changed

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
#
# Copyright (c) 2021 Guy Baconniere.
#
## How to use this Makefile
#
# cd git
# mkdir ex00
# cd ex00
# make -f ../../Makefile ex00
#
clone:
@git clone git@vogsphere.42lausanne.ch:vogsphere/intra-uuid-0206809b-f597-4ba0-ab8d-b06ca894f9ce-3717791 git
cc:
@norminette -R CheckForbiddenSourceHeader
@gcc -Wall -Wextra -Werror -o a.out *.c
@./a.out
@rm -f a.out
all: clone
BIN
View File
Binary file not shown.
Binary file not shown.
+39
View File
@@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/09 13:27:29 by gbaconni #+# #+# */
/* Updated: 2021/08/11 14:49:52 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
char *ft_strcpy(char *dest, char *src)
{
int i;
int src_size;
int dest_size;
src_size = 0;
while (src[src_size++] != '\0')
continue ;
dest_size = 0;
while (dest[dest_size++] != '\0')
continue ;
i = 0;
while (i < src_size)
{
dest[i] = src[i];
i++;
}
while (i < dest_size)
{
dest[i] = '\0';
i++;
}
return (dest);
}
+33
View File
@@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/09 13:15:38 by gbaconni #+# #+# */
/* Updated: 2021/08/11 14:30:26 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
char *ft_strcpy(char *dest, char *src);
int main(void)
{
char src[32];
char dest[32];
char *result;
printf("Input [max 31]: ");
scanf("%s", src);
result = ft_strcpy(dest, src);
printf("src=%s dest=%s result=%s (ft_strcpy)\n", src, dest, result);
result = strcpy(dest, src);
printf("src=%s dest=%s result=%s (strcpy)\n", src, dest, result);
return (0);
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out
+29
View File
@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/09 18:19:08 by gbaconni #+# #+# */
/* Updated: 2021/08/12 09:49:18 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
unsigned int i;
i = 0;
while (i < n && src[i] != '\0')
{
dest[i] = src[i];
i++;
}
while (i < n)
{
dest[i] = '\0';
i++;
}
return (dest);
}
+37
View File
@@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/09 18:18:58 by gbaconni #+# #+# */
/* Updated: 2021/08/11 18:07:07 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
char *ft_strncpy(char *dest, char *src, unsigned int n);
int main(void)
{
char src[32];
char dest[64];
unsigned int n;
char *result;
n = 0;
printf("Input String [max 31]: ");
scanf("%s", src);
printf("Input Size: ");
scanf("%d", &n);
result = ft_strncpy(dest, src, n);
printf("src=%s dest=%s n=%d result=%s (ft_strncpy)\n", src, dest, n, result);
result = strncpy(dest, src, n);
printf("src=%s dest=%s n=%d result=%s (strncpy)\n", src, dest, n, result);
return (0);
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out
Binary file not shown.
+33
View File
@@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_alpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/09 17:43:26 by gbaconni #+# #+# */
/* Updated: 2021/08/10 09:58:08 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_alpha(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= 'a' && str[i] <= 'z') \
|| (str[i] >= 'A' && str[i] <= 'Z');
i++;
}
return (r);
}
+30
View File
@@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/09 17:44:56 by gbaconni #+# #+# */
/* Updated: 2021/08/09 17:48:47 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
int ft_str_is_alpha(char *str);
int main(void)
{
char str[32];
int result;
printf("Input [max 31]: ");
scanf("%s", str);
result = ft_str_is_alpha(str);
printf("str=%s result=%d\n", str, result);
return (0);
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out
Binary file not shown.
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_numeric.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 10:14:17 by gbaconni #+# #+# */
/* Updated: 2021/08/10 10:15:38 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_numeric(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= '0' && str[i] <= '9');
i++;
}
return (r);
}
+30
View File
@@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 10:13:03 by gbaconni #+# #+# */
/* Updated: 2021/08/10 10:15:13 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
int ft_str_is_numeric(char *str);
int main(void)
{
char str[32];
int result;
printf("Input [max 31]: ");
scanf("%s", str);
result = ft_str_is_numeric(str);
printf("str=%s result=%d\n", str, result);
return (0);
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out
Binary file not shown.
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_lowercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 10:45:53 by gbaconni #+# #+# */
/* Updated: 2021/08/10 10:45:56 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_lowercase(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= 'a' && str[i] <= 'z');
i++;
}
return (r);
}
+30
View File
@@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 10:44:33 by gbaconni #+# #+# */
/* Updated: 2021/08/10 10:44:58 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
int ft_str_is_lowercase(char *str);
int main(void)
{
char str[32];
int result;
printf("Input [max 31]: ");
scanf("%s", str);
result = ft_str_is_lowercase(str);
printf("str=%s result=%d\n", str, result);
return (0);
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out
Binary file not shown.
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_uppercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 10:47:51 by gbaconni #+# #+# */
/* Updated: 2021/08/10 10:48:16 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_uppercase(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= 'A' && str[i] <= 'Z');
i++;
}
return (r);
}
+30
View File
@@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 10:48:33 by gbaconni #+# #+# */
/* Updated: 2021/08/10 10:48:53 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
int ft_str_is_uppercase(char *str);
int main(void)
{
char str[32];
int result;
printf("Input [max 31]: ");
scanf("%s", str);
result = ft_str_is_uppercase(str);
printf("str=%s result=%d\n", str, result);
return (0);
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out
Binary file not shown.
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_printable.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:05:18 by gbaconni #+# #+# */
/* Updated: 2021/08/10 11:10:03 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_printable(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= ' ' && str[i] <= '~');
i++;
}
return (r);
}
+30
View File
@@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:05:36 by gbaconni #+# #+# */
/* Updated: 2021/08/10 11:05:59 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
int ft_str_is_printable(char *str);
int main(void)
{
char str[32];
int result;
printf("Input [max 31]: ");
scanf("%s", str);
result = ft_str_is_printable(str);
printf("str=%s result=%d\n", str, result);
return (0);
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out
+29
View File
@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strupcase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:15:09 by gbaconni #+# #+# */
/* Updated: 2021/08/10 11:25:39 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strupcase(char *str)
{
int i;
int size;
size = 0;
while (str[size++] != '\0')
continue ;
i = 0;
while (i < size)
{
if (str[i] >= 'a' && str[i] <= 'z')
str[i] = str[i] - 32;
i++;
}
return (str);
}
+31
View File
@@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:12:33 by gbaconni #+# #+# */
/* Updated: 2021/08/10 11:25:31 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
char *ft_strupcase(char *str);
int main(void)
{
char str[32];
char *result;
printf("Input [max 31]: ");
scanf("%s", str);
printf("str=%s\n", str);
result = ft_strupcase(str);
printf("str=%s result=%s\n", str, result);
return (0);
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out
+29
View File
@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlowcase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:34:35 by gbaconni #+# #+# */
/* Updated: 2021/08/10 11:40:03 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strlowcase(char *str)
{
int i;
int size;
size = 0;
while (str[size++] != '\0')
continue ;
i = 0;
while (i < size)
{
if (str[i] >= 'A' && str[i] <= 'Z')
str[i] += 32;
i++;
}
return (str);
}
+31
View File
@@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:40:15 by gbaconni #+# #+# */
/* Updated: 2021/08/10 11:40:52 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
char *ft_strlowcase(char *str);
int main(void)
{
char str[32];
char *result;
printf("Input [max 31]: ");
scanf("%s", str);
printf("str=%s\n", str);
result = ft_strlowcase(str);
printf("str=%s result=%s\n", str, result);
return (0);
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out
+37
View File
@@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcapitalize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:43:39 by gbaconni #+# #+# */
/* Updated: 2021/08/12 09:47:40 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strcapitalize(char *str)
{
int i;
char prev_c;
prev_c = ' ';
i = 0;
while (str[i] != '\0')
{
if (\
(\
(prev_c >= ' ' && prev_c <= '/') || \
(prev_c >= ':' && prev_c <= '@') || \
(prev_c >= '[' && prev_c <= '`') || \
(prev_c >= '{' && prev_c <= '~') \
) && \
(str[i] >= 'a' && str[i] <= 'z') \
)
str[i] -= 32;
else if (str[i] >= 'A' && str[i] <= 'Z')
str[i] += 32;
prev_c = str[i++];
}
return (str);
}
+31
View File
@@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:43:49 by gbaconni #+# #+# */
/* Updated: 2021/08/10 11:55:53 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
char *ft_strcapitalize(char *str);
int main(void)
{
char str[256];
char *result;
printf("Input [max 255]: ");
scanf("%255[^\n]", str);
printf("str=%s\n", str);
result = ft_strcapitalize(str);
printf("str=%s result=%s\n", str, result);
return (0);
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out
Binary file not shown.
+29
View File
@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/11 10:20:13 by gbaconni #+# #+# */
/* Updated: 2021/08/12 10:40:17 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
unsigned int ft_strlcpy(char *dest, char *src, unsigned int size)
{
char *p_dest;
char *p_src;
unsigned int n;
p_dest = dest;
p_src = src;
n = size;
while (n != 0 && --n != 0 && *p_src != '\0')
*p_dest++ = *p_src++;
if (size != 0)
*p_dest = '\0';
while (*p_src++)
continue ;
return (p_src - src - 1);
}
+36
View File
@@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/11 09:43:24 by gbaconni #+# #+# */
/* Updated: 2021/08/11 10:43:00 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
unsigned int ft_strlcpy(char *dest, char *src, unsigned int size);
int main(void)
{
unsigned int size;
unsigned int result;
char src[16];
char dest[16];
printf("Input Text [max 15]: ");
scanf("%15[^\n]", src);
printf("Input Size: ");
scanf("%u", &size);
result = ft_strlcpy(dest, src, size);
printf("src=%s dest=%s result=%d (ft_strlcpy)\n", src, dest, result);
result = strlcpy(dest, src, size);
printf("src=%s dest=%s result=%d (strlcpy)\n", src, dest, result);
return (0);
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out
Binary file not shown.
+40
View File
@@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr_non_printable.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/11 11:29:09 by gbaconni #+# #+# */
/* Updated: 2021/08/12 11:40:23 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include <stdio.h>
// for i in {0..127}; do printf "%02x" $i; done
void ft_putstr_non_printable(char *str)
{
const char *hex = "\
000102030405060708090a0b0c0d0e0f\
101112131415161718191a1b1c1d1e1f\
202122232425262728292a2b2c2d2e2f\
303132333435363738393a3b3c3d3e3f\
404142434445464748494a4b4c4d4e4f\
505152535455565758595a5b5c5d5e5f\
606162636465666768696a6b6c6d6e6f\
707172737475767778797a7b7c7d7e7f";
while (*str != '\0')
{
if (*str >= ' ' && *str != '~' + 1)
write(1, str, 1);
else
{
write(1, "\\", 1);
write(1, hex + *str * 2, 2);
}
str++;
}
}
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/11 11:24:31 by gbaconni #+# #+# */
/* Updated: 2021/08/12 11:44:53 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
void ft_putstr_non_printable(char *str);
int main(void)
{
const char *test = "Coucou\ntu vas bien ?";
char str[256];
printf("Input [max 255]: ");
scanf("%255[^\n]", str);
printf("str=%s\n", str);
ft_putstr_non_printable(str);
printf("test=%s\n", test);
ft_putstr_non_printable((char *)test);
return (0);
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out
+7
View File
@@ -0,0 +1,7 @@
**/main.c
**/main.sh
**/a.out
**/a.sh
**/Makefile
**/*.swp
**/*~
+39
View File
@@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/09 13:27:29 by gbaconni #+# #+# */
/* Updated: 2021/08/11 14:49:52 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
char *ft_strcpy(char *dest, char *src)
{
int i;
int src_size;
int dest_size;
src_size = 0;
while (src[src_size++] != '\0')
continue ;
dest_size = 0;
while (dest[dest_size++] != '\0')
continue ;
i = 0;
while (i < src_size)
{
dest[i] = src[i];
i++;
}
while (i < dest_size)
{
dest[i] = '\0';
i++;
}
return (dest);
}
+37
View File
@@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/09 18:19:08 by gbaconni #+# #+# */
/* Updated: 2021/08/11 18:05:56 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include <stdio.h>
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
unsigned int i;
unsigned int dest_size;
dest_size = 0;
while (dest[dest_size++] != '\0')
continue ;
i = 0;
while (n > 0 && i < n)
{
dest[i] = src[i];
i++;
}
while (i < dest_size)
{
printf("Hello\n");
dest[i] = '\0';
i++;
}
return (dest);
}
+33
View File
@@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_alpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/09 17:43:26 by gbaconni #+# #+# */
/* Updated: 2021/08/10 09:58:08 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_alpha(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= 'a' && str[i] <= 'z') \
|| (str[i] >= 'A' && str[i] <= 'Z');
i++;
}
return (r);
}
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_numeric.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 10:14:17 by gbaconni #+# #+# */
/* Updated: 2021/08/10 10:15:38 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_numeric(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= '0' && str[i] <= '9');
i++;
}
return (r);
}
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_lowercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 10:45:53 by gbaconni #+# #+# */
/* Updated: 2021/08/10 10:45:56 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_lowercase(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= 'a' && str[i] <= 'z');
i++;
}
return (r);
}
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_uppercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 10:47:51 by gbaconni #+# #+# */
/* Updated: 2021/08/10 10:48:16 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_uppercase(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= 'A' && str[i] <= 'Z');
i++;
}
return (r);
}
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_printable.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:05:18 by gbaconni #+# #+# */
/* Updated: 2021/08/10 11:10:03 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_printable(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= ' ' && str[i] <= '~');
i++;
}
return (r);
}
+29
View File
@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strupcase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:15:09 by gbaconni #+# #+# */
/* Updated: 2021/08/10 11:25:39 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strupcase(char *str)
{
int i;
int size;
size = 0;
while (str[size++] != '\0')
continue ;
i = 0;
while (i < size)
{
if (str[i] >= 'a' && str[i] <= 'z')
str[i] = str[i] - 32;
i++;
}
return (str);
}
+29
View File
@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlowcase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:34:35 by gbaconni #+# #+# */
/* Updated: 2021/08/10 11:40:03 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strlowcase(char *str)
{
int i;
int size;
size = 0;
while (str[size++] != '\0')
continue ;
i = 0;
while (i < size)
{
if (str[i] >= 'A' && str[i] <= 'Z')
str[i] += 32;
i++;
}
return (str);
}
+39
View File
@@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcapitalize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:43:39 by gbaconni #+# #+# */
/* Updated: 2021/08/11 09:11:42 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strcapitalize(char *str)
{
int i;
int size;
char prev_c;
size = 0;
while (str[size++] != '\0')
continue ;
prev_c = ' ';
i = 0;
while (i < size - 1)
{
if (\
(str[i] >= 'a' && str[i] <= 'z') && \
(\
(prev_c >= ' ' && prev_c <= '/') || \
(prev_c >= ':' && prev_c <= '@') || \
(prev_c >= '[' && prev_c <= '`') || \
(prev_c >= '{' && prev_c <= '~') \
) \
)
str[i] -= 32;
prev_c = str[i++];
}
return (str);
}
+37
View File
@@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/11 10:20:13 by gbaconni #+# #+# */
/* Updated: 2021/08/11 15:36:08 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
unsigned int ft_strlcpy(char *dest, char *src, unsigned int size)
{
unsigned int i;
unsigned int src_size;
unsigned int dest_size;
src_size = 0;
while (src[src_size++] != '\0')
continue ;
dest_size = 0;
while (dest[dest_size++] != '\0')
continue ;
i = 0;
while (size > 0 && i < size - 1)
{
dest[i] = src[i];
i++;
}
while (i < dest_size)
{
dest[i] = '\0';
i++;
}
return (--src_size);
}
@@ -0,0 +1,59 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr_non_printable.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/11 11:29:09 by gbaconni #+# #+# */
/* Updated: 2021/08/11 16:56:40 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include <stdio.h>
// for i in {0..255}; do printf "%02x" $i; done
void ft_putstr_non_printable(char *str)
{
int size;
const char *hex = "000102030405060708090a\
0b0c0d0e0f101112131415\
161718191a1b1c1d1e1f20\
2122232425262728292a2b\
2c2d2e2f30313233343536\
3738393a3b3c3d3e3f4041\
42434445464748494a4b4c\
4d4e4f5051525354555657\
58595a5b5c5d5e5f606162\
636465666768696a6b6c6d\
6e6f707172737475767778\
797a7b7c7d7e7f80818283\
8485868788898a8b8c8d8e\
8f90919293949596979899\
9a9b9c9d9e9fa0a1a2a3a4\
a5a6a7a8a9aaabacadaeaf\
b0b1b2b3b4b5b6b7b8b9ba\
bbbcbdbebfc0c1c2c3c4c5\
c6c7c8c9cacbcccdcecfd0\
d1d2d3d4d5d6d7d8d9dadb\
dcdddedfe0e1e2e3e4e5e6\
e7e8e9eaebecedeeeff0f1\
f2f3f4f5f6f7f8f9fafbfc\
fdfeff";
size = 0;
while (str[size++] != '\0')
continue ;
while (--size)
{
if (*str >= ' ' && *str <= '~')
write(1, str, 1);
else
{
write(1, "\\", 1);
write(1, hex + *str * 2, 2);
}
str++;
}
}
+7
View File
@@ -0,0 +1,7 @@
**/main.c
**/main.sh
**/a.out
**/a.sh
**/Makefile
**/*.swp
**/*~
+39
View File
@@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/09 13:27:29 by gbaconni #+# #+# */
/* Updated: 2021/08/11 14:49:52 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
char *ft_strcpy(char *dest, char *src)
{
int i;
int src_size;
int dest_size;
src_size = 0;
while (src[src_size++] != '\0')
continue ;
dest_size = 0;
while (dest[dest_size++] != '\0')
continue ;
i = 0;
while (i < src_size)
{
dest[i] = src[i];
i++;
}
while (i < dest_size)
{
dest[i] = '\0';
i++;
}
return (dest);
}
+29
View File
@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/09 18:19:08 by gbaconni #+# #+# */
/* Updated: 2021/08/12 09:49:18 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
unsigned int i;
i = 0;
while (i < n && src[i] != '\0')
{
dest[i] = src[i];
i++;
}
while (i < n)
{
dest[i] = '\0';
i++;
}
return (dest);
}
+33
View File
@@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_alpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/09 17:43:26 by gbaconni #+# #+# */
/* Updated: 2021/08/10 09:58:08 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_alpha(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= 'a' && str[i] <= 'z') \
|| (str[i] >= 'A' && str[i] <= 'Z');
i++;
}
return (r);
}
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_numeric.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 10:14:17 by gbaconni #+# #+# */
/* Updated: 2021/08/10 10:15:38 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_numeric(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= '0' && str[i] <= '9');
i++;
}
return (r);
}
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_lowercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 10:45:53 by gbaconni #+# #+# */
/* Updated: 2021/08/10 10:45:56 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_lowercase(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= 'a' && str[i] <= 'z');
i++;
}
return (r);
}
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_uppercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 10:47:51 by gbaconni #+# #+# */
/* Updated: 2021/08/10 10:48:16 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_uppercase(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= 'A' && str[i] <= 'Z');
i++;
}
return (r);
}
+32
View File
@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_printable.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:05:18 by gbaconni #+# #+# */
/* Updated: 2021/08/10 11:10:03 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_printable(char *str)
{
int i;
int r;
int size;
size = 0;
while (str[size] != '\0')
{
size++;
}
r = 1;
i = 0;
while (i < size)
{
r &= (str[i] >= ' ' && str[i] <= '~');
i++;
}
return (r);
}
+29
View File
@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strupcase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:15:09 by gbaconni #+# #+# */
/* Updated: 2021/08/10 11:25:39 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strupcase(char *str)
{
int i;
int size;
size = 0;
while (str[size++] != '\0')
continue ;
i = 0;
while (i < size)
{
if (str[i] >= 'a' && str[i] <= 'z')
str[i] = str[i] - 32;
i++;
}
return (str);
}
+29
View File
@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlowcase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:34:35 by gbaconni #+# #+# */
/* Updated: 2021/08/10 11:40:03 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strlowcase(char *str)
{
int i;
int size;
size = 0;
while (str[size++] != '\0')
continue ;
i = 0;
while (i < size)
{
if (str[i] >= 'A' && str[i] <= 'Z')
str[i] += 32;
i++;
}
return (str);
}
+37
View File
@@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcapitalize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/10 11:43:39 by gbaconni #+# #+# */
/* Updated: 2021/08/12 09:47:40 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strcapitalize(char *str)
{
int i;
char prev_c;
prev_c = ' ';
i = 0;
while (str[i] != '\0')
{
if (\
(\
(prev_c >= ' ' && prev_c <= '/') || \
(prev_c >= ':' && prev_c <= '@') || \
(prev_c >= '[' && prev_c <= '`') || \
(prev_c >= '{' && prev_c <= '~') \
) && \
(str[i] >= 'a' && str[i] <= 'z') \
)
str[i] -= 32;
else if (str[i] >= 'A' && str[i] <= 'Z')
str[i] += 32;
prev_c = str[i++];
}
return (str);
}
+29
View File
@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/11 10:20:13 by gbaconni #+# #+# */
/* Updated: 2021/08/12 10:40:17 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
unsigned int ft_strlcpy(char *dest, char *src, unsigned int size)
{
char *p_dest;
char *p_src;
unsigned int n;
p_dest = dest;
p_src = src;
n = size;
while (n != 0 && --n != 0 && *p_src != '\0')
*p_dest++ = *p_src++;
if (size != 0)
*p_dest = '\0';
while (*p_src++)
continue ;
return (p_src - src - 1);
}
@@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr_non_printable.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/11 11:29:09 by gbaconni #+# #+# */
/* Updated: 2021/08/12 11:40:23 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include <stdio.h>
// for i in {0..127}; do printf "%02x" $i; done
void ft_putstr_non_printable(char *str)
{
const char *hex = "\
000102030405060708090a0b0c0d0e0f\
101112131415161718191a1b1c1d1e1f\
202122232425262728292a2b2c2d2e2f\
303132333435363738393a3b3c3d3e3f\
404142434445464748494a4b4c4d4e4f\
505152535455565758595a5b5c5d5e5f\
606162636465666768696a6b6c6d6e6f\
707172737475767778797a7b7c7d7e7f";
while (*str != '\0')
{
if (*str >= ' ' && *str != '~' + 1)
write(1, str, 1);
else
{
write(1, "\\", 1);
write(1, hex + *str * 2, 2);
}
str++;
}
}
+21
View File
@@ -0,0 +1,21 @@
<!DOCTYPE html><html style="font-size: 10px;font-family: Roboto, Arial, sans-serif;" lang="en" typography typography-spacing><head><script nonce="oAuyCnL9WzPQrJbIFKUAbw">var ytcfg={d:function(){return window.yt&&yt.config_||ytcfg.data_||(ytcfg.data_={})},get:function(k,o){return k in ytcfg.d()?ytcfg.d()[k]:o},set:function(){var a=arguments;if(a.length>1)ytcfg.d()[a[0]]=a[1];else for(var k in a[0])ytcfg.d()[k]=a[0][k]}};
window.ytcfg.set('EMERGENCY_BASE_URL', '\/error_204?t\x3djserror\x26level\x3dERROR\x26client.name\x3d1\x26client.version\x3d2.20210806.00.00');</script><script nonce="oAuyCnL9WzPQrJbIFKUAbw">(function(){window.yterr=window.yterr||true;window.unhandledErrorMessages={};window.unhandledErrorCount=0;
window.onerror=function(msg,url,line,columnNumber,error){var err;if(error)err=error;else{err=new Error;err.stack="";err.message=msg;err.fileName=url;err.lineNumber=line;if(!isNaN(columnNumber))err["columnNumber"]=columnNumber}var message=String(err.message);if(!err.message||message in window.unhandledErrorMessages||window.unhandledErrorCount>=5)return;window.unhandledErrorCount+=1;window.unhandledErrorMessages[message]=true;var img=new Image;window.emergencyTimeoutImg=img;img.onload=img.onerror=function(){delete window.emergencyTimeoutImg};
var combinedLineAndColumn=err.lineNumber;if(!isNaN(err["columnNumber"]))combinedLineAndColumn+=":"+err["columnNumber"];var stack=err.stack||"";var values={"msg":message,"type":err.name,"client.params":"unhandled window error","file":err.fileName,"line":combinedLineAndColumn,"stack":stack.substr(0,500)};var thirdPartyScript=!err.fileName||err.fileName==="<anonymous>"||stack.indexOf("extension://")>=0;var replaced=stack.replace(/https:\/\/www.youtube.com\//g,"");if(replaced.match(/https?:\/\/[^/]+\//))thirdPartyScript=
true;else if(stack.indexOf("trapProp")>=0&&stack.indexOf("trapChain")>=0)thirdPartyScript=true;else if(message.indexOf("redefine non-configurable")>=0&&message.indexOf("userAgent")>=0)thirdPartyScript=true;var baseUrl=window["ytcfg"].get("EMERGENCY_BASE_URL","https://www.youtube.com/error_204?t=jserror&level=ERROR");var unsupported=message.indexOf("window.customElements is undefined")>=0;if(thirdPartyScript||unsupported)baseUrl=baseUrl.replace("level=ERROR","level=WARNING");var parts=[baseUrl];for(var key in values){var value=
values[key];if(value)parts.push(key+"="+encodeURIComponent(value))}img.src=parts.join("&")};
(function(){function _getExtendedNativePrototype(tag){var p=this._nativePrototypes[tag];if(!p){p=Object.create(this.getNativePrototype(tag));var p$=Object.getOwnPropertyNames(window["Polymer"].Base);for(var i=0,n=undefined;i<p$.length&&(n=p$[i]);i++)if(!window["Polymer"].BaseDescriptors[n])try{p[n]=window["Polymer"].Base[n]}catch(e){throw new Error("Error while copying property: "+n+". Tag is "+tag);}try{Object.defineProperties(p,window["Polymer"].BaseDescriptors)}catch(e$0){throw new Error("Polymer define property failed for "+
Object.keys(p));}this._nativePrototypes[tag]=p}return p}function handlePolymerError(msg){window.onerror(msg,window.location.href,0,0,new Error(Array.prototype.join.call(arguments,",")))}var origPolymer=window["Polymer"];var newPolymer=function(config){if(!origPolymer._ytIntercepted&&window["Polymer"].Base){origPolymer._ytIntercepted=true;window["Polymer"].Base._getExtendedNativePrototype=_getExtendedNativePrototype;window["Polymer"].Base._error=handlePolymerError;window["Polymer"].Base._warn=handlePolymerError}return origPolymer.apply(this,
arguments)};var origDescriptor=Object.getOwnPropertyDescriptor(window,"Polymer");Object.defineProperty(window,"Polymer",{set:function(p){if(origDescriptor&&origDescriptor.set&&origDescriptor.get){origDescriptor.set(p);origPolymer=origDescriptor.get()}else origPolymer=p;if(typeof origPolymer==="function")Object.defineProperty(window,"Polymer",{value:origPolymer,configurable:true,enumerable:true,writable:true})},get:function(){return typeof origPolymer==="function"?newPolymer:origPolymer},configurable:true,
enumerable:true})})();}).call(this);
</script><script nonce="oAuyCnL9WzPQrJbIFKUAbw">window.Polymer=window.Polymer||{};window.Polymer.legacyOptimizations=true;window.Polymer.setPassiveTouchGestures=true;window.ShadyDOM={force:true,preferPerformance:true,noPatch:true};
window.ShadyCSS = {disableRuntime: true};</script><link rel="shortcut icon" href="https://www.youtube.com/s/desktop/65defdc1/img/favicon.ico" type="image/x-icon"><link rel="icon" href="https://www.youtube.com/s/desktop/65defdc1/img/favicon_32x32.png" sizes="32x32"><link rel="icon" href="https://www.youtube.com/s/desktop/65defdc1/img/favicon_48x48.png" sizes="48x48"><link rel="icon" href="https://www.youtube.com/s/desktop/65defdc1/img/favicon_96x96.png" sizes="96x96"><link rel="icon" href="https://www.youtube.com/s/desktop/65defdc1/img/favicon_144x144.png" sizes="144x144"><script nonce="oAuyCnL9WzPQrJbIFKUAbw">var ytcsi={gt:function(n){n=(n||"")+"data_";return ytcsi[n]||(ytcsi[n]={tick:{},info:{}})},now:window.performance&&window.performance.timing&&window.performance.now&&window.performance.timing.navigationStart?function(){return window.performance.timing.navigationStart+window.performance.now()}:function(){return(new Date).getTime()},tick:function(l,t,n){var ticks=ytcsi.gt(n).tick;var v=t||ytcsi.now();if(ticks[l]){ticks["_"+l]=ticks["_"+l]||[ticks[l]];ticks["_"+l].push(v)}ticks[l]=v},info:function(k,
v,n){ytcsi.gt(n).info[k]=v},setStart:function(s,t,n){ytcsi.info("yt_sts",s,n);ytcsi.tick("_start",t,n)}};
(function(w,d){ytcsi.setStart("dhs",w.performance?w.performance.timing.responseStart:null);var isPrerender=(d.visibilityState||d.webkitVisibilityState)=="prerender";var vName=!d.visibilityState&&d.webkitVisibilityState?"webkitvisibilitychange":"visibilitychange";if(isPrerender){ytcsi.info("prerender",1);var startTick=function(){ytcsi.setStart("dhs");d.removeEventListener(vName,startTick)};d.addEventListener(vName,startTick,false)}if(d.addEventListener)d.addEventListener(vName,function(){ytcsi.tick("vc")},
false);function isGecko(){if(!w.navigator)return false;try{if(w.navigator.userAgentData&&w.navigator.userAgentData.brands&&w.navigator.userAgentData.brands.length){var brands=w.navigator.userAgentData.brands;for(var i=0;i<brands.length;i++)if(brands[i]&&brands[i].brand==="Firefox")return true;return false}}catch(e){setTimeout(function(){throw e;})}if(!w.navigator.userAgent)return false;var ua=w.navigator.userAgent;return ua.indexOf("Gecko")>0&&ua.toLowerCase().indexOf("webkit")<0&&ua.indexOf("Edge")<
0&&ua.indexOf("Trident")<0&&ua.indexOf("MSIE")<0}if(isGecko()){var isHidden=(d.visibilityState||d.webkitVisibilityState)=="hidden";if(isHidden)ytcsi.tick("vc")}var slt=function(el,t){setTimeout(function(){var n=ytcsi.now();el.loadTime=n;if(el.slt)el.slt()},t)};w.__ytRIL=function(el){if(!el.getAttribute("data-thumb"))if(w.requestAnimationFrame)w.requestAnimationFrame(function(){slt(el,0)});else slt(el,16)}})(window,document);
</script><link rel="preload" href="https://i.ytimg.com/generate_204" as="fetch"><link as="script" rel="preload" href="https://www.youtube.com/s/desktop/65defdc1/jsbin/desktop_polymer_ambiguate_properties.vflset/desktop_polymer_ambiguate_properties.js" nonce="oAuyCnL9WzPQrJbIFKUAbw"><script src="https://www.youtube.com/s/desktop/65defdc1/jsbin/web-animations-next-lite.min.vflset/web-animations-next-lite.min.js" nonce="oAuyCnL9WzPQrJbIFKUAbw"></script><script src="https://www.youtube.com/s/desktop/65defdc1/jsbin/custom-elements-es5-adapter.vflset/custom-elements-es5-adapter.js" nonce="oAuyCnL9WzPQrJbIFKUAbw"></script><script src="https://www.youtube.com/s/desktop/65defdc1/jsbin/webcomponents-sd.vflset/webcomponents-sd.js" nonce="oAuyCnL9WzPQrJbIFKUAbw"></script><script nonce="oAuyCnL9WzPQrJbIFKUAbw">if (window.ytcsi) {window.ytcsi.tick('lpcs', null, '');}</script><script nonce="oAuyCnL9WzPQrJbIFKUAbw">(function() {window.ytplayer={};
ytcfg.set({"CLIENT_CANARY_STATE":"none","DEVICE":"cbr\u003dSafari\u0026cbrand\u003dapple\u0026cbrver\u003d14.1.1\u0026ceng\u003dWebKit\u0026cengver\u003d605.1.15\u0026cos\u003dMacintosh\u0026cosver\u003d10_15_7\u0026cplatform\u003dDESKTOP\u0026cyear\u003d2013","DISABLE_YT_IMG_DELAY_LOADING":false,"ELEMENT_POOL_DEFAULT_CAP":75,"EVENT_ID":"M9MQYZClMoid8gP7vLuwBg","EXPERIMENT_FLAGS":{"spf_kevlar_assume_chunked":true,"enable_memberships_and_purchases":true,"live_chat_attestation_signal":true,"kevlar_playlist_autonav_loop_fix":true,"kevlar_collect_battery_network_status":true,"kevlar_op_infra":true,"enable_button_behavior_reuse":true,"kevlar_snap_state_refresh":true,"kevlar_disable_background_prefetch":true,"web_player_watch_next_response":true,"is_mweb_wexit_main_launch":true,"kevlar_tuner_run_default_comments_delay":true,"flush_gel":true,"cache_visitor_cookie_before_consent":true,"kevlar_playback_associated_queue":true,"web_offline_promo_via_get_player":true,"kevlar_playlist_responsive":true,"clear_visitor_id_in_ytconfig_before_consent":true,"kevlar_log_initial_screen":true,"web_favicon_image_update":true,"kevlar_passive_event_listeners":true,"html5_pacf_enable_dai":true,"web_prs_testing_mode_killswitch":true,"kevlar_command_handler_toggle_buttons":true,"kevlar_guide_ajax_migration":true,"kevlar_include_query_in_search_endpoint":true,"kevlar_larger_three_dot_tap":true,"kevlar_typography_spacing_update":true,"kevlar_rendererstamper_event_listener":true,"enable_gel_log_commands":true,"enable_microformat_data":true,"kevlar_voice_search":true,"desktop_fix_carousel_video_timeout":true,"kevlar_frontend_queue_recover":true,"kevlar_client_save_subs_preferences":true,"kevlar_transcript_panel_refreshed_styles":true,"enable_polymer_resin_migration":true,"kevlar_watch_js_panel_height":true,"live_chat_unicode_emoji_skintone_update":true,"kevlar_one_pick_add_video_to_playlist":true,"kevlar_set_internal_player_size":true,"enable_programmed_playlist_color_sample":true,"kevlar_home_skeleton":true,"kevlar_enable_reorderable_playlists":true,"kevlar_miniplayer_queue_user_activation":true,"offline_error_handling":true,"desktop_mic_background":true,"kevlar_decorate_endpoint_with_onesie_config":true,"disable_simple_mixed_direction_formatted_strings":true,"is_part_of_any_user_engagement_experiment":true,"no_cookie_before_consent":true,"kevlar_collect_hover_touch_support":true,"kevlar_fluid_touch_scroll":true,"kevlar_player_disable_rvs_update":true,"desktop_suggest_dropdown_fix":true,"kevlar_guide_store":true,"kevlar_updated_logo_icons":true,"kevlar_hide_playlist_playback_status":true,"ytidb_stop_transaction_commit":true,"screen_manager_log_servlet_ei":true,"enable_ytc_refunds_submit_form_signal_action":true,"kevlar_mealbar_above_player":true,"disable_child_node_auto_formatted_strings":true,"kevlar_enable_parent_tools_integration":true,"kevlar_update_youtube_sans":true,"enable_web_ketchup_hero_animation":true,"kevlar_shell_for_downloads_page":true,"enable_client_streamz_web":true,"kevlar_miniplayer":true,"kevlar_miniplayer_set_watch_next":true,"kevlar_app_initializer_cleanup":true,"searchbox_reporting":true,"kevlar_resolve_playlist_endpoint_as_watch_endpoint":true,"nwl_sw_health_payloads":true,"kevlar_populate_command_on_download_button":true,"player_allow_autonav_after_playlist":true,"kevlar_watch_next_chips_continuations_migration":true,"cb_use_v2_filler":true,"kevlar_copy_playlist":true,"kevlar_gel_error_routing":true,"web_forward_command_on_pbj":true,"kevlar_logged_out_topbar_menu_migration":true,"check_user_lact_at_prompt_shown_time_on_web":true,"kevlar_hide_time_continue_url_param":true,"enable_business_email_reveal_servlet_migration":true,"kevlar_topbar_logo_fallback_home":true,"kevlar_no_url_params":true,"kevlar_miniplayer_expand_top":true,"kevlar_channel_trailer_multi_attach":true,"kevlar_transcript_engagement_panel":true,"desktop_swipeable_guide":true,"kevlar_miniplayer_play_pause_on_scrim":true,"kevlar_player_response_swf_config_wrapper_killswitch":true,"autoescape_tempdata_url":true,"networkless_gel":true,"web_visitorid_in_datasync":true,"kevlar_cache_on_ttl":true,"web_clean_sw_logs_store":true,"web_log_player_watch_next_ticks":true,"kevlar_continue_playback_without_player_response":true,"web_dedupe_ve_grafting":true,"live_chat_show_ongoing_poll_results_in_banner":true,"kevlar_variable_youtube_sans":true,"desktop_add_to_playlist_renderer_dialog_popup":true,"kevlar_allow_playlist_reorder":true,"nwl_send_fast_on_unload":true,"pdg_disable_web_super_vod_explicit_click_logging":true,"kevlar_woffle_dl_manager":true,"web_enable_ad_signals_in_it_context":true,"use_screen_manager_util":true,"deprecate_pair_servlet_enabled":true,"disable_signout_supex_users":true,"kevlar_disable_formatted_string_empty_style_class":true,"desktop_mix_use_sampled_color_for_bottom_bar_search":true,"fill_web_player_context_config":true,"botguard_periodic_refresh":true,"record_app_crashed_web":true,"kevlar_dragdrop_fast_scroll":true,"kevlar_use_response_Line truncated
setMessage({"ADDED_TO_QUEUE":"Added to queue","ADD_TO_DROPDOWN_LABEL":"Save to...","AD_BADGE_TEXT":"Ad","APPLAUD_FOR_X":"Applaud for $amount","BACK_ALT_LABEL":"Back","CANCEL":"Cancel","CHECK_CONNECTION_OR_DOWNLOADS":"Please check your connection or watch your downloaded videos.","CLEAR":"Clear","CONNECT_TO_THE_INTERNET":"Connect to the internet","CONTINUE_WATCHING":"Continue watching","DELETE":"Delete","DELETE_ALL_DOWNLOADS_PROMPT":"Delete all downloads?","DELETE_FROM_DOWNLOADS":"Remove from downloads","DESCRIPTION":"Description","DOWNLOAD":"Download","DOWNLOADED":"Downloaded","DOWNLOADING":"Downloading","DOWNLOADING_PERCENT":"Downloading... $percent%","DOWNLOADS":"Downloads","DOWNLOADS_AVAILABILITY":"Downloads remain available as long as your device has an active internet connection at least once every 30 days.","DOWNLOADS_SETTINGS":"Downloads Settings","DOWNLOAD_QUALITY":"Download Quality","DO_NOT_HAVE_DOWNLOADS":"You do not have any downloads","EDIT_AVATAR_LABEL":"Edit profile picture","EDU_GOT_IT":"Got It","ENTER_DATE_OR_EARLIER":"Enter $allowed_date or earlier","ENTER_DATE_OR_LATER":"Enter $allowed_date or later","FREEBIE_JOIN_MEMBERSHIP_EDU_TEXT":"This channel offers a membership which you can join for free with YouTube Premium","GO_TO_DOWNLOADS":"Go to downloads","GUIDE_ALT_LABEL":"Guide","IMAGE_HORIZONTAL_POSITION_LABEL":"The center of the preview is $x_percent% from the left and $y_percent% from the right.","IMAGE_VERTICAL_POSITION_LABEL":"The center of the preview is $x_percent% from the top and $y_percent% from the bottom.","INVALID_DATE_ERROR":"Invalid Date","JOIN_MEMBERSHIP_EDU_TEXT":"Get access to exclusive perks when you purchase a membership to this channel.","JOIN_MEMBERSHIP_EDU_TITLE":"Membership","KEEP_OPEN":"Keep this window open to continue","LIBRARY_GUIDE_ITEM_EDU_TEXT":"Find your history, playlists, purchases, and more","LIBRARY_GUIDE_ITEM_EDU_TITLE":"Check out your new Library","LOCAL_TIME_LABEL":"Local Time","LOGO_ALT_LABEL":"YouTube Home","MANAGE_MEMBERSHIP_EDU_TEXT":"Access your benefits and manage your membership from here.","MENTIONS_EDU_TEXT":"Go to the Help Center to see how mentions work on YouTube.","MENTIONS_EDU_TITLE":"Learn more","MINIPLAYER_CLOSE":"Close player","MINIPLAYER_COLLAPSE_LABEL":"Collapse","MINIPLAYER_EXPAND_LABEL":"Expand","NO_ANGLE_BRACKET_LABEL":"Playlist title cannot contain \u003c or \u003e","NO_DOWNLOADS":"No downloads","NO_INTERNET_CONNECTION":"No internet connection","OFFLINE_CHECK_CONNECTION":"You\u0027re offline. Check your connection.","PLAYER_LABEL_MUTE":"Mute (m)","PLAYER_LABEL_PAUSE":"Pause (k)","PLAYER_LABEL_PLAY":"Play (k)","PLAYER_LABEL_UNMUTE":"Unmute (m)","QUEUE":"Queue","QUEUE_CLEARED":"{count,plural, \u003d1{1 video in the queue removed}other{# videos in the queue removed}}","QUEUE_CLEARED_UNPLURALIZED":"Queue cleared","QUEUE_CLOSE_MINIPLAYER_CONFIRM_BODY_TEXT":"Are you sure you want to close the player?","QUEUE_CLOSE_MINIPLAYER_CONFIRM_TITLE":"Queue will be cleared","QUEUE_RECOVER_BUTTON":"Restore","QUEUE_RECOVER_MESSAGE":"Recover queue","REACH_BOTTOM_OF_IMAGE_TEXT":"You have reached the bottom of the image","REACH_LEFT_OF_IMAGE_TEXT":"You have reached the left of the image","REACH_RIGHT_OF_IMAGE_TEXT":"You have reached the right of the image","REACH_TOP_OF_IMAGE_TEXT":"You have reached the top of the image","REMEMBER_MY_SETTINGS":"Remember my settings","REPOSITION_IMAGE_HORIZONTALLY_LABEL":"Use left and right arrow keys to reposition the preview","REPOSITION_IMAGE_VERTICALLY_LABEL":"Use up and down arrow keys to reposition the preview","REQUIRED_LABEL":"Required","RETRY":"Retry","SBOX_INAPPROPRIATE_ADDITIONAL":"Provide additional details (optional)","SBOX_INAPPROPRIATE_CANCEL":"Cancel","SBOX_INAPPROPRIATE_CATEGORY":"The selected predictions are:","SBOX_INAPPROPRIATE_DANGEROUS":"Dangerous and harmful activity","SBOX_INAPPROPRIATE_EXPLICIT":"Sexually explicit","SBOX_INAPPROPRIATE_HATEFUL":"Hateful","SBOX_INAPPROPRIATE_OTHER":"Other","SBOX_INAPPROPRIATE_PROMPT":"Report search predictions","SBOX_INAPPROPRIATE_REASON":"Reason (required)","SBOX_INAPPROPRIATE_REPORT":"Report","SBOX_INAPPROPRIATE_SUBMIT":"Submit","SBOX_INAPPROPRIATE_SUGGESTIONS":"Select predictions you would like to report:","SBOX_INAPPROPRIATE_TITLE":"Report search predictions","SBOX_INAPPROPRIATE_TOAST":"Thanks for your feedback!","SBOX_INAPPROPRIATE_VIOLENT":"Violent","SBOX_PLACEHOLDER":"Search","SBOX_VOICE_OVERLAY_PLACEHOLDER":"Listening...","SHARE_LABEL":"Share","SHARE_POST_EDU_TEXT":"Now you can share posts on YouTube","SHOW_LESS":"Show less","SHOW_MORE":"Show more","SIGN_IN_LABEL":"Sign in","SUBS_FILTER_EDU_CHANNEL_TEXT":"Now showing new videos from this channel.","SUBS_FILTER_EDU_TEXT":"See new videos from each channel","SUBS_GUIDE_ITEM_EDU_TEXT":"See new videos from all of your subscriptions","TIMEZONE_FORMAT":"($utc_offset_text) $city_name","TRANSFER_FAILED":"Download failed","TRY_AGAIN_LATER":"Something went wrong. Please try again later.","UNDO":"Undo","UTC_OFFSET_FLine truncated
</script><script nonce="oAuyCnL9WzPQrJbIFKUAbw">if (window.ytcsi) {window.ytcsi.tick('lpcf', null, '');}</script><script src="https://www.youtube.com/s/desktop/65defdc1/jsbin/scheduler.vflset/scheduler.js" nonce="oAuyCnL9WzPQrJbIFKUAbw"></script><script src="https://www.youtube.com/s/desktop/65defdc1/jsbin/www-i18n-constants-en_US.vflset/www-i18n-constants.js" nonce="oAuyCnL9WzPQrJbIFKUAbw"></script><script src="https://www.youtube.com/s/desktop/65defdc1/jsbin/www-tampering.vflset/www-tampering.js" nonce="oAuyCnL9WzPQrJbIFKUAbw"></script><script src="https://www.youtube.com/s/desktop/65defdc1/jsbin/spf.vflset/spf.js" nonce="oAuyCnL9WzPQrJbIFKUAbw"></script><script nonce="oAuyCnL9WzPQrJbIFKUAbw">if(window["_spf_state"])window["_spf_state"].config={"assume-all-json-requests-chunked":true};
</script><script src="https://www.youtube.com/s/desktop/65defdc1/jsbin/network.vflset/network.js" nonce="oAuyCnL9WzPQrJbIFKUAbw"></script><script nonce="oAuyCnL9WzPQrJbIFKUAbw">if (window.ytcsi) {window.ytcsi.tick('csl', null, '');}</script><link rel="stylesheet" href="//fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=YouTube+Sans:wght@300..900&display=swap" nonce="tn0wNhJlb9YAcpiSoKXqVA"><script name="www-roboto" nonce="oAuyCnL9WzPQrJbIFKUAbw">if (document.fonts && document.fonts.load) {document.fonts.load("400 10pt Roboto", ""); document.fonts.load("500 10pt Roboto", "");}</script><link rel="stylesheet" href="https://www.youtube.com/s/desktop/65defdc1/cssbin/www-onepick.css" nonce="tn0wNhJlb9YAcpiSoKXqVA"><style class="global_styles" nonce="tn0wNhJlb9YAcpiSoKXqVA">body{padding:0;margin:0;overflow-y:scroll}body.autoscroll{overflow-y:auto}body.no-scroll{overflow:hidden}body.no-y-scroll{overflow-y:hidden}.hidden{display:none}textarea{--paper-input-container-input_-_white-space:pre-wrap}.grecaptcha-badge{visibility:hidden}</style><style class="masthead_shell" nonce="tn0wNhJlb9YAcpiSoKXqVA">ytd-masthead.shell{background:rgba(255,255,255,0.98);position:fixed;top:0;right:0;left:0;display:-ms-flex;display:-webkit-flex;display:flex;height:56px;-ms-flex-align:center;-webkit-align-items:center;align-items:center}ytd-masthead.shell #menu-icon{margin-left:16px}ytd-app>ytd-masthead.chunked{position:fixed;top:0;width:100%}ytd-masthead.shell.dark,ytd-masthead.shell.theater{background:rgba(40,40,40,0.98)}ytd-masthead.shell.full-window-mode{background:rgba(40,40,40,0.98);opacity:0;transform:translateY(calc(-100% - 5px))}ytd-masthead.shell>*:first-child{padding-left:16px}ytd-masthead.shell>*:last-child{padding-right:16px}ytd-masthead #masthead-logo{display:-ms-flex;display:-webkit-flex;display:flex}ytd-masthead #masthead-logo #country-code{margin-right:2px}ytd-masthead.shell #yt-logo-updated-svg,ytd-masthead.shell #yt-logo-red-updated-svg,ytd-masthead.shell #yt-logo-svg,ytd-masthead.shell #yt-logo-red-svg{align-self:center;margin-left:8px;padding:0;color:black}ytd-masthead.shell #a11y-skip-nav{display:none}ytd-masthead.shell svg{width:40px;height:40px;padding:8px;margin-right:8px;box-sizing:border-box;color:#606060;fill:currentColor}ytd-masthead .external-icon{width:24px;height:24px}ytd-masthead .yt-icons-ext{fill:currentColor;color:#606060}ytd-masthead.shell.dark .yt-icons-ext ytd-masthead.shell.theater .yt-icons-ext{fill:#ffffff}ytd-masthead svg#yt-logo-svg{width:80px}ytd-masthead svg#yt-logo-red-svg{width:106.4px}ytd-masthead svg#yt-logo-updated-svg{width:90px}ytd-masthead svg#yt-logo-red-updated-svg{width:97px}@media (max-width:656px){ytd-masthead.shell>*:first-child{padding-left:8px}ytd-masthead.shell>*:last-child{padding-right:8px}ytd-masthead.shell svg{margin-right:0}ytd-masthead #masthead-logo{-ms-flex:1 1 0.000000001px;-webkit-flex:1;flex:1;-webkit-flex-basis:0.000000001px;flex-basis:0.000000001px}ytd-masthead.shell #yt-logo-svg,ytd-masthead.shell #yt-logo-red-svg{margin-left:4px}}@media (min-width:876px){ytd-masthead #masthead-logo{width:129px}}#masthead-skeleton-icons{display:flex;flex:1;flex-direction:row;justify-content:flex-end}ytd-masthead.masthead-finish #masthead-skeleton-icons{display:none}.masthead-skeleton-icon{border-radius:50%;height:32px;width:32px;margin:0 8px;background-color:hsl(0,0%,89%)}ytd-masthead.dark .masthead-skeleton-icon{background-color:hsl(0,0%,16%)}</style><style class="masthead_custom_styles" is="custom-style" id="ext-styles" nonce="tn0wNhJlb9YAcpiSoKXqVA">ytd-masthead .yt-icons-ext{color:var(--yt-spec-icon-active-other)}ytd-masthead svg#yt-logo-svg #youtube-paths path,ytd-masthead svg#yt-logo-red-svg #youtube-red-paths path,ytd-masthead svg#yt-logo-updated-svg #youtube-paths path,ytd-masthead svg#yt-logo-red-updated-svg #youtube-red-paths path{fill:#282828}ytd-masthead.dark svg#yt-logo-svg #youtube-paths path,ytd-masthead.dark svg#yt-logo-red-svg #youtube-red-paths path,ytd-masthead.dark svg#yt-logo-updated-svg #youtube-paths path,ytd-masthead.dark svg#yt-logo-red-updated-svg #youtube-red-paths path,ytd-masthead.theater svg#yt-logo-svg #youtube-paths path,ytd-masthead.theater svg#yt-logo-red-svg #youtube-red-paths path{fill:rgb(255,255,255)}</style><style class="searchbox" nonce="tn0wNhJlb9YAcpiSoKXqVA">#search-input.ytd-searchbox-spt input{-webkit-appearance:none;-webkit-font-smoothing:antialiased;background-color:transparent;border:none;box-shadow:none;color:inherit;font-family:'Roboto','Noto',sans-serif;font-size:16px;font-weight:400;line-height:24px;margin-left:4px;max-width:100%;outline:none;text-align:inherit;width:100%;-ms-flex:1 1 0.000000001px;-webkit-flex:1;flex:1;-webkit-flex-basis:0.000000001px;flex-basis:0.000000001px}#search-container.ytd-searchbox-spt{pointer-events:none;position:absolute;top:0;right:0;bottom:0;left:0}#search-input.ytd-searchbox-spt #search::-webkit-input-placeholder{color:hsl(0,0%,53.3%)}#search-input.ytd-searchbox-spt #search::-moLine truncated
+34
View File
@@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ex00.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/08 15:02:50 by tkondrac #+# #+# */
/* Updated: 2021/08/08 17:02:48 by tkondrac ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../ex00/ft_strcpy.c"
int main(void)
{
char s[42];
char *d;
char *r;
d = (char*)malloc(43 * sizeof(char));
printf("Enter string (max 42 char): ");
scanf("%s", s);
r = ft_strcpy(d, s);
printf("destination : %s | return : %s\n", d, r);
free(d);
d = (char*)malloc(43 * sizeof(char));
printf("strcpy : %s\n", strcpy(d, s));
free(d);
return(0);
}
+57
View File
@@ -0,0 +1,57 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ex01.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/08 15:03:03 by tkondrac #+# #+# */
/* Updated: 2021/08/08 16:59:55 by tkondrac ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../ex01/ft_strncpy.c"
#include "rand_string.c"
int ft_test(char *src, unsigned int l);
int main(void)
{
ft_test("0123456789", 15);
ft_test("test", 8);
ft_test("0123456789" , 3);
ft_test("un autre test" , 0);
return (0);
}
int ft_test(char *src, unsigned int l)
{
char *dest;
char *dest2;
int i;
i = 0;
dest = (char*)malloc(11 * sizeof(char));
while(i < 10)
{
*(dest + i) = '0';
i++;
}
*(dest + i) = '\0';
dest2 = ft_strncpy(dest, src, l);
printf("-------------\nTest\nsrc string : %s | copy lenght : %u\ndest string : %s | output string : %s\n", src, l, dest, dest2);
// Strncpy tests
while(i < 10)
{
*(dest + i) = '0';
i++;
}
*(dest + i) = '\0';
dest2 = strncpy(dest, src, l);
printf("TEST string : %s | output TEST : %s\n", dest, dest2);
free(dest);
return (0);
}
+26
View File
@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ex02.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/08 15:03:45 by tkondrac #+# #+# */
/* Updated: 2021/08/08 15:03:53 by tkondrac ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "../ex02/ft_str_is_alpha.c"
int main(void)
{
char c[42];
while(1)
{
scanf("%s", c);
printf("is alpha ? : %d\n", ft_str_is_alpha(c));
}
return (0);
}
+26
View File
@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ex03.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/08 15:03:58 by tkondrac #+# #+# */
/* Updated: 2021/08/08 15:04:00 by tkondrac ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "../ex03/ft_str_is_numeric.c"
int main(void)
{
char c[42];
while(1)
{
scanf("%s", c);
printf("is numeric ? : %d\n", ft_str_is_numeric(c));
}
return (0);
}
+26
View File
@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ex04.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/08 15:07:35 by tkondrac #+# #+# */
/* Updated: 2021/08/08 15:11:12 by tkondrac ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "../ex04/ft_str_is_lowercase.c"
int main(void)
{
char c[42];
while(1)
{
scanf("%s", c);
printf("is lowercase ? : %d\n", ft_str_is_lowercase(c));
}
return (0);
}
+26
View File
@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ex05.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/08 15:13:08 by tkondrac #+# #+# */
/* Updated: 2021/08/08 15:13:13 by tkondrac ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "../ex05/ft_str_is_uppercase.c"
int main(void)
{
char c[42];
while(1)
{
scanf("%s", c);
printf("is uppercase ? : %d\n", ft_str_is_uppercase(c));
}
return (0);
}
+26
View File
@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ex06.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/08 15:13:19 by tkondrac #+# #+# */
/* Updated: 2021/08/08 15:13:37 by tkondrac ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "../ex06/ft_str_is_printable.c"
int main(void)
{
char c[42];
while(1)
{
scanf("%s", c);
printf("is printable ? : %d\n", ft_str_is_printable(c));
}
return (0);
}
+26
View File
@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ex07.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/08 15:13:42 by tkondrac #+# #+# */
/* Updated: 2021/08/08 15:13:47 by tkondrac ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "../ex07/ft_strupcase.c"
int main(void)
{
char c[42];
while(1)
{
scanf("%s", c);
printf("upcased : %s\n", ft_strupcase(c));
}
return (0);
}
+26
View File
@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ex08.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/08 15:13:52 by tkondrac #+# #+# */
/* Updated: 2021/08/08 15:13:55 by tkondrac ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "../ex08/ft_strlowcase.c"
int main(void)
{
char c[42];
while(1)
{
scanf("%s", c);
printf("lowcased : %s\n", ft_strlowcase(c));
}
return (0);
}
+23
View File
@@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ex09.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/08 15:14:28 by tkondrac #+# #+# */
/* Updated: 2021/08/08 15:14:31 by tkondrac ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "../ex09/ft_strcapitalize.c"
int main(void)
{
char c[] = "salut, comment tu vas ? 42mots quarante-deux; cinquante+et+un";
printf("original :%s\n", c);
printf("capitalized :%s\n", ft_strcapitalize(c));
return (0);
}
+47
View File
@@ -0,0 +1,47 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ex10.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/08 15:16:23 by tkondrac #+# #+# */
/* Updated: 2021/08/11 15:01:07 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../ex10/ft_strlcpy.c"
#include "rand_string.c"
int ft_test(unsigned int s, unsigned int d);
int main(void)
{
ft_test(15 , 8);
ft_test(8 , 15);
ft_test(10 , 2);
ft_test(5 , 0);
return (0);
}
int ft_test(unsigned int s, unsigned int d)
{
char *dest;
char *src;
unsigned int n;
size_t t;
dest = (char*)malloc(d * sizeof(char));
src = rand_string(s);
n = ft_strlcpy(dest, src, d);
printf("-------------\nTest\nsrc string : %s | dest size : %u\ndest string : %s | output size : %d\n", src, d, dest, n);
free(dest);
dest = (char*)malloc(d * sizeof(char));
t = strlcpy(dest, src, d);
printf("TEST string : %s | output TEST : %d\n", dest, n);
free(dest);
free(src);
return (0);
}
+26
View File
@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ex11.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/08 15:48:26 by tkondrac #+# #+# */
/* Updated: 2021/08/11 16:50:37 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "../ex11/ft_putstr_non_printable.c"
int main(void)
{
char c[] = "special : | speciaux : ";
c[10] = '\n';
c[25] = 14;
c[26] = 127;
printf("%s\n ------ \n", c);
ft_putstr_non_printable(c);
return (0);
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
test=$1
set -e
norminette -R CheckForbiddenSourceHeader ../$test/ft_*.c
gcc -Wall -Wextra -Werror -o a.out $test.c
#gcc -o a.out $test.c
./a.out
rm -f a.out
+31
View File
@@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rand_string.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tkondrac <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/08 12:07:16 by tkondrac #+# #+# */
/* Updated: 2021/08/08 13:04:23 by tkondrac ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
char *rand_string(unsigned int size)
{
char *c;
unsigned int i;
c = (char*)malloc(size * sizeof(char));
i = 0;
srand(time(0));
while(i < size - 1)
{
*(c + i) = (rand() % 94) + 32;
i++;
}
*(c + i) = '\0';
return (c);
}
Submodule
+1
Submodule C_02/tmp added at 75cf975de3.