environment.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /** @file environment.h
  2. *
  3. * @brief Handle LSUP environment initialization and teardown.
  4. *
  5. * #LSUP_init() should be called before performing any other interaction with
  6. * this library.
  7. *
  8. * #LSUP_done() is called automatically on program exit (`atexit`).
  9. */
  10. #ifndef _LSUP_ENVIRONMENT_H
  11. #define _LSUP_ENVIRONMENT_H
  12. #include "lsup/term.h"
  13. /**@defgroup environment Environment module
  14. * @ingroup public
  15. * @{
  16. */
  17. /*
  18. * External variables.
  19. */
  20. /// Default namespace prefix map.
  21. extern LSUP_NSMap *LSUP_default_nsm;
  22. /// Default context.
  23. extern LSUP_Term *LSUP_default_ctx;
  24. /// Serialized default context.
  25. extern LSUP_Buffer *LSUP_default_ctx_buf;
  26. /** @brief Initialize the default environment.
  27. *
  28. * This must be called before using the library.
  29. *
  30. * The default environment is cleaned up automatically on exit.
  31. *
  32. * This environment should suit most cases, unless an application needs to use
  33. * multiple environments and call #LSUP_init with specific handles. Such
  34. * other environment(s) must be freed up manually with #LSUP_done().
  35. */
  36. LSUP_rc
  37. LSUP_init (void);
  38. /** @brief Close the default environment.
  39. *
  40. * This is called by atexit(). If called before then, subsequent calls have
  41. * no effect.
  42. */
  43. void
  44. LSUP_done (void);
  45. /** TODO
  46. */
  47. LSUP_rc
  48. LSUP_env_put_id (const uint32_t key, const char *data);
  49. /** TODO
  50. */
  51. const char *
  52. LSUP_env_get_id (const uint32_t key);
  53. /// @} END defgroup environment
  54. #endif /* _LSUP_ENVIRONMENT_H */