cstdlib.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // Copyright (c) 2012 Artyom Beilis (Tonkikh)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // https://www.boost.org/LICENSE_1_0.txt
  6. #ifndef BOOST_NOWIDE_CSTDLIB_HPP_INCLUDED
  7. #define BOOST_NOWIDE_CSTDLIB_HPP_INCLUDED
  8. #include <boost/nowide/config.hpp>
  9. #if !defined(BOOST_WINDOWS)
  10. #include <cstdlib>
  11. #endif
  12. namespace boost {
  13. namespace nowide {
  14. #if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN)
  15. using std::getenv;
  16. using std::system;
  17. #else
  18. ///
  19. /// \brief UTF-8 aware getenv. Returns 0 if the variable is not set.
  20. ///
  21. /// This function is not thread safe or reenterable as defined by the standard library
  22. ///
  23. BOOST_NOWIDE_DECL char* getenv(const char* key);
  24. ///
  25. /// Same as std::system but cmd is UTF-8.
  26. ///
  27. BOOST_NOWIDE_DECL int system(const char* cmd);
  28. #endif
  29. ///
  30. /// \brief Set environment variable \a key to \a value
  31. ///
  32. /// if overwrite is not 0, that the old value is always overwritten, otherwise,
  33. /// if the variable exists it remains unchanged
  34. ///
  35. /// \a key and \a value are UTF-8 on Windows
  36. /// \return zero on success, else nonzero
  37. ///
  38. BOOST_NOWIDE_DECL int setenv(const char* key, const char* value, int overwrite);
  39. ///
  40. /// \brief Remove environment variable \a key
  41. ///
  42. /// \a key is UTF-8 on Windows
  43. /// \return zero on success, else nonzero
  44. ///
  45. BOOST_NOWIDE_DECL int unsetenv(const char* key);
  46. ///
  47. /// \brief Adds or changes an environment variable, \a string must be in format KEY=VALUE
  48. ///
  49. /// \a string MAY become part of the environment, hence changes to the value MAY change
  50. /// the environment. For portability it is hence recommended NOT to change it.
  51. /// \a string is UTF-8 on Windows
  52. /// \return zero on success, else nonzero
  53. ///
  54. BOOST_NOWIDE_DECL int putenv(char* string);
  55. } // namespace nowide
  56. } // namespace boost
  57. #endif