[1693] | 1 | (* ***** BEGIN LICENSE BLOCK *****
|
---|
| 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
| 3 | *
|
---|
| 4 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
| 5 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
| 6 | * the License. You may obtain a copy of the License at
|
---|
| 7 | * http://www.mozilla.org/MPL/
|
---|
| 8 | *
|
---|
| 9 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
| 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
| 11 | * for the specific language governing rights and limitations under the
|
---|
| 12 | * License.
|
---|
| 13 | *
|
---|
| 14 | * Copyright (C) 2006
|
---|
| 15 | * Miha Vrhovnik (http://simail.sf.net, http://xcollect.sf.net)
|
---|
| 16 | * All Rights Reserved.
|
---|
| 17 | *
|
---|
| 18 | * Contributor(s):
|
---|
| 19 | *
|
---|
| 20 | *
|
---|
| 21 | * Alternatively, the contents of this file may be used under the terms of
|
---|
| 22 | * either the GNU General Public License Version 2 or later (the "GPL"), or
|
---|
| 23 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
| 24 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
| 25 | * of those above. If you wish to allow use of your version of this file only
|
---|
| 26 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
| 27 | * use your version of this file under the terms of the MPL, indicate your
|
---|
| 28 | * decision by deleting the provisions above and replace them with the notice
|
---|
| 29 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
| 30 | * the provisions above, a recipient may use your version of this file under
|
---|
| 31 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
| 32 | *
|
---|
| 33 | * ***** END LICENSE BLOCK ***** **)
|
---|
| 34 | unit uHunSpellLib;
|
---|
| 35 |
|
---|
| 36 | interface
|
---|
| 37 | uses Windows, SysUtils;
|
---|
| 38 |
|
---|
| 39 | var hunspell_initialize: function(aff_file: PAnsiChar; dict_file: PAnsiChar): Pointer; cdecl;
|
---|
| 40 | var hunspell_uninitialize: procedure(sspel: Pointer); cdecl;
|
---|
| 41 | var hunspell_spell: function(spell: Pointer; word: PAnsiChar): Boolean; cdecl;
|
---|
| 42 | var hunspell_suggest: function(spell: Pointer; word: PAnsiChar; var suggestions: PPAnsiChar): Integer; cdecl;
|
---|
| 43 | var hunspell_suggest_auto: function(spell: Pointer; word: PAnsiChar; var suggestions: PPAnsiChar): Integer; cdecl;
|
---|
| 44 | var hunspell_suggest_free: procedure(spell: Pointer; suggestions: PPAnsiChar; suggestLen: Integer); cdecl;
|
---|
| 45 | var hunspell_get_dic_encoding: function(spell: Pointer): PAnsiChar; cdecl;
|
---|
| 46 | var hunspell_put_word: function(spell: Pointer; word: PAnsiChar): Integer; cdecl;
|
---|
| 47 |
|
---|
| 48 | var LibsLoaded: Boolean = False;
|
---|
| 49 | var DLLHandle: THandle;
|
---|
| 50 |
|
---|
| 51 | function LoadLibHunspell(libraryName: String): Boolean;
|
---|
| 52 |
|
---|
| 53 | implementation
|
---|
| 54 |
|
---|
| 55 | function LoadLibHunspell(libraryName: String): Boolean;
|
---|
| 56 | begin
|
---|
| 57 | if libraryName = '' then
|
---|
| 58 | libraryName := 'hunspelldll.dll';
|
---|
| 59 |
|
---|
| 60 | Result := LibsLoaded;
|
---|
| 61 | if Result then //already loaded.
|
---|
| 62 | exit;
|
---|
| 63 |
|
---|
| 64 | DLLHandle := LoadLibrary(PChar(libraryName));
|
---|
| 65 | if DLLHandle <> 0 then begin
|
---|
| 66 | Result := True; //assume everything ok unless..
|
---|
| 67 |
|
---|
| 68 | @hunspell_initialize := GetProcAddress(DLLHandle, 'hunspell_initialize');
|
---|
| 69 | if not Assigned(@hunspell_initialize) then Result := False;
|
---|
| 70 | @hunspell_uninitialize := GetProcAddress(DLLHandle, 'hunspell_uninitialize');
|
---|
| 71 | if not Assigned(@hunspell_uninitialize) then Result := False;
|
---|
| 72 | @hunspell_spell := GetProcAddress(DLLHandle, 'hunspell_spell');
|
---|
| 73 | if not Assigned(@hunspell_spell) then Result := False;
|
---|
| 74 | @hunspell_suggest := GetProcAddress(DLLHandle, 'hunspell_suggest');
|
---|
| 75 | if not Assigned(@hunspell_suggest) then Result := False;
|
---|
| 76 | @hunspell_suggest_auto := GetProcAddress(DLLHandle, 'hunspell_suggest_auto');
|
---|
| 77 | if not Assigned(@hunspell_suggest_auto) then Result := False;
|
---|
| 78 | @hunspell_suggest_free := GetProcAddress(DLLHandle, 'hunspell_suggest_free');
|
---|
| 79 | if not Assigned(@hunspell_suggest_free) then Result := False;
|
---|
| 80 | @hunspell_get_dic_encoding := GetProcAddress(DLLHandle, 'hunspell_get_dic_encoding');
|
---|
| 81 | if not Assigned(@hunspell_get_dic_encoding) then Result := False;
|
---|
| 82 | @hunspell_put_word := GetProcAddress(DLLHandle, 'hunspell_put_word');
|
---|
| 83 | if not Assigned(@hunspell_put_word) then Result := False;
|
---|
| 84 | end;
|
---|
| 85 | end;
|
---|
| 86 |
|
---|
| 87 | initialization
|
---|
| 88 |
|
---|
| 89 | finalization
|
---|
| 90 | if DLLHandle <> 0 then
|
---|
| 91 | FreeLibrary(DLLHandle);
|
---|
| 92 | end.
|
---|