256 lines
7.0 KiB
HTML
256 lines
7.0 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
|
<title>Qp0zDltEnv()--Delete an Environment Variable</title>
|
|
<!-- Begin Header Records ========================================== -->
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<!-- Change History: -->
|
|
<!-- YYMMDD USERID Change description -->
|
|
<!-- Direct1 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
|
<!-- This file has undergone html cleanup on 04/29/02 by JET -->
|
|
<!-- End Header Records -->
|
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
|
</head>
|
|
<body>
|
|
<!-- Java sync-link -->
|
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
|
|
</script>
|
|
|
|
<a name="Top_Of_Page"></a>
|
|
|
|
<h2>Qp0zDltEnv()--Delete an Environment Variable</h2>
|
|
|
|
<div class="box" style="width: 70%;">
|
|
<br>
|
|
Syntax
|
|
|
|
<pre>
|
|
#include <qp0z1170.h>
|
|
|
|
int Qp0zDltEnv(const char <em>*name</em>);
|
|
|
|
</pre>
|
|
|
|
Service Program Name: QP0ZCPA<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: Yes. See Usage Notes for more information.<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>The <strong>Qp0zDltEnv()</strong> function deletes a single job-level
|
|
environment variable or deletes all environment variables from the current job.
|
|
If the <em>name</em> parameter is NULL, all environment variables in the job
|
|
are deleted.</p>
|
|
|
|
<p>The <em>name</em> parameter does not include the equal (=) symbol or the
|
|
<samp>value</samp> of the environment variable <samp>name=value</samp>
|
|
pair.</p>
|
|
|
|
<br>
|
|
<h3>Parameters</h3>
|
|
|
|
<dl>
|
|
<dt><strong><em>name</em></strong></dt>
|
|
|
|
<dd>(Input) A pointer to the <samp>name</samp> part of the environment variable
|
|
<samp>name=value</samp> string.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3>Authorities</h3>
|
|
|
|
<p>None.</p>
|
|
|
|
<br>
|
|
<h3>Return Value</h3>
|
|
|
|
<table cellpadding="5">
|
|
<!-- cols="5 95" -->
|
|
<tr>
|
|
<td align="left" valign="top"><em>0</em></td>
|
|
<td align="left" valign="top"><strong>Qp0zDltEnv()</strong> was
|
|
successful.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top"><em>-1</em></td>
|
|
<td align="left" valign="top"><strong>Qp0zDltEnv()</strong> was not successful.
|
|
The <em>errno</em> variable is set to indicate the error.</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
<br>
|
|
<h3>Error Conditions</h3>
|
|
|
|
<p>If <strong>Qp0zDltEnv()</strong> is not successful, <em>errno</em> indicates
|
|
one of the following errors.</p>
|
|
|
|
<dl compact>
|
|
<dt><em>[ENOENT]</em></dt>
|
|
|
|
<dd>
|
|
<p>No such path or directory.</p>
|
|
|
|
<p>The directory or a component of the path name specified does not exist.</p>
|
|
|
|
<p>A named file or directory does not exist or is an empty string.</p>
|
|
|
|
<p>The parameter <samp>name</samp> is not NULL and does not point to an
|
|
environment variable name that currently exists in the environment list.</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3>Usage Notes</h3>
|
|
|
|
<ol type="1">
|
|
<li>Although <strong>Qp0zDltEnv()</strong> is threadsafe, if a thread calls an
|
|
environment variable function while another thread is accessing an environment
|
|
variable from the environ array the thread may see undefined results. The
|
|
environ array can be accessed directly or by using a pointer returned from the
|
|
<strong>getenv()</strong> or <strong>Qp0zGetEnv()</strong> functions. The
|
|
environment contents are only protected during calls to the environment
|
|
variable functions.</li>
|
|
</ol>
|
|
|
|
<br>
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li><a href="evgetenv.htm">getenv()</a>--Get Value of Environment Variable</li>
|
|
|
|
<li><a href="evputenv.htm">putenv()</a>--Change or Add Environment
|
|
Variable</li>
|
|
|
|
<li><a href="evdltsev.htm">Qp0zDltSysEnv()</a>--Delete a System-Level
|
|
Environment Variable</li>
|
|
|
|
<li><a href="evgetall.htm">Qp0zGetAllSysEnv(</a>)--Get All System-Level
|
|
Environment Variables</li>
|
|
|
|
<li><a href="evgenvxt.htm">Qp0zGetEnv()</a>--Get Value of Environment Variable
|
|
(Extended)</li>
|
|
|
|
<li><a href="evgetsev.htm">Qp0zGetSysEnv()</a>--Get Value of System-Level
|
|
Environment Variable</li>
|
|
|
|
<li><a href="evinenv.htm">Qp0zInitEnv()</a>--Initialize Environment for
|
|
Variables</li>
|
|
|
|
<li><a href="evpenvxt.htm">Qp0zPutEnv()</a>--Change or Add Environment Variable
|
|
(Extended)</li>
|
|
|
|
<li><a href="evputsev.htm">Qp0zPutSysEnv()</a>--Change or Add a System-Level
|
|
Environment</li>
|
|
</ul>
|
|
|
|
<br>
|
|
<h3>Example</h3>
|
|
|
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
|
for information pertaining to code examples.</p>
|
|
|
|
<p>The following example uses <strong>Qp0zDltEnv()</strong>, <strong>
|
|
putenv()</strong> and the environ array.</p>
|
|
|
|
<pre>
|
|
<!-- <font size="-1"> -->
|
|
|
|
#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;
|
|
}
|
|
<!-- </font> -->
|
|
</pre>
|
|
|
|
<p><strong>Output:</strong></p>
|
|
|
|
<pre>
|
|
<!-- <font size="-1"> -->
|
|
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
|
|
<!-- </font> -->
|
|
</pre>
|
|
|
|
<br>
|
|
<hr>
|
|
API introduced: V4R3
|
|
|
|
<hr>
|
|
<center>
|
|
<table cellpadding="2" cellspacing="2">
|
|
<tr align="center">
|
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
|
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</body>
|
|
</html>
|
|
|