chiark / gitweb /
Include `crc32.h' for @CRC32@ macro.
[mLib] / env.h
CommitLineData
e19206c2 1/* -*-c-*-
2 *
c6e0eaf0 3 * $Id: env.h,v 1.2 1999/12/10 23:42:04 mdw Exp $
e19206c2 4 *
5 * Fiddling with environment variables
6 *
7 * (c) 1999 Straylight/Edgeware
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of the mLib utilities library.
13 *
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.
18 *
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.
23 *
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,
27 * MA 02111-1307, USA.
28 */
29
30/*----- Revision history --------------------------------------------------*
31 *
32 * $Log: env.h,v $
c6e0eaf0 33 * Revision 1.2 1999/12/10 23:42:04 mdw
34 * Change header file guard names.
35 *
e19206c2 36 * Revision 1.1 1999/07/26 23:15:57 mdw
37 * Fiddling with environment variables.
38 *
39 */
40
c6e0eaf0 41#ifndef MLIB_ENV_H
42#define MLIB_ENV_H
e19206c2 43
44#ifdef __cplusplus
45 extern "C" {
46#endif
47
48/*----- Header files ------------------------------------------------------*/
49
c6e0eaf0 50#ifndef MLIB_SYM_H
e19206c2 51# include "sym.h"
52#endif
53
54/*----- Functions provided ------------------------------------------------*/
55
56/* --- @env_get@ --- *
57 *
58 * Arguments: @sym_table *t@ = pointer to a symbol table
59 * @const char *name@ = pointer to variable name to look up
60 *
61 * Returns: Pointer to corresponding value string, or null.
62 *
63 * Use: Looks up an environment variable in the table and returns its
64 * value. If the variable can't be found, a null pointer is
65 * returned.
66 */
67
68extern char *env_get(sym_table */*t*/, const char */*name*/);
69
70/* --- @env_put@ --- *
71 *
72 * Arguments: @sym_table *t@ = pointer to a symbol table
73 * @const char *name@ = pointer to variable name to set
74 * @const char *value@ = pointer to value string to assign
75 *
76 * Returns: ---
77 *
78 * Use: Assigns a value to a variable. If the @name@ contains an
79 * equals character, then it's assumed to be of the form
80 * `VAR=VALUE' and @value@ argument is ignored. Otherwise, if
81 * @value@ is null, the variable is deleted. Finally, the
82 * normal case: @name@ is a plain name, and @value@ is a normal
83 * string causes the variable to be assigned the value in the
84 * way you'd expect.
85 */
86
87extern void env_put(sym_table */*t*/,
88 const char */*name*/, const char */*value*/);
89
90/* --- @env_import@ --- *
91 *
92 * Arguments: @sym_table *t@ = pointer to a symbol table
93 * @char **env@ = pointer to an environment list
94 *
95 * Returns: ---
96 *
97 * Use: Inserts all of the environment variables listed into a symbol
98 * table for rapid access. Equivalent to a lot of calls to
99 * @env_put@.
100 */
101
102extern void env_import(sym_table */*t*/, char **/*env*/);
103
104/* --- @env_export@ --- *
105 *
106 * Arguments: @sym_table *t@ = pointer to a symbol table
107 *
108 * Returns: A big environment list.
109 *
110 * Use: Extracts an environment table from a symbol table
111 * representation of an environment. The table and all of the
112 * strings are in one big block allocated from the heap.
113 */
114
115extern char **env_export(sym_table */*t*/);
116
117/* --- @env_destroy@ --- *
118 *
119 * Arguments: @sym_table *t@ = pointer to symbol table
120 *
121 * Returns: ---
122 *
123 * Use: Destroys all the variables in the symbol table.
124 */
125
126extern void env_destroy(sym_table */*t*/);
127
128/*----- That's all, folks -------------------------------------------------*/
129
130#ifdef __cplusplus
131 }
132#endif
133
134#endif