8672 proc_t changes broke genunix dmods and walker
[unleashed.git] / usr / src / cmd / oawk / awk.def
blob109214013b16e034f27f12eecfc3ca0b4fc04c50
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright (c) 1996, by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include <locale.h>
29 #include <euc.h>
30 #include <widec.h>
31 #define xfree(a) { if (a!=NULL) { yfree(a); a=NULL; } }
32 #define yfree free
33 #ifdef DEBUG
34 #define dprintf if (dbg) printf
35 #else
36 # define dprintf(x1, x2, x3, x4)
37 #endif
38 #define WC_VERY_SMALL ((wchar_t) 0x0001)
39 #define WC_VERY_LARGE ((wchar_t) ~0x0000)
40 typedef double awkfloat;
42 extern wchar_t **FS;
43 extern wchar_t **RS;
44 extern wchar_t **ORS;
45 extern wchar_t **OFS;
46 extern wchar_t **OFMT;
47 extern awkfloat *NR;
48 extern awkfloat *NF;
49 extern wchar_t **FILENAME;
51 extern wchar_t record[];
52 extern wchar_t L_NULL[];
53 extern int dbg;
54 extern long long lineno;
55 extern int errorflag;
56 extern int donefld; /* 1 if record broken into fields */
57 extern int donerec; /* 1 if record is valid (no fld has changed */
59 /* CELL: all information about a variable or constant */
61 typedef struct val {
62 char ctype; /* CELL, BOOL, JUMP, etc. */
63 char csub; /* subtype of ctype */
64 wchar_t *nval; /* name, for variables only */
65 wchar_t *sval; /* string value */
66 awkfloat fval; /* value as number */
67 unsigned tval; /* type info */
68 struct val *nextval; /* ptr to next if chained */
69 } CELL;
71 extern CELL *symtab[];
72 extern CELL *setsymtab(), *lookup(), **makesymtab();
74 extern CELL *recloc; /* location of input record */
75 extern CELL *nrloc; /* NR */
76 extern CELL *nfloc; /* NF */
77 extern CELL *maxmfld; /* pointer to CELL for maximum field assigned to */
79 /* CELL.tval values: */
80 #define STR 01 /* string value is valid */
81 #define NUM 02 /* number value is valid */
82 #define FLD 04 /* FLD means don't free string space */
83 #define CON 010 /* this is a constant */
84 #define ARR 020 /* this is an array */
86 awkfloat setfval(), getfval();
87 wchar_t *setsval(), *getsval();
88 wchar_t *tostring(), *tokname();
89 char *toeuccode();
90 double log(), sqrt(), exp(), atof();
92 /* function types */
93 #define FLENGTH 1
94 #define FSQRT 2
95 #define FEXP 3
96 #define FLOG 4
97 #define FINT 5
99 #define BOTCH 1
100 typedef struct nd {
101 char ntype;
102 char subtype;
103 struct nd *nnext;
104 int nobj;
105 struct nd *narg[BOTCH]; /* C won't take a zero length array */
106 } NODE;
108 extern NODE *winner;
110 /* ctypes */
111 #define OCELL 1
112 #define OBOOL 2
113 #define OJUMP 3
115 /* CELL subtypes */
116 #define CCON 5
117 #define CTEMP 4
118 #define CNAME 3
119 #define CVAR 2
120 #define CFLD 1
122 /* bool subtypes */
123 #define BTRUE 1
124 #define BFALSE 2
126 /* jump subtypes */
127 #define JEXIT 1
128 #define JNEXT 2
129 #define JBREAK 3
130 #define JCONT 4
132 /* node types */
133 #define NVALUE 1
134 #define NSTAT 2
135 #define NEXPR 3
137 extern CELL *(*proctab[])();
138 extern int pairstack[], paircnt;
140 #define cantexec(n) (n->ntype == NVALUE)
141 #define notlegal(n) (n <= FIRSTTOKEN || n >= LASTTOKEN || \
142 proctab[n-FIRSTTOKEN]== nullproc)
143 #define isexpr(n) (n->ntype == NEXPR)
144 #define isjump(n) (n->ctype == OJUMP)
145 #define isexit(n) (n->ctype == OJUMP && n->csub == JEXIT)
146 #define isbreak(n) (n->ctype == OJUMP && n->csub == JBREAK)
147 #define iscont(n) (n->ctype == OJUMP && n->csub == JCONT)
148 #define isnext(n) (n->ctype == OJUMP && n->csub == JNEXT)
149 #define isstr(n) (n->tval & STR)
150 #define isnum(n) (n->tval & NUM)
151 #define istrue(n) (n->ctype == OBOOL && n->csub == BTRUE)
152 #define istemp(n) (n->ctype == OCELL && n->csub == CTEMP)
153 #define isfld(n) (!donefld && n->csub==CFLD && n->ctype==OCELL && \
154 n->nval==0)
155 #define isrec(n) (donefld && n->csub==CFLD && n->ctype==OCELL && \
156 n->nval!=0)
157 extern CELL *nullproc();
158 extern CELL *relop();
160 #define MAXSYM 50
161 #define HAT 0177 /* matches ^ in regular expr */
162 /* watch out for mach dep */
164 * The code set number can be knew from actual character, but "b.c"
165 * will use some pseudo codes. And that psedo code will not confirm
166 * to rule of real code set.
168 typedef struct ccl_chars {
169 unsigned short cc_ns; /* Code set Number */
170 wchar_t cc_cs; /* Actual character */
171 unsigned short cc_ne;
172 wchar_t cc_ce;
173 } ccl_chars_t;
175 ccl_chars_t *cclenter();
177 extern void error();