dict.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. /* Runes for special purposes (0xe800-0xfdff is Private Use Area) */
  10. enum { NONE=0xe800, /* Emit nothing */
  11. TAGS, /* Start of tag */
  12. TAGE, /* End of tag */
  13. SPCS, /* Start of special character name */
  14. PAR, /* Newline, indent */
  15. LIGS, /* Start of ligature codes */
  16. LACU=LIGS, /* Acute (´) ligatures */
  17. LGRV, /* Grave (ˋ) ligatures */
  18. LUML, /* Umlaut (¨) ligatures */
  19. LCED, /* Cedilla (¸) ligatures */
  20. LTIL, /* Tilde (˜) ligatures */
  21. LBRV, /* Breve (˘) ligatures */
  22. LRNG, /* Ring (˚) ligatures */
  23. LDOT, /* Dot (˙) ligatures */
  24. LDTB, /* Dot below (.) ligatures */
  25. LFRN, /* Frown (⌢) ligatures */
  26. LFRB, /* Frown below (̯) ligatures */
  27. LOGO, /* Ogonek (˛) ligatures */
  28. LMAC, /* Macron (¯) ligatures */
  29. LHCK, /* Hacek (ˇ) ligatures */
  30. LASP, /* Asper (ʽ) ligatures */
  31. LLEN, /* Lenis (ʼ) ligatures */
  32. LBRB, /* Breve below (̮) ligatures */
  33. LIGE, /* End of ligature codes */
  34. MULTI, /* Start of multi-rune codes */
  35. MAAS=MULTI, /* ʽα */
  36. MALN, /* ʼα */
  37. MAND, /* and */
  38. MAOQ, /* a/q */
  39. MBRA, /* <| */
  40. MDD, /* .. */
  41. MDDD, /* ... */
  42. MEAS, /* ʽε */
  43. MELN, /* ʼε */
  44. MEMM, /* —— */
  45. MHAS, /* ʽη */
  46. MHLN, /* ʼη */
  47. MIAS, /* ʽι */
  48. MILN, /* ʼι */
  49. MLCT, /* ct */
  50. MLFF, /* ff */
  51. MLFFI, /* ffi */
  52. MLFFL, /* ffl */
  53. MLFL, /* fl */
  54. MLFI, /* fi */
  55. MLLS, /* ll with swing */
  56. MLST, /* st */
  57. MOAS, /* ʽο */
  58. MOLN, /* ʼο */
  59. MOR, /* or */
  60. MRAS, /* ʽρ */
  61. MRLN, /* ʼρ */
  62. MTT, /* ~~ */
  63. MUAS, /* ʽυ */
  64. MULN, /* ʼυ */
  65. MWAS, /* ʽω */
  66. MWLN, /* ʼω */
  67. MOE, /* oe */
  68. MES, /* em space */
  69. MULTIE, /* End of multi-rune codes */
  70. };
  71. #define Nligs (LIGE-LIGS)
  72. #define Nmulti (MULTIE-MULTI)
  73. typedef struct Entry Entry;
  74. typedef struct Assoc Assoc;
  75. typedef struct Nassoc Nassoc;
  76. typedef struct Dict Dict;
  77. struct Entry {
  78. char *start; /* entry starts at start */
  79. char *end; /* and finishes just before end */
  80. long doff; /* dictionary offset (for debugging) */
  81. };
  82. struct Assoc {
  83. char *key;
  84. long val;
  85. };
  86. struct Nassoc {
  87. long key;
  88. long val;
  89. };
  90. struct Dict {
  91. char *name; /* dictionary name */
  92. char *desc; /* description */
  93. char *path; /* path to dictionary data */
  94. char *indexpath; /* path to index data */
  95. long (*nextoff)(long); /* function to find next entry offset from arg */
  96. void (*printentry)(Entry, int); /* function to print entry */
  97. void (*printkey)(void); /* function to print pronunciation key */
  98. };
  99. int acomp(Rune*, Rune*);
  100. Rune *changett(Rune *, Rune *, int);
  101. void err(char*, ...);
  102. void fold(Rune *);
  103. void foldre(char*, char*);
  104. Rune liglookup(Rune, Rune);
  105. long lookassoc(Assoc*, int, char*);
  106. long looknassoc(Nassoc*, int, long);
  107. void outprint(char*, ...);
  108. void outrune(long);
  109. void outrunes(Rune *);
  110. void outchar(int);
  111. void outchars(char *);
  112. void outnl(int);
  113. void outpiece(char *, char *);
  114. void runescpy(Rune*, Rune*);
  115. long runetol(Rune*);
  116. long oednextoff(long);
  117. void oedprintentry(Entry, int);
  118. void oedprintkey(void);
  119. long ahdnextoff(long);
  120. void ahdprintentry(Entry, int);
  121. void ahdprintkey(void);
  122. long pcollnextoff(long);
  123. void pcollprintentry(Entry, int);
  124. void pcollprintkey(void);
  125. long pcollgnextoff(long);
  126. void pcollgprintentry(Entry, int);
  127. void pcollgprintkey(void);
  128. long movienextoff(long);
  129. void movieprintentry(Entry, int);
  130. void movieprintkey(void);
  131. long pgwnextoff(long);
  132. void pgwprintentry(Entry,int);
  133. void pgwprintkey(void);
  134. void rogetprintentry(Entry, int);
  135. long rogetnextoff(long);
  136. void rogetprintkey(void);
  137. long slangnextoff(long);
  138. void slangprintentry(Entry, int);
  139. void slangprintkey(void);
  140. long robertnextoff(long);
  141. void robertindexentry(Entry, int);
  142. void robertprintkey(void);
  143. long robertnextflex(long);
  144. void robertflexentry(Entry, int);
  145. long simplenextoff(long);
  146. void simpleprintentry(Entry, int);
  147. void simpleprintkey(void);
  148. long thesnextoff(long);
  149. void thesprintentry(Entry, int);
  150. void thesprintkey(void);
  151. long worldnextoff(long);
  152. void worldprintentry(Entry, int);
  153. void worldprintkey(void);
  154. extern Biobuf *bdict;
  155. extern Biobuf *bout;
  156. extern int linelen;
  157. extern int breaklen;
  158. extern int outinhibit;
  159. extern int debug;
  160. extern Rune *multitab[];
  161. extern Dict dicts[];
  162. #define asize(a) (sizeof (a)/sizeof(a[0]))