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 11 #include <boost/nowide/config.hpp> 12 #if !defined(BOOST_WINDOWS) 13 #include <cstdlib> 14 #endif 15 16 namespace boost { 17 namespace nowide { 18 #if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN) 19 using std::getenv; 20 using std::system; 21 #else 22 /// 23 /// \brief UTF-8 aware getenv. Returns 0 if the variable is not set. 24 /// 25 /// This function is not thread safe or reenterable as defined by the standard library 26 /// 27 BOOST_NOWIDE_DECL char* getenv(const char* key); 28 29 /// 30 /// Same as std::system but cmd is UTF-8. 31 /// 32 BOOST_NOWIDE_DECL int system(const char* cmd); 33 34 #endif 35 /// 36 /// \brief Set environment variable \a key to \a value 37 /// 38 /// if overwrite is not 0, that the old value is always overwritten, otherwise, 39 /// if the variable exists it remains unchanged 40 /// 41 /// \a key and \a value are UTF-8 on Windows 42 /// \return zero on success, else nonzero 43 /// 44 BOOST_NOWIDE_DECL int setenv(const char* key, const char* value, int overwrite); 45 46 /// 47 /// \brief Remove environment variable \a key 48 /// 49 /// \a key is UTF-8 on Windows 50 /// \return zero on success, else nonzero 51 /// 52 BOOST_NOWIDE_DECL int unsetenv(const char* key); 53 54 /// 55 /// \brief Adds or changes an environment variable, \a string must be in format KEY=VALUE 56 /// 57 /// \a string MAY become part of the environment, hence changes to the value MAY change 58 /// the environment. For portability it is hence recommended NOT to change it. 59 /// \a string is UTF-8 on Windows 60 /// \return zero on success, else nonzero 61 /// 62 BOOST_NOWIDE_DECL int putenv(char* string); 63 64 } // namespace nowide 65 } // namespace boost 66 67 #endif 68