3 * Fiddling with environment variables
5 * (c) 1999 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the mLib utilities library.
12 * mLib is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * mLib is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
35 /*----- Header files ------------------------------------------------------*/
41 /*----- Functions provided ------------------------------------------------*/
43 /* --- @env_get@ --- *
45 * Arguments: @sym_table *t@ = pointer to a symbol table
46 * @const char *name@ = pointer to variable name to look up
48 * Returns: Pointer to corresponding value string, or null.
50 * Use: Looks up an environment variable in the table and returns its
51 * value. If the variable can't be found, a null pointer is
55 extern char *env_get(sym_table */*t*/, const char */*name*/);
57 /* --- @env_put@ --- *
59 * Arguments: @sym_table *t@ = pointer to a symbol table
60 * @const char *name@ = pointer to variable name to set
61 * @const char *value@ = pointer to value string to assign
65 * Use: Assigns a value to a variable. If the @name@ contains an
66 * equals character, then it's assumed to be of the form
67 * `VAR=VALUE' and @value@ argument is ignored. Otherwise, if
68 * @value@ is null, the variable is deleted. Finally, the
69 * normal case: @name@ is a plain name, and @value@ is a normal
70 * string causes the variable to be assigned the value in the
74 extern void env_put(sym_table */*t*/,
75 const char */*name*/, const char */*value*/);
77 /* --- @env_import@ --- *
79 * Arguments: @sym_table *t@ = pointer to a symbol table
80 * @char **env@ = pointer to an environment list
84 * Use: Inserts all of the environment variables listed into a symbol
85 * table for rapid access. Equivalent to a lot of calls to
89 extern void env_import(sym_table */*t*/, char **/*env*/);
91 /* --- @env_export@ --- *
93 * Arguments: @sym_table *t@ = pointer to a symbol table
95 * Returns: A big environment list.
97 * Use: Extracts an environment table from a symbol table
98 * representation of an environment. The table and all of the
99 * strings are in one big block allocated from the heap.
102 extern char **env_export(sym_table */*t*/);
104 /* --- @env_destroy@ --- *
106 * Arguments: @sym_table *t@ = pointer to symbol table
110 * Use: Destroys all the variables in the symbol table.
113 extern void env_destroy(sym_table */*t*/);
115 /*----- That's all, folks -------------------------------------------------*/