tgrekov-fdf
HIVE fdf May 2024
Loading...
Searching...
No Matches
string.c
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* string.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2023/11/01 08:25:24 by tgrekov #+# #+# */
9/* Updated: 2024/04/26 10:29:04 by tgrekov ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include <stdarg.h>
14#include <unistd.h>
15#include "../sequence.h"
16#include "../../../../../libft.h"
17#include "../../utils/internal_types.h"
18
19static int process_string(t_sequence seq, int *fd, int total)
20{
21 (void) total;
22 return (write(*fd, (char *) seq.data, seq.total_len));
23}
24
25void pre_string(va_list args, t_sequence *seq)
26{
27 seq->data = (t_ubiggest) va_arg(args, char *);
28 if (!seq->data)
29 seq->data = (t_ubiggest) "(null)";
30 seq->total_len = (int) ft_strlen((char *) seq->data);
32}
void pre_string(va_list args, t_sequence *seq)
Preprocess the string specifier by retrieving the address, setting s_sequence::data to the address,...
Definition string.c:50
static int process_string(t_sequence seq, int *fd, int total)
Process the string specifier by writing the string. (Rocket science)
Definition string.c:34
unsigned long long t_ubiggest
Convenience typedef for largest unsigned type I need to handle.
size_t ft_strlen(const char *str)
Get length of str.
Definition ft_strlen.c:28
Holds information regarding the current format specifier sequence.
Definition sequence.h:49
int(* process)(struct s_sequence, int *, int)
Function to use for processing this sequence's value.
Definition sequence.h:56
t_ubiggest data
Retrieved variable argument.
Definition sequence.h:53
int total_len
Total number of characters after padding.
Definition sequence.h:54