sh1.c File Reference

#include <sys/types.h>
#include <signal.h>
#include <errno.h>
#include <setjmp.h>
#include "sh.h"

Include dependency graph for sh1.c:

Go to the source code of this file.

Data Structures

struct  region

Defines

#define Extern   extern
#define CMASK   0377
#define QUOTE   0200
#define QMASK   (CMASK&~QUOTE)
#define NOT   '!'
#define REGSIZE   sizeof(struct region)
#define GROWBY   256
#define FREE   32767
#define BUSY   0
#define ALIGN   (sizeof(int)-1)

Functions

 _PROTOTYPE (void(*qflag),(int))
 _PROTOTYPE (int main,(int argc, char **argv))
 _PROTOTYPE (int newfile,(char *s))
 _PROTOTYPE (static char *findeq,(char *cp))
 _PROTOTYPE (static char *cclass,(char *p, int sub))
 _PROTOTYPE (void initarea,(void))
int main (int argc, char **argv)
void setdash ()
int newfile (char *s)
void onecommand ()
void fail ()
void leave ()
void warn (char *s)
void err (char *s)
int newenv (int f)
void quitenv ()
int anys (char *s1, char *s2)
int any (int c, char *s)
char * putn (int n)
char * itoa (unsigned u, int n)
void next (int f)
void onintr (int s)
int letter (register c)
int digit (register c)
int letnum (register c)
char * space (int n)
char * strsave (char *s, int a)
void xfree (char *s)
void sig (int i)
void runtrap (int i)
varlookup (char *n)
void setval (struct var *vp, char *val)
void nameval (struct var *vp, char *val, char *name)
void export (struct var *vp)
void ronly (struct var *vp)
int isassign (char *s)
int assign (char *s, int cf)
int checkname (char *cp)
void putvlist (int f, int out)
int eqname (char *n1, char *n2)
static char * findeq (char *cp)
int gmatch (char *s, char *p)
static char * cclass (char *p, int sub)
void initarea ()
char * getcell (unsigned nbytes)
void freecell (char *cp)
void freearea (int a)
void setarea (char *cp, int a)
int getarea (char *cp)
void garbage ()

Variables

int intr
int inparse
char flags ['z'-'a'+1]
char * flag = flags-'a'
char * elinep = line+sizeof(line)-5
char * null = ""
int heedint = 1
env e
char ** environ
char shellname [] = "/bin/sh"
char search [] = ":/bin:/usr/bin"
static struct regionareabot
static struct regionareatop
static struct regionareanxt


Define Documentation

#define ALIGN   (sizeof(int)-1)
 

Definition at line 794 of file sh1.c.

#define BUSY   0
 

Definition at line 793 of file sh1.c.

Referenced by initarea().

#define CMASK   0377
 

Definition at line 721 of file sh1.c.

Referenced by cclass(), gmatch(), and selected().

#define Extern   extern
 

Definition at line 1 of file sh1.c.

#define FREE   32767
 

Definition at line 792 of file sh1.c.

#define GROWBY   256
 

Definition at line 790 of file sh1.c.

#define NOT   '!'
 

Definition at line 724 of file sh1.c.

#define QMASK   (CMASK&~QUOTE)
 

Definition at line 723 of file sh1.c.

Referenced by gmatch().

#define QUOTE   0200
 

Definition at line 722 of file sh1.c.

#define REGSIZE   sizeof(struct region)
 

Definition at line 789 of file sh1.c.

Referenced by getcell(), and initarea().


Function Documentation

_PROTOTYPE void  initarea,
(void) 
 

_PROTOTYPE static char *  cclass,
(char *p, int sub) 
 

_PROTOTYPE static char *  findeq,
(char *cp
 

_PROTOTYPE int  newfile,
(char *s
 

_PROTOTYPE int  main,
(int argc, char **argv) 
 

_PROTOTYPE void *  qflag,
(int) 
 

int any int  c,
char *  s
 

Definition at line 366 of file sh1.c.

Referenced by anys(), blank(), dodot(), dollar(), doread(), getprotoent(), getservent(), glob(), globname(), herein(), rexecve(), and yylex().

int anys char *  s1,
char *  s2
 

Definition at line 353 of file sh1.c.

References any().

Referenced by anyspcl(), expand(), and globname().

int assign char *  s,
int  cf
 

Definition at line 646 of file sh1.c.

References COPYV, cp, GETCELL, letnum(), letter(), lookup(), nameval(), NULL, and var::status.

static char* cclass char *  p,
int  sub
[static]
 

Definition at line 764 of file sh1.c.

References c, CMASK, d, NOT, and NULL.

Referenced by gmatch().

int checkname char *  cp  ) 
 

Definition at line 666 of file sh1.c.

References letnum(), and letter().

Referenced by rdexp().

int digit register  c  ) 
 

Definition at line 441 of file sh1.c.

int eqname char *  n1,
char *  n2
 

Definition at line 695 of file sh1.c.

Referenced by lookup().

void err char *  s  ) 
 

Definition at line 297 of file sh1.c.

References closeall(), e, env::errpt, flag, env::iobase, env::iop, iostack, leave(), talking, and warn.

void export struct var vp  ) 
 

Definition at line 619 of file sh1.c.

References EXPORT.

Referenced by doexport(), forkexec(), and main().

void fail  ) 
 

Definition at line 265 of file sh1.c.

References failpt.

static char* findeq char *  cp  )  [static]
 

Definition at line 705 of file sh1.c.

void freearea int  a  ) 
 

Definition at line 902 of file sh1.c.

References areabot, areatop, FREE, p, and top.

Referenced by execute(), grave(), onecommand(), and run().

void freecell char *  cp  ) 
 

Definition at line 888 of file sh1.c.

References areanxt, FREE, and p.

void garbage  ) 
 

Definition at line 932 of file sh1.c.

References areabot, areanum, areanxt, areatop, region::next, p, and top.

int getarea char *  cp  ) 
 

Definition at line 925 of file sh1.c.

Referenced by freehere().

char* getcell unsigned  nbytes  ) 
 

Definition at line 825 of file sh1.c.

References abort(), areanum, areanxt, i, region::next, p, and REGSIZE.

Referenced by space(), and tree().

int gmatch char *  s,
char *  p
 

Definition at line 727 of file sh1.c.

References cclass(), CMASK, NULL, pc, QMASK, and QUOTE.

Referenced by find1case(), and globname().

void initarea  ) 
 

Definition at line 813 of file sh1.c.

References ALIGN, region::area, areabot, areanxt, areatop, BUSY, region::next, REGSIZE, and sbrk.

Referenced by main().

int isassign char *  s  ) 
 

Definition at line 634 of file sh1.c.

References letnum(), and letter().

char* itoa unsigned  u,
int  n
 

Definition at line 384 of file sh1.c.

References cp, m, and s.

void leave  ) 
 

Definition at line 272 of file sh1.c.

References execflg, exit(), exstat, fail, freehere(), runtrap(), and scraphere().

Referenced by do_getty(), doexit(), err(), execute(), main(), onecommand(), onintr(), and warn().

int letnum register  c  ) 
 

Definition at line 448 of file sh1.c.

References digit, and letter().

Referenced by assign(), checkname(), dollar(), isassign(), and varput().

int letter register  c  ) 
 

Definition at line 434 of file sh1.c.

Referenced by assign(), checkname(), dollar(), isassign(), letnum(), and ronly().

struct var* lookup char *  n  ) 
 

Definition at line 521 of file sh1.c.

References c, cp, digit, dolc, dolv, dummy, eqname(), var::name, var::next, null, RONLY, space(), and vlist.

int main int  argc,
char **  argv
 

Definition at line 40 of file sh1.c.

References areanum, assign(), cflag, closeall(), COPYV, cprompt, environ, exit(), EXPORT, export(), filechar(), flag, geteuid, getpid, homedir, ifs, initarea(), int(), itoa(), linechar(), lookup(), newfile, nlchar(), null, NULL, path, prompt, PUSHIO, s, search, setval(), shell, shellname, SIG_DFL, talking, and var::value.

void nameval struct var vp,
char *  val,
char *  name
 

Definition at line 579 of file sh1.c.

References cp, err, GETCELL, NULL, putc, RONLY, setarea(), space(), strlen(), and xfree().

Referenced by assign(), and setval().

int newenv int  f  ) 
 

Definition at line 312 of file sh1.c.

References e, ep, errpt, env::errpt, fail, NULL, env::oenv, quitenv(), and space().

Referenced by eval(), expand(), herein(), readhere(), and run().

int newfile char *  s  ) 
 

Definition at line 198 of file sh1.c.

References err, next, open, prs(), remap(), and strcmp.

void next int  f  ) 
 

Definition at line 409 of file sh1.c.

References filechar(), and PUSHIO.

void onecommand  ) 
 

Definition at line 217 of file sh1.c.

References areanum, brklist, e, env::errpt, execflg, execute(), failpt, flag, freearea(), freehere(), garbage(), i, inparse, intr, iolist, leave(), env::linep, m1, multiline, NOPIPE, env::oenv, outtree, quitenv(), runtrap(), scraphere(), setjmp, talking, trapset, wdlist, yynerrs, and yyparse().

Referenced by grave().

void onintr int  s  ) 
 

Definition at line 416 of file sh1.c.

References execflg, fail, heedint, inparse, intr, leave(), onintr(), prs(), SIGINT, signal(), and talking.

char* putn int  n  ) 
 

Definition at line 377 of file sh1.c.

References itoa().

Referenced by doshift(), execute(), setstatus(), and tempname().

void putvlist int  f,
int  out
 

Definition at line 678 of file sh1.c.

References EXPORT, if(), var::name, var::next, RONLY, var::status, vlist, and write.

Referenced by rdexp().

void quitenv  ) 
 

Definition at line 334 of file sh1.c.

References close, DELETE, e, ep, env::iofd, NULL, and env::oenv.

Referenced by expand(), herein(), newenv(), onecommand(), and run().

void ronly struct var vp  ) 
 

Definition at line 626 of file sh1.c.

References letter(), and RONLY.

Referenced by doreadonly().

void runtrap int  i  ) 
 

Definition at line 499 of file sh1.c.

References nlchar(), NULL, RUN, and trap.

Referenced by execute(), leave(), and onecommand().

void setarea char *  cp,
int  a
 

Definition at line 914 of file sh1.c.

References region::area, and p.

Referenced by nameval(), and strsave().

void setdash  ) 
 

Definition at line 184 of file sh1.c.

References c, cp, flag, lookup(), m, and setval().

void setval struct var vp,
char *  val
 

Definition at line 564 of file sh1.c.

References nameval(), and NULL.

Referenced by doread(), doshift(), execute(), main(), setdash(), and setstatus().

void sig int  i  ) 
 

Definition at line 492 of file sh1.c.

References signal(), and trapset.

char* space int  n  ) 
 

Definition at line 455 of file sh1.c.

References cp, err, and getcell().

Referenced by doHELP(), generate(), getwords(), globname(), lookup(), markhere(), nameval(), newenv(), newword(), and strsave().

char* strsave char *  s,
int  a
 

Definition at line 466 of file sh1.c.

References cp, NULL, setarea(), space(), and strlen().

void warn char *  s  ) 
 

Definition at line 284 of file sh1.c.

References exstat, flag, leave(), and prs().

void xfree char *  s  ) 
 

Definition at line 482 of file sh1.c.

References DELETE.

Referenced by nameval().


Variable Documentation

struct region* areabot [static]
 

Definition at line 808 of file sh1.c.

Referenced by freearea(), garbage(), and initarea().

struct region* areanxt [static]
 

Definition at line 810 of file sh1.c.

Referenced by freecell(), garbage(), getcell(), and initarea().

struct region* areatop [static]
 

Definition at line 809 of file sh1.c.

Referenced by freearea(), garbage(), and initarea().

struct env e
 

Initial value:

{line, iostack, iostack-1,
                    (xint *)NULL, FDBASE, (struct env *)NULL}

Definition at line 21 of file sh1.c.

char* elinep = line+sizeof(line)-5
 

Definition at line 18 of file sh1.c.

Referenced by dollar(), doread(), getc(), grave(), and yylex().

char** environ
 

Definition at line 19 of file environ.c.

char* flag = flags-'a'
 

Definition at line 17 of file sh1.c.

char flags['z'-'a'+1]
 

Definition at line 16 of file sh1.c.

int heedint = 1
 

Definition at line 20 of file sh1.c.

Referenced by onintr(), and waitfor().

int inparse
 

Definition at line 15 of file sh1.c.

Referenced by onecommand(), and onintr().

int intr
 

Definition at line 14 of file sh1.c.

char* null = ""
 

Definition at line 19 of file sh1.c.

char search[] = ":/bin:/usr/bin"
 

Definition at line 30 of file sh1.c.

Referenced by __diff(), cmdcomp(), dec(), inc(), main(), SF(), and SR().

char shellname[] = "/bin/sh"
 

Definition at line 29 of file sh1.c.

Referenced by f_pshinf(), and main().


Generated on Fri Apr 14 23:06:03 2006 for minix by  doxygen 1.4.6