putenv Change or add a name-value pair to the environment. Syntax (on unix systems, it is usually defined in: #include ) extern int putenv ( char* name_value ); Parameters name_value string in one of the following 2 forms: name to remove the name variable name=value to assign a value to the name variable Return Values 0 Success in the name variable removal, change, or addition. ENOENT name variable not found in the environment to remove. ERANGE value for JCW name not in range of 0..65535. EINVAL Invalid variable name. Read-only system variable name. Reserved name for JCW value (OK,WARN,FATAL,SYSTEM). Invalid integer value for system JCW. Description The putenv function performs one of 2 functions depending on the form of the given string value. When only a variable name is given, the variable is removed from the environment. Otherwise, if the variable does not exist, it is created; then assigned the value part which follows the "=" assignment char. Unlike unix systems, the MPE/iX environment for variables is globally defined for the Session or Job. It is not unique per process. Therefore the name_value string can be a literal and is not used as part of the environment strings. name variables must follow the rules of MPE/iX variable names. values can be integer, boolean: TRUE FALSE, or string. When they are placed into the environment, their value types are set to integer, boolean, or string. Examples #define _MPEXL_SOURCE #include /* printf */ #include /* strerror */ #include /* errno, _mpe_status */ int main () { int x; x = putenv ( "JCW=2" ); /* set system JCW value */ x = putenv ( "MYVAR=some value" ); /* create MYVAR */ printf ( "putenv=%d errno %d %s mpestat %d:%d\n", x, errno, strerror ( errno ), _mpe_status.decode.error_num, _mpe_status.decode.subsys_num ); x = putenv ( "MYVAR" ); /* delete MYVAR */ } See Also getenv(), intrinsics HPCIDELETEVAR, HPCIPUTVAR, HPCIGETVAR Author: Keven Miller 05/01/2011