res_curl.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (c) 2008, Digium, Inc.
  5. *
  6. * Tilghman Lesher <res_curl_v1@the-tilghman.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. /*! \file
  19. *
  20. * \brief curl resource engine
  21. *
  22. * \author Tilghman Lesher <res_curl_v1@the-tilghman.com>
  23. *
  24. * Depends on the CURL library - http://curl.haxx.se/
  25. *
  26. */
  27. /*! \li \ref res_curl.c uses the configuration file \ref res_curl.conf
  28. * \addtogroup configuration_file Configuration Files
  29. */
  30. /*!
  31. * \page res_curl.conf res_curl.conf
  32. * \verbinclude res_curl.conf.sample
  33. */
  34. /*** MODULEINFO
  35. <depend>curl</depend>
  36. <support_level>core</support_level>
  37. ***/
  38. #include "asterisk.h"
  39. #include <curl/curl.h>
  40. #include "asterisk/module.h"
  41. static int unload_module(void)
  42. {
  43. curl_global_cleanup();
  44. return 0;
  45. }
  46. static int load_module(void)
  47. {
  48. int res = AST_MODULE_LOAD_SUCCESS;
  49. if (curl_global_init(CURL_GLOBAL_ALL)) {
  50. ast_log(LOG_ERROR, "Unable to initialize the cURL library. Cannot load res_curl.so\n");
  51. return AST_MODULE_LOAD_DECLINE;
  52. }
  53. return res;
  54. }
  55. AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "cURL Resource Module",
  56. .support_level = AST_MODULE_SUPPORT_CORE,
  57. .load = load_module,
  58. .unload = unload_module,
  59. .load_pri = AST_MODPRI_REALTIME_DEPEND,
  60. );