' *** Adapted for FreeBasic by Electrik
#ifndef _MYSPELLMGR_BI_
#define _MYSPELLMGR_BI_
#inclib "hunspell"

extern "c"

type as any Hunhandle

declare function Hunspell_create(byval affpath as zstring ptr, byval dpath as zstring ptr) as Hunhandle ptr

declare function Hunspell_create_key(byval affpath as zstring ptr, byval dpath as zstring ptr, _
    byval key as zstring ptr) as Hunhandle ptr

declare sub Hunspell_destroy(byval pHunspell as Hunhandle ptr)

/' spell(word) - spellcheck word
 * output: 0 = bad word, not 0 = good word
 '/
declare function Hunspell_spell(byval pHunspell as Hunhandle ptr, byval as zstring ptr) as integer

declare function Hunspell_get_dic_encoding(byval pHunspell as Hunhandle ptr) as zstring ptr

/' suggest(suggestions, word) - search suggestions
 * input: pointer to an array of strings pointer and the (bad) word
 *   array of strings pointer (here *slst) may not be initialized
 * output: number of suggestions in string array, and suggestions in
 *   a newly allocated array of strings (*slts will be NULL when number
 *   of suggestion equals 0.)
 '/
declare function Hunspell_suggest(byval pHunspell as Hunhandle ptr, byval slst as zstring ptr ptr ptr, byval word as zstring ptr) as integer

 /' morphological functions '/

 /' analyze(result, word) - morphological analysis of the word '/

declare function Hunspell_analyze(byval pHunspell as Hunhandle ptr, byval slst as zstring ptr ptr ptr, byval word as zstring ptr) as integer

 /' stem(result, word) - stemmer function '/

declare function Hunspell_stem(byval pHunspell as Hunhandle ptr, byval slst as zstring ptr ptr ptr, byval word as zstring ptr) as integer

 /' stem(result, analysis, n) - get stems from a morph. analysis
  * example:
  * dim as zstring ptr ptr result, result2
  * dim as integer n1 = Hunspell_analyze(result, "words")
  * dim as integer n2 = Hunspell_stem2(result2, result, n1)   
  '/

declare function Hunspell_stem2(byval pHunspell as Hunhandle ptr, byval slst as zstring ptr ptr ptr, byval desc as zstring ptr ptr, byval n as integer) as integer

 /' generate(result, word, word2) - morphological generation by example(s) '/

declare function Hunspell_generate(byval pHunspell as Hunhandle ptr, byval slst as zstring ptr ptr ptr, byval word as zstring ptr, _
    byval word2 as zstring ptr) as integer

 /' generate(result, word, desc, n) - generation by morph. description(s)
  * example:
  * dim as zstring ptr ptr result
  * dim as zstring ptr affix = @"is:plural" ' description depends from dictionaries, too
  * dim as integer n = Hunspell_generate2(result, "word", @affix, 1)
  * for i as integer = 0 to n-1 : printf(!"%s\n", result[i]) : next
  '/

declare function Hunspell_generate2(byval pHunspell as Hunhandle ptr, byval slst as zstring ptr ptr ptr, byval word as zstring ptr, _
    byval desc as zstring ptr ptr, byval n as integer) as integer

  /' functions for run-time modification of the dictionary '/

  /' add word to the run-time dictionary '/
  
declare function Hunspell_add(byval pHunspell as Hunhandle ptr, byval word as zstring ptr) as integer

  /' add word to the run-time dictionary with affix flags of
   * the example (a dictionary word): Hunspell will recognize
   * affixed forms of the new word, too.
   '/
  
declare function Hunspell_add_with_affix(byval pHunspell as Hunhandle ptr, byval word as zstring ptr, byval example as zstring ptr) as integer

  /' remove word from the run-time dictionary '/

declare function Hunspell_remove(byval pHunspell as Hunhandle ptr, byval word as zstring ptr) as integer

  /' free suggestion lists '/

declare sub Hunspell_free_list(byval pHunspell as Hunhandle ptr, byval slst as zstring ptr ptr ptr, byval n as integer)

end extern
#endif
