aspelldyn.pp 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  1. {$IFNDEF FPC_DOTTEDUNITS}
  2. unit aspelldyn;
  3. {$ENDIF FPC_DOTTEDUNITS}
  4. { * This file is header translation of The New Aspell
  5. * Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL
  6. * license version 2.0 or 2.1. You should have received a copy of the
  7. * LGPL license along with this library if you did not you can find it
  8. * at http://www.gnu.org/. * }
  9. { * Translation to pascal (c) 2008 by Aleš Katona. * }
  10. {$PACKRECORDS C}
  11. interface
  12. {$IFDEF FPC_DOTTEDUNITS}
  13. uses
  14. System.CTypes;
  15. {$ELSE FPC_DOTTEDUNITS}
  16. uses
  17. cTypes;
  18. {$ENDIF FPC_DOTTEDUNITS}
  19. {$IFDEF UNIX}
  20. // TODO: check if it works pathless in beosOB
  21. {$ifndef DARWIN}
  22. const libaspell = 'libaspell.so';
  23. {$ELSE}
  24. {WARNING Is it possible to omit the path?}
  25. const libaspell = 'libaspell.dylib';
  26. {$ENDIF}
  27. {$ELSE}
  28. {$IFDEF WINDOWS}
  29. const libaspell = 'aspell-15.dll';
  30. {$ELSE}
  31. {$MESSAGE ERROR Target not supported'}
  32. {$ENDIF}
  33. {$ENDIF}
  34. {$i aspelltypes.inc}
  35. {************************* mutable container ************************* }
  36. var
  37. aspell_mutable_container_add: function(ths:PAspellMutableContainer; to_add:PAnsiChar):cint;cdecl;
  38. aspell_mutable_container_remove: function(ths:PAspellMutableContainer; to_rem:PAnsiChar):cint;cdecl;
  39. aspell_mutable_container_clear: procedure(ths:PAspellMutableContainer);cdecl;
  40. aspell_mutable_container_to_mutable_container: function(ths:PAspellMutableContainer):PAspellMutableContainer;cdecl;
  41. {******************************* config ******************************* }
  42. aspell_key_info_enumeration_at_end: function(ths:PAspellKeyInfoEnumeration):cint;cdecl;
  43. aspell_key_info_enumeration_next: function(ths:PAspellKeyInfoEnumeration):PAspellKeyInfo;cdecl;
  44. delete_aspell_key_info_enumeration: procedure(ths:PAspellKeyInfoEnumeration);cdecl;
  45. aspell_key_info_enumeration_clone: function(ths:PAspellKeyInfoEnumeration):PAspellKeyInfoEnumeration;cdecl;
  46. aspell_key_info_enumeration_assign: procedure(ths:PAspellKeyInfoEnumeration; other:PAspellKeyInfoEnumeration);cdecl;
  47. new_aspell_config: function():PAspellConfig;cdecl;
  48. delete_aspell_config: procedure(ths:PAspellConfig);cdecl;
  49. aspell_config_clone: function(ths:PAspellConfig):PAspellConfig;cdecl;
  50. aspell_config_assign: procedure(ths:PAspellConfig; other:PAspellConfig);cdecl;
  51. aspell_config_error_number: function(ths:PAspellConfig):cuint;cdecl;
  52. aspell_config_error_message: function(ths:PAspellConfig):PAnsiChar;cdecl;
  53. aspell_config_error: function(ths:PAspellConfig):PAspellError;cdecl;
  54. { Sets extra keys which this config class should
  55. * accept. begin and end are expected to point to
  56. * the beginning and ending of an array of Aspell
  57. * Key Info. }
  58. aspell_config_set_extra: procedure(ths:PAspellConfig; b:PAspellKeyInfo; e:PAspellKeyInfo);cdecl;
  59. { Returns the KeyInfo object for the
  60. * corresponding key or returns NULL and sets
  61. * error_num to PERROR_UNKNOWN_KEY if the key is
  62. * not valid. The pointer returned is valid for
  63. * the lifetime of the object. }
  64. aspell_config_keyinfo: function(ths:PAspellConfig; key:PAnsiChar):PAspellKeyInfo;cdecl;
  65. { Returns a newly allocated enumeration of all
  66. * the possible objects this config class uses. }
  67. aspell_config_possible_elements: function(ths:PAspellConfig; include_extra:cint):PAspellKeyInfoEnumeration;cdecl;
  68. { Returns the default value for given key which
  69. * may involve substituting variables, thus it is
  70. * not the same as keyinfo(key)->def returns NULL
  71. * and sets error_num to PERROR_UNKNOWN_KEY if
  72. * the key is not valid. Uses the temporary
  73. * string. }
  74. aspell_config_get_default: function(ths:PAspellConfig; key:PAnsiChar):PAnsiChar;cdecl;
  75. { Returns a newly allocated enumeration of all
  76. * the key/value pairs. This DOES not include ones
  77. * which are set to their default values. }
  78. aspell_config_elements: function(ths:PAspellConfig):PAspellStringPairEnumeration;cdecl;
  79. { Inserts an item, if the item already exists it
  80. * will be replaced. Returns TRUE if it succeeded
  81. * or FALSE on error. If the key is not valid it
  82. * sets error_num to PERROR_UNKNOWN_KEY, if the
  83. * value is not valid it will set error_num to
  84. * PERROR_BAD_VALUE, if the value can not be
  85. * changed it sets error_num to
  86. * PERROR_CANT_CHANGE_VALUE, and if the value is
  87. * a list and you are trying to set its directory,
  88. * it sets error_num to PERROR_LIST_SET }
  89. aspell_config_replace: function(ths:PAspellConfig; key:PAnsiChar; value:PAnsiChar):cint;cdecl;
  90. { Remove a key and returns TRUE if it exists
  91. * otherwise return FALSE. This effectively sets
  92. * the key to its default value. Calling replace
  93. * with a value of "<default>" will also call
  94. * remove. If the key does not exist then it sets
  95. * error_num to 0 or PERROR_NOT, if the key is
  96. * not valid then it sets error_num to
  97. * PERROR_UNKNOWN_KEY, if the value can not be
  98. * changed then it sets error_num to
  99. * PERROR_CANT_CHANGE_VALUE }
  100. aspell_config_remove: function(ths:PAspellConfig; key:PAnsiChar):cint;cdecl;
  101. aspell_config_have: function(ths:PAspellConfig; key:PAnsiChar):cint;cdecl;
  102. { Returns NULL on error. }
  103. aspell_config_retrieve: function(ths:PAspellConfig; key:PAnsiChar):PAnsiChar;cdecl;
  104. aspell_config_retrieve_list: function(ths:PAspellConfig; key:PAnsiChar; lst:PAspellMutableContainer):cint;cdecl;
  105. { In "ths" Aspell configuration, search for a
  106. * character string matching "key" string.
  107. * If "key" is found then return 1 else return 0.
  108. * If error encountered, then return -1. }
  109. aspell_config_retrieve_bool: function(ths:PAspellConfig; key:PAnsiChar):cint;cdecl;
  110. { In "ths" Aspell configuration, search for an
  111. * integer value matching "key" string.
  112. * Return -1 on error. }
  113. aspell_config_retrieve_int: function(ths:PAspellConfig; key:PAnsiChar):cint;cdecl;
  114. {******************************* error ******************************* }
  115. aspell_error_is_a: function(ths:PAspellError; e:PAspellErrorInfo):cint;cdecl;
  116. {*************************** can have error *************************** }
  117. aspell_error_number: function(ths:PAspellCanHaveError):cuint;cdecl;
  118. aspell_error_message: function(ths:PAspellCanHaveError):PAnsiChar;cdecl;
  119. aspell_error: function(ths:PAspellCanHaveError):PAspellError;cdecl;
  120. delete_aspell_can_have_error: procedure(ths:PAspellCanHaveError);cdecl;
  121. {******************************* errors ******************************* }
  122. // ignored
  123. {****************************** speller ****************************** }
  124. new_aspell_speller: function(config:PAspellConfig):PAspellCanHaveError;cdecl;
  125. to_aspell_speller: function(obj:PAspellCanHaveError):PAspellSpeller;cdecl;
  126. delete_aspell_speller: procedure(ths:PAspellSpeller);cdecl;
  127. aspell_speller_error_number: function(ths:PAspellSpeller):cuint;cdecl;
  128. aspell_speller_error_message: function(ths:PAspellSpeller):PAnsiChar;cdecl;
  129. aspell_speller_error: function(ths:PAspellSpeller):PAspellError;cdecl;
  130. aspell_speller_config: function(ths:PAspellSpeller):PAspellConfig;cdecl;
  131. { Returns 0 if it is not in the dictionary,
  132. * 1 if it is, or -1 on error. }
  133. aspell_speller_check: function(ths:PAspellSpeller; word:PAnsiChar; word_size:cint):cint;cdecl;
  134. { Add this word to your own personal word list. }
  135. aspell_speller_add_to_personal: function(ths:PAspellSpeller; word:PAnsiChar; word_size:cint):cint;cdecl;
  136. { Add this word to the current spelling session. }
  137. aspell_speller_add_to_session: function(ths:PAspellSpeller; word:PAnsiChar; word_size:cint):cint;cdecl;
  138. { This is your own personal word list file plus
  139. * any extra words added during this session to
  140. * your own personal word list. }
  141. aspell_speller_personal_word_list: function(ths:PAspellSpeller):PAspellWordList;cdecl;
  142. { This is a list of words added to this session
  143. * that are not in the main word list or in your
  144. * own personal list but are considered valid for
  145. * this spelling session. }
  146. aspell_speller_session_word_list: function(ths:PAspellSpeller):PAspellWordList;cdecl;
  147. { This is the main list of words used during this
  148. * spelling session. }
  149. aspell_speller_main_word_list: function(ths:PAspellSpeller):PAspellWordList;cdecl;
  150. aspell_speller_save_all_word_lists: function(ths:PAspellSpeller):cint;cdecl;
  151. aspell_speller_clear_session: function(ths:PAspellSpeller):cint;cdecl;
  152. { Return NULL on error.
  153. * The word list returned by suggest is only
  154. * valid until the next call to suggest. }
  155. aspell_speller_suggest: function(ths:PAspellSpeller; word:PAnsiChar; word_size:cint):PAspellWordList;cdecl;
  156. aspell_speller_store_replacement: function(ths:PAspellSpeller; mis:PAnsiChar; mis_size:cint; cor:PAnsiChar; cor_size:cint):cint;cdecl;
  157. {******************************* filter ******************************* }
  158. delete_aspell_filter: procedure(ths:PAspellFilter);cdecl;
  159. aspell_filter_error_number: function(ths:PAspellFilter):cuint;cdecl;
  160. aspell_filter_error_message: function(ths:PAspellFilter):PAnsiChar;cdecl;
  161. aspell_filter_error: function(ths:PAspellFilter):PAspellError;cdecl;
  162. to_aspell_filter: function(obj:PAspellCanHaveError):PAspellFilter;cdecl;
  163. {************************** document checker ************************** }
  164. delete_aspell_document_checker: procedure(ths:PAspellDocumentChecker);cdecl;
  165. aspell_document_checker_error_number: function(ths:PAspellDocumentChecker):cuint;cdecl;
  166. aspell_document_checker_error_message: function(ths:PAspellDocumentChecker):PAnsiChar;cdecl;
  167. aspell_document_checker_error: function(ths:PAspellDocumentChecker):PAspellError;cdecl;
  168. { Creates a new document checker.
  169. * The speller class is expected to last until
  170. * this class is destroyed.
  171. * If config is given it will be used to override
  172. * any relevent options set by this speller class.
  173. is: function done.cdecl;
  174. * If filter is given then it will take ownership of
  175. * the filter class and use it to do the filtering.
  176. * You are expected to free the checker when done. }
  177. new_aspell_document_checker: function(speller: PAspellSpeller): PAspellCanHaveError;cdecl;
  178. to_aspell_document_checker: function(obj:PAspellCanHaveError):PAspellDocumentChecker;cdecl;
  179. { Reset the internal state of the filter.
  180. * Should be called whenever a new document is
  181. * being filtered. }
  182. aspell_document_checker_reset: procedure(ths:PAspellDocumentChecker);cdecl;
  183. { Process a string.
  184. * The string passed in should only be split on
  185. * white space characters. Furthermore, between
  186. * calls to reset, each string should be passed
  187. * in exactly once and in the order they appeared
  188. * in the document. Passing in strings out of
  189. * order, skipping strings or passing them in
  190. * more than once may lead to undefined results. }
  191. aspell_document_checker_process: procedure(ths:PAspellDocumentChecker; str:PAnsiChar; size:cint);cdecl;
  192. { Returns the next misspelled word in the
  193. * processed string. If there are no more
  194. * misspelled words, then token.word will be
  195. * NULL and token.size will be 0 }
  196. // hack around struct/cdecl problem
  197. __aspell_document_checker_next_misspelling: function(ths:PAspellDocumentChecker):{$IFDEF CPU64}{$IFDEF LINUX}QWord{$ELSE}AspellToken{$ENDIF}{$ELSE}AspellToken{$ENDIF};cdecl;
  198. { Returns the underlying filter class. }
  199. aspell_document_checker_filter: function(ths:PAspellDocumentChecker):PAspellFilter;cdecl;
  200. {***************************** word list ***************************** }
  201. aspell_word_list_empty: function(ths:PAspellWordList):cint;cdecl;
  202. aspell_word_list_size: function(ths:PAspellWordList):cuint;cdecl;
  203. aspell_word_list_elements: function(ths:PAspellWordList):PAspellStringEnumeration;cdecl;
  204. {************************* string enumeration ************************* }
  205. delete_aspell_string_enumeration: procedure(ths:PAspellStringEnumeration);cdecl;
  206. aspell_string_enumeration_clone: function(ths:PAspellStringEnumeration):PAspellStringEnumeration;cdecl;
  207. aspell_string_enumeration_assign: procedure(ths:PAspellStringEnumeration; other:PAspellStringEnumeration);cdecl;
  208. aspell_string_enumeration_at_end: function(ths:PAspellStringEnumeration):cint;cdecl;
  209. aspell_string_enumeration_next: function(ths:PAspellStringEnumeration):PAnsiChar;cdecl;
  210. {******************************** info ******************************** }
  211. get_aspell_module_info_list: function(config:PAspellConfig):PAspellModuleInfoList;cdecl;
  212. aspell_module_info_list_empty: function(ths:PAspellModuleInfoList):cint;cdecl;
  213. aspell_module_info_list_size: function(ths:PAspellModuleInfoList):cuint;cdecl;
  214. aspell_module_info_list_elements: function(ths:PAspellModuleInfoList):PAspellModuleInfoEnumeration;cdecl;
  215. get_aspell_dict_info_list: function(config:PAspellConfig):PAspellDictInfoList;cdecl;
  216. aspell_dict_info_list_empty: function(ths:PAspellDictInfoList):cint;cdecl;
  217. aspell_dict_info_list_size: function(ths:PAspellDictInfoList):cuint;cdecl;
  218. aspell_dict_info_list_elements: function(ths:PAspellDictInfoList):PAspellDictInfoEnumeration;cdecl;
  219. aspell_module_info_enumeration_at_end: function(ths:PAspellModuleInfoEnumeration):cint;cdecl;
  220. aspell_module_info_enumeration_next: function(ths:PAspellModuleInfoEnumeration):PAspellModuleInfo;cdecl;
  221. delete_aspell_module_info_enumeration: procedure(ths:PAspellModuleInfoEnumeration);cdecl;
  222. aspell_module_info_enumeration_clone: function(ths:PAspellModuleInfoEnumeration):PAspellModuleInfoEnumeration;cdecl;
  223. aspell_module_info_enumeration_assign: procedure(ths:PAspellModuleInfoEnumeration; other:PAspellModuleInfoEnumeration);cdecl;
  224. aspell_dict_info_enumeration_at_end: function(ths:PAspellDictInfoEnumeration):cint;cdecl;
  225. aspell_dict_info_enumeration_next: function(ths:PAspellDictInfoEnumeration):PAspellDictInfo;cdecl;
  226. delete_aspell_dict_info_enumeration: procedure(ths:PAspellDictInfoEnumeration);cdecl;
  227. aspell_dict_info_enumeration_clone: function(ths:PAspellDictInfoEnumeration):PAspellDictInfoEnumeration;cdecl;
  228. aspell_dict_info_enumeration_assign: procedure(ths:PAspellDictInfoEnumeration; other:PAspellDictInfoEnumeration);cdecl;
  229. {**************************** string list **************************** }
  230. new_aspell_string_list: function():PAspellStringList;cdecl;
  231. aspell_string_list_empty: function(ths:PAspellStringList):cint;cdecl;
  232. aspell_string_list_size: function(ths:PAspellStringList):cuint;cdecl;
  233. aspell_string_list_elements: function(ths:PAspellStringList):PAspellStringEnumeration;cdecl;
  234. aspell_string_list_add: function(ths:PAspellStringList; to_add:PAnsiChar):cint;cdecl;
  235. aspell_string_list_remove: function(ths:PAspellStringList; to_rem:PAnsiChar):cint;cdecl;
  236. aspell_string_list_clear: procedure(ths:PAspellStringList);cdecl;
  237. aspell_string_list_to_mutable_container: function(ths:PAspellStringList):PAspellMutableContainer;cdecl;
  238. delete_aspell_string_list: procedure(ths:PAspellStringList);cdecl;
  239. aspell_string_list_clone: function(ths:PAspellStringList):PAspellStringList;cdecl;
  240. aspell_string_list_assign: procedure(ths:PAspellStringList; other:PAspellStringList);cdecl;
  241. {***************************** string map ***************************** }
  242. new_aspell_string_map: function():PAspellStringMap;cdecl;
  243. aspell_string_map_add: function(ths:PAspellStringMap; to_add:PAnsiChar):cint;cdecl;
  244. aspell_string_map_remove: function(ths:PAspellStringMap; to_rem:PAnsiChar):cint;cdecl;
  245. aspell_string_map_clear: procedure(ths:PAspellStringMap);cdecl;
  246. aspell_string_map_to_mutable_container: function(ths:PAspellStringMap):PAspellMutableContainer;cdecl;
  247. delete_aspell_string_map: procedure(ths:PAspellStringMap);cdecl;
  248. aspell_string_map_clone: function(ths:PAspellStringMap):PAspellStringMap;cdecl;
  249. aspell_string_map_assign: procedure(ths:PAspellStringMap; other:PAspellStringMap);cdecl;
  250. aspell_string_map_empty: function(ths:PAspellStringMap):cint;cdecl;
  251. aspell_string_map_size: function(ths:PAspellStringMap):cuint;cdecl;
  252. aspell_string_map_elements: function(ths:PAspellStringMap):PAspellStringPairEnumeration;cdecl;
  253. { Insert a new element.
  254. * Will NOT overwrite an existing entry.
  255. * Returns FALSE if the element already exists. }
  256. aspell_string_map_insert: function(ths:PAspellStringMap; key:PAnsiChar; value:PAnsiChar):cint;cdecl;
  257. { Insert a new element.
  258. * Will overwrite an existing entry.
  259. * Always returns TRUE. }
  260. aspell_string_map_replace: function(ths:PAspellStringMap; key:PAnsiChar; value:PAnsiChar):cint;cdecl;
  261. { Looks up an element and returns the value.
  262. * Returns NULL if the element does not exist.
  263. * Returns an empty string if the element exists
  264. * but has a NULL value. }
  265. aspell_string_map_lookup: function(ths:PAspellStringMap; key:PAnsiChar):PAnsiChar;cdecl;
  266. {********************** string pair enumeration ********************** }
  267. aspell_string_pair_enumeration_at_end: function(ths:PAspellStringPairEnumeration):cint;cdecl;
  268. aspell_string_pair_enumeration_next: function(ths:PAspellStringPairEnumeration):AspellStringPair;cdecl;
  269. delete_aspell_string_pair_enumeration: procedure(ths:PAspellStringPairEnumeration);cdecl;
  270. aspell_string_pair_enumeration_clone: function(ths:PAspellStringPairEnumeration):PAspellStringPairEnumeration;cdecl;
  271. aspell_string_pair_enumeration_assign: procedure(ths:PAspellStringPairEnumeration; other:PAspellStringPairEnumeration);cdecl;
  272. {******************************* cache ******************************* }
  273. { Reset the global cache(s) so that cache queries will
  274. * create a new object. If existing objects are still in
  275. * use they are not deleted. If which is NULL then all
  276. * caches will be reset. Current caches are "encode",
  277. * "decode", "dictionary", "language", and "keyboard". }
  278. aspell_reset_cache: function(which:PAnsiChar):cint;cdecl;
  279. function aspell_init(const libn: ansistring): Boolean;
  280. function aspell_loaded: Boolean;
  281. function aspell_document_checker_next_misspelling(ths:PAspellDocumentChecker):AspellToken;
  282. implementation
  283. {$IFDEF FPC_DOTTEDUNITS}
  284. uses
  285. {$IFDEF WINDOWS}
  286. Windows, SysUtils, Classes,
  287. {$ENDIF}
  288. System.DynLibs;
  289. {$ELSE FPC_DOTTEDUNITS}
  290. uses
  291. {$IFDEF WINDOWS}
  292. Windows, SysUtils, Classes,
  293. {$ENDIF}
  294. dynlibs;
  295. {$ENDIF FPC_DOTTEDUNITS}
  296. var
  297. LibHandle: TLibHandle = 0;
  298. {$IFDEF WINDOWS}
  299. function RegistryQueryValue (name,sub:shortstring):shortstring;
  300. const
  301. maxkeysize=255;
  302. var
  303. buf:string [maxkeysize];
  304. bufsize:longint;
  305. buftype:longint;
  306. res:longint;
  307. key,rkey:hkey;
  308. p,sp:PAnsiChar;
  309. begin
  310. RegistryQueryValue:='';
  311. name:=name+#0; p:=@name[1];
  312. if sub='' then sp:=nil else begin sub:=sub+#0; sp:=@sub[1]; end;
  313. bufsize:=maxkeysize;
  314. buftype:=REG_SZ;
  315. key:=HKEY_LOCAL_MACHINE;
  316. res:=RegOpenKeyExA (key,p,0,KEY_QUERY_VALUE,rkey);
  317. if res<>ERROR_SUCCESS then exit;
  318. res:=RegQueryValueExA (rkey,sp,nil,@buftype,@buf[1],@bufsize);
  319. if res<>ERROR_SUCCESS then exit;
  320. buf[0]:=chr(bufsize-1);
  321. RegCloseKey (rkey);
  322. RegistryQueryValue:=buf;
  323. end;
  324. {$ENDIF}
  325. function aspell_init(const libn: ansistring): Boolean;
  326. var
  327. libname: ansistring;
  328. bversion, path: ansistring;
  329. version: dword;
  330. i: Integer;
  331. s: AnsiString;
  332. begin
  333. aspell_init := True;
  334. libname := libn;
  335. {$IFDEF windows}
  336. bversion := RegistryQueryValue('SOFTWARE\Aspell','AspellVersion');
  337. if Length(bversion) >= 4 then begin
  338. move(bversion[1], version, 4);
  339. path := RegistryQueryValue('SOFTWARE\Aspell','Path');
  340. // will work if they passed %s, won't bork if they passed absolute
  341. libname := path + PathDelim + StringReplace(libn, '%s', IntToStr(Version), [rfReplaceAll]);
  342. end;
  343. {$ENDIF}
  344. LibHandle := LoadLibrary(libname);
  345. {$ifdef darwin}
  346. if LibHandle = 0 then begin
  347. libname := '/sw/lib/libaspell.dylib';
  348. LibHandle := LoadLibrary(libname);
  349. end;
  350. if LibHandle = 0 then begin
  351. libname := '/opt/local/lib/libaspell.dylib';
  352. LibHandle := LoadLibrary(libname);
  353. end;
  354. {$else}
  355. {$ifdef unix} // we're not in windblows
  356. if LibHandle = 0 then begin
  357. for i := 15 to 20 do begin // TODO: make sure to cut this if they break compat
  358. str(i, s);
  359. libname := libn + '.' + s;
  360. LibHandle := LoadLibrary(libname);
  361. if LibHandle <> 0 then
  362. Break;
  363. end;
  364. end;
  365. {$endif} // unix
  366. {$endif} // darwin
  367. if LibHandle = 0 then
  368. Exit(False);
  369. aspell_mutable_container_add := nil;
  370. Pointer(aspell_mutable_container_add) := GetProcedureAddress(LibHandle, 'aspell_mutable_container_add');
  371. if not Assigned(aspell_mutable_container_add) then Exit(False);
  372. aspell_mutable_container_remove := nil;
  373. Pointer(aspell_mutable_container_remove) := GetProcedureAddress(LibHandle, 'aspell_mutable_container_remove');
  374. if not Assigned(aspell_mutable_container_remove) then Exit(False);
  375. aspell_mutable_container_clear := nil;
  376. Pointer(aspell_mutable_container_clear) := GetProcedureAddress(LibHandle, 'aspell_mutable_container_clear');
  377. if not Assigned(aspell_mutable_container_clear) then Exit(False);
  378. aspell_mutable_container_to_mutable_container := nil;
  379. Pointer(aspell_mutable_container_to_mutable_container) := GetProcedureAddress(LibHandle, 'aspell_mutable_container_to_mutable_container');
  380. if not Assigned(aspell_mutable_container_to_mutable_container) then Exit(False);
  381. aspell_key_info_enumeration_at_end := nil;
  382. Pointer(aspell_key_info_enumeration_at_end) := GetProcedureAddress(LibHandle, 'aspell_key_info_enumeration_at_end');
  383. if not Assigned(aspell_key_info_enumeration_at_end) then Exit(False);
  384. aspell_key_info_enumeration_next := nil;
  385. Pointer(aspell_key_info_enumeration_next) := GetProcedureAddress(LibHandle, 'aspell_key_info_enumeration_next');
  386. if not Assigned(aspell_key_info_enumeration_next) then Exit(False);
  387. delete_aspell_key_info_enumeration := nil;
  388. Pointer(delete_aspell_key_info_enumeration) := GetProcedureAddress(LibHandle, 'delete_aspell_key_info_enumeration');
  389. if not Assigned(delete_aspell_key_info_enumeration) then Exit(False);
  390. aspell_key_info_enumeration_clone := nil;
  391. Pointer(aspell_key_info_enumeration_clone) := GetProcedureAddress(LibHandle, 'aspell_key_info_enumeration_clone');
  392. if not Assigned(aspell_key_info_enumeration_clone) then Exit(False);
  393. aspell_key_info_enumeration_assign := nil;
  394. Pointer(aspell_key_info_enumeration_assign) := GetProcedureAddress(LibHandle, 'aspell_key_info_enumeration_assign');
  395. if not Assigned(aspell_key_info_enumeration_assign) then Exit(False);
  396. new_aspell_config := nil;
  397. Pointer(new_aspell_config) := GetProcedureAddress(LibHandle, 'new_aspell_config');
  398. if not Assigned(new_aspell_config) then Exit(False);
  399. delete_aspell_config := nil;
  400. Pointer(delete_aspell_config) := GetProcedureAddress(LibHandle, 'delete_aspell_config');
  401. if not Assigned(delete_aspell_config) then Exit(False);
  402. aspell_config_clone := nil;
  403. Pointer(aspell_config_clone) := GetProcedureAddress(LibHandle, 'aspell_config_clone');
  404. if not Assigned(aspell_config_clone) then Exit(False);
  405. aspell_config_assign := nil;
  406. Pointer(aspell_config_assign) := GetProcedureAddress(LibHandle, 'aspell_config_assign');
  407. if not Assigned(aspell_config_assign) then Exit(False);
  408. aspell_config_error_number := nil;
  409. Pointer(aspell_config_error_number) := GetProcedureAddress(LibHandle, 'aspell_config_error_number');
  410. if not Assigned(aspell_config_error_number) then Exit(False);
  411. aspell_config_error_message := nil;
  412. Pointer(aspell_config_error_message) := GetProcedureAddress(LibHandle, 'aspell_config_error_message');
  413. if not Assigned(aspell_config_error_message) then Exit(False);
  414. aspell_config_error := nil;
  415. Pointer(aspell_config_error) := GetProcedureAddress(LibHandle, 'aspell_config_error');
  416. if not Assigned(aspell_config_error) then Exit(False);
  417. aspell_config_set_extra := nil;
  418. Pointer(aspell_config_set_extra) := GetProcedureAddress(LibHandle, 'aspell_config_set_extra');
  419. if not Assigned(aspell_config_set_extra) then Exit(False);
  420. aspell_config_keyinfo := nil;
  421. Pointer(aspell_config_keyinfo) := GetProcedureAddress(LibHandle, 'aspell_config_keyinfo');
  422. if not Assigned(aspell_config_keyinfo) then Exit(False);
  423. aspell_config_possible_elements := nil;
  424. Pointer(aspell_config_possible_elements) := GetProcedureAddress(LibHandle, 'aspell_config_possible_elements');
  425. if not Assigned(aspell_config_possible_elements) then Exit(False);
  426. aspell_config_get_default := nil;
  427. Pointer(aspell_config_get_default) := GetProcedureAddress(LibHandle, 'aspell_config_get_default');
  428. if not Assigned(aspell_config_get_default) then Exit(False);
  429. aspell_config_elements := nil;
  430. Pointer(aspell_config_elements) := GetProcedureAddress(LibHandle, 'aspell_config_elements');
  431. if not Assigned(aspell_config_elements) then Exit(False);
  432. aspell_config_replace := nil;
  433. Pointer(aspell_config_replace) := GetProcedureAddress(LibHandle, 'aspell_config_replace');
  434. if not Assigned(aspell_config_replace) then Exit(False);
  435. aspell_config_remove := nil;
  436. Pointer(aspell_config_remove) := GetProcedureAddress(LibHandle, 'aspell_config_remove');
  437. if not Assigned(aspell_config_remove) then Exit(False);
  438. aspell_config_have := nil;
  439. Pointer(aspell_config_have) := GetProcedureAddress(LibHandle, 'aspell_config_have');
  440. if not Assigned(aspell_config_have) then Exit(False);
  441. aspell_config_retrieve := nil;
  442. Pointer(aspell_config_retrieve) := GetProcedureAddress(LibHandle, 'aspell_config_retrieve');
  443. if not Assigned(aspell_config_retrieve) then Exit(False);
  444. aspell_config_retrieve_list := nil;
  445. Pointer(aspell_config_retrieve_list) := GetProcedureAddress(LibHandle, 'aspell_config_retrieve_list');
  446. if not Assigned(aspell_config_retrieve_list) then Exit(False);
  447. aspell_config_retrieve_bool := nil;
  448. Pointer(aspell_config_retrieve_bool) := GetProcedureAddress(LibHandle, 'aspell_config_retrieve_bool');
  449. if not Assigned(aspell_config_retrieve_bool) then Exit(False);
  450. aspell_config_retrieve_int := nil;
  451. Pointer(aspell_config_retrieve_int) := GetProcedureAddress(LibHandle, 'aspell_config_retrieve_int');
  452. if not Assigned(aspell_config_retrieve_int) then Exit(False);
  453. aspell_error_is_a := nil;
  454. Pointer(aspell_error_is_a) := GetProcedureAddress(LibHandle, 'aspell_error_is_a');
  455. if not Assigned(aspell_error_is_a) then Exit(False);
  456. aspell_error_number := nil;
  457. Pointer(aspell_error_number) := GetProcedureAddress(LibHandle, 'aspell_error_number');
  458. if not Assigned(aspell_error_number) then Exit(False);
  459. aspell_error_message := nil;
  460. Pointer(aspell_error_message) := GetProcedureAddress(LibHandle, 'aspell_error_message');
  461. if not Assigned(aspell_error_message) then Exit(False);
  462. aspell_error := nil;
  463. Pointer(aspell_error) := GetProcedureAddress(LibHandle, 'aspell_error');
  464. if not Assigned(aspell_error) then Exit(False);
  465. delete_aspell_can_have_error := nil;
  466. Pointer(delete_aspell_can_have_error) := GetProcedureAddress(LibHandle, 'delete_aspell_can_have_error');
  467. if not Assigned(delete_aspell_can_have_error) then Exit(False);
  468. new_aspell_speller := nil;
  469. Pointer(new_aspell_speller) := GetProcedureAddress(LibHandle, 'new_aspell_speller');
  470. if not Assigned(new_aspell_speller) then Exit(False);
  471. to_aspell_speller := nil;
  472. Pointer(to_aspell_speller) := GetProcedureAddress(LibHandle, 'to_aspell_speller');
  473. if not Assigned(to_aspell_speller) then Exit(False);
  474. delete_aspell_speller := nil;
  475. Pointer(delete_aspell_speller) := GetProcedureAddress(LibHandle, 'delete_aspell_speller');
  476. if not Assigned(delete_aspell_speller) then Exit(False);
  477. aspell_speller_error_number := nil;
  478. Pointer(aspell_speller_error_number) := GetProcedureAddress(LibHandle, 'aspell_speller_error_number');
  479. if not Assigned(aspell_speller_error_number) then Exit(False);
  480. aspell_speller_error_message := nil;
  481. Pointer(aspell_speller_error_message) := GetProcedureAddress(LibHandle, 'aspell_speller_error_message');
  482. if not Assigned(aspell_speller_error_message) then Exit(False);
  483. aspell_speller_error := nil;
  484. Pointer(aspell_speller_error) := GetProcedureAddress(LibHandle, 'aspell_speller_error');
  485. if not Assigned(aspell_speller_error) then Exit(False);
  486. aspell_speller_config := nil;
  487. Pointer(aspell_speller_config) := GetProcedureAddress(LibHandle, 'aspell_speller_config');
  488. if not Assigned(aspell_speller_config) then Exit(False);
  489. aspell_speller_check := nil;
  490. Pointer(aspell_speller_check) := GetProcedureAddress(LibHandle, 'aspell_speller_check');
  491. if not Assigned(aspell_speller_check) then Exit(False);
  492. aspell_speller_add_to_personal := nil;
  493. Pointer(aspell_speller_add_to_personal) := GetProcedureAddress(LibHandle, 'aspell_speller_add_to_personal');
  494. if not Assigned(aspell_speller_add_to_personal) then Exit(False);
  495. aspell_speller_add_to_session := nil;
  496. Pointer(aspell_speller_add_to_session) := GetProcedureAddress(LibHandle, 'aspell_speller_add_to_session');
  497. if not Assigned(aspell_speller_add_to_session) then Exit(False);
  498. aspell_speller_personal_word_list := nil;
  499. Pointer(aspell_speller_personal_word_list) := GetProcedureAddress(LibHandle, 'aspell_speller_personal_word_list');
  500. if not Assigned(aspell_speller_personal_word_list) then Exit(False);
  501. aspell_speller_session_word_list := nil;
  502. Pointer(aspell_speller_session_word_list) := GetProcedureAddress(LibHandle, 'aspell_speller_session_word_list');
  503. if not Assigned(aspell_speller_session_word_list) then Exit(False);
  504. aspell_speller_main_word_list := nil;
  505. Pointer(aspell_speller_main_word_list) := GetProcedureAddress(LibHandle, 'aspell_speller_main_word_list');
  506. if not Assigned(aspell_speller_main_word_list) then Exit(False);
  507. aspell_speller_save_all_word_lists := nil;
  508. Pointer(aspell_speller_save_all_word_lists) := GetProcedureAddress(LibHandle, 'aspell_speller_save_all_word_lists');
  509. if not Assigned(aspell_speller_save_all_word_lists) then Exit(False);
  510. aspell_speller_clear_session := nil;
  511. Pointer(aspell_speller_clear_session) := GetProcedureAddress(LibHandle, 'aspell_speller_clear_session');
  512. if not Assigned(aspell_speller_clear_session) then Exit(False);
  513. aspell_speller_suggest := nil;
  514. Pointer(aspell_speller_suggest) := GetProcedureAddress(LibHandle, 'aspell_speller_suggest');
  515. if not Assigned(aspell_speller_suggest) then Exit(False);
  516. aspell_speller_store_replacement := nil;
  517. Pointer(aspell_speller_store_replacement) := GetProcedureAddress(LibHandle, 'aspell_speller_store_replacement');
  518. if not Assigned(aspell_speller_store_replacement) then Exit(False);
  519. delete_aspell_filter := nil;
  520. Pointer(delete_aspell_filter) := GetProcedureAddress(LibHandle, 'delete_aspell_filter');
  521. if not Assigned(delete_aspell_filter) then Exit(False);
  522. aspell_filter_error_number := nil;
  523. Pointer(aspell_filter_error_number) := GetProcedureAddress(LibHandle, 'aspell_filter_error_number');
  524. if not Assigned(aspell_filter_error_number) then Exit(False);
  525. aspell_filter_error_message := nil;
  526. Pointer(aspell_filter_error_message) := GetProcedureAddress(LibHandle, 'aspell_filter_error_message');
  527. if not Assigned(aspell_filter_error_message) then Exit(False);
  528. aspell_filter_error := nil;
  529. Pointer(aspell_filter_error) := GetProcedureAddress(LibHandle, 'aspell_filter_error');
  530. if not Assigned(aspell_filter_error) then Exit(False);
  531. to_aspell_filter := nil;
  532. Pointer(to_aspell_filter) := GetProcedureAddress(LibHandle, 'to_aspell_filter');
  533. if not Assigned(to_aspell_filter) then Exit(False);
  534. delete_aspell_document_checker := nil;
  535. Pointer(delete_aspell_document_checker) := GetProcedureAddress(LibHandle, 'delete_aspell_document_checker');
  536. if not Assigned(delete_aspell_document_checker) then Exit(False);
  537. aspell_document_checker_error_number := nil;
  538. Pointer(aspell_document_checker_error_number) := GetProcedureAddress(LibHandle, 'aspell_document_checker_error_number');
  539. if not Assigned(aspell_document_checker_error_number) then Exit(False);
  540. aspell_document_checker_error_message := nil;
  541. Pointer(aspell_document_checker_error_message) := GetProcedureAddress(LibHandle, 'aspell_document_checker_error_message');
  542. if not Assigned(aspell_document_checker_error_message) then Exit(False);
  543. aspell_document_checker_error := nil;
  544. Pointer(aspell_document_checker_error) := GetProcedureAddress(LibHandle, 'aspell_document_checker_error');
  545. if not Assigned(aspell_document_checker_error) then Exit(False);
  546. new_aspell_document_checker := nil;
  547. Pointer(new_aspell_document_checker) := GetProcedureAddress(LibHandle, 'new_aspell_document_checker');
  548. if not Assigned(new_aspell_document_checker) then Exit(False);
  549. to_aspell_document_checker := nil;
  550. Pointer(to_aspell_document_checker) := GetProcedureAddress(LibHandle, 'to_aspell_document_checker');
  551. if not Assigned(to_aspell_document_checker) then Exit(False);
  552. aspell_document_checker_reset := nil;
  553. Pointer(aspell_document_checker_reset) := GetProcedureAddress(LibHandle, 'aspell_document_checker_reset');
  554. if not Assigned(aspell_document_checker_reset) then Exit(False);
  555. aspell_document_checker_process := nil;
  556. Pointer(aspell_document_checker_process) := GetProcedureAddress(LibHandle, 'aspell_document_checker_process');
  557. if not Assigned(aspell_document_checker_process) then Exit(False);
  558. __aspell_document_checker_next_misspelling := nil;
  559. Pointer(__aspell_document_checker_next_misspelling) := GetProcedureAddress(LibHandle, 'aspell_document_checker_next_misspelling');
  560. if not Assigned(__aspell_document_checker_next_misspelling) then Exit(False);
  561. aspell_document_checker_filter := nil;
  562. Pointer(aspell_document_checker_filter) := GetProcedureAddress(LibHandle, 'aspell_document_checker_filter');
  563. if not Assigned(aspell_document_checker_filter) then Exit(False);
  564. aspell_word_list_empty := nil;
  565. Pointer(aspell_word_list_empty) := GetProcedureAddress(LibHandle, 'aspell_word_list_empty');
  566. if not Assigned(aspell_word_list_empty) then Exit(False);
  567. aspell_word_list_size := nil;
  568. Pointer(aspell_word_list_size) := GetProcedureAddress(LibHandle, 'aspell_word_list_size');
  569. if not Assigned(aspell_word_list_size) then Exit(False);
  570. aspell_word_list_elements := nil;
  571. Pointer(aspell_word_list_elements) := GetProcedureAddress(LibHandle, 'aspell_word_list_elements');
  572. if not Assigned(aspell_word_list_elements) then Exit(False);
  573. delete_aspell_string_enumeration := nil;
  574. Pointer(delete_aspell_string_enumeration) := GetProcedureAddress(LibHandle, 'delete_aspell_string_enumeration');
  575. if not Assigned(delete_aspell_string_enumeration) then Exit(False);
  576. aspell_string_enumeration_clone := nil;
  577. Pointer(aspell_string_enumeration_clone) := GetProcedureAddress(LibHandle, 'aspell_string_enumeration_clone');
  578. if not Assigned(aspell_string_enumeration_clone) then Exit(False);
  579. aspell_string_enumeration_assign := nil;
  580. Pointer(aspell_string_enumeration_assign) := GetProcedureAddress(LibHandle, 'aspell_string_enumeration_assign');
  581. if not Assigned(aspell_string_enumeration_assign) then Exit(False);
  582. aspell_string_enumeration_at_end := nil;
  583. Pointer(aspell_string_enumeration_at_end) := GetProcedureAddress(LibHandle, 'aspell_string_enumeration_at_end');
  584. if not Assigned(aspell_string_enumeration_at_end) then Exit(False);
  585. aspell_string_enumeration_next := nil;
  586. Pointer(aspell_string_enumeration_next) := GetProcedureAddress(LibHandle, 'aspell_string_enumeration_next');
  587. if not Assigned(aspell_string_enumeration_next) then Exit(False);
  588. get_aspell_module_info_list := nil;
  589. Pointer(get_aspell_module_info_list) := GetProcedureAddress(LibHandle, 'get_aspell_module_info_list');
  590. if not Assigned(get_aspell_module_info_list) then Exit(False);
  591. aspell_module_info_list_empty := nil;
  592. Pointer(aspell_module_info_list_empty) := GetProcedureAddress(LibHandle, 'aspell_module_info_list_empty');
  593. if not Assigned(aspell_module_info_list_empty) then Exit(False);
  594. aspell_module_info_list_size := nil;
  595. Pointer(aspell_module_info_list_size) := GetProcedureAddress(LibHandle, 'aspell_module_info_list_size');
  596. if not Assigned(aspell_module_info_list_size) then Exit(False);
  597. aspell_module_info_list_elements := nil;
  598. Pointer(aspell_module_info_list_elements) := GetProcedureAddress(LibHandle, 'aspell_module_info_list_elements');
  599. if not Assigned(aspell_module_info_list_elements) then Exit(False);
  600. get_aspell_dict_info_list := nil;
  601. Pointer(get_aspell_dict_info_list) := GetProcedureAddress(LibHandle, 'get_aspell_dict_info_list');
  602. if not Assigned(get_aspell_dict_info_list) then Exit(False);
  603. aspell_dict_info_list_empty := nil;
  604. Pointer(aspell_dict_info_list_empty) := GetProcedureAddress(LibHandle, 'aspell_dict_info_list_empty');
  605. if not Assigned(aspell_dict_info_list_empty) then Exit(False);
  606. aspell_dict_info_list_size := nil;
  607. Pointer(aspell_dict_info_list_size) := GetProcedureAddress(LibHandle, 'aspell_dict_info_list_size');
  608. if not Assigned(aspell_dict_info_list_size) then Exit(False);
  609. aspell_dict_info_list_elements := nil;
  610. Pointer(aspell_dict_info_list_elements) := GetProcedureAddress(LibHandle, 'aspell_dict_info_list_elements');
  611. if not Assigned(aspell_dict_info_list_elements) then Exit(False);
  612. aspell_module_info_enumeration_at_end := nil;
  613. Pointer(aspell_module_info_enumeration_at_end) := GetProcedureAddress(LibHandle, 'aspell_module_info_enumeration_at_end');
  614. if not Assigned(aspell_module_info_enumeration_at_end) then Exit(False);
  615. aspell_module_info_enumeration_next := nil;
  616. Pointer(aspell_module_info_enumeration_next) := GetProcedureAddress(LibHandle, 'aspell_module_info_enumeration_next');
  617. if not Assigned(aspell_module_info_enumeration_next) then Exit(False);
  618. delete_aspell_module_info_enumeration := nil;
  619. Pointer(delete_aspell_module_info_enumeration) := GetProcedureAddress(LibHandle, 'delete_aspell_module_info_enumeration');
  620. if not Assigned(delete_aspell_module_info_enumeration) then Exit(False);
  621. aspell_module_info_enumeration_clone := nil;
  622. Pointer(aspell_module_info_enumeration_clone) := GetProcedureAddress(LibHandle, 'aspell_module_info_enumeration_clone');
  623. if not Assigned(aspell_module_info_enumeration_clone) then Exit(False);
  624. aspell_module_info_enumeration_assign := nil;
  625. Pointer(aspell_module_info_enumeration_assign) := GetProcedureAddress(LibHandle, 'aspell_module_info_enumeration_assign');
  626. if not Assigned(aspell_module_info_enumeration_assign) then Exit(False);
  627. aspell_dict_info_enumeration_at_end := nil;
  628. Pointer(aspell_dict_info_enumeration_at_end) := GetProcedureAddress(LibHandle, 'aspell_dict_info_enumeration_at_end');
  629. if not Assigned(aspell_dict_info_enumeration_at_end) then Exit(False);
  630. aspell_dict_info_enumeration_next := nil;
  631. Pointer(aspell_dict_info_enumeration_next) := GetProcedureAddress(LibHandle, 'aspell_dict_info_enumeration_next');
  632. if not Assigned(aspell_dict_info_enumeration_next) then Exit(False);
  633. delete_aspell_dict_info_enumeration := nil;
  634. Pointer(delete_aspell_dict_info_enumeration) := GetProcedureAddress(LibHandle, 'delete_aspell_dict_info_enumeration');
  635. if not Assigned(delete_aspell_dict_info_enumeration) then Exit(False);
  636. aspell_dict_info_enumeration_clone := nil;
  637. Pointer(aspell_dict_info_enumeration_clone) := GetProcedureAddress(LibHandle, 'aspell_dict_info_enumeration_clone');
  638. if not Assigned(aspell_dict_info_enumeration_clone) then Exit(False);
  639. aspell_dict_info_enumeration_assign := nil;
  640. Pointer(aspell_dict_info_enumeration_assign) := GetProcedureAddress(LibHandle, 'aspell_dict_info_enumeration_assign');
  641. if not Assigned(aspell_dict_info_enumeration_assign) then Exit(False);
  642. new_aspell_string_list := nil;
  643. Pointer(new_aspell_string_list) := GetProcedureAddress(LibHandle, 'new_aspell_string_list');
  644. if not Assigned(new_aspell_string_list) then Exit(False);
  645. aspell_string_list_empty := nil;
  646. Pointer(aspell_string_list_empty) := GetProcedureAddress(LibHandle, 'aspell_string_list_empty');
  647. if not Assigned(aspell_string_list_empty) then Exit(False);
  648. aspell_string_list_size := nil;
  649. Pointer(aspell_string_list_size) := GetProcedureAddress(LibHandle, 'aspell_string_list_size');
  650. if not Assigned(aspell_string_list_size) then Exit(False);
  651. aspell_string_list_elements := nil;
  652. Pointer(aspell_string_list_elements) := GetProcedureAddress(LibHandle, 'aspell_string_list_elements');
  653. if not Assigned(aspell_string_list_elements) then Exit(False);
  654. aspell_string_list_add := nil;
  655. Pointer(aspell_string_list_add) := GetProcedureAddress(LibHandle, 'aspell_string_list_add');
  656. if not Assigned(aspell_string_list_add) then Exit(False);
  657. aspell_string_list_remove := nil;
  658. Pointer(aspell_string_list_remove) := GetProcedureAddress(LibHandle, 'aspell_string_list_remove');
  659. if not Assigned(aspell_string_list_remove) then Exit(False);
  660. aspell_string_list_clear := nil;
  661. Pointer(aspell_string_list_clear) := GetProcedureAddress(LibHandle, 'aspell_string_list_clear');
  662. if not Assigned(aspell_string_list_clear) then Exit(False);
  663. aspell_string_list_to_mutable_container := nil;
  664. Pointer(aspell_string_list_to_mutable_container) := GetProcedureAddress(LibHandle, 'aspell_string_list_to_mutable_container');
  665. if not Assigned(aspell_string_list_to_mutable_container) then Exit(False);
  666. delete_aspell_string_list := nil;
  667. Pointer(delete_aspell_string_list) := GetProcedureAddress(LibHandle, 'delete_aspell_string_list');
  668. if not Assigned(delete_aspell_string_list) then Exit(False);
  669. aspell_string_list_clone := nil;
  670. Pointer(aspell_string_list_clone) := GetProcedureAddress(LibHandle, 'aspell_string_list_clone');
  671. if not Assigned(aspell_string_list_clone) then Exit(False);
  672. aspell_string_list_assign := nil;
  673. Pointer(aspell_string_list_assign) := GetProcedureAddress(LibHandle, 'aspell_string_list_assign');
  674. if not Assigned(aspell_string_list_assign) then Exit(False);
  675. new_aspell_string_map := nil;
  676. Pointer(new_aspell_string_map) := GetProcedureAddress(LibHandle, 'new_aspell_string_map');
  677. if not Assigned(new_aspell_string_map) then Exit(False);
  678. aspell_string_map_add := nil;
  679. Pointer(aspell_string_map_add) := GetProcedureAddress(LibHandle, 'aspell_string_map_add');
  680. if not Assigned(aspell_string_map_add) then Exit(False);
  681. aspell_string_map_remove := nil;
  682. Pointer(aspell_string_map_remove) := GetProcedureAddress(LibHandle, 'aspell_string_map_remove');
  683. if not Assigned(aspell_string_map_remove) then Exit(False);
  684. aspell_string_map_clear := nil;
  685. Pointer(aspell_string_map_clear) := GetProcedureAddress(LibHandle, 'aspell_string_map_clear');
  686. if not Assigned(aspell_string_map_clear) then Exit(False);
  687. aspell_string_map_to_mutable_container := nil;
  688. Pointer(aspell_string_map_to_mutable_container) := GetProcedureAddress(LibHandle, 'aspell_string_map_to_mutable_container');
  689. if not Assigned(aspell_string_map_to_mutable_container) then Exit(False);
  690. delete_aspell_string_map := nil;
  691. Pointer(delete_aspell_string_map) := GetProcedureAddress(LibHandle, 'delete_aspell_string_map');
  692. if not Assigned(delete_aspell_string_map) then Exit(False);
  693. aspell_string_map_clone := nil;
  694. Pointer(aspell_string_map_clone) := GetProcedureAddress(LibHandle, 'aspell_string_map_clone');
  695. if not Assigned(aspell_string_map_clone) then Exit(False);
  696. aspell_string_map_assign := nil;
  697. Pointer(aspell_string_map_assign) := GetProcedureAddress(LibHandle, 'aspell_string_map_assign');
  698. if not Assigned(aspell_string_map_assign) then Exit(False);
  699. aspell_string_map_empty := nil;
  700. Pointer(aspell_string_map_empty) := GetProcedureAddress(LibHandle, 'aspell_string_map_empty');
  701. if not Assigned(aspell_string_map_empty) then Exit(False);
  702. aspell_string_map_size := nil;
  703. Pointer(aspell_string_map_size) := GetProcedureAddress(LibHandle, 'aspell_string_map_size');
  704. if not Assigned(aspell_string_map_size) then Exit(False);
  705. aspell_string_map_elements := nil;
  706. Pointer(aspell_string_map_elements) := GetProcedureAddress(LibHandle, 'aspell_string_map_elements');
  707. if not Assigned(aspell_string_map_elements) then Exit(False);
  708. aspell_string_map_insert := nil;
  709. Pointer(aspell_string_map_insert) := GetProcedureAddress(LibHandle, 'aspell_string_map_insert');
  710. if not Assigned(aspell_string_map_insert) then Exit(False);
  711. aspell_string_map_replace := nil;
  712. Pointer(aspell_string_map_replace) := GetProcedureAddress(LibHandle, 'aspell_string_map_replace');
  713. if not Assigned(aspell_string_map_replace) then Exit(False);
  714. aspell_string_map_lookup := nil;
  715. Pointer(aspell_string_map_lookup) := GetProcedureAddress(LibHandle, 'aspell_string_map_lookup');
  716. if not Assigned(aspell_string_map_lookup) then Exit(False);
  717. aspell_string_pair_enumeration_at_end := nil;
  718. Pointer(aspell_string_pair_enumeration_at_end) := GetProcedureAddress(LibHandle, 'aspell_string_pair_enumeration_at_end');
  719. if not Assigned(aspell_string_pair_enumeration_at_end) then Exit(False);
  720. aspell_string_pair_enumeration_next := nil;
  721. Pointer(aspell_string_pair_enumeration_next) := GetProcedureAddress(LibHandle, 'aspell_string_pair_enumeration_next');
  722. if not Assigned(aspell_string_pair_enumeration_next) then Exit(False);
  723. delete_aspell_string_pair_enumeration := nil;
  724. Pointer(delete_aspell_string_pair_enumeration) := GetProcedureAddress(LibHandle, 'delete_aspell_string_pair_enumeration');
  725. if not Assigned(delete_aspell_string_pair_enumeration) then Exit(False);
  726. aspell_string_pair_enumeration_clone := nil;
  727. Pointer(aspell_string_pair_enumeration_clone) := GetProcedureAddress(LibHandle, 'aspell_string_pair_enumeration_clone');
  728. if not Assigned(aspell_string_pair_enumeration_clone) then Exit(False);
  729. aspell_string_pair_enumeration_assign := nil;
  730. Pointer(aspell_string_pair_enumeration_assign) := GetProcedureAddress(LibHandle, 'aspell_string_pair_enumeration_assign');
  731. if not Assigned(aspell_string_pair_enumeration_assign) then Exit(False);
  732. aspell_reset_cache := nil;
  733. Pointer(aspell_reset_cache) := GetProcedureAddress(LibHandle, 'aspell_reset_cache');
  734. if not Assigned(aspell_reset_cache) then Exit(False);
  735. end;
  736. function aspell_loaded: Boolean;
  737. begin
  738. aspell_loaded := LibHandle <> 0;
  739. end;
  740. function aspell_document_checker_next_misspelling(ths: PAspellDocumentChecker
  741. ): AspellToken;
  742. begin
  743. // yup...
  744. aspell_document_checker_next_misspelling := AspellToken(__aspell_document_checker_next_misspelling(ths));
  745. end;
  746. initialization
  747. aspell_init(libaspell);
  748. finalization
  749. if LibHandle <> 0 then
  750. UnloadLibrary(LibHandle);
  751. end.