C-Shell
A simple shell written in C.
Loading...
Searching...
No Matches
parse.h File Reference
#include <stddef.h>

Macros

#define C_SHELL_TOK_DELIM   " \t\r\n"
 
#define JOB_DELIM   ";"
 
#define PIPE_DELIM   "|"
 

Functions

struct commandparse_command (char *command, size_t command_len)
 Parse a command string into a command struct.
 
struct jobparse_job (char *job_str)
 Parse a command string containing pipes into a job struct. The string should not have any semicolons.
 
struct jobparse_line_to_jobs (char *line)
 Parse a line into a list of jobs.
 

Macro Definition Documentation

◆ C_SHELL_TOK_DELIM

#define C_SHELL_TOK_DELIM   " \t\r\n"

◆ JOB_DELIM

#define JOB_DELIM   ";"

◆ PIPE_DELIM

#define PIPE_DELIM   "|"

Function Documentation

◆ parse_command()

struct command * parse_command ( char * command,
size_t command_len )

Parse a command string into a command struct.

Parameters
commandThe command string
command_lenThe length of the command string
Returns
The parsed command struct

◆ parse_job()

struct job * parse_job ( char * job_str)

Parse a command string containing pipes into a job struct. The string should not have any semicolons.

Parameters
job_strThe command string
Returns
The parsed job struct

Using '\0' instead of ' ' will cause a segfault with strlen.

◆ parse_line_to_jobs()

struct job * parse_line_to_jobs ( char * line)

Parse a line into a list of jobs.

Parameters
lineThe line to parse
Returns
A pointer to the first job in a linked list