1 /* RCS $Id: eold.c,v 1.1.1.1 2000-09-22 15:33:27 hr Exp $
4 -- Set up and free for environ
7 -- This file contains routines that will fill in and dispose of the
8 -- list of environmental variables in the environ global variable.
11 -- Dennis Vadura, dvadura@dmake.wticorp.com
15 -- http://dmake.wticorp.com/
18 -- Copyright (c) 1996,1997 by WTI Corp. All rights reserved.
20 -- This program is NOT free software; you can redistribute it and/or
21 -- modify it under the terms of the Software License Agreement Provided
22 -- in the file <distribution-root>/readme/license.txt.
25 -- Use cvs log to obtain detailed change logs.
32 * Keep track of any environmental variables that have '='s in their
37 struct equalsign
*fpNext
;
38 } /* struct EqualPos */
40 struct EqualPos
*gpEqualList
;
43 * The character used to replae the equal signs.
45 const char gEqualReplace
= '_';
50 * Set up the environmental variables in a format used by
51 * the environ global variable.
53 * environ has already been set to main's envp argument when
54 * this suboroutine is called.
59 struct equalpos
*pNewEqual
;
63 for (ppCurEnv
= environ
; *ppCurEnv
!= NULL
; ++ppCurEnv
) {
64 for (pCurPos
= *ppCurEnv
; *pCurPos
!= '\0'; ++pCurPos
) {
65 if (*pCurPos
== '=') {
67 (struct EqualPos
*) malloc (sizeof (struct EqualPos
))) ==
69 fputs ("Out of Memory", stderr
);
72 pNewEqual
->fpPos
= pCurPos
;
73 pNewEqual
->fpNext
= gpEqualList
;
74 gpEqualList
= pNewEqual
;
76 *pCurPos
= gEqualReplace
;
82 } /* void main_env () */
87 * Reset the environmental variables so they look like they did
88 * before the main_env() call.
90 * environ has already been set to main's envp argument when
91 * this suboroutine is called.
96 struct equalpos
*pNewEqual
;
100 for (ppCurEnv
= environ
; *ppCurEnv
!= NULL
; ++ppCurEnv
) {
101 for (pCurPos
= *ppCurEnv
; *pCurPos
!= '\0'; ++pCurPos
) {
102 if (*pCurPos
== '=') {
104 (struct EqualPos
*) malloc (sizeof (struct EqualPos
))) ==
106 fputs ("Out of Memory", stderr
);
109 pNewEqual
->fpPos
= pCurPos
;
110 pNewEqual
->fpNext
= gpEqualList
;
111 gpEqualList
= pNewEqual
;
113 *pCurPos
= gEqualReplace
;
119 } /* void main_env () */