environment.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 "term.h"
  13. /*
  14. * External variables.
  15. */
  16. extern LSUP_NSMap *LSUP_default_nsm; /// Default namespace prefix map.
  17. extern LSUP_Term *LSUP_default_ctx; /// Default context.
  18. extern LSUP_Buffer *LSUP_default_ctx_buf; /// Serialized default context.
  19. /** @brief Initialize the default environment.
  20. *
  21. * This must be called before using the library.
  22. *
  23. * The default environment is cleaned up automatically on exit.
  24. *
  25. * This environment should suit most cases, unless an application needs to use
  26. * multiple environments and call #LSUP_init with specific handles. Such
  27. * other environment(s) must be freed up manually with #LSUP_done().
  28. */
  29. LSUP_rc
  30. LSUP_init (void);
  31. /** @brief Close the default environment.
  32. *
  33. * This is called by atexit(). If called before then, subsequent calls have
  34. * no effect.
  35. */
  36. void
  37. LSUP_done (void);
  38. /** TODO
  39. */
  40. LSUP_rc
  41. LSUP_env_put_id (const uint32_t key, const char *data);
  42. /** TODO
  43. */
  44. const char *
  45. LSUP_env_get_id (const uint32_t key);
  46. #endif /* _LSUP_ENVIRONMENT_H */