CHashTable 1
Loading...
Searching...
No Matches
argument_parser.c File Reference

Argument parser API for interactive mode. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "argument_parser_internal.h"
Include dependency graph for argument_parser.c:

Data Structures

struct  StrToIntResult
 Result type for str_to_int() More...
 

Functions

static StrToIntResult str_to_int (const char *str)
 Converts string to int with error reporting.
 
static void print_error (FILE *stream, const char *err)
 Prints red-colored error.
 
ParsedInput get_input (FILE *input_stream, FILE *output_stream)
 Prompts user for interactive mode command and arguments.
 

Detailed Description

Argument parser API for interactive mode.

Function Documentation

◆ get_input()

ParsedInput get_input ( FILE *  input_stream,
FILE *  output_stream 
)

Prompts user for interactive mode command and arguments.

Parameters
input_streamStream to get the input from
output_streamStream to print to
Returns
ParsedInput object with parsed command and argument

◆ print_error()

static void print_error ( FILE *  stream,
const char *  err 
)
static

Prints red-colored error.

Parameters
streamStream to print to
errError string

◆ str_to_int()

static StrToIntResult str_to_int ( const char *  str)
static

Converts string to int with error reporting.

Parameters
strString to convert
Returns
StrToIntResult object with the int and success