You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

init.lua 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --[[
  2. Copyright (c) 2019, Vsevolod Stakhov <vsevolod@highsecure.ru>
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ]]--
  13. --[[[
  14. -- @module lua_ffi
  15. -- This module contains ffi interfaces (requires luajit or lua-ffi)
  16. --]]
  17. local ffi
  18. local exports = {}
  19. if type(jit) == 'table' then
  20. ffi = require "ffi"
  21. local NULL = ffi.new 'void*'
  22. exports.is_null = function(o)
  23. return o ~= NULL
  24. end
  25. else
  26. local ret,result_or_err = pcall(require, 'ffi')
  27. if not ret then
  28. return {}
  29. end
  30. ffi = result_or_err
  31. -- Lua ffi
  32. local NULL = ffi.NULL or ffi.C.NULL
  33. exports.is_null = function(o)
  34. return o ~= NULL
  35. end
  36. end
  37. pcall(ffi.load, "rspamd-server", true)
  38. exports.common = require "lua_ffi/common"
  39. exports.dkim = require "lua_ffi/dkim"
  40. exports.spf = require "lua_ffi/spf"
  41. exports.linalg = require "lua_ffi/linalg"
  42. for k,v in pairs(ffi) do
  43. -- Preserve all stuff to use lua_ffi as ffi itself
  44. exports[k] = v
  45. end
  46. return exports