1 |
/* RCSid: $Id: meta.h,v 1.1 2003/02/22 02:07:26 greg Exp $ */ |
2 |
/* |
3 |
* Standard meta-file definitions and limits |
4 |
*/ |
5 |
#ifndef _RAD_META_H_ |
6 |
#define _RAD_META_H_ |
7 |
#ifdef __cplusplus |
8 |
extern "C" { |
9 |
#endif |
10 |
|
11 |
#include "copyright.h" |
12 |
|
13 |
#include <stdio.h> |
14 |
#include <stdlib.h> |
15 |
#include <malloc.h> |
16 |
|
17 |
#include <ctype.h> |
18 |
|
19 |
|
20 |
#define TRUE 1 |
21 |
#define FALSE 0 |
22 |
|
23 |
#define PEOF 'F' /* end of file global */ |
24 |
#define PEOP 'E' /* end of page global */ |
25 |
#define PPAUSE 'P' /* pause global */ |
26 |
#define PDRAW 'D' /* draw global */ |
27 |
#define POPEN 'O' /* open segment */ |
28 |
#define PCLOSE 'C' /* close segment */ |
29 |
#define PSET 'S' /* set global */ |
30 |
#define PUNSET 'U' /* unset global */ |
31 |
#define PRESET 'R' /* reset global to default */ |
32 |
#define PINCL 'I' /* include file */ |
33 |
|
34 |
#define PLSEG 'l' /* line segment command */ |
35 |
#define PRFILL 'r' /* rectangle fill command */ |
36 |
#define PTFILL 't' /* triangle fill command */ |
37 |
#define PMSTR 'm' /* matrix string command */ |
38 |
#define PVSTR 'v' /* vector string command */ |
39 |
#define PSEG 's' /* print segment command */ |
40 |
#define PPFILL 'p' /* polygon fill command */ |
41 |
|
42 |
#define NCOMMANDS 17 /* number of commands */ |
43 |
|
44 |
#define COML "lrtmsvpOCESURPDIF" /* command letters */ |
45 |
|
46 |
#define ADELIM '`' /* additional argument delimiter */ |
47 |
#define CDELIM '#' /* comment delimiter */ |
48 |
|
49 |
#define MAXARGS 512 /* maximum # of arguments for primitive */ |
50 |
|
51 |
#define SALL 0 /* set all */ |
52 |
#define SPAT0 04 /* set pattern 0 */ |
53 |
#define SPAT1 05 /* set pattern 1 */ |
54 |
#define SPAT2 06 /* set pattern 2 */ |
55 |
#define SPAT3 07 /* set pattern 3 */ |
56 |
|
57 |
#define SYSTEM 0 /* system error, internal, fatal */ |
58 |
#define USER 1 /* user error, fatal */ |
59 |
#define WARNING 2 /* user error, not fatal */ |
60 |
|
61 |
#ifdef UNIX |
62 |
#define TDIR "/tmp/" /* directory for temporary files */ |
63 |
#ifndef MDIR |
64 |
#define MDIR "/usr/local/lib/meta/" /* directory for metafiles */ |
65 |
#endif |
66 |
#define TTY "/dev/tty" /* console name */ |
67 |
#endif |
68 |
|
69 |
#ifdef MAC |
70 |
#define TDIR "5:tmp/" /* directory for temporary files */ |
71 |
#define MDIR "/meta/" /* directory for metafiles */ |
72 |
#define TTY ".con" /* console name */ |
73 |
#endif |
74 |
|
75 |
#ifdef CPM |
76 |
#define TDIR "0/" /* directory for temporary files */ |
77 |
#define MDIR "0/" /* directory for metafiles */ |
78 |
#define TTY "CON:" /* console name */ |
79 |
#endif |
80 |
|
81 |
#ifdef _WIN32 /* XXX */ |
82 |
#define MDIR "c\\tmp\\" /* XXX we just need something to compile for now */ |
83 |
#define TTY "CON:" /* XXX this probably doesn't work */ |
84 |
#endif /* XXX */ |
85 |
|
86 |
#define MAXFNAME 64 /* maximum file name length */ |
87 |
|
88 |
#define XYSIZE (1<<14) /* metafile coordinate size */ |
89 |
|
90 |
#ifndef max |
91 |
#define max(x, y) ((x) > (y) ? (x) : (y)) |
92 |
#endif |
93 |
#ifndef min |
94 |
#define min(x, y) ((x) < (y) ? (x) : (y)) |
95 |
#endif |
96 |
|
97 |
#define abs(x) ((x) < 0 ? -(x) : (x)) |
98 |
|
99 |
#define iscom(c) (comndx(c) != -1) |
100 |
#define isglob(c) isupper(c) |
101 |
#define isprim(c) islower(c) |
102 |
|
103 |
#define WIDTH(wspec) ((wspec)==0 ? 0 : 12*(1<<(wspec))) |
104 |
#define CONV(coord, size) ((int)(((long)(coord)*(size))>>14)) |
105 |
#define ICONV(dcoord, size) ((int)(((long)(dcoord)<<14)/(size))) |
106 |
|
107 |
#define XMN 0 /* index in xy array for xmin */ |
108 |
#define YMN 1 /* index in xy array for ymin */ |
109 |
#define XMX 2 /* index in xy array for xmax */ |
110 |
#define YMX 3 /* index in xy array for ymax */ |
111 |
|
112 |
|
113 |
/* |
114 |
* Structure definitions for primitives |
115 |
*/ |
116 |
|
117 |
struct primitive { /* output primitive */ |
118 |
short com, /* command (0 - 127) */ |
119 |
arg0; /* first argument (1 byte) */ |
120 |
int xy[4]; /* extent=(xmin,ymin,xmax,ymax) */ |
121 |
char *args; /* additional arguments */ |
122 |
struct primitive *pnext; /* next primitive */ |
123 |
}; |
124 |
|
125 |
typedef struct primitive PRIMITIVE; |
126 |
|
127 |
struct plist { /* list of primitives */ |
128 |
PRIMITIVE *ptop, *pbot; |
129 |
}; |
130 |
|
131 |
typedef struct plist PLIST; |
132 |
|
133 |
|
134 |
/* |
135 |
* External declarations |
136 |
*/ |
137 |
|
138 |
char *savestr(); |
139 |
|
140 |
PRIMITIVE *pop(); |
141 |
|
142 |
FILE *efopen(), *mfopen(); |
143 |
|
144 |
extern char coms[]; |
145 |
extern char errmsg[]; |
146 |
extern char *progname; |
147 |
|
148 |
/* expand.c */ |
149 |
extern void expand(FILE *infp, short *exlist); |
150 |
/* palloc.c */ |
151 |
extern PRIMITIVE *palloc(void); |
152 |
extern void pfree(register PRIMITIVE *p); |
153 |
extern void plfree(register PLIST *pl); |
154 |
/* sort.c */ |
155 |
extern void sort(FILE *infp, int (*pcmp)()); |
156 |
extern void mergesort(FILE *fi[], int nf, PLIST *pl, int (*pcmp)(), FILE *ofp); |
157 |
/* metacalls.c */ |
158 |
extern void mdraw(int x, int y); |
159 |
extern void msegment(int xmin, int ymin, int xmax, int ymax, char *sname, |
160 |
int d, int thick, int color); |
161 |
extern void mvstr(int xmin, int ymin, int xmax, int ymax, char *s, |
162 |
int d, int thick, int color); |
163 |
extern void mtext(int x, int y, char *s, int cpi, int color); |
164 |
extern void mpoly(int x, int y, int border, int pat, int color); |
165 |
extern void mtriangle(int xmin, int ymin, int xmax, int ymax, |
166 |
int d, int pat, int color); |
167 |
extern void mrectangle(int xmin, int ymin, int xmax, int ymax, |
168 |
int pat, int color); |
169 |
extern void mline(int x, int y, int type, int thick, int color); |
170 |
extern void mcloseseg(void); |
171 |
extern void mopenseg(char *sname); |
172 |
extern void msetpat(int pn, char *pat); |
173 |
extern void minclude(char *fname); |
174 |
extern void mdone(void); |
175 |
extern void mendpage(void); |
176 |
|
177 |
|
178 |
#ifdef __cplusplus |
179 |
} |
180 |
#endif |
181 |
#endif /* _RAD_META_H_ */ |
182 |
|