LumaOS  v0.1.116
An experimental x86-64 OS
Loading...
Searching...
No Matches
parser.c File Reference

Parses flags and values from strings. More...

#include <lib/parser.h>
#include <stdbool.h>
#include <limits.h>
#include <lib/kstring.h>
Include dependency graph for parser.c:

Go to the source code of this file.

Functions

static bool find_argument (const char *flag, const char *str, const char **value)
 Find a flag and its associated value in a string.
bool parse_flag (const char *flag, const char *str)
 Checks if a flag is present in a string.
bool parse_bool (const char *flag, const char *str)
 Checks if a flag is present in a string and if its set to true or false.
long parse_int (const char *flag, const char *str)
 Gets the int value of a flag.
bool parse_string (const char *flag, const char *str, char *out, size_t out_size)

Detailed Description

Parses flags and values from strings.

Author
Matheus Boscariol
Since
19/11/2026

Definition in file parser.c.

Function Documentation

◆ find_argument()

bool find_argument ( const char * flag,
const char * str,
const char ** value )
static

Find a flag and its associated value in a string.

Parameters
flagThe flag to search for
strThe string to search in
valueIf the flag is found, the value associated with it will be stored here
Returns
True if the flag was found, false otherwise

Definition at line 21 of file parser.c.

Here is the call graph for this function:

◆ parse_bool()

bool parse_bool ( const char * flag,
const char * str )

Checks if a flag is present in a string and if its set to true or false.

Parameters
flagThe expected flag
strThe string to check
Returns
If the flag was found or not or if the flag is set to true or false

Definition at line 83 of file parser.c.

Here is the call graph for this function:

◆ parse_flag()

bool parse_flag ( const char * flag,
const char * str )

Checks if a flag is present in a string.

Parameters
flagThe expected flag
strThe string to check
Returns
If the flag was found or not

Definition at line 76 of file parser.c.

Here is the call graph for this function:

◆ parse_int()

long parse_int ( const char * flag,
const char * str )

Gets the int value of a flag.

Parameters
flagThe expected flag
strThe string to check
Returns
0 if the flag was not found or had an invalid value, or the number that it holds

Definition at line 133 of file parser.c.

Here is the call graph for this function:

◆ parse_string()

bool parse_string ( const char * flag,
const char * str,
char * out,
size_t out_size )

Definition at line 185 of file parser.c.