aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/grap/grap.h
blob: b392539c0cfac4d38b5705f5bf64dfb20e3f9d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
extern	char	errbuf[200];

#undef	sprintf	/* Snow Leopard */

#define	ERROR	sprintf(errbuf,
#define	FATAL	), yyerror(errbuf), exit(1)
#define	WARNING	), yyerror(errbuf)

#define	dprintf	if(dbg)printf

#define	String	01
#define	Macro	02
#define	File	04
#define	Char	010
#define	Thru	020
#define	Free	040

#define	MARGIN	0.07	/* default margin around data */
#define	SLOP	1.001	/* slop for limits of for loops */
#define	FRAMEWID 3	/* default width for boxes and ellipses */
#define	FRAMEHT	2	/* default height and line length */
#define	TICKLEN	0.1

#define	MAXNUM	200

#define	XFLAG	01
#define	YFLAG	02

#define	INTICK	01
#define	OUTICK	02

#define	BOT	01
#define	TOP	02
#define	RIGHT	04
#define	LEFT	010

#define	RJUST	01
#define	LJUST	02
#define	ABOVE	04
#define	BELOW	010

typedef struct infile {
	FILE	*fin;
	char	*fname;
	int	lineno;
} Infile;

typedef struct {	/* input source */
	int	type;	/* Macro, String, File */
	char	*sp;	/* if String or Macro */
} Src;

extern	Src	src[], *srcp;	/* input source stack */

#define	MAXARGS	100
typedef struct {	/* argument stack */
	char	*argstk[MAXARGS];	/* pointers to args */
	char	*argval;	/* points to space containing args */
} Arg;

extern	Infile	infile[10];
extern	Infile	*curfile;

typedef struct {
	struct obj *obj;
	double	x, y;
} Point;

typedef struct attr {	/* e.g., DASH 1.1 or "..." rjust size *.5 */
	int	type;
	double	fval;
	char	*sval;
	int	just;	/* justification, for STRING type */
	int	op;	/* optional operator, ditto */
	struct attr *next;
} Attr;

typedef struct obj {	/* a name and its properties */
	char	*name;
	char	*val;	/* body of define, etc. */
	double	fval;	/* if a numeric variable */
	Point	pt;	/* usually for max and min */
	Point	pt1;
	int	type;	/* NAME, DEFNAME, ... */
	int	first;	/* 1 after 1st item seen */
	int	coord;	/* 1 if coord system specified for this name */
	int	log;	/* x, y, or z (= x+y) */
	Attr	*attr;	/* DASH, etc., for now */
	struct obj *next;
} Obj;

typedef union {		/* the yacc stack type */
	int	i;
	char	*p;
	double	f;
	Point	pt;
	Obj	*op;
	Attr	*ap;
} YYSTYPE;

extern	YYSTYPE	yylval, yyval;

extern	int	dbg;

extern	int	ntext;
extern	double	num[MAXNUM];
extern	int	nnum;
extern	int	ntick, tside;

extern	char	*tostring(char *);
extern char *grow(char *, char *, int, int);

extern	int	lineno;
extern	int	synerr;
extern	int	codegen;
extern	char	*tempfile;
extern	FILE	*tfd;

extern	Point	ptmin, ptmax;

extern	char	*dflt_coord;
extern	char	*curr_coord;
extern	int	ncoord;
extern	int	auto_x;
extern	double	margin;
extern	int	autoticks;
extern	int	pointsize, ps_set;


#define	logit(x) (x) = log10(x)
#define	Log10(x) errcheck(log10(x), "log")
#define	Exp(x)	errcheck(exp(x), "exp")
#define	Sqrt(x)	errcheck(sqrt(x), "sqrt")

#define	min(x,y)	(((x) <= (y)) ? (x) : (y))
#define	max(x,y)	(((x) >= (y)) ? (x) : (y))

extern	char	*unsharp(char*);

extern	void	yyerror(char *);
extern void coord_x(Point);
extern void coord_y(Point);
extern void coordlog(int);
extern void coord(Obj *);
extern void resetcoord(Obj *);
extern void savenum(int, double);
extern void setjust(int);
extern void setsize(int, double);
extern void range(Point);
extern void halfrange(Obj *, int, double);
extern Obj *lookup(char *, int);
extern double getvar(Obj *);
extern double setvar(Obj *, double);
extern Point makepoint(Obj *, double, double);
extern Attr *makefattr(int, double);
extern Attr *makesattr(char *);
extern Attr *makeattr(int, double, char *, int, int);
extern Attr *addattr(Attr *, Attr *);
extern void freeattr(Attr *);
extern char *slprint(Attr *);
extern char *juststr(int);
extern char *sprntf(char *, Attr *);
extern void forloop(Obj *, double, double, int, double, char *);
extern void nextfor(void);
extern void endfor(void);
extern char *ifstat(double, char *, char *);
extern void frame(void);
extern void frameht(double);
extern void framewid(double);
extern void frameside(int, Attr *);
extern void pushsrc(int, char *);
extern void popsrc(void);
extern void definition(char *);
extern char *delimstr(char *);
extern int baldelim(int, char *);
extern void dodef(Obj *);
extern int getarg(char *);
extern int input(void);
extern int nextchar(void);
extern void do_thru(void);
extern int unput(int);
extern void pbstr(char *);
extern double errcheck(double, char *);
extern void yyerror(char *);
extern void eprint(void);
extern int yywrap(void);
extern void copyfile(char *);
extern void copydef(Obj *);
extern Obj *copythru(char *);
extern char *addnewline(char *);
extern void copyuntil(char *);
extern void copy(void);
extern void shell_init(void);
extern void shell_text(char *);
extern void shell_exec(void);
extern void labelwid(double);
extern void labelmove(int, double);
extern void label(int, Attr *);
extern void lab_adjust(void);
extern char *sizeit(Attr *);
extern void line(int, Point, Point, Attr *);
extern void circle(double, Point);
extern char *xyname(Point);
extern void pic(char *);
extern void numlist(void);
extern void plot(Attr *, Point);
extern void plotnum(double, char *, Point);
extern void drawdesc(int, Obj *, Attr *, char *);
extern void next(Obj *, Point, Attr *);
#define print grapprint
extern void print(void);
extern void endstat(void);
extern void graph(char *);
extern void setup(void);
extern void do_first(void);
extern void reset(void);
extern void opentemp(void);
extern void savetick(double, char *);
extern void dflt_tick(double);
extern void tickside(int);
extern void tickoff(int);
extern void gridtickoff(void);
extern void setlist(void);
extern void tickdir(int, double, int);
extern void ticks(void);
extern double modfloor(double, double);
extern double modceil(double, double);
extern void do_autoticks(Obj *);
extern void logtick(double, double, double);
extern Obj *setauto(void);
extern void autoside(Obj *, int);
extern void autolog(Obj *, int);
extern void iterator(double, double, int, double, char *);
extern void ticklist(Obj *, int);
extern void print_ticks(int, int, Obj *, char *, char *);
extern void maketick(int, char *, int, int, double, char *, char *, char *);
extern void griddesc(Attr *);
extern void gridlist(Obj *);
extern char *desc_str(Attr *);
extern int sidelog(int, int);

extern	Obj	*objlist;