1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #ifndef EXTENSIONS_SPELLCHECK_HUNSPELL_GLUE_RLBOXHUNSPELL_H_
7 #define EXTENSIONS_SPELLCHECK_HUNSPELL_GLUE_RLBOXHUNSPELL_H_
8 
9 #include "RLBoxHunspellTypes.h"
10 
11 // Load general firefox configuration of RLBox
12 #include "mozilla/rlbox/rlbox_config.h"
13 
14 #ifdef MOZ_WASM_SANDBOXING_HUNSPELL
15 #  include "mozilla/rlbox/rlbox_lucet_sandbox.hpp"
16 #else
17 // Extra configuration for no-op sandbox
18 #  define RLBOX_USE_STATIC_CALLS() rlbox_noop_sandbox_lookup_symbol
19 #  include "mozilla/rlbox/rlbox_noop_sandbox.hpp"
20 #endif
21 
22 #include "mozilla/rlbox/rlbox.hpp"
23 
24 #include <hunspell.h>
25 #include "mozHunspellRLBoxGlue.h"
26 
27 class RLBoxHunspell {
28  public:
29   RLBoxHunspell(const nsAutoCString& affpath, const nsAutoCString& dpath);
30   ~RLBoxHunspell();
31 
32   int spell(const std::string& stdWord);
33   const std::string& get_dict_encoding() const;
34 
35   std::vector<std::string> suggest(const std::string& word);
36 
37  private:
38   rlbox_sandbox_hunspell mSandbox;
39   sandbox_callback_hunspell<hunspell_create_filemgr_t*> mCreateFilemgr;
40   sandbox_callback_hunspell<hunspell_get_line_t*> mGetLine;
41   sandbox_callback_hunspell<hunspell_get_line_num_t*> mGetLineNum;
42   sandbox_callback_hunspell<hunspell_destruct_filemgr_t*> mDestructFilemgr;
43   sandbox_callback_hunspell<hunspell_ToUpperCase_t*> mHunspellToUpperCase;
44   sandbox_callback_hunspell<hunspell_ToLowerCase_t*> mHunspellToLowerCase;
45   sandbox_callback_hunspell<hunspell_get_current_cs_t*> mHunspellGetCurrentCS;
46   tainted_hunspell<Hunhandle*> mHandle;
47   std::string mDicEncoding;
48 };
49 
50 #endif
51