1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 #ifndef ISPELL_CHECKER_H
3 #define ISPELL_CHECKER_H
5 #include <glib.h> // give glib a chance to override MAXPATHLEN first before it is set in ispell.h
12 ISpellChecker(EnchantBroker * broker);
15 bool checkWord(const char * const word, size_t len);
16 char ** suggestWord(const char * const word, size_t len, size_t * out_n_suggs);
18 bool requestDictionary (const char * szLang);
21 EnchantBroker* m_broker;
24 ISpellChecker(const ISpellChecker&); // no impl
25 void operator=(const ISpellChecker&); // no impl
27 char * loadDictionary (const char * szLang );
28 bool loadDictionaryForLanguage ( const char * szLang );
29 void setDictionaryEncoding ( const char * hashname, const char * enc );
32 // The member functions after this point were formerly global functions
33 // passed a context structure pointer...
36 void try_autodetect_charset(const char * inEncoding);
39 // From ispell correct.c
42 int casecmp P ((char * a, char * b, int canonical));
43 void makepossibilities P ((ichar_t * word));
44 int insert P ((ichar_t * word));
45 #ifndef NO_CAPITALIZATION_SUPPORT
46 void wrongcapital P ((ichar_t * word));
47 #endif /* NO_CAPITALIZATION_SUPPORT */
48 void wrongletter P ((ichar_t * word));
49 void extraletter P ((ichar_t * word));
50 void missingletter P ((ichar_t * word));
51 void missingspace P ((ichar_t * word));
52 int compoundgood P ((ichar_t * word, int pfxopts));
53 void transposedletter P ((ichar_t * word));
54 int ins_cap P ((ichar_t * word, ichar_t * pattern));
55 int save_cap P ((ichar_t * word, ichar_t * pattern,
56 ichar_t savearea[MAX_CAPS][INPUTWORDLEN + MAXAFFIXLEN]));
57 int ins_root_cap P ((ichar_t * word, ichar_t * pattern,
58 int prestrip, int preadd, int sufstrip, int sufadd,
59 struct dent * firstdent, struct flagent * pfxent,
60 struct flagent * sufent));
61 void save_root_cap P ((ichar_t * word, ichar_t * pattern,
62 int prestrip, int preadd, int sufstrip, int sufadd,
63 struct dent * firstdent, struct flagent * pfxent,
64 struct flagent * sufent,
65 ichar_t savearea[MAX_CAPS][INPUTWORDLEN + MAXAFFIXLEN],
72 int good (ichar_t* w, int ignoreflagbits, int allhits, int pfxopts, int sfxopts);
73 void chk_aff (ichar_t* word, ichar_t* ucword, int len, int ignoreflagbits, int allhits, int pfxopts, int sfxopts);
75 struct dent * ispell_lookup (ichar_t* s, int dotree);
76 int strtoichar (ichar_t* out, char* in, int outlen, int canonical);
77 int ichartostr (char* out, ichar_t* in, int outlen, int canonical);
78 char * ichartosstr (ichar_t* in, int canonical);
79 int findfiletype (const char * name, int searchnames, int * deformatter);
80 long whatcap (ichar_t* word);
83 HACK: macros replaced with function implementations
84 so we could do a side-effect-free check for unicode
85 characters which aren't in hashheader
87 char myupper(ichar_t c);
88 char mylower(ichar_t c);
89 int myspace(ichar_t c);
90 char iswordch(ichar_t c);
91 char isboundarych(ichar_t c);
92 char isstringstart(ichar_t c);
93 ichar_t mytolower(ichar_t c);
94 ichar_t mytoupper(ichar_t c);
97 int cap_ok (ichar_t* word, struct success* hit, int len);
99 int hash (ichar_t* s, int hashtblsize);
103 // From ispell lookup.c
106 void clearindex P ((struct flagptr * indexp));
107 void initckch P ((char *));
109 void alloc_ispell_struct();
110 void free_ispell_struct();
113 // From ispell makedent.c
116 int addvheader P ((struct dent * ent));
117 void upcase P ((ichar_t * string));
118 void lowcase P ((ichar_t * string));
119 void chupcase P ((char * s));
121 int stringcharlen P ((char * bufp, int canonical));
122 ichar_t * strtosichar P ((char * in, int canonical));
123 char * printichar P ((int in));
126 // From ispell tgood.c
129 void pfx_list_chk P ((ichar_t * word, ichar_t * ucword,
130 int len, int optflags, int sfxopts, struct flagptr * ind,
131 int ignoreflagbits, int allhits));
132 void chk_suf P ((ichar_t * word, ichar_t * ucword, int len,
133 int optflags, struct flagent * pfxent, int ignoreflagbits,
135 void suf_list_chk P ((ichar_t * word, ichar_t * ucword, int len,
136 struct flagptr * ind, int optflags, struct flagent * pfxent,
137 int ignoreflagbits, int allhits));
138 int expand_pre P ((char * croot, ichar_t * rootword,
139 MASKTYPE mask[], int option, char * extra));
140 int pr_pre_expansion P ((char * croot, ichar_t * rootword,
141 struct flagent * flent, MASKTYPE mask[], int option,
143 int expand_suf P ((char * croot, ichar_t * rootword,
144 MASKTYPE mask[], int optflags, int option, char * extra));
145 int pr_suf_expansion P ((char * croot, ichar_t * rootword,
146 struct flagent * flent, int option, char * extra));
147 void forcelc P ((ichar_t * dst, int len));
149 /* this is used for converting form unsigned short to UCS-4 */
151 int deftflag; /* NZ for TeX mode by default */
152 int prefstringchar; /* Preferred string character type */
153 bool m_bSuccessfulInit;
156 // The members after this point were formerly global variables
157 // in the original ispell code
160 char * m_BC; /* backspace if not ^H */
161 char * m_cd; /* clear to end of display */
162 char * m_cl; /* clear display */
163 char * m_cm; /* cursor movement */
164 char * m_ho; /* home */
165 char * m_nd; /* non-destructive space */
166 char * m_so; /* standout */
167 char * m_se; /* standout end */
168 int m_sg; /* space taken by so/se */
169 char * m_ti; /* terminal initialization sequence */
170 char * m_te; /* terminal termination sequence */
171 int m_li; /* lines */
172 int m_co; /* columns */
174 char m_ctoken[INPUTWORDLEN + MAXAFFIXLEN]; /* Current token as char */
175 ichar_t m_itoken[INPUTWORDLEN + MAXAFFIXLEN]; /* Ctoken as ichar_t str */
177 int m_numhits; /* number of hits in dictionary lookups */
179 m_hits[MAX_HITS]; /* table of hits gotten in lookup */
181 char * m_hashstrings; /* Strings in hash table */
183 m_hashheader; /* Header of hash table */
185 m_hashtbl; /* Main hash table, for dictionary */
186 int m_hashsize; /* Size of main hash table */
188 char m_hashname[MAXPATHLEN]; /* Name of hash table file */
190 int m_aflag; /* NZ if -a or -A option specified */
191 int m_cflag; /* NZ if -c (crunch) option */
192 int m_lflag; /* NZ if -l (list) option */
193 int m_incfileflag; /* whether xgets() acts exactly like gets() */
194 int m_nodictflag; /* NZ if dictionary not needed */
196 int m_uerasechar; /* User's erase character, from stty */
197 int m_ukillchar; /* User's kill character */
199 unsigned int m_laststringch; /* Number of last string character */
200 int m_defdupchar; /* Default duplicate string type */
202 int m_numpflags; /* Number of prefix flags in table */
203 int m_numsflags; /* Number of suffix flags in table */
204 struct flagptr m_pflagindex[SET_SIZE + MAXSTRINGCHARS];
205 /* Fast index to pflaglist */
206 struct flagent * m_pflaglist; /* Prefix flag control list */
207 struct flagptr m_sflagindex[SET_SIZE + MAXSTRINGCHARS];
208 /* Fast index to sflaglist */
209 struct flagent * m_sflaglist; /* Suffix flag control list */
211 struct strchartype * /* String character type collection */
214 FILE * m_infile; /* File being corrected */
215 FILE * m_outfile; /* Corrected copy of infile */
217 char * m_askfilename; /* File specified in -f option */
219 int m_changes; /* NZ if changes made to cur. file */
220 int m_readonly; /* NZ if current file is readonly */
221 int m_quit; /* NZ if we're done with this file */
223 #define MAXPOSSIBLE 100 /* Max no. of possibilities to generate */
225 char m_possibilities[MAXPOSSIBLE][INPUTWORDLEN + MAXAFFIXLEN];
226 /* Table of possible corrections */
227 int m_pcount; /* Count of possibilities generated */
228 int m_maxposslen; /* Length of longest possibility */
229 int m_easypossibilities; /* Number of "easy" corrections found */
230 /* ..(defined as those using legal affixes) */
233 * The following array contains a list of characters that should be tried
234 * in "missingletter." Note that lowercase characters are omitted.
236 int m_Trynum; /* Size of "Try" array */
237 ichar_t m_Try[SET_SIZE + MAXSTRINGCHARS];
239 GIConv m_translate_in; /* Selected translation from/to Unicode */
240 GIConv m_translate_out;
243 #endif /* ISPELL_CHECKER_H */