1 .\" Copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de)
2 .\" Distributed under GPL
3 .\" based on the description in glibc source and infopages
5 .\" Corrections and additions, aeb
7 .\" Japanese Version Copyright (c) 2002 Akihiro MOTOKI, all rights reserved.
8 .\" Translated Mon Feb 2 2003 by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
10 .TH ENVZ_ADD 3 2007-05-18 "" "Linux Programmer's Manual"
13 .\"O envz_add, envz_entry, envz_get, envz_merge,
14 .\"O envz_remove, envz_strip \- environment string support
15 envz_add, envz_entry, envz_get, envz_merge,
16 envz_remove, envz_strip \- ´Ä¶ÊÑ¿ôʸ»úÎó¤ÎÁàºî
20 .B "#include <envz.h>"
22 .BI "error_t envz_add(char **" envz ", size_t *" envz_len ,
24 .BI "const char *" name ", const char *" value );
26 .BI "char *envz_entry(const char *" envz ", size_t *" envz_len \
27 ", const char *" name );
29 .BI "char *envz_get(const char *" envz ", size_t *" envz_len \
30 ", const char *" name );
32 .BI "error_t envz_merge(char **" envz ", size_t *" envz_len ,
34 .BI "const char *" envz2 ", size_t " envz2_len ", int " override );
36 .BI "void envz_remove(char **" envz ", size_t *" envz_len \
37 ", const char *" name );
39 .BI "void envz_strip(char **" envz ", size_t *" envz_len );
43 .\"O These functions are glibc-specific.
44 ¤³¤ì¤é¤Î´Ø¿ô glibc ¸ÇͤǤ¢¤ë¡£
46 .\"O An argz vector is a pointer to a character buffer together with a length,
48 .\"O .BR argz_add (3).
49 .\"O An envz vector is a special argz vector, namely one where the strings
50 .\"O have the form "name=value".
51 .\"O Everything after the first \(aq=\(aq is considered
53 .\"O If there is no \(aq=\(aq, the value is taken to be NULL.
54 .\"O (While the value in case of a trailing \(aq=\(aq is the empty string "".)
55 argz vector ¤ÏŤµ¾ðÊóÉÕ¤¤Îʸ»ú¥Ð¥Ã¥Õ¥¡¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
58 envz vector ¤Ï¡¢Ê¸»úÎó¤¬ "name=value (̾Á°=ÃÍ)" ¤Î·Á¼°¤Ë¤Ê¤Ã¤Æ¤¤¤ëÆÃÊ̤Ê
60 ºÇ½é¤Î \(aq=\(aq °Ê¹ß¤Ï¤¹¤Ù¤ÆÃͤȤߤʤµ¤ì¤ë¡£\(aq=\(aq ¤¬¤Ê¤±¤ì¤Ð¡¢
61 ÃÍ¤Ï NULL ¤È²ò¼á¤µ¤ì¤ë¡£(ʸ»úÎó¤Î°ìÈֺǸå¤Îʸ»ú¤¬ \(aq=\(aq ¤Î¾ì¹ç¡¢Ãͤ϶õʸ»úÎó
64 .\"O These functions are for handling envz vectors.
65 ¤³¤ì¤é¤Î´Ø¿ô¤Ï envz vector ¤òÁàºî¤¹¤ë¤¿¤á¤Î¤â¤Î¤Ç¤¢¤ë¡£
69 .\"O .RI \&" name = value \&"
76 .\"O is NULL) to the envz vector
77 .\"O .RI ( *envz ,\ *envz_len )
82 .\"O If an entry with the same
84 .\"O existed, it is removed.
87 .RI \&" name = value \&"
89 ¤¬ NULL ¤Ç¤Ê¤¤¾ì¹ç) ¤Þ¤¿¤Ï
94 .RI ( *envz ,\ *envz_len )
101 ¤ÈƱ¤¸Ì¾Á°¤ò»ý¤Ä¥¨¥ó¥È¥ê¤¬¤¢¤Ã¤¿¾ì¹ç¡¢¸µ¤Î¥¨¥ó¥È¥ê¤Ïºï½ü¤µ¤ì¤ë¡£
103 .\"O .BR envz_entry ()
106 .\"O in the envz vector
107 .\"O .RI ( envz ,\ envz_len )
108 .\"O and returns the entry if found, or NULL if not.
111 .RI ( envz ,\ envz_len )
114 ¤Î¥¨¥ó¥È¥ê¤ò¸¡º÷¤¹¤ë¡£
115 ¸«¤Ä¤«¤Ã¤¿¾ì¹ç¤Ï¤½¤Î¥¨¥ó¥È¥ê¤òÊÖ¤·¡¢¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï NULL ¤òÊÖ¤¹¡£
120 .\"O in the envz vector
121 .\"O .RI ( envz ,\ envz_len )
122 .\"O and returns the value if found, or NULL if not.
123 .\"O (Note that the value can also be NULL, namely when there is
126 .\"O without \(aq=\(aq sign.)
129 .RI ( envz ,\ envz_len )
132 ¤Î¥¨¥ó¥È¥ê¤ò¸¡º÷¤¹¤ë¡£
133 ¸«¤Ä¤«¤Ã¤¿¾ì¹ç¤Ï¥¨¥ó¥È¥ê¤ÎÃͤòÊÖ¤·¡¢¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï NULL ¤òÊÖ¤¹¡£
134 (ÃÍ¤Ï NULL ¤Î¾ì¹ç¤â¤¢¤ë¤³¤È¤ËÃí°Õ¤¹¤ë¤³¤È¡£Ì¾Á°¤¬
136 ¤Î¥¨¥ó¥È¥ê¤Ë \(aq=\(aq Éä¹æ¤¬¤Ê¤¤¾ì¹ç¤¬³ºÅö¤¹¤ë¡£)
138 .\"O .BR envz_merge ()
139 .\"O adds each entry in
144 .\"O .BR envz_add ().
147 .\"O is true, then values in
149 .\"O will supersede those with the same name in
165 Æâ¤ÎƱ¤¸Ì¾Á°¤ò¤â¤ÄÃͤϾå½ñ¤¤µ¤ì¤ë¡£
166 µ¶¤Î¾ì¹ç¤Ï¾å½ñ¤¤µ¤ì¤Ê¤¤¡£
168 .\"O .BR envz_remove ()
169 .\"O removes the entry for
172 .\"O .RI ( *envz ,\ *envz_len )
173 .\"O if there was one.
178 .RI ( *envz ,\ *envz_len )
181 .\"O .BR envz_strip ()
182 .\"O removes all entries with value NULL.
184 ¤Ï¡¢Ãͤ¬ NULL ¤Î¥¨¥ó¥È¥ê¤ò¤¹¤Ù¤Æºï½ü¤¹¤ë¡£
185 .\"O .SH "RETURN VALUE"
187 .\"O All envz functions that do memory allocation have a return type of
188 .\"O \fIerror_t\fP, and return 0 for success, and \fBENOMEM\fP
189 .\"O if an allocation error occurs.
190 ¥á¥â¥ê³ä¤êÅö¤Æ¤ò¹Ô¤¦ envz ´Ø¿ô·²¤Ï¤¹¤Ù¤Æ \fIerror_t\fP ·¿¤ÎÊÖ¤êÃͤò»ý¤Ä¡£
191 À®¸ù¤·¤¿¾ì¹ç¤Ï 0 ¤òÊÖ¤·¡¢³ä¤êÅö¤Æ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï
192 \fBENOMEM\fP ¤òÊÖ¤¹¡£
193 .\"O .SH "CONFORMING TO"
195 .\"O These functions are a GNU extension.
196 .\"O Handle with care.
197 ¤³¤ì¤é¤Î´Ø¿ô¤Ï GNU ¤Ë¤è¤ë³ÈÄ¥¤Ç¤¢¤ë¡£Ãí°Õ¤·¤Æ»ÈÍѤ¹¤ë¤³¤È¡£
206 main(int argc, char *argv[], char *envp[])
211 for (i = 0; envp[i] != NULL; i++)
212 e_len += strlen(envp[i]) + 1;
214 str = envz_entry(*envp, e_len, "HOME");
215 printf("%s\en", str);
216 str = envz_get(*envp, e_len, "HOME");
217 printf("%s\en", str);