2004 by Marc J. Rochkind. All rights reserved. Portions marked "Open Source" may be copied under license.

 

Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

c6/sh3.c File Reference


Detailed Description

real shell (version 4) [Sec. 6.4]

Definition in file sh3.c.

Go to the source code of this file.

Defines

#define WANT_TESTx
#define MAXARG   50
#define MAXFNAME   500
#define MAXWORD   500
#define PROMPT   "* "

Enumerations

enum  TOKEN {
  T_WORD, T_BAR, T_AMP, T_SEMI,
  T_GT, T_GTGT, T_LT, T_NL,
  T_EOF, T_ERROR
}

Functions

void fd_check (void)
bool store_char (char *word, size_t maxword, int c, size_t *np)
TOKEN gettoken (char *word, size_t maxword)
bool builtin (int argc, char *argv[], int srcfd, int dstfd)
bool ignore_sig (void)
bool entry_sig (void)
bool wait_and_display (pid_t pid)
void redirect (int srcfd, const char *srcfile, int dstfd, const char *dstfile, bool append, bool bckgrnd)
pid_t invoke (int argc, char *argv[], int srcfd, const char *srcfile, int dstfd, const char *dstfile, bool append, bool bckgrnd, int closefd)
TOKEN command (pid_t *wpid, bool makepipe, int *pipefdp)
int main (void)

Variables

sigaction entry_int entry_quit


Define Documentation

#define MAXARG   50
 

Definition at line 28 of file sh3.c.

#define MAXFNAME   500
 

Definition at line 29 of file sh3.c.

Referenced by command().

#define MAXWORD   500
 

Definition at line 30 of file sh3.c.

Referenced by command().

#define PROMPT   "* "
 

Definition at line 32 of file sh3.c.

Referenced by main().

#define WANT_TESTx
 

Definition at line 25 of file sh3.c.


Enumeration Type Documentation

enum TOKEN
 

Enumeration values:
T_WORD 
T_BAR 
T_AMP 
T_SEMI 
T_GT 
T_GTGT 
T_LT 
T_NL 
T_EOF 
T_ERROR 

Definition at line 60 of file sh3.c.

Referenced by command(), gettoken(), and main().


Function Documentation

bool builtin int  argc,
char *  argv[],
int  srcfd,
int  dstfd
[static]
 

Definition at line 143 of file sh3.c.

References asg(), chdir(), getenv(), and set().

Referenced by invoke().

TOKEN command pid_t *  wpid,
bool  makepipe,
int *  pipefdp
[static]
 

Definition at line 296 of file sh3.c.

References EC_CLEANUP_BGN, EC_CLEANUP_END, ec_neg1, exit(), gettoken(), invoke(), MAXARG, MAXFNAME, MAXWORD, pipe(), T_AMP, T_BAR, T_EOF, T_ERROR, T_GT, T_GTGT, T_LT, T_NL, T_SEMI, T_WORD, and TOKEN.

Referenced by main().

bool entry_sig void   )  [static]
 

Definition at line 191 of file sh3.c.

References EC_CLEANUP_BGN, EC_CLEANUP_END, ec_neg1, entry_quit, and sigaction().

Referenced by invoke().

void fd_check void   )  [static]
 

Definition at line 34 of file sh3.c.

References _exit(), errno, and fcntl().

Referenced by main(), and redirect().

TOKEN gettoken char *  word,
size_t  maxword
[static]
 

Definition at line 63 of file sh3.c.

References EC_CLEANUP_BGN, EC_CLEANUP_END, ec_false, store_char(), T_AMP, T_BAR, T_EOF, T_ERROR, T_GT, T_GTGT, T_LT, T_NL, T_SEMI, T_WORD, and TOKEN.

Referenced by command().

bool ignore_sig void   )  [static]
 

Definition at line 168 of file sh3.c.

References EC_CLEANUP_BGN, EC_CLEANUP_END, ec_neg1, entry_quit, sigaction::sa_handler, and sigaction().

Referenced by main().

pid_t invoke int  argc,
char *  argv[],
int  srcfd,
const char *  srcfile,
int  dstfd,
const char *  dstfile,
bool  append,
bool  bckgrnd,
int  closefd
[static]
 

Definition at line 251 of file sh3.c.

References _exit(), builtin(), close(), EC_CLEANUP_BGN, EC_CLEANUP_END, ec_false, ec_neg1, entry_sig(), execvp(), fork(), and redirect().

Referenced by command().

int main void   ) 
 

Definition at line 389 of file sh3.c.

References command(), EC_FLUSH, fd_check(), ignore_sig(), PROMPT, T_AMP, T_ERROR, T_NL, TOKEN, and wait_and_display().

void redirect int  srcfd,
const char *  srcfile,
int  dstfd,
const char *  dstfile,
bool  append,
bool  bckgrnd
[static]
 

Definition at line 218 of file sh3.c.

References _exit(), close(), dup2(), EC_CLEANUP_BGN, EC_CLEANUP_END, ec_neg1, fd_check(), open(), and PERM_FILE.

Referenced by invoke().

bool store_char char *  word,
size_t  maxword,
int  c,
size_t *  np
[static]
 

Definition at line 48 of file sh3.c.

References EC_CLEANUP_BGN, EC_CLEANUP_END, ec_false, and errno.

Referenced by gettoken().

bool wait_and_display pid_t  pid  )  [static]
 

Definition at line 202 of file sh3.c.

References display_status(), EC_CLEANUP_BGN, EC_CLEANUP_END, ec_neg1, and waitpid().


Variable Documentation

struct sigaction entry_int entry_quit [static]
 

Definition at line 166 of file sh3.c.

Referenced by entry_sig(), and ignore_sig().


Generated on Fri Apr 23 10:57:09 2004 for AUP2 Example Source by doxygen 1.3.1