#include <qp0z1170.h> int Qp0zDltEnv(const char *name);
|
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.
Parameters
Authorities
None.
Return Value
Error Conditions
If Qp0zDltEnv() is not successful, errno indicates one of the following errors.
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.
Usage Notes
Related Information
Example
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 | Environment Variable APIs | APIs by category |
| [Information Center Home Page | Feedback ] | [Legal | AS/400 Glossary] |