3 * $Id: env.h,v 1.3 2004/04/08 01:36:11 mdw Exp $
5 * Fiddling with environment variables
7 * (c) 1999 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the mLib utilities library.
14 * mLib is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * mLib is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with mLib; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
37 /*----- Header files ------------------------------------------------------*/
43 /*----- Functions provided ------------------------------------------------*/
45 /* --- @env_get@ --- *
47 * Arguments: @sym_table *t@ = pointer to a symbol table
48 * @const char *name@ = pointer to variable name to look up
50 * Returns: Pointer to corresponding value string, or null.
52 * Use: Looks up an environment variable in the table and returns its
53 * value. If the variable can't be found, a null pointer is
57 extern char *env_get(sym_table */
*t*/
, const char */
*name*/
);
59 /* --- @env_put@ --- *
61 * Arguments: @sym_table *t@ = pointer to a symbol table
62 * @const char *name@ = pointer to variable name to set
63 * @const char *value@ = pointer to value string to assign
67 * Use: Assigns a value to a variable. If the @name@ contains an
68 * equals character, then it's assumed to be of the form
69 * `VAR=VALUE' and @value@ argument is ignored. Otherwise, if
70 * @value@ is null, the variable is deleted. Finally, the
71 * normal case: @name@ is a plain name, and @value@ is a normal
72 * string causes the variable to be assigned the value in the
76 extern void env_put(sym_table */
*t*/
,
77 const char */
*name*/
, const char */
*value*/
);
79 /* --- @env_import@ --- *
81 * Arguments: @sym_table *t@ = pointer to a symbol table
82 * @char **env@ = pointer to an environment list
86 * Use: Inserts all of the environment variables listed into a symbol
87 * table for rapid access. Equivalent to a lot of calls to
91 extern void env_import(sym_table */
*t*/
, char **/
*env*/
);
93 /* --- @env_export@ --- *
95 * Arguments: @sym_table *t@ = pointer to a symbol table
97 * Returns: A big environment list.
99 * Use: Extracts an environment table from a symbol table
100 * representation of an environment. The table and all of the
101 * strings are in one big block allocated from the heap.
104 extern char **env_export(sym_table */
*t*/
);
106 /* --- @env_destroy@ --- *
108 * Arguments: @sym_table *t@ = pointer to symbol table
112 * Use: Destroys all the variables in the symbol table.
115 extern void env_destroy(sym_table */
*t*/
);
117 /*----- That's all, folks -------------------------------------------------*/