summaryrefslogtreecommitdiff
path: root/usr/src/lib/libresolv2/common/bsd/setenv.c
diff options
context:
space:
mode:
authorRao Shoaib <Rao.Shoaib@Sun.COM>2009-11-11 08:45:41 -0800
committerRao Shoaib <Rao.Shoaib@Sun.COM>2009-11-11 08:45:41 -0800
commit9525b14bcdeb5b5f6f95ab27c2f48f18bd2ec829 (patch)
treedf51891a276edf456c1481f49653a76cdfedee53 /usr/src/lib/libresolv2/common/bsd/setenv.c
parent0324f02a004039d6377111191fdd7134452d7817 (diff)
downloadillumos-gate-9525b14bcdeb5b5f6f95ab27c2f48f18bd2ec829.tar.gz
6289479 libresolv2 clean up and alignment with libbind.6.0
Diffstat (limited to 'usr/src/lib/libresolv2/common/bsd/setenv.c')
-rw-r--r--usr/src/lib/libresolv2/common/bsd/setenv.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/usr/src/lib/libresolv2/common/bsd/setenv.c b/usr/src/lib/libresolv2/common/bsd/setenv.c
index 963d0e6e1b..baf00f6ff2 100644
--- a/usr/src/lib/libresolv2/common/bsd/setenv.c
+++ b/usr/src/lib/libresolv2/common/bsd/setenv.c
@@ -1,11 +1,6 @@
-/*
- * Copyright (c) 1997, by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)setenv.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id: setenv.c,v 8.4 1997/04/24 22:00:38 vixie Exp $";
+static const char sccsid[] = "@(#)setenv.c 8.1 (Berkeley) 6/4/93";
+static const char rcsid[] = "$Id: setenv.c,v 1.2 2005/04/27 04:56:11 sra Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -41,9 +36,6 @@ static char rcsid[] = "$Id: setenv.c,v 8.4 1997/04/24 22:00:38 vixie Exp $";
* SUCH DAMAGE.
*/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "port_before.h"
#include <stddef.h>
@@ -60,40 +52,40 @@ extern char **environ;
static char *findenv(const char *name, int *offset);
-/*
+/*%
* setenv --
* Set the value of the environmental variable "name" to be
* "value". If rewrite is set, replace any current value.
*/
setenv(const char *name, const char *value, int rewrite) {
extern char **environ;
- static int alloced; /* if allocated space before */
+ static int alloced; /*%< if allocated space before */
char *c;
int l_value, offset;
- if (*value == '=') /* no `=' in value */
+ if (*value == '=') /*%< no `=' in value */
++value;
l_value = strlen(value);
- if ((c = findenv(name, &offset))) { /* find if already exists */
+ if ((c = findenv(name, &offset))) { /*%< find if already exists */
if (!rewrite)
return (0);
- if (strlen(c) >= l_value) { /* old larger; copy over */
+ if (strlen(c) >= l_value) { /*%< old larger; copy over */
while (*c++ = *value++);
return (0);
}
- } else { /* create new slot */
+ } else { /*%< create new slot */
int cnt;
char **p;
for (p = environ, cnt = 0; *p; ++p, ++cnt);
- if (alloced) { /* just increase size */
+ if (alloced) { /*%< just increase size */
environ = (char **)realloc((char *)environ,
(size_t)(sizeof(char *) * (cnt + 2)));
if (!environ)
return (-1);
}
- else { /* get new space */
- alloced = 1; /* copy old entries into it */
+ else { /*%< get new space */
+ alloced = 1; /*%< copy old entries into it */
p = malloc((size_t)(sizeof(char *) * (cnt + 2)));
if (!p)
return (-1);
@@ -103,8 +95,8 @@ setenv(const char *name, const char *value, int rewrite) {
environ[cnt + 1] = NULL;
offset = cnt;
}
- for (c = (char *)name; *c && *c != '='; ++c); /* no `=' in name */
- if (!(environ[offset] = /* name + `=' + value */
+ for (c = (char *)name; *c && *c != '='; ++c); /*%< no `=' in name */
+ if (!(environ[offset] = /*%< name + `=' + value */
malloc((size_t)((int)(c - name) + l_value + 2))))
return (-1);
for (c = environ[offset]; (*c = *name++) && *c != '='; ++c);
@@ -112,7 +104,7 @@ setenv(const char *name, const char *value, int rewrite) {
return (0);
}
-/*
+/*%
* unsetenv(name) --
* Delete environmental variable "name".
*/
@@ -121,13 +113,13 @@ unsetenv(const char *name) {
char **p;
int offset;
- while (findenv(name, &offset)) /* if set multiple times */
+ while (findenv(name, &offset)) /*%< if set multiple times */
for (p = &environ[offset];; ++p)
if (!(*p = *(p + 1)))
break;
}
-/*
+/*%
* findenv --
* Returns pointer to value associated with name, if any, else NULL.
* Sets offset to be the offset of the name/value combination in the
@@ -155,3 +147,5 @@ findenv(const char *name, int *offset) {
return (NULL);
}
#endif
+
+/*! \file */