Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <env.h>
    int setenv( const char *name,
                const char *newvalue,
                int overwrite );
    int _setenv( const char *name,
                 const char *newvalue,
                 int overwrite );
    int _wsetenv( const wchar_t *name,
                  const wchar_t *newvalue,
                  int overwrite );

Description:
    The environment list consists of a number of environment names, each of
    which has a value associated with it.  Entries can be added to the
    environment list with the DOS set command or with the setenv function.
     All entries in the environment list can be displayed by using the DOS
    set command with no arguments.  A program can obtain the value for an
    environment variable by using the  getenv function.

    The setenv function searches the environment list for an entry of the
    form name=value.  If no such string is present, setenv adds an entry of
    the form name=newvalue to the environment list.  Otherwise, if the
    overwrite argument is non-zero, setenv either will change the existing
    value to newvalue or will delete the string name=value and add the
    string name=newvalue.

    If the newvalue pointer is NULL, all strings of the form name=value in
    the environment list will be deleted.

    The value of the pointer  environ may change across a call to the setenv
    function.

    The setenv function will make copies of the strings associated with name
    and newvalue.

    The matching is case-insensitive; all lowercase letters are treated as
    if they were in upper case.

    Entries can also be added to the environment list with the DOS set
    command or with the  putenv or setenv functions.  All entries in the
    environment list can be obtained by using the  getenv function.

    To assign a string to a variable and place it in the environment list:


             C>SET INCLUDE=C:\WATCOM\H

    To see what variables are in the environment list, and their current
    assignments:


             C>SET
             COMSPEC=C:\COMMAND.COM
             PATH=C:\;C:\WATCOM
             INCLUDE=C:\WATCOM\H
             C>

    The _setenv function is identical to setenv.  Use _setenv for ANSI
    naming conventions.

    The _wsetenv function is a wide-character version of setenv that
    operates with wide-character strings.

Returns:
    The setenv function returns zero upon successful completion.  Otherwise,
    it will return a non-zero value and set  errno to indicate the error.

Errors:
    When an error has occurred,  errno contains a value indicating the type
    of error that has been detected.

    ENOMEM
        Not enough memory to allocate a new environment string.


Example:
    The following will change the string assigned to  INCLUDE and then
    display the new string.

    #include <stdio.h>
    #include <stdlib.h>
    #include <env.h>

    void main()
      {
        char *path;

        if( setenv( "INCLUDE", "D:\\WATCOM\\H", 1 ) == 0 )
          if( (path = getenv( "INCLUDE" )) != NULL )
            printf( "INCLUDE=%s\n", path );
      }

Classification:
    setenv is POSIX 1003.1, _setenv is not POSIX, _wsetenv is not POSIX

Systems:
     setenv - All

    _setenv - DOS, Windows, Win386, Win32, QNX/16, OS/2 1.x(all), OS/2-32
    _wsetenv - DOS, Windows, Win386, Win32, QNX/16, OS/2 1.x(all), OS/2-32

See Also:
    clearenv, exec Functions, getenv, putenv, _searchenv, spawn Functions,
    system

See Also: clearenv

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson