#include <qp0z1170.h> int Qp0zDltEnv(const char *name);Service Program Name: QP0ZCPA
The Qp0zDltEnv() function deletes a single job-level environment variable or deletes all environment variables from the current job. If the name parameter is NULL, all environment variables in the job are deleted.
The name parameter does not include the equal (=) symbol or the value of the environment variable name=value pair.
None.
0 | Qp0zDltEnv() was successful. |
-1 | Qp0zDltEnv() was not successful. The errno variable is set to indicate the error. |
If Qp0zDltEnv() is not successful, errno indicates one of the following errors.
No such path or directory.
The directory or a component of the path name specified does not exist.
A named file or directory does not exist or is an empty string.
The parameter name is not NULL and does not point to an environment variable name that currently exists in the environment list.
See Code disclaimer information for information pertaining to code examples.
The following example uses Qp0zDltEnv(), putenv() and the environ array.
#include <stdio.h> #include <errno.h> #include <qp0z1170.h> #include <stdlib.h> extern char **environ; #define ASSERT(x, y) \ { if (!(x)) { \ printf("Assertion Failed: " #x \ ", Description: " y \ ", errno=%d", errno); \ exit(EXIT_FAILURE); \ } \ } int main(int argc, char **argv) { int rc=0; int e=0; printf("Enter Testcase - %s\n", argv[0]); rc = putenv("PATH=/usr/bin:/home/me:%LIBL%"); ASSERT((rc == 0), "putenv(PATH)"); rc = putenv("TEST0=42"); ASSERT((rc == 0), "putenv(TEST0)"); rc = putenv("TEST1=42"); ASSERT((rc == 0), "putenv(TEST1)"); printf("Before delete, these environment variables are set: \n"); while (environ[e] != NULL) { printf(" %s\n", environ[e]); ++e; } printf("Delete the environment variables\n"); rc = Qp0zDltEnv("TEST0"); ASSERT((rc==0), "Qp0zDltEnv(TEST0)"); rc = Qp0zDltEnv("TEST1"); ASSERT((rc==0), "Qp0zDltEnv(TEST1)"); printf("After delete, these environment variables are set: \n"); e=0; while (environ[e] != NULL) { printf(" %s\n", environ[e]); ++e; } printf("Main completed\n"); return 0; }
Output:
Enter Testcase - QP0WTEST/TPZDLTE0 Before delete, these environment variables are set: PATH=/usr/bin:/home/me:%LIBL% TEST0=42 TEST1=42 Delete the environment variables After delete, these environment variables are set: PATH=/usr/bin:/home/me:%LIBL% Main completed
Top | UNIX-Type APIs | APIs by category |