tgrekov-ft_printf
HIVE printf Feb 2024
Loading...
Searching...
No Matches
libft.h
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* libft.h :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2023/10/23 14:26:57 by tgrekov #+# #+# */
9/* Updated: 2023/12/12 09:35:47 by tgrekov ### ########.fr */
10/* */
11/* ************************************************************************** */
12
20#ifndef LIBFT_H
21# define LIBFT_H
22
23# include <stdlib.h>
24# include <unistd.h>
25
29# define FT_LONG_MAX 9223372036854775807L
30
43typedef struct s_list
44{
45 void *content;
46 struct s_list *next;
48
49int ft_atoi(const char *str);
50void ft_bzero(void *s, size_t n);
51void *ft_calloc(size_t count, size_t size);
52int ft_isalnum(int c);
53int ft_isalpha(int c);
54int ft_isascii(int c);
55int ft_isdigit(int c);
56int ft_isprint(int c);
57char *ft_itoa(int n);
58void ft_lstiter(t_list *lst, void (*f)(void *));
59void ft_lstadd_back(t_list **lst, t_list *new);
60void ft_lstadd_front(t_list **lst, t_list *new);
61void ft_lstclear(t_list **lst, void (*del)(void *));
62void ft_lstdelone(t_list *lst, void (*del)(void *));
64t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
66int ft_lstsize(t_list *lst);
67void *ft_memchr(const void *s, int c, size_t n);
68int ft_memcmp(const void *s1, const void *s2, size_t n);
69void *ft_memcpy(void *dst, const void *src, size_t n);
70void *ft_memmove(void *dst, const void *src, size_t len);
71void *ft_memset(void *b, int c, size_t len);
72void ft_putchar_fd(char c, int fd);
73void ft_putendl_fd(char *s, int fd);
74void ft_putnbr_fd(int n, int fd);
75void ft_putstr_fd(char *s, int fd);
76char **ft_split(char const *s, char c);
77char *ft_strchr(const char *s, int c);
78char *ft_strdup(const char *s1);
79void ft_striteri(char *s, void (*f)(unsigned int, char *));
80char *ft_strjoin(char const *s1, char const *s2);
81size_t ft_strlcat(char *dst, const char *src, size_t dstsize);
82size_t ft_strlcpy(char *dst, const char *src, size_t dstsize);
83size_t ft_strlen(const char *str);
84char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
85int ft_strncmp(const char *s1, const char *s2, size_t n);
86char *ft_strnstr(const char *haystack, const char *needle, size_t len);
87char *ft_strrchr(const char *s, int c);
88char *ft_strtrim(char const *s1, char const *set);
89char *ft_substr(char const *s, unsigned int start, size_t len);
90int ft_tolower(int c);
91int ft_toupper(int c);
92
93#endif
void ft_lstadd_front(t_list **lst, t_list *new)
Insert node new into the start of the list pointed to by the pointer at lst.
int ft_memcmp(const void *s1, const void *s2, size_t n)
Compares n bytes of byte string s1 against byte string s2.
Definition ft_memcmp.c:34
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
Copy at most dstsize - 1 characters from string src into dst.
Definition ft_strlcpy.c:36
void ft_lstiter(t_list *lst, void(*f)(void *))
Iterates over a list and applies the function f over each node.
void * ft_memset(void *b, int c, size_t len)
Fills len bytes of byte string b with value c.
Definition ft_memset.c:31
char * ft_strdup(const char *s1)
Allocates memory for, copies to, and returns a duplicate of s1.
Definition ft_strdup.c:28
int ft_isdigit(int c)
Is c a numeric character.
Definition ft_isdigit.c:26
char * ft_strrchr(const char *s, int c)
Finds last occurence of c in string at s.
Definition ft_strrchr.c:30
void ft_lstadd_back(t_list **lst, t_list *new)
Adds node at pointer new to the end of the list starting at pointer pointed to by lst.
void ft_bzero(void *s, size_t n)
Write n zeroes to byte string at pointer s.
Definition ft_bzero.c:28
void * ft_memcpy(void *dst, const void *src, size_t n)
Copies n bytes from byte string src to byte string dst.
Definition ft_memcpy.c:36
char * ft_strtrim(char const *s1, char const *set)
Allocates and returns a copy of s1 with any successive characters found in string set removed from th...
Definition ft_strtrim.c:31
void ft_putnbr_fd(int n, int fd)
Converts integer n to it's ASCII representation and writes it to file descriptor fd.
char * ft_strmapi(char const *s, char(*f)(unsigned int, char))
Allocates and creates a new string from the output of function f processing each character of string ...
Definition ft_strmapi.c:34
struct s_list t_list
Linked list node.
void ft_lstclear(t_list **lst, void(*del)(void *))
Delete every node in a list along with it's content.
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
Appends at most dstsize - ft_strlen(dst) - 1 characters of string src to the end of string dst.
Definition ft_strlcat.c:34
char * ft_substr(char const *s, unsigned int start, size_t len)
Allocates and returns a substring of s, starting at s + start, and ending no later than s + start + l...
Definition ft_substr.c:32
t_list * ft_lstmap(t_list *lst, void *(*f)(void *), void(*del)(void *))
Iterate over a list and create a new one from the results of applying f to the content of each node.
size_t ft_strlen(const char *str)
Get length of str.
Definition ft_strlen.c:28
char * ft_itoa(int n)
Converts integer n to an allocated ASCII string.
Definition ft_itoa.c:50
void ft_putchar_fd(char c, int fd)
Write character c to file descriptor fd.
t_list * ft_lstnew(void *content)
Allocates a new node, set it's content, and return it's address.
char * ft_strjoin(char const *s1, char const *s2)
Allocates enough space for and appends string s2 to string s1 and returns the new string.
Definition ft_strjoin.c:30
int ft_isalnum(int c)
Is c an alphanumeric character.
Definition ft_isalnum.c:29
int ft_strncmp(const char *s1, const char *s2, size_t n)
Compare up to n characters of string s1 with string s2.
Definition ft_strncmp.c:33
int ft_lstsize(t_list *lst)
Counts the number of nodes in a list.
char ** ft_split(char const *s, char c)
Split string s by characer c into allocated array of strings, with NULL as the last element.
Definition ft_split.c:72
char * ft_strchr(const char *s, int c)
Finds first occurence of character c in string s.
Definition ft_strchr.c:30
int ft_tolower(int c)
Convert uppercase letter to corresponding lowercase letter.
Definition ft_tolower.c:28
int ft_isprint(int c)
Is c a printable character.
Definition ft_isprint.c:26
int ft_isascii(int c)
Is c in the ASCII character range.
Definition ft_isascii.c:26
void * ft_memchr(const void *s, int c, size_t n)
Finds first occurence of c in byte string at s within n bytes.
Definition ft_memchr.c:33
int ft_isalpha(int c)
Is c an alphabetical character.
Definition ft_isalpha.c:27
void ft_lstdelone(t_list *lst, void(*del)(void *))
Delete a node and it's content.
void * ft_memmove(void *dst, const void *src, size_t len)
Copies len bytes from byte string src to byte string dst non-destructively.
Definition ft_memmove.c:34
void ft_putstr_fd(char *s, int fd)
Write string at pointer s to file descriptor fd.
void ft_striteri(char *s, void(*f)(unsigned int, char *))
Applies function f to each character of string s.
Definition ft_striteri.c:31
char * ft_strnstr(const char *haystack, const char *needle, size_t len)
Finds first occurence of needle in string haystack.
Definition ft_strnstr.c:33
void * ft_calloc(size_t count, size_t size)
Allocates count * size bytes with malloc and returns a pointer to the result.
Definition ft_calloc.c:34
void ft_putendl_fd(char *s, int fd)
Write string at pointer s followed by a newline to file descriptor fd.
t_list * ft_lstlast(t_list *lst)
Get the last node in a list.
int ft_toupper(int c)
Convert lowercase letter to corresponding uppercase letter.
Definition ft_toupper.c:28
int ft_atoi(const char *str)
Converts ASCII string str to integer representation.
Definition ft_atoi.c:42
Linked list node.
Definition libft.h:44
struct s_list * next
Pointer to the next node.
Definition libft.h:46
void * content
void* to the node's contents.
Definition libft.h:45