tgrekov-push_swap
HIVE push_swap July 2024
Loading...
Searching...
No Matches
input.c File Reference

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* input.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/06 04:18:07 by tgrekov #+# #+# */
/* Updated: 2024/07/17 11:04:33 by tgrekov ### ########.fr */
/* */
/* ************************************************************************** */

Definition in file input.c.

#include <stdlib.h>
#include <libft.h>
#include "utils/utils.h"
#include "stack/stack.h"
Include dependency graph for input.c:

Go to the source code of this file.

Functions

static int init_stacks (int argc, char **argv, char ***arg2, t_stack *stack)
 Split input if it was provided as a single argument, validate input length, and allocate stacks.
 
static int validate_arg (char *arg, int parsed)
 Check that parsed is identical to the source arg when converted back into a string.
 
static int duplicate_check (t_stack stack, int n)
 Check if n is already present in the stack.
 
static int parse_args (char **argv, t_stack *stack)
 Parse and validate input arguments and add them to the first stack.
 
int input (int argc, char **argv, t_stack *stack)
 Parse and validate program input, initialize stacks and fill the first stack.
 

Function Documentation

◆ duplicate_check()

static int duplicate_check ( t_stack  stack,
int  n 
)
static

Check if n is already present in the stack.

Parameters
[in]stack
[in]n
Return values
int

Definition at line 92 of file input.c.

Here is the caller graph for this function:

◆ init_stacks()

static int init_stacks ( int  argc,
char **  argv,
char ***  arg2,
t_stack stack 
)
static

Split input if it was provided as a single argument, validate input length, and allocate stacks.

Parameters
[in]argc
[in]argv
[out]arg2
[out]stack
Return values
int

Definition at line 35 of file input.c.

References arr_len(), and ft_split().

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

◆ input()

int input ( int  argc,
char **  argv,
t_stack stack 
)

Parse and validate program input, initialize stacks and fill the first stack.

Parameters
[in]argc
[in]argv
[out]stack
Return values
int

Definition at line 134 of file input.c.

References arr_free(), err(), init_stacks(), and parse_args().

Here is the call graph for this function:

◆ parse_args()

static int parse_args ( char **  argv,
t_stack stack 
)
static

Parse and validate input arguments and add them to the first stack.

Parameters
[in]argv
[in,out]stack
Return values
int

Definition at line 110 of file input.c.

References duplicate_check(), ft_atoi(), and validate_arg().

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

◆ validate_arg()

static int validate_arg ( char *  arg,
int  parsed 
)
static

Check that parsed is identical to the source arg when converted back into a string.

Parameters
[in]arg
[in]parsed
Return values
int

Definition at line 66 of file input.c.

References ft_itoa(), ft_strlen(), and ft_strncmp().

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