1 |
/* RCSid: $Id: meta.h,v 1.6 2003/07/14 22:24:00 schorsch Exp $ */ |
2 |
/* |
3 |
* Standard meta-file definitions and limits |
4 |
*/ |
5 |
#ifndef _RAD_META_H_ |
6 |
#define _RAD_META_H_ |
7 |
|
8 |
#include "copyright.h" |
9 |
|
10 |
#include <stdio.h> |
11 |
#include <stdlib.h> |
12 |
#include <ctype.h> |
13 |
|
14 |
#include "rterror.h" |
15 |
|
16 |
#ifdef __cplusplus |
17 |
extern "C" { |
18 |
#endif |
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 PPAUS '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 |
|
58 |
#ifdef _WIN32 /* XXX */ |
59 |
#define MDIR "c\\tmp\\" /* XXX we just need something to compile for now */ |
60 |
#define TTY "CON:" /* XXX this probably doesn't work */ |
61 |
#else /* XXX */ |
62 |
|
63 |
#define TDIR "/tmp/" /* directory for temporary files */ |
64 |
#ifndef MDIR |
65 |
#define MDIR "/usr/local/lib/meta/" /* directory for metafiles */ |
66 |
#endif |
67 |
#define TTY "/dev/tty" /* console name */ |
68 |
#endif |
69 |
|
70 |
#define MAXFNAME 64 /* maximum file name length */ |
71 |
|
72 |
#define XYSIZE (1<<14) /* metafile coordinate size */ |
73 |
|
74 |
#ifndef max |
75 |
#define max(x, y) ((x) > (y) ? (x) : (y)) |
76 |
#endif |
77 |
#ifndef min |
78 |
#define min(x, y) ((x) < (y) ? (x) : (y)) |
79 |
#endif |
80 |
|
81 |
#define abs(x) ((x) < 0 ? -(x) : (x)) |
82 |
|
83 |
#define iscom(c) (comndx(c) != -1) |
84 |
#define isglob(c) isupper(c) |
85 |
#define isprim(c) islower(c) |
86 |
|
87 |
#define WIDTH(wspec) ((wspec)==0 ? 0 : 12*(1<<(wspec))) |
88 |
#define CONV(coord, size) ((int)(((long)(coord)*(size))>>14)) |
89 |
#define ICONV(dcoord, size) ((int)(((long)(dcoord)<<14)/(size))) |
90 |
|
91 |
#define XMN 0 /* index in xy array for xmin */ |
92 |
#define YMN 1 /* index in xy array for ymin */ |
93 |
#define XMX 2 /* index in xy array for xmax */ |
94 |
#define YMX 3 /* index in xy array for ymax */ |
95 |
|
96 |
|
97 |
/* |
98 |
* Structure definitions for primitives |
99 |
*/ |
100 |
|
101 |
struct primitive { /* output primitive */ |
102 |
short com, /* command (0 - 127) */ |
103 |
arg0; /* first argument (1 byte) */ |
104 |
int xy[4]; /* extent=(xmin,ymin,xmax,ymax) */ |
105 |
char *args; /* additional arguments */ |
106 |
struct primitive *pnext; /* next primitive */ |
107 |
}; |
108 |
|
109 |
typedef struct primitive PRIMITIVE; |
110 |
|
111 |
struct plist { /* list of primitives */ |
112 |
PRIMITIVE *ptop, *pbot; |
113 |
}; |
114 |
|
115 |
typedef struct plist PLIST; |
116 |
|
117 |
|
118 |
/* |
119 |
* External declarations |
120 |
*/ |
121 |
|
122 |
char *savestr(); |
123 |
|
124 |
PRIMITIVE *pop(); |
125 |
|
126 |
FILE *efopen(), *mfopen(); |
127 |
|
128 |
extern char coms[]; |
129 |
extern char errmsg[]; |
130 |
extern char *progname; |
131 |
|
132 |
/* expand.c */ |
133 |
extern void expand(FILE *infp, short *exlist); |
134 |
/* palloc.c */ |
135 |
extern PRIMITIVE *palloc(void); |
136 |
extern void pfree(register PRIMITIVE *p); |
137 |
extern void plfree(register PLIST *pl); |
138 |
/* sort.c */ |
139 |
extern void sort(FILE *infp, int (*pcmp)()); |
140 |
extern void pmergesort(FILE *fi[], int nf, PLIST *pl, int (*pcmp)(), FILE *ofp); |
141 |
/* metacalls.c */ |
142 |
extern void mdraw(int x, int y); |
143 |
extern void msegment(int xmin, int ymin, int xmax, int ymax, char *sname, |
144 |
int d, int thick, int color); |
145 |
extern void mvstr(int xmin, int ymin, int xmax, int ymax, char *s, |
146 |
int d, int thick, int color); |
147 |
extern void mtext(int x, int y, char *s, int cpi, int color); |
148 |
extern void mpoly(int x, int y, int border, int pat, int color); |
149 |
extern void mtriangle(int xmin, int ymin, int xmax, int ymax, |
150 |
int d, int pat, int color); |
151 |
extern void mrectangle(int xmin, int ymin, int xmax, int ymax, |
152 |
int pat, int color); |
153 |
extern void mline(int x, int y, int type, int thick, int color); |
154 |
extern void mcloseseg(void); |
155 |
extern void mopenseg(char *sname); |
156 |
extern void msetpat(int pn, char *pat); |
157 |
extern void minclude(char *fname); |
158 |
extern void mdone(void); |
159 |
extern void mendpage(void); |
160 |
|
161 |
|
162 |
#ifdef __cplusplus |
163 |
} |
164 |
#endif |
165 |
#endif /* _RAD_META_H_ */ |
166 |
|