environment.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. /** @brief Default context.
  21. *
  22. * The actual default context IRI used throughout the application may use a
  23. * value from the `LSUP_DEFAULT_CTX_URI` environment variable.
  24. */
  25. #define DEFAULT_CTX_LABEL LSUP_NS "default"
  26. /// Default context.
  27. extern LSUP_Term *LSUP_default_ctx;
  28. /// Serialized default context.
  29. extern LSUP_Buffer *LSUP_default_ctx_buf;
  30. /** @brief Initialize the default environment.
  31. *
  32. * This must be called before using the library.
  33. *
  34. * The default environment is cleaned up automatically on exit.
  35. *
  36. * This environment should suit most cases, unless an application needs to use
  37. * multiple environments and call #LSUP_init with specific handles. Such
  38. * other environment(s) must be freed up manually with #LSUP_done().
  39. */
  40. LSUP_rc
  41. LSUP_init (void);
  42. /** @brief Close the default environment.
  43. *
  44. * This is called by atexit(). If called before then, subsequent calls have
  45. * no effect.
  46. */
  47. void
  48. LSUP_done (void);
  49. /** TODO
  50. */
  51. LSUP_rc
  52. LSUP_env_put_id (const uint32_t key, const char *data);
  53. /** TODO
  54. */
  55. const char *
  56. LSUP_env_get_id (const uint32_t key);
  57. /// @} END defgroup environment
  58. #endif /* _LSUP_ENVIRONMENT_H */