tgrekov-ft_printf
HIVE printf Feb 2024
Loading...
Searching...
No Matches
handle_sequence.c File Reference

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* handle_sequence.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/01 00:41:01 by tgrekov #+# #+# */
/* Updated: 2024/02/13 07:11:50 by tgrekov ### ########.fr */
/* */
/* ************************************************************************** */

Definition in file handle_sequence.c.

#include <stdarg.h>
#include "sequence.h"
#include "../utils/utils.h"
#include "../../../libft/libft.h"
Include dependency graph for handle_sequence.c:

Go to the source code of this file.

Functions

void init_subspec (t_subspec *subspec)
 Sets initial values for a s_subspec that are not always set elsewhere.
 
void identify_sequence (va_list args, t_sequence *seq)
 Initialize a s_sequence and determine which specifier it needs to handle, and runs the preprocessing function for that specifier. Sets s_sequence::specifier to 0 on failure.
 
void parse_subspec (const char **format, t_subspec *subspec, va_list args)
 Parse flags, width, precision, and length.
 
static int print (t_sequence seq, int *fd, int total)
 Print appropriate padding characters on either side, as well as the sign / prefix, and call the processing function for the given specifier.
 
int handle_sequence (const char **format, va_list args, int *fd, int total)
 Prepares and executes a sequence.
 

Function Documentation

◆ handle_sequence()

int handle_sequence ( const char **  format,
va_list  args,
int *  fd,
int  total 
)

Prepares and executes a sequence.

Initializes and parses any subspecifiers, identifies the sequence and executes the preprocessor for it, adds up the final predicted lengths, prints padding, prefixes, and executes the processor for the sequence.

Parameters
[in,out]format
[in,out]args
[in,out]fd
[in]total
Return values
intNumber of characters printed, or -1 on error.

Definition at line 77 of file handle_sequence.c.

References ft_strlen(), identify_sequence(), init_subspec(), s_subspec::min_width, s_sequence::pad_len, parse_subspec(), print(), s_sequence::sign, s_sequence::specifier, s_sequence::subspec, and s_sequence::total_len.

Here is the call graph for this function:

◆ identify_sequence()

void identify_sequence ( va_list  args,
t_sequence seq 
)

Initialize a s_sequence and determine which specifier it needs to handle, and runs the preprocessing function for that specifier. Sets s_sequence::specifier to 0 on failure.

Parameters
[in,out]args
[in,out]seq

Definition at line 44 of file identify_sequence.c.

References init_sequence(), pre_char(), pre_int(), pre_percent(), pre_ptr(), pre_set_fd(), pre_store(), pre_string(), pre_uhex(), pre_uint(), pre_uoct(), and s_sequence::specifier.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_subspec()

void init_subspec ( t_subspec subspec)

Sets initial values for a s_subspec that are not always set elsewhere.

Parameters
[in,out]subspec

Definition at line 31 of file parse_subspec.c.

References s_subspec::force_decimal, s_subspec::forced_sign, s_subspec::left_justify, s_subspec::lenmod, s_subspec::min_width, s_subspec::pad_str, and s_subspec::precision.

Here is the caller graph for this function:

◆ parse_subspec()

void parse_subspec ( const char **  format,
t_subspec subspec,
va_list  args 
)

Parse flags, width, precision, and length.

Parameters
[in,out]format
[in,out]subspec
[in,out]args

Definition at line 99 of file parse_subspec.c.

References s_subspec::force_decimal, s_subspec::forced_sign, ft_isdigit(), ft_strchr(), s_subspec::left_justify, s_subspec::min_width, s_subspec::pad_str, parse_lenmod(), s_subspec::precision, and subspec_parse_width_or_precision().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print()

static int print ( t_sequence  seq,
int *  fd,
int  total 
)
static

Print appropriate padding characters on either side, as well as the sign / prefix, and call the processing function for the given specifier.

Parameters
[in]seq
[in,out]fd
[in]total
Return values
intNumber of characters printed, or -1 on error.

Definition at line 39 of file handle_sequence.c.

References ft_strlen(), s_subspec::left_justify, s_sequence::pad_len, s_subspec::pad_str, s_sequence::process, repeat_str_n(), s_sequence::sign, s_sequence::subspec, and wrap_err().

Here is the call graph for this function:
Here is the caller graph for this function: