home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / src / cmd / sh / defs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1979-01-12  |  4.5 KB  |  288 lines

  1. #
  2. /*
  3.  *    UNIX shell
  4.  */
  5.  
  6. /* error exits from various parts of shell */
  7. #define ERROR    1
  8. #define SYNBAD    2
  9. #define SIGFAIL 3
  10. #define SIGFLG    0200
  11.  
  12. /* command tree */
  13. #define FPRS    020
  14. #define FINT    040
  15. #define FAMP    0100
  16. #define FPIN    0400
  17. #define FPOU    01000
  18. #define FPCL    02000
  19. #define FCMD    04000
  20. #define COMMSK    017
  21.  
  22. #define TCOM    0
  23. #define TPAR    1
  24. #define TFIL    2
  25. #define TLST    3
  26. #define TIF    4
  27. #define TWH    5
  28. #define TUN    6
  29. #define TSW    7
  30. #define TAND    8
  31. #define TORF    9
  32. #define TFORK    10
  33. #define TFOR    11
  34.  
  35. /* execute table */
  36. #define SYSSET    1
  37. #define SYSCD    2
  38. #define SYSEXEC    3
  39. #define SYSLOGIN 4
  40. #define SYSTRAP    5
  41. #define SYSEXIT    6
  42. #define SYSSHFT 7
  43. #define SYSWAIT    8
  44. #define SYSCONT 9
  45. #define SYSBREAK 10
  46. #define SYSEVAL 11
  47. #define SYSDOT    12
  48. #define SYSRDONLY 13
  49. #define SYSTIMES 14
  50. #define SYSXPORT 15
  51. #define SYSNULL 16
  52. #define SYSREAD 17
  53. #define SYSTST    18
  54. #define    SYSUMASK    19
  55.  
  56. /* used for input and output of shell */
  57. #define INIO 10
  58. #define OTIO 11
  59.  
  60. /*io nodes*/
  61. #define USERIO    10
  62. #define IOUFD    15
  63. #define IODOC    16
  64. #define IOPUT    32
  65. #define IOAPP    64
  66. #define IOMOV    128
  67. #define IORDW    256
  68. #define INPIPE    0
  69. #define OTPIPE    1
  70.  
  71. /* arg list terminator */
  72. #define ENDARGS    0
  73.  
  74. #include    "mac.h"
  75. #include    "mode.h"
  76. #include    "name.h"
  77.  
  78.  
  79. /* result type declarations */
  80. #define alloc malloc
  81. ADDRESS        alloc();
  82. VOID        addblok();
  83. STRING        make();
  84. STRING        movstr();
  85. TREPTR        cmd();
  86. TREPTR        makefork();
  87. NAMPTR        lookup();
  88. VOID        setname();
  89. VOID        setargs();
  90. DOLPTR        useargs();
  91. REAL        expr();
  92. STRING        catpath();
  93. STRING        getpath();
  94. STRING        *scan();
  95. STRING        mactrim();
  96. STRING        macro();
  97. STRING        execs();
  98. VOID        await();
  99. VOID        post();
  100. STRING        copyto();
  101. VOID        exname();
  102. STRING        staknam();
  103. VOID        printnam();
  104. VOID        printflg();
  105. VOID        prs();
  106. VOID        prc();
  107. VOID        getenv();
  108. STRING        *setenv();
  109.  
  110. #define attrib(n,f)    (n->namflg |= f)
  111. #define round(a,b)    (((int)((ADR(a)+b)-1))&~((b)-1))
  112. #define closepipe(x)    (close(x[INPIPE]), close(x[OTPIPE]))
  113. #define eq(a,b)        (cf(a,b)==0)
  114. #define max(a,b)    ((a)>(b)?(a):(b))
  115. #define assert(x)    ;
  116.  
  117. /* temp files and io */
  118. UFD        output;
  119. INT        ioset;
  120. IOPTR        iotemp;        /* files to be deleted sometime */
  121. IOPTR        iopend;        /* documents waiting to be read at NL */
  122.  
  123. /* substitution */
  124. INT        dolc;
  125. STRING        *dolv;
  126. DOLPTR        argfor;
  127. ARGPTR        gchain;
  128.  
  129. /* stack */
  130. #define        BLK(x)    ((BLKPTR)(x))
  131. #define        BYT(x)    ((BYTPTR)(x))
  132. #define        STK(x)    ((STKPTR)(x))
  133. #define        ADR(x)    ((char*)(x))
  134.  
  135. /* stak stuff */
  136. #include    "stak.h"
  137.  
  138. /* string constants */
  139. MSG        atline;
  140. MSG        readmsg;
  141. MSG        colon;
  142. MSG        minus;
  143. MSG        nullstr;
  144. MSG        sptbnl;
  145. MSG        unexpected;
  146. MSG        endoffile;
  147. MSG        synmsg;
  148.  
  149. /* name tree and words */
  150. SYSTAB        reserved;
  151. INT        wdval;
  152. INT        wdnum;
  153. ARGPTR        wdarg;
  154. INT        wdset;
  155. BOOL        reserv;
  156.  
  157. /* prompting */
  158. MSG        stdprompt;
  159. MSG        supprompt;
  160. MSG        profile;
  161.  
  162. /* built in names */
  163. NAMNOD        fngnod;
  164. NAMNOD        ifsnod;
  165. NAMNOD        homenod;
  166. NAMNOD        mailnod;
  167. NAMNOD        pathnod;
  168. NAMNOD        ps1nod;
  169. NAMNOD        ps2nod;
  170.  
  171. /* special names */
  172. MSG        flagadr;
  173. STRING        cmdadr;
  174. STRING        exitadr;
  175. STRING        dolladr;
  176. STRING        pcsadr;
  177. STRING        pidadr;
  178.  
  179. MSG        defpath;
  180.  
  181. /* names always present */
  182. MSG        mailname;
  183. MSG        homename;
  184. MSG        pathname;
  185. MSG        fngname;
  186. MSG        ifsname;
  187. MSG        ps1name;
  188. MSG        ps2name;
  189.  
  190. /* transput */
  191. CHAR        tmpout[];
  192. STRING        tmpnam;
  193. INT        serial;
  194. #define        TMPNAM 7
  195. FILE        standin;
  196. #define input    (standin->fdes)
  197. #define eof    (standin->feof)
  198. INT        peekc;
  199. STRING        comdiv;
  200. MSG        devnull;
  201.  
  202. /* flags */
  203. #define        noexec    01
  204. #define        intflg    02
  205. #define        prompt    04
  206. #define        setflg    010
  207. #define        errflg    020
  208. #define        ttyflg    040
  209. #define        forked    0100
  210. #define        oneflg    0200
  211. #define        rshflg    0400
  212. #define        waiting    01000
  213. #define        stdflg    02000
  214. #define        execpr    04000
  215. #define        readpr    010000
  216. #define        keyflg    020000
  217. INT        flags;
  218.  
  219. /* error exits from various parts of shell */
  220. #include    <setjmp.h>
  221. jmp_buf        subshell;
  222. jmp_buf        errshell;
  223.  
  224. /* fault handling */
  225. #include    "brkincr.h"
  226. POS        brkincr;
  227.  
  228. #define MINTRAP    0
  229. #define MAXTRAP    17
  230.  
  231. #define INTR    2
  232. #define QUIT    3
  233. #define MEMF    11
  234. #define ALARM    14
  235. #define KILL    15
  236. #define TRAPSET    2
  237. #define SIGSET    4
  238. #define SIGMOD    8
  239.  
  240. VOID        fault();
  241. BOOL        trapnote;
  242. STRING        trapcom[];
  243. BOOL        trapflg[];
  244.  
  245. /* name tree and words */
  246. STRING        *environ;
  247. CHAR        numbuf[];
  248. MSG        export;
  249. MSG        readonly;
  250.  
  251. /* execflgs */
  252. INT        exitval;
  253. BOOL        execbrk;
  254. INT        loopcnt;
  255. INT        breakcnt;
  256.  
  257. /* messages */
  258. MSG        mailmsg;
  259. MSG        coredump;
  260. MSG        badopt;
  261. MSG        badparam;
  262. MSG        badsub;
  263. MSG        nospace;
  264. MSG        notfound;
  265. MSG        badtrap;
  266. MSG        baddir;
  267. MSG        badshift;
  268. MSG        illegal;
  269. MSG        restricted;
  270. MSG        execpmsg;
  271. MSG        notid;
  272. MSG        wtfailed;
  273. MSG        badcreate;
  274. MSG        piperr;
  275. MSG        badopen;
  276. MSG        badnum;
  277. MSG        arglist;
  278. MSG        txtbsy;
  279. MSG        toobig;
  280. MSG        badexec;
  281. MSG        notfound;
  282. MSG        badfile;
  283.  
  284. address    end[];
  285.  
  286. #include    "ctype.h"
  287.  
  288.