+struct globals {
+ struct env global_env;
+ struct ioarg temparg; // = { .afid = AFID_NOBUF }; /* temporary for PUSHIO */
+ unsigned bufid; // = AFID_ID; /* buffer id counter */
+ char ourtrap[_NSIG + 1];
+ char *trap[_NSIG + 1];
+ struct iobuf sharedbuf; /* in main(): set to { AFID_NOBUF } */
+ struct iobuf mainbuf; /* in main(): set to { AFID_NOBUF } */
+ struct ioarg ioargstack[NPUSH];
+ /*
+ * flags:
+ * -e: quit on error
+ * -k: look for name=value everywhere on command line
+ * -n: no execution
+ * -t: exit after reading and executing one command
+ * -v: echo as read
+ * -x: trace
+ * -u: unset variables net diagnostic
+ */
+ char flags['z' - 'a' + 1];
+ char filechar_cmdbuf[BUFSIZ];
+ char line[LINELIM];
+ char child_cmd[LINELIM];
+
+ struct io iostack[NPUSH];
+
+ char grave__var_name[LINELIM];
+ char grave__alt_value[LINELIM];
+};
+
+#define G (*ptr_to_globals)
+#define global_env (G.global_env )
+#define temparg (G.temparg )
+#define bufid (G.bufid )
+#define ourtrap (G.ourtrap )
+#define trap (G.trap )
+#define sharedbuf (G.sharedbuf )
+#define mainbuf (G.mainbuf )
+#define ioargstack (G.ioargstack )
+/* this looks weird, but is OK ... we index FLAG with 'a'...'z' */
+#define FLAG (G.flags - 'a' )
+#define filechar_cmdbuf (G.filechar_cmdbuf)
+#define line (G.line )
+#define child_cmd (G.child_cmd )
+#define iostack (G.iostack )
+#define INIT_G() do { \
+ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
+ global_env.linep = line; \
+ global_env.iobase = iostack; \
+ global_env.iop = iostack - 1; \
+ global_env.iofd = FDBASE; \
+ temparg.afid = AFID_NOBUF; \
+ bufid = AFID_ID; \
+} while (0)
+