1 #include <u.h> 2 #include <libc.h> 3 #include <bio.h> 4 #include <ctype.h> 5 6 enum 7 { 8 Unbsp = 0x00A0, 9 Uprivate = 0xF000, 10 Uempty, /* \& */ 11 Uamp, /* raw & */ 12 Ult, /* raw < */ 13 Ugt, /* raw > */ 14 Utick, /* raw ' */ 15 Ubtick, /* raw ` */ 16 Uminus, /* raw - */ 17 Uspace, /* raw space */ 18 Upl, /* symbol + */ 19 Ueq, /* symbol = */ 20 Umi, /* symbol - */ 21 Uformatted, /* start diverted output */ 22 Uunformatted, /* end diverted output */ 23 24 UPI = 720, /* units per inch */ 25 UPX = 10, /* units per pixel */ 26 27 /* special input modes */ 28 CopyMode = 1<<1, 29 ExpandMode = 1<<2, 30 ArgMode = 1<<3, 31 HtmlMode = 1<<4, 32 33 MaxLine = 1024, 34 }; 35 36 Rune* L(char*); 37 38 void addesc(Rune, int (*)(void), int); 39 void addraw(Rune*, void(*)(Rune*)); 40 void addreq(Rune*, void(*)(int, Rune**), int); 41 void af(Rune*, Rune*); 42 void as(Rune*, Rune*); 43 void br(void); 44 void closehtml(void); 45 Rune* copyarg(void); 46 void delraw(Rune*); 47 void delreq(Rune*); 48 void ds(Rune*, Rune*); 49 int dv(int); 50 int e_nop(void); 51 int e_warn(void); 52 void* emalloc(uint); 53 void* erealloc(void*, uint); 54 Rune* erunesmprint(char*, ...); 55 Rune* erunestrdup(Rune*); 56 char* esmprint(char*, ...); 57 char* estrdup(char*); 58 int eval(Rune*); 59 int evalscale(Rune*, int); 60 Rune* getname(void); 61 int getnext(void); 62 Rune* getds(Rune*); 63 Rune* _getnr(Rune*); 64 int getnr(Rune*); 65 int getnrr(Rune*); 66 int getrune(void); 67 Rune* getqarg(void); 68 Rune* getline(void); 69 void hideihtml(void); 70 void html(Rune*, Rune*); 71 void htmlinit(void); 72 void ihtml(Rune*, Rune*); 73 void inputnotify(void(*)(void)); 74 void itrap(void); 75 void itrapset(void); 76 int linefmt(Fmt*); 77 void nr(Rune*, int); 78 void _nr(Rune*, Rune*); 79 void out(Rune*); 80 void (*outcb)(Rune); 81 void outhtml(Rune*); 82 void outrune(Rune); 83 void outtrap(void); 84 int popinput(void); 85 void printds(int); 86 int pushinputfile(Rune*); 87 void pushinputstring(Rune*); 88 int pushstdin(void); 89 int queueinputfile(Rune*); 90 int queuestdin(void); 91 void r_nop(int, Rune**); 92 void r_warn(int, Rune**); 93 Rune *readline(int); 94 void reitag(void); 95 void renraw(Rune*, Rune*); 96 void renreq(Rune*, Rune*); 97 void run(void); 98 void runinput(void); 99 int runmacro(int, int, Rune**); 100 void runmacro1(Rune*); 101 Rune* rune2html(Rune); 102 void setlinenumber(Rune*, int); 103 void showihtml(void); 104 void sp(int); 105 void t1init(void); 106 void t2init(void); 107 void t3init(void); 108 void t4init(void); 109 void t5init(void); 110 void t6init(void); 111 void t7init(void); 112 void t8init(void); 113 void t9init(void); 114 void t10init(void); 115 void t11init(void); 116 void t12init(void); 117 void t13init(void); 118 void t14init(void); 119 void t15init(void); 120 void t16init(void); 121 void t17init(void); 122 void t18init(void); 123 void t19init(void); 124 void t20init(void); 125 Rune troff2rune(Rune*); 126 void unfont(void); 127 void ungetnext(Rune); 128 void ungetrune(Rune); 129 void unitag(void); 130 void warn(char*, ...); 131 132 extern int backslash; 133 extern int bol; 134 extern Biobuf bout; 135 extern int broke; 136 extern int dot; 137 extern int inputmode; 138 extern int inrequest; 139 extern int tick; 140 extern int utf8; 141 extern int verbose; 142 extern int linepos; 143 144 #define runemalloc(n) (Rune*)emalloc((n)*sizeof(Rune)) 145 #define runerealloc(r, n) (Rune*)erealloc(r, (n)*sizeof(Rune)) 146 #define runemove(a, b, n) memmove(a, b, (n)*sizeof(Rune)) 147 148 #pragma varargck type "L" void 149