VMS Help  —  CRTL  setenv
    Inserts or resets the environment variable specified by name in
    the current environment list.

    Format

      #include  <stdlib.h>

      int setenv  (const char *name, const char *value, int
                  overwrite);

1  –  Arguments

 name

    A variable name in the environment variable list.

 value

    The value for the environment variable.

 overwrite

    A value of 0 or 1 indicating whether to reset the environment
    variable, if it exists.

2  –  Description

    The setenv function inserts or resets the environment variable
    name in the current environment list. If the variable name does
    not exist in the list, it is inserted with the value argument. If
    the variable does exist, the overwrite argument is tested. When
    the overwrite argument value is:

    o  0 then the variable is not reset.

    o  1 then the variable is reset to value.

                                   NOTE

       Do not use the setenv, getenv, and putenv functions to
       manipulate symbols and logicals. Instead, use the OpenVMS
       library calls lib$set_logical, lib$get_logical, lib$set_
       symbol, and lib$get_symbol. The *env functions deliberately
       provide UNIX behavior, and are not a substitute for these
       OpenVMS runtime library calls.

       OpenVMS DCL symbols, not logical names, are the closest
       analog to environment variables on UNIX systems. While
       getenv is a mechanism to retrieve either a logical name
       or a symbol, it maintains an internal cache of values for
       use with setenv and subsequent getenv calls. The setenv
       function does not write or create DCL symbols or OpenVMS
       logical names.

       This is consistent with UNIX behavior. On UNIX systems,
       setenv does not change or create any symbols that will be
       visible in the shell after the program exits.

3  –  Return Values

    0                  Indicates success.
    -1                 Indicates an error. errno is set to ENOMEM-
                       Not enough memory available to expand the
                       environment list.
Close Help