Classes | Functions

shellutils.h File Reference

Helper functions for shell implementations. More...

Go to the source code of this file.

Classes

struct  COMMAND
 The COMMAND structure contains a parsed command. More...

Functions

COMMANDparseCommandLine (char *cmdLine)
 Parses a command line.
void printStat (const char *cmdLine, int status)
 Prints the status of a terminated or stopped child process.
void prompt ()
 Prints a prompt symbol including the working directory.

Detailed Description

Helper functions for shell implementations.


Function Documentation

COMMAND* parseCommandLine ( char *  cmdLine  ) 

Parses a command line.

This function parses a command line string that may contain & (for background execution) and > for stdout redirection. parseCommand will generate the argv array for the given commandline and return a COMMAND structure containing the result. The COMMAND structure is dynamically allocated and needs to be free'd by the caller (i.e., YOU).

Parameters:
cmdLine the cmdLine to be parsed. cmdLine is tokenized during parseCommandLine.
Returns:
pointer to the parsed COMMAND or NULL on error, with errno set appropriately. In case a custom error message is supplied, the function returns a COMMAND structure that has the parseError field set to a custom error message. If the parseError field is set to a value other than null, parsing the command line has failed and the remaining fields of the COMMAND structure must not be interpreted.
void printStat ( const char *  cmdLine,
int  status 
)

Prints the status of a terminated or stopped child process.

Parameters:
cmdLine command line of the child process
status process status as returned by wait(2)
 All Classes Files Functions Variables