Libft
42 Libft library documentation
Loading...
Searching...
No Matches
libft.h
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* libft.h :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: raphalme <raphalme@student.42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/07/18 23:12:04 by raphael #+# #+# */
9/* Updated: 2026/04/14 10:46:11 by raphalme ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#ifndef LIBFT_H
14# define LIBFT_H
15
16# include <unistd.h>
17# include <stdlib.h>
18# include <stddef.h>
19#include "types.h"
20
21int ft_isalpha(int c);
22int ft_isdigit(int c);
23int ft_isalnum(int c);
24int ft_isascii(int c);
25int ft_isprint(int c);
26size_t ft_strlen(const char *str);
27void *ft_memset(void *s, int c, size_t len);
28void ft_bzero(void *s, size_t n);
29void *ft_memcpy(void *dest, const void *src, size_t n);
30void *ft_memmove(void *dst, const void *src, size_t len);
31size_t ft_strlcpy(char *dest, const char *src, size_t size);
32size_t ft_strlcat(char *dest, const char *src, size_t len);
33int ft_toupper(int c);
34int ft_tolower(int c);
35char *ft_strchr(const char *s, int c);
36char *ft_strrchr(const char *s, int c);
37int ft_strncmp(const char *s1, const char *s2, size_t n);
38void *ft_memchr(const void *s, int c, size_t n);
39int ft_memcmp(const void *s1, const void *s2, size_t n);
40char *ft_strnstr(const char *haystack, const char *needle, size_t len);
41int ft_atoi(const char *str);
42void *ft_calloc(size_t count, size_t size);
43char *ft_strdup(const char *s1);
44
45char *ft_substr(char const *s, unsigned int start, size_t len);
46char *ft_strjoin(char const *s1, char const *s2);
47char *ft_strtrim(char const *s1, char const *set);
48char **ft_split(char const *s, char c);
49char *ft_itoa(int n);
50char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
51void ft_striteri(char *s, void (*f)(unsigned int, char*));
52void ft_putchar_fd(char c, int fd);
53void ft_putstr_fd(char *s, int fd);
54void ft_putendl_fd(char *s, int fd);
55void ft_putnbr_fd(int n, int fd);
56
57t_list *ft_lstnew(void *content);
58void ft_lstadd_front(t_list **lst, t_list *new);
59int ft_lstsize(t_list *lst);
61void ft_lstadd_back(t_list **lst, t_list *new);
62void ft_lstdelone(t_list *lst, void (*del)(void*));
63void ft_lstclear(t_list **lst, void (*del)(void*));
64void ft_lstiter(t_list *lst, void (*f)(void *));
65t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
66
67#endif
void ft_lstadd_front(t_list **lst, t_list *new)
Adds a new element to the front of a linked list. This function takes a pointer to the first element ...
int ft_memcmp(const void *s1, const void *s2, size_t n)
Compares two memory areas byte by byte.
Definition ft_memcmp.c:23
void ft_lstiter(t_list *lst, void(*f)(void *))
Iterates over a linked list and applies a function to each element. This function takes a linked list...
Definition ft_lstiter.c:23
char * ft_strdup(const char *s1)
Duplicates a C string into newly allocated memory.
Definition ft_strdup.c:21
int ft_isdigit(int c)
Checks whether a character is a decimal digit.
Definition ft_isdigit.c:19
void * ft_memset(void *s, int c, size_t len)
Fills a memory area with a byte value.
Definition ft_memset.c:23
void * ft_memcpy(void *dest, const void *src, size_t n)
Copies bytes from source to destination.
Definition ft_memcpy.c:25
char * ft_strrchr(const char *s, int c)
Finds the last occurrence of a character in a string.
Definition ft_strrchr.c:22
void ft_lstadd_back(t_list **lst, t_list *new)
Adds a new element to the end of a linked list. This function takes a pointer to the first element of...
void ft_bzero(void *s, size_t n)
Sets a memory area to zero bytes.
Definition ft_bzero.c:21
char * ft_strtrim(char const *s1, char const *set)
Trims leading and trailing characters from a set.
Definition ft_strtrim.c:22
void ft_putnbr_fd(int n, int fd)
Writes an integer in decimal format to a file descriptor.
char * ft_strmapi(char const *s, char(*f)(unsigned int, char))
Maps a function over a string into a new allocated string.
Definition ft_strmapi.c:22
void ft_lstclear(t_list **lst, void(*del)(void *))
Clears a linked list. This function takes a pointer to the first element of a linked list and a funct...
Definition ft_lstclear.c:25
char * ft_substr(char const *s, unsigned int start, size_t len)
Extracts a substring from a string.
Definition ft_substr.c:23
t_list * ft_lstmap(t_list *lst, void *(*f)(void *), void(*del)(void *))
Creates a new linked list with the results of applying a function to each element of the original lis...
Definition ft_lstmap.c:26
size_t ft_strlen(const char *str)
Returns the length of a null-terminated string.
Definition ft_strlen.c:21
char * ft_itoa(int n)
Converts an integer to a newly allocated decimal string.
Definition ft_itoa.c:23
void ft_putchar_fd(char c, int fd)
Writes one character to a file descriptor.
t_list * ft_lstnew(void *content)
Creates a new linked-list node.
Definition ft_lstnew.c:24
char * ft_strjoin(char const *s1, char const *s2)
Concatenates two strings into a newly allocated string.
Definition ft_strjoin.c:22
size_t ft_strlcat(char *dest, const char *src, size_t len)
Appends a string to a bounded destination buffer.
Definition ft_strlcat.c:23
size_t ft_strlcpy(char *dest, const char *src, size_t size)
Copies a string into a bounded destination buffer.
Definition ft_strlcpy.c:23
int ft_isalnum(int c)
Checks whether a character is alphanumeric.
Definition ft_isalnum.c:19
int ft_strncmp(const char *s1, const char *s2, size_t n)
Compares two strings up to a maximum number of characters.
Definition ft_strncmp.c:23
int ft_lstsize(t_list *lst)
Counts the number of nodes in a linked list.
Definition ft_lstsize.c:21
char ** ft_split(char const *s, char c)
Splits a string into an array of substrings.
Definition ft_split.c:30
char * ft_strchr(const char *s, int c)
Finds the first occurrence of a character in a string.
Definition ft_strchr.c:24
int ft_tolower(int c)
Converts an uppercase ASCII letter to lowercase.
Definition ft_tolower.c:19
int ft_isprint(int c)
Checks whether a character is printable in ASCII.
Definition ft_isprint.c:19
int ft_isascii(int c)
Checks whether a character value is a valid ASCII byte.
Definition ft_isascii.c:19
void * ft_memchr(const void *s, int c, size_t n)
Scans a memory area for a byte value.
Definition ft_memchr.c:23
int ft_isalpha(int c)
void ft_lstdelone(t_list *lst, void(*del)(void *))
Deletes and frees a single element from a linked list. This function takes an element from a linked l...
void * ft_memmove(void *dst, const void *src, size_t len)
Copies bytes between potentially overlapping memory areas.
Definition ft_memmove.c:23
void ft_putstr_fd(char *s, int fd)
Writes a string to a file descriptor.
void ft_striteri(char *s, void(*f)(unsigned int, char *))
Applies a callback to each character of a string in place.
Definition ft_striteri.c:21
char * ft_strnstr(const char *haystack, const char *needle, size_t len)
Finds a substring within a bounded string region.
Definition ft_strnstr.c:25
void * ft_calloc(size_t count, size_t size)
Allocates and zero-initializes an array.
Definition ft_calloc.c:26
void ft_putendl_fd(char *s, int fd)
Writes a string followed by a newline to a file descriptor.
t_list * ft_lstlast(t_list *lst)
Returns the last element of a linked list. This function takes a linked list and returns a pointer to...
Definition ft_lstlast.c:23
int ft_toupper(int c)
Converts a lowercase ASCII letter to uppercase.
Definition ft_toupper.c:19
int ft_atoi(const char *str)
Converts an ASCII string to an int value.
Definition ft_atoi.c:22
Definition types.h:4