tgrekov-fdf
HIVE fdf May 2024
Loading...
Searching...
No Matches
int.c
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* int.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2023/11/01 05:18:23 by tgrekov #+# #+# */
9/* Updated: 2024/02/12 00:46:41 by tgrekov ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include <stdarg.h>
14#include <unistd.h>
15#include <stdlib.h>
16#include "../sequence.h"
17#include "../../utils/utils.h"
18#include "../../utils/internal_types.h"
19
20int process_uint(t_sequence seq, int *fd, int total);
21
23{
24 if (n < 0)
25 n = -n;
26 return (n);
27}
28
29void pre_int(va_list args, t_sequence *seq)
30{
31 t_biggest n;
32
33 n = va_arg(args, int);
34 if (n < 0)
35 seq->sign = "-";
36 seq->data = lltull(n);
37 seq->total_len = u_len_base(seq->data, 10);
38 seq->process = process_uint;
39}
int process_uint(t_sequence seq, int *fd, int total)
Processes the unsigned integer specifier by printing the number in base 10.
Definition uint.c:36
static t_ubiggest lltull(t_biggest n)
Safely converts a signed integer to an unsigned one.
Definition int.c:64
void pre_int(va_list args, t_sequence *seq)
Preprocess the signed integer specifier by retrieving the argument in the appropriate size,...
Definition int.c:88
long long t_biggest
Convenience typedef for largest signed type I need to handle.
unsigned long long t_ubiggest
Convenience typedef for largest unsigned type I need to handle.
int u_len_base(t_ubiggest n, int base)
Determine the length of unsigned number n in base base.
Definition u_len_base.c:29
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
char * sign
String containing the prefix for the value. Set during preprocessing for a format handler.
Definition sequence.h:52