C-Shell
A simple shell written in C.
Loading...
Searching...
No Matches
parse.c File Reference

The parser. More...

#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "parse.h"
#include "shelltypes.h"

Functions

bool is_blank (const char *str)
 
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.
 

Detailed Description

The parser.

Function Documentation

◆ is_blank()

bool is_blank ( const char * str)

◆ 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