1 /* ///////////////////////////////////////////////////////////////////////// 2 * File: unixem/setenv.h 3 * 4 * Purpose: Definition of the setenv() and unsetenv() functions. 5 * 6 * Created: 9th December 2005 7 * Updated: 13th August 2010 8 * 9 * Home: http://synesis.com.au/software/ 10 * 11 * Copyright (c) 2005-2010, Matthew Wilson and Synesis Software 12 * All rights reserved. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions are 16 * met: 17 * 18 * - Redistributions of source code must retain the above copyright notice, 19 * this list of conditions and the following disclaimer. 20 * - Redistributions in binary form must reproduce the above copyright 21 * notice, this list of conditions and the following disclaimer in the 22 * documentation and/or other materials provided with the distribution. 23 * - Neither the name(s) of Matthew Wilson and Synesis Software nor the 24 * names of any contributors may be used to endorse or promote products 25 * derived from this software without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 28 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 29 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 31 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 32 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 33 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 34 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 35 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 36 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 37 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 * 39 * ////////////////////////////////////////////////////////////////////// */ 40 41 42 /** \file unixem/setenv.h Definition of the setenv() and unsetenv() functions 43 */ 44 45 #ifndef SYNSOFT_UNIXEM_INCL_UNIXEM_H_SETENV 46 #define SYNSOFT_UNIXEM_INCL_UNIXEM_H_SETENV 47 48 #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION 49 # define UNIXEM_VER_UNIXEM_H_SETENV_MAJOR 2 50 # define UNIXEM_VER_UNIXEM_H_SETENV_MINOR 0 51 # define UNIXEM_VER_UNIXEM_H_SETENV_REVISION 1 52 # define UNIXEM_VER_UNIXEM_H_SETENV_EDIT 7 53 #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */ 54 55 /* ///////////////////////////////////////////////////////////////////////// 56 * Includes 57 */ 58 59 #include <unixem/unixem.h> 60 #include <stddef.h> /* for size_t */ 61 #include <sys/types.h> /* for mode_t */ 62 63 #if defined(__WATCOMC__) 64 # error The Watcom RTL provides setenv() 65 #endif /* compiler */ 66 67 /* ////////////////////////////////////////////////////////////////////// */ 68 69 /** \weakgroup unixem Synesis Software UNIX Emulation for Win32 70 * \brief The UNIX emulation library 71 */ 72 73 /** \weakgroup unixem_setenv setenv.h 74 * \ingroup UNIXem unixem 75 * \brief setenv() and unsetenv() functions 76 * @{ 77 */ 78 79 /* ///////////////////////////////////////////////////////////////////////// 80 * API functions 81 */ 82 83 # ifdef __cplusplus 84 extern "C" { 85 # endif /* __cplusplus */ 86 87 /** Inserts or resets the value of an environment variable. 88 * 89 * This function creates a link from \c originalFile to \c linkName. 90 * 91 * \param name The name of the environment variable to add / set 92 * \param value The value of the environment variable 93 * \param bOverwrite Determines whether to overwrite the variable, if it exists, 94 * or to leave its current value intact 95 * 96 * \return O on success, or -1 if there is an error 97 */ 98 int unixem_setenv( 99 char const* name 100 , char const* value 101 , int bOverwrite 102 ); 103 104 105 /** Deletes the named environment variable, if it exists. 106 * 107 * \param name The name of the environment to delete 108 * 109 * \return O on success, or -1 if there is an error 110 */ 111 void unixem_unsetenv(char const* name); 112 113 # ifdef __cplusplus 114 } /* extern "C" */ 115 # endif /* __cplusplus */ 116 117 /* ////////////////////////////////////////////////////////////////////// */ 118 119 /** @} // end of group unixem_setenv */ 120 121 /* ////////////////////////////////////////////////////////////////////// */ 122 123 #endif /* SYNSOFT_UNIXEM_INCL_UNIXEM_H_SETENV */ 124 125 /* ///////////////////////////// end of file //////////////////////////// */ 126