inserted line thingy

This commit is contained in:
Maieul BOYER 2024-07-05 20:00:33 +02:00
parent fb3a2d94a0
commit 0e18e20181
No known key found for this signature in database
9 changed files with 1198 additions and 3 deletions

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 18:10:27 by maiboyer #+# #+# */
/* Updated: 2024/02/09 15:06:53 by maiboyer ### ########.fr */
/* Updated: 2024/07/05 19:54:25 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,6 +16,10 @@
# include "me/types.h"
# include <stdarg.h>
# ifndef FS_H
typedef struct s_fd t_fd;
# endif
typedef struct s_fprintf_arg
{
t_usize total_print;
@ -85,4 +89,17 @@ t_usize me_vprintf(t_const_str fmt, va_list *args);
/// @return the number of characters printed
t_usize me_veprintf(t_const_str fmt, va_list *args);
/// @brief Print a formatted string to the given fd
/// @param fmt the format string
/// @param ... the arguments to format
/// @return the number of characters printed
t_usize me_printf_fd(t_fd *, t_const_str fmt, ...);
/// @brief Print a formatted string to the given fd
/// @param fmt the format string
/// @param args the arguments to format as a va_list
/// @return the number of characters printed
t_usize me_vprintf_fd(t_fd *, t_const_str fmt, va_list *args);
#endif

View file

@ -0,0 +1,47 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* printf_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/05 19:55:09 by maiboyer #+# #+# */
/* Updated: 2024/07/05 19:57:23 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/fs/fs.h"
#include "me/printf/formatter/utils.h"
#include "me/printf/printf.h"
#include "me/types.h"
#include <stdarg.h>
void me_printf_write(t_const_str to_write, t_usize to_write_len, void *p_args);
t_usize me_vprintf_fd(t_fd *fd, t_const_str fmt, va_list *args)
{
t_fprintf_arg passthru;
passthru = (t_fprintf_arg){
.fd = fd->fd,
.total_print = 0,
};
me_printf_str_inner(fmt, &me_printf_write, args, (void *)&passthru);
return (passthru.total_print);
}
t_usize me_printf_fd(t_fd *fd, t_const_str fmt, ...)
{
va_list args;
t_fprintf_arg passthru;
passthru = (t_fprintf_arg){
.fd = fd->fd,
.total_print = 0,
};
va_start(args, fmt);
me_printf_str_inner(fmt, &me_printf_write, &args, (void *)&passthru);
va_end(args);
return (passthru.total_print);
}