post: support links with "x X link"
[neatpost.git] / post.h
blob7fb2efc5bf4687a5835b85e59f93f5a693dbfa09
1 /* predefined array limits */
2 #define PATHLEN 1024 /* path length */
3 #define NFONTS 32 /* 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 */
14 extern int dev_res;
15 extern int dev_uwid;
16 extern int dev_hor;
17 extern int dev_ver;
19 struct glyph {
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);
30 void dev_close(void);
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);
45 /* output functions */
46 void out(char *s, ...);
47 void outc(char *s);
48 void outh(int h);
49 void outv(int v);
50 void outrel(int h, int v);
51 void outfont(int f);
52 void outsize(int s);
53 void outcolor(int c);
54 void outrotate(int deg);
55 void outeps(char *eps);
56 void outlink(char *spec);
57 void outpage(void);
58 void outmnt(int f);
59 void outgname(int g);
60 extern char o_fonts[];
62 void drawbeg(void);
63 void drawend(int close, int fill);
64 void drawmbeg(char *s);
65 void drawmend(char *s);
66 void drawl(int h, int v);
67 void drawc(int c);
68 void drawe(int h, int v);
69 void drawa(int h1, int v1, int h2, int v2);
70 void draws(int h1, int v1, int h2, int v2);
72 /* postscript functions */
73 void ps_header(int pagewidth, int pageheight, int linewidth);
74 void ps_trailer(int pages, char *fonts);
75 void ps_pagebeg(int n);
76 void ps_pageend(int n);
78 /* colors */
79 #define CLR_R(c) (((c) >> 16) & 0xff)
80 #define CLR_G(c) (((c) >> 8) & 0xff)
81 #define CLR_B(c) ((c) & 0xff)
82 #define CLR_RGB(r, g, b) (((r) << 16) | ((g) << 8) | (b))
84 char *clr_str(int c);
85 int clr_get(char *s);
87 /* mapping integers to sets */
88 struct iset *iset_make(void);
89 void iset_free(struct iset *iset);
90 int *iset_get(struct iset *iset, int key);
91 void iset_put(struct iset *iset, int key, int ent);
92 int iset_len(struct iset *iset, int key);
94 /* mapping strings to longs */
95 struct dict *dict_make(int notfound, int dupkeys);
96 void dict_free(struct dict *d);
97 void dict_put(struct dict *d, char *key, int val);
98 int dict_get(struct dict *d, char *key);
99 int dict_idx(struct dict *d, char *key);
100 char *dict_key(struct dict *d, int idx);
101 int dict_val(struct dict *d, int idx);
102 int dict_prefix(struct dict *d, char *key, int *idx);
104 /* memory allocation */
105 void *xmalloc(long len);
106 void *mextend(void *old, long oldsz, long newsz, int memsz);