1 /* predefined array limits */
2 #define PATHLEN 1024 /* path length */
3 #define NFONTS 1024 /* number of fonts */
4 #define FNLEN 64 /* font name length */
5 #define GNLEN 32 /* glyph name length */
6 #define ILNLEN 1000 /* line limit of input files */
7 #define LNLEN 4000 /* line buffer length (ren.c/out.c) */
9 #define MIN(a, b) ((a) < (b) ? (a) : (b))
10 #define MAX(a, b) ((a) < (b) ? (b) : (a))
11 #define LEN(a) (sizeof(a) / sizeof((a)[0]))
13 /* device related variables */
20 char id
[GNLEN
]; /* device-dependent glyph identifier */
21 char name
[GNLEN
]; /* the first character mapped to this glyph */
22 struct font
*font
; /* glyph font */
23 int wid
; /* character width */
24 int type
; /* character type; ascender/descender */
25 int pos
; /* glyph code */
28 /* output device functions */
29 int dev_open(char *dir
, char *dev
);
31 int dev_mnt(int pos
, char *id
, char *name
);
32 struct font
*dev_font(int fn
);
33 int dev_fontid(struct font
*fn
);
34 struct glyph
*dev_glyph(char *c
, int fn
);
36 /* font-related functions */
37 struct font
*font_open(char *path
);
38 void font_close(struct font
*fn
);
39 struct glyph
*font_glyph(struct font
*fn
, char *id
);
40 struct glyph
*font_find(struct font
*fn
, char *name
);
41 int font_wid(struct font
*fn
, int sz
, int w
);
42 int font_swid(struct font
*fn
, int sz
);
43 char *font_name(struct font
*fn
);
44 char *font_path(struct font
*fn
);
45 int font_glnum(struct font
*fn
, struct glyph
*g
);
46 struct glyph
*font_glget(struct font
*fn
, int id
);
48 /* output functions */
49 void out(char *s
, ...);
53 void outrel(int h
, int v
);
57 void outrotate(int deg
);
58 void outeps(char *eps
);
59 void outlink(char *spec
);
65 void drawend(int close
, int fill
);
66 void drawmbeg(char *s
);
67 void drawmend(char *s
);
68 void drawl(int h
, int v
);
70 void drawe(int h
, int v
);
71 void drawa(int h1
, int v1
, int h2
, int v2
);
72 void draws(int h1
, int v1
, int h2
, int v2
);
74 /* postscript functions */
75 void ps_header(char *title
, int pagewidth
, int pageheight
, int linewidth
);
76 void ps_trailer(int pages
);
77 void ps_pagebeg(int n
);
78 void ps_pageend(int n
);
81 #define CLR_R(c) (((c) >> 16) & 0xff)
82 #define CLR_G(c) (((c) >> 8) & 0xff)
83 #define CLR_B(c) ((c) & 0xff)
84 #define CLR_RGB(r, g, b) (((r) << 16) | ((g) << 8) | (b))
89 /* mapping integers to sets */
90 struct iset
*iset_make(void);
91 void iset_free(struct iset
*iset
);
92 int *iset_get(struct iset
*iset
, int key
);
93 void iset_put(struct iset
*iset
, int key
, int ent
);
94 int iset_len(struct iset
*iset
, int key
);
96 /* mapping strings to longs */
97 struct dict
*dict_make(int notfound
, int dupkeys
);
98 void dict_free(struct dict
*d
);
99 void dict_put(struct dict
*d
, char *key
, int val
);
100 int dict_get(struct dict
*d
, char *key
);
101 int dict_idx(struct dict
*d
, char *key
);
102 char *dict_key(struct dict
*d
, int idx
);
103 int dict_val(struct dict
*d
, int idx
);
104 int dict_prefix(struct dict
*d
, char *key
, int *idx
);
106 /* memory allocation */
107 void *mextend(void *old
, long oldsz
, long newsz
, int memsz
);
110 struct sbuf
*sbuf_make(void);
111 char *sbuf_buf(struct sbuf
*sb
);
112 char *sbuf_done(struct sbuf
*sb
);
113 void sbuf_free(struct sbuf
*sb
);
114 int sbuf_len(struct sbuf
*sbuf
);
115 void sbuf_str(struct sbuf
*sbuf
, char *s
);
116 void sbuf_printf(struct sbuf
*sbuf
, char *s
, ...);
117 void sbuf_chr(struct sbuf
*sbuf
, int c
);