cstdlib.hpp 1.9 KB

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