chiark / gitweb /
New function `pquis'.
[mLib] / man / env.3
CommitLineData
e19206c2 1.\" -*-nroff-*-
2.TH env 3 "26 July 1999" mLib
3.SH "NAME"
00667e86 4env \- efficient fiddling with environment variables
e19206c2 5.\" @env_get
6.\" @env_put
7.\" @env_import
8.\" @env_export
9.\" @env_destroy
10.SH "SYNOPSIS"
11.nf
12.B "#include <mLib/env.h>"
13
14.BI "char *env_get(sym_table *" t ", const char *" name );
f4d2cec8 15.BI "void env_put(sym_table *" t ,
e19206c2 16.BI " const char *" name ", const char *" value );
17.BI "void env_import(sym_table *" t ", char **" env );
18.BI "char **env_export(sym_table *" t );
19.fi
20.SH "DESCRIPTION"
21The functions in the
22.B "<mLib/env.h>"
23header manipulate environment variables stored in a hash table.
24.PP
25The function
26.B env_import
27reads a standard Unix environment array and stores the variables in the
28symbol table. (A standard Unix environment array is an array of
29pointers to strings of the form
30.IB name = value
31terminated by a null pointer. This format is used for the global
32.B environ
33variable, and by the
34.BR execve (2)
35function.) The symbol table must have already been created (see
36.BR sym_create (3)).
37.PP
38The function
39.B env_export
40creates a Unix environment array from a symbol table. The environment
41array is one big block of memory allocated using
42.BR malloc (3);
43hence, one call to
44.BR free (3)
45releases all the memory used for the pointer array and the strings.
46.PP
47The
48.B env_get
49function looks up a variable in an environment symbol table. The
50returned result is the variable's value if it exists, or a null pointer
51if not.
52.PP
53The
54.B env_put
55function sets or deletes environment variables. If the
56.I name
57argument contains an
58.RB ` = '
59character, it is assumed to be of the form
60.IB n = v\fR;
61the
62.I value argument is ignored, and the variable
63.I n
64is assigned the value
65.IR v .
66Otherwise, if
67.I value
68is not a null pointer, the variable
69.I name
70is assigned the value
71.I value .
72Finally, if
73.I value
74is null, the variable
75.I name
76is deleted.
77.PP
78The
79.B env_destroy
80function frees all the memory used by an environment symbol table. The
81table itself is destroyed too.
82.SH "SEE ALSO"
83.BR sym (3),
84.BR mLib (3).
85.SH "AUTHOR"
86Mark Wooding, <mdw@nsict.org>