| 1 |
/* RCSid: $Id: meta.h,v 1.9 2003/11/15 02:13:37 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 2048 /* maximum argument string 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 |
#define TDIR "C:\\tmp\\" /* XXX we just need something to compile for now */ |
| 62 |
#else /* XXX */ |
| 63 |
|
| 64 |
#define TDIR "/tmp/" /* directory for temporary files */ |
| 65 |
#ifndef MDIR |
| 66 |
#define MDIR "/usr/local/lib/meta/" /* directory for metafiles */ |
| 67 |
#endif |
| 68 |
#define TTY "/dev/tty" /* console name */ |
| 69 |
#endif |
| 70 |
|
| 71 |
#define MAXFNAME 64 /* maximum file name length */ |
| 72 |
|
| 73 |
#define XYSIZE (1<<14) /* metafile coordinate size */ |
| 74 |
|
| 75 |
#ifndef max |
| 76 |
#define max(x, y) ((x) > (y) ? (x) : (y)) |
| 77 |
#endif |
| 78 |
#ifndef min |
| 79 |
#define min(x, y) ((x) < (y) ? (x) : (y)) |
| 80 |
#endif |
| 81 |
|
| 82 |
#define abs(x) ((x) < 0 ? -(x) : (x)) |
| 83 |
|
| 84 |
#define iscom(c) (comndx(c) != -1) |
| 85 |
#define isglob(c) isupper(c) |
| 86 |
#define isprim(c) islower(c) |
| 87 |
|
| 88 |
#define WIDTH(wspec) ((wspec)==0 ? 0 : 12*(1<<(wspec))) |
| 89 |
#define CONV(coord, size) ((int)(((long)(coord)*(size))>>14)) |
| 90 |
#define ICONV(dcoord, size) ((int)(((long)(dcoord)<<14)/(size))) |
| 91 |
|
| 92 |
#define XMN 0 /* index in xy array for xmin */ |
| 93 |
#define YMN 1 /* index in xy array for ymin */ |
| 94 |
#define XMX 2 /* index in xy array for xmax */ |
| 95 |
#define YMX 3 /* index in xy array for ymax */ |
| 96 |
|
| 97 |
|
| 98 |
/* |
| 99 |
* Structure definitions for primitives |
| 100 |
*/ |
| 101 |
|
| 102 |
struct primitive { /* output primitive */ |
| 103 |
short com, /* command (0 - 127) */ |
| 104 |
arg0; /* first argument (1 byte) */ |
| 105 |
int xy[4]; /* extent=(xmin,ymin,xmax,ymax) */ |
| 106 |
char *args; /* additional arguments */ |
| 107 |
struct primitive *pnext; /* next primitive */ |
| 108 |
}; |
| 109 |
|
| 110 |
typedef struct primitive PRIMITIVE; |
| 111 |
|
| 112 |
struct plist { /* list of primitives */ |
| 113 |
PRIMITIVE *ptop, *pbot; |
| 114 |
}; |
| 115 |
|
| 116 |
typedef struct plist PLIST; |
| 117 |
|
| 118 |
|
| 119 |
/* |
| 120 |
* External declarations |
| 121 |
*/ |
| 122 |
|
| 123 |
char *savestr(); |
| 124 |
|
| 125 |
PRIMITIVE *pop(); |
| 126 |
|
| 127 |
FILE *efopen(), *mfopen(); |
| 128 |
|
| 129 |
extern char coms[]; |
| 130 |
extern char errmsg[]; |
| 131 |
extern char *progname; |
| 132 |
|
| 133 |
/* expand.c */ |
| 134 |
extern void expand(FILE *infp, short *exlist); |
| 135 |
/* palloc.c */ |
| 136 |
extern PRIMITIVE *palloc(void); |
| 137 |
extern void pfree(PRIMITIVE *p); |
| 138 |
extern void plfree(PLIST *pl); |
| 139 |
/* sort.c */ |
| 140 |
extern void sort(FILE *infp, int (*pcmp)()); |
| 141 |
extern void pmergesort(FILE *fi[], int nf, PLIST *pl, int (*pcmp)(), FILE *ofp); |
| 142 |
/* metacalls.c */ |
| 143 |
extern void mdraw(int x, int y); |
| 144 |
extern void msegment(int xmin, int ymin, int xmax, int ymax, char *sname, |
| 145 |
int d, int thick, int color); |
| 146 |
extern void mvstr(int xmin, int ymin, int xmax, int ymax, char *s, |
| 147 |
int d, int thick, int color); |
| 148 |
extern void mtext(int x, int y, char *s, int cpi, int color); |
| 149 |
extern void mpoly(int x, int y, int border, int pat, int color); |
| 150 |
extern void mtriangle(int xmin, int ymin, int xmax, int ymax, |
| 151 |
int d, int pat, int color); |
| 152 |
extern void mrectangle(int xmin, int ymin, int xmax, int ymax, |
| 153 |
int pat, int color); |
| 154 |
extern void mline(int x, int y, int type, int thick, int color); |
| 155 |
extern void mcloseseg(void); |
| 156 |
extern void mopenseg(char *sname); |
| 157 |
extern void msetpat(int pn, char *pat); |
| 158 |
extern void minclude(char *fname); |
| 159 |
extern void mdone(void); |
| 160 |
extern void mendpage(void); |
| 161 |
/* misc.c */ |
| 162 |
extern int comndx(int c); |
| 163 |
extern PRIMITIVE *pop(PLIST *pl); |
| 164 |
extern void push(PRIMITIVE *p, PLIST *pl); |
| 165 |
extern void add(PRIMITIVE *p, PLIST *pl); |
| 166 |
extern void append(PLIST *pl1, PLIST *pl2); |
| 167 |
extern void fargs(PRIMITIVE *p); |
| 168 |
extern char * nextscan(char *start, char *format, char *result); |
| 169 |
extern void mcopy(char *p1, char *p2, int n); |
| 170 |
/* segment.c */ |
| 171 |
extern int inseg(void); |
| 172 |
extern void closeseg(void); |
| 173 |
extern void openseg(char *name); |
| 174 |
extern void segprim(PRIMITIVE *p); |
| 175 |
extern void segment(PRIMITIVE *p, void (*funcp)(PRIMITIVE *p)); |
| 176 |
extern int xlate(short extrema, PRIMITIVE *p, PRIMITIVE *px); |
| 177 |
/* cgraph.c */ |
| 178 |
extern void cgraph(int width, int length); |
| 179 |
extern void cplot(void); |
| 180 |
extern void cpoint(int c, double x, double y); |
| 181 |
/* gcalc.c */ |
| 182 |
extern void gcalc(char *types); |
| 183 |
/* hfio.c, mfio.c */ |
| 184 |
extern int readp(PRIMITIVE *p, FILE *fp); |
| 185 |
extern void writep(PRIMITIVE *p, FILE *fp); |
| 186 |
extern void writeof(FILE *fp); |
| 187 |
|
| 188 |
|
| 189 |
#ifdef __cplusplus |
| 190 |
} |
| 191 |
#endif |
| 192 |
#endif /* _RAD_META_H_ */ |
| 193 |
|