xv6/sh.c File Reference

#include "types.h"
#include "user.h"
#include "fcntl.h"

Go to the source code of this file.

Data Structures

struct  cmd
struct  execcmd
struct  redircmd
struct  pipecmd
struct  listcmd
struct  backcmd

Defines

#define EXEC   1
#define REDIR   2
#define PIPE   3
#define LIST   4
#define BACK   5
#define MAXARGS   10

Functions

int fork1 (void)
void panic (char *)
struct cmdparsecmd (char *)
void runcmd (struct cmd *cmd)
int getcmd (char *buf, int nbuf)
int main (void)
struct cmdexeccmd (void)
struct cmdredircmd (struct cmd *subcmd, char *file, char *efile, int mode, int fd)
struct cmdpipecmd (struct cmd *left, struct cmd *right)
struct cmdlistcmd (struct cmd *left, struct cmd *right)
struct cmdbackcmd (struct cmd *subcmd)
int gettoken (char **ps, char *es, char **q, char **eq)
int peek (char **ps, char *es, char *toks)
struct cmdparseline (char **, char *)
struct cmdparsepipe (char **, char *)
struct cmdparseexec (char **, char *)
struct cmdnulterminate (struct cmd *)
struct cmdparseredirs (struct cmd *cmd, char **ps, char *es)
struct cmdparseblock (char **ps, char *es)

Variables

char whitespace [] = " \t\r\n\v"
char symbols [] = "<|>&;()"


Define Documentation

#define BACK   5

Definition at line 12 of file sh.c.

Referenced by backcmd(), nulterminate(), and runcmd().

#define EXEC   1

Definition at line 8 of file sh.c.

Referenced by execcmd(), nulterminate(), and runcmd().

#define LIST   4

Definition at line 11 of file sh.c.

Referenced by listcmd(), nulterminate(), and runcmd().

#define MAXARGS   10

Definition at line 14 of file sh.c.

Referenced by parseexec().

#define PIPE   3

Definition at line 10 of file sh.c.

Referenced by nulterminate(), pipecmd(), and runcmd().

#define REDIR   2

Definition at line 9 of file sh.c.

Referenced by nulterminate(), redircmd(), and runcmd().


Function Documentation

struct cmd* backcmd ( struct cmd subcmd  )  [read]

Definition at line 249 of file sh.c.

References BACK, backcmd::cmd, malloc(), memset(), and backcmd::type.

Referenced by parseline().

struct cmd* execcmd ( void   )  [read]

Definition at line 196 of file sh.c.

References EXEC, malloc(), memset(), and execcmd::type.

Referenced by parseexec().

int fork1 ( void   ) 

Definition at line 183 of file sh.c.

References fork(), and panic().

Referenced by main(), and runcmd().

int getcmd ( char *  buf,
int  nbuf 
)

Definition at line 134 of file sh.c.

References gets(), memset(), and printf().

Referenced by main().

int gettoken ( char **  ps,
char *  es,
char **  q,
char **  eq 
)

Definition at line 265 of file sh.c.

References strchr(), symbols, and whitespace.

Referenced by parseblock(), parseexec(), parseline(), parsepipe(), and parseredirs().

struct cmd* listcmd ( struct cmd left,
struct cmd right 
) [read]

Definition at line 236 of file sh.c.

References listcmd::left, LIST, malloc(), memset(), listcmd::right, and listcmd::type.

Referenced by parseline().

int main ( void   ) 

Definition at line 145 of file sh.c.

References chdir(), close(), exit(), fork1(), getcmd(), O_RDWR, open(), parsecmd(), printf(), runcmd(), strlen(), and wait().

struct cmd * nulterminate ( struct cmd cmd  )  [read]

void panic ( char *  s  ) 

struct cmd* parseblock ( char **  ps,
char *  es 
) [read]

Definition at line 399 of file sh.c.

References gettoken(), panic(), parseline(), parseredirs(), and peek().

Referenced by parseexec().

struct cmd * parsecmd ( char *  s  )  [read]

Definition at line 327 of file sh.c.

References nulterminate(), panic(), parseline(), peek(), printf(), and strlen().

Referenced by main().

struct cmd * parseexec ( char **  ps,
char *  es 
) [read]

Definition at line 415 of file sh.c.

References execcmd::argv, execcmd::eargv, execcmd(), gettoken(), MAXARGS, panic(), parseblock(), parseredirs(), and peek().

Referenced by parsepipe().

struct cmd * parseline ( char **  ps,
char *  es 
) [read]

Definition at line 344 of file sh.c.

References backcmd(), gettoken(), listcmd(), parsepipe(), and peek().

Referenced by parseblock(), and parsecmd().

struct cmd * parsepipe ( char **  ps,
char *  es 
) [read]

Definition at line 361 of file sh.c.

References gettoken(), parseexec(), peek(), and pipecmd().

Referenced by parseline().

struct cmd* parseredirs ( struct cmd cmd,
char **  ps,
char *  es 
) [read]

Definition at line 374 of file sh.c.

References gettoken(), O_CREATE, O_RDONLY, O_WRONLY, panic(), peek(), and redircmd().

Referenced by parseblock(), and parseexec().

int peek ( char **  ps,
char *  es,
char *  toks 
)

Definition at line 310 of file sh.c.

References strchr(), and whitespace.

Referenced by parseblock(), parsecmd(), parseexec(), parseline(), parsepipe(), and parseredirs().

struct cmd* pipecmd ( struct cmd left,
struct cmd right 
) [read]

Definition at line 223 of file sh.c.

References pipecmd::left, malloc(), memset(), PIPE, pipecmd::right, and pipecmd::type.

Referenced by parsepipe().

struct cmd* redircmd ( struct cmd subcmd,
char *  file,
char *  efile,
int  mode,
int  fd 
) [read]

void runcmd ( struct cmd cmd  ) 


Variable Documentation

char symbols[] = "<|>&;()"

Definition at line 262 of file sh.c.

Referenced by gettoken().

char whitespace[] = " \t\r\n\v"

Definition at line 261 of file sh.c.

Referenced by gettoken(), and peek().


Generated on Fri Jan 7 12:25:49 2011 for xv6 by  doxygen 1.5.6