{"id":7158,"date":"2022-12-20T19:35:40","date_gmt":"2022-12-20T22:35:40","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/envz_add-man3\/"},"modified":"2022-12-20T19:35:40","modified_gmt":"2022-12-20T22:35:40","slug":"envz_add-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/envz_add-man3\/","title":{"rendered":"ENVZ_ADD (man3)"},"content":{"rendered":"<h1 align=\"center\">ENVZ_ADD<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#ATTRIBUTES\">ATTRIBUTES<\/a><br \/> <a href=\"#CONFORMING TO\">CONFORMING TO<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COLOPHON\">COLOPHON<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">envz_add, envz_entry, envz_get, envz_merge, envz_remove, envz_strip \u2212 environment string support<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <envz.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>error_t envz_add(char **<\/b><i>envz<\/i><b>, size_t *<\/b><i>envz_len<\/i><b>, <br \/> const char *<\/b><i>name<\/i><b>, const char *<\/b><i>value<\/i><b>);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>char *envz_entry(const char *<\/b><i>envz<\/i><b>, size_t<\/b> <i>envz_len<\/i><b>, const char *<\/b><i>name<\/i><b>);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>char *envz_get(const char *<\/b><i>envz<\/i><b>, size_t<\/b> <i>envz_len<\/i><b>, const char *<\/b><i>name<\/i><b>);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>error_t envz_merge(char **<\/b><i>envz<\/i><b>, size_t *<\/b><i>envz_len<\/i><b>, <br \/> const char *<\/b><i>envz2<\/i><b>, size_t<\/b> <i>envz2_len<\/i><b>, int<\/b> <i>override<\/i><b>);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>void envz_remove(char **<\/b><i>envz<\/i><b>, size_t *<\/b><i>envz_len<\/i><b>, const char *<\/b><i>name<\/i><b>);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>void envz_strip(char **<\/b><i>envz<\/i><b>, size_t *<\/b><i>envz_len<\/i><b>);<\/b><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">These functions are glibc-specific.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">An argz vector is a pointer to a character buffer together with a length, see <b>argz_add<\/b>(3). An envz vector is a special argz vector, namely one where the strings have the form &#8220;name=value&#8221;. Everything after the first &#8216;=&#8217; is considered to be the value. If there is no &#8216;=&#8217;, the value is taken to be NULL. (While the value in case of a trailing &#8216;=&#8217; is the empty string &#8220;&#8221;.)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">These functions are for handling envz vectors.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>envz_add<\/b>() adds the string &#8220;<i>name<\/i>=<i>value<\/i>&#8221; (in case <i>value<\/i> is non-NULL) or &#8220;<i>name<\/i>&#8221; (in case <i>value<\/i> is NULL) to the envz vector (<i>*envz<\/i>,\u00a0<i>*envz_len<\/i>) and updates <i>*envz<\/i> and <i>*envz_len<\/i>. If an entry with the same <i>name<\/i> existed, it is removed.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>envz_entry<\/b>() looks for <i>name<\/i> in the envz vector (<i>envz<\/i>,\u00a0<i>envz_len<\/i>) and returns the entry if found, or NULL if not.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>envz_get<\/b>() looks for <i>name<\/i> in the envz vector (<i>envz<\/i>,\u00a0<i>envz_len<\/i>) and returns the value if found, or NULL if not. (Note that the value can also be NULL, namely when there is an entry for <i>name<\/i> without &#8216;=&#8217; sign.)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>envz_merge<\/b>() adds each entry in <i>envz2<\/i> to <i>*envz<\/i>, as if with <b>envz_add<\/b>(). If <i>override<\/i> is true, then values in <i>envz2<\/i> will supersede those with the same name in <i>*envz<\/i>, otherwise not.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>envz_remove<\/b>() removes the entry for <i>name<\/i> from (<i>*envz<\/i>,\u00a0<i>*envz_len<\/i>) if there was one.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>envz_strip<\/b>() removes all entries with value NULL.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">All envz functions that do memory allocation have a return type of <i>error_t<\/i> (an integer type), and return 0 for success, and <b>ENOMEM<\/b> if an allocation error occurs.<\/p>\n<h2>ATTRIBUTES <a name=\"ATTRIBUTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">For an explanation of the terms used in this section, see <b>attributes<\/b>(7).<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"> <\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"62%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"62%\"> <\/td>\n<\/tr>\n<\/table>\n<p align=\"center\"><img decoding=\"async\" src=\"grohtml-1618361.png\" alt=\"Image grohtml-1618361.png\"><\/p>\n<h2>CONFORMING TO <a name=\"CONFORMING TO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">These functions are a GNU extension.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">#include <stdio.h> <br \/> #include <stdlib.h> <br \/> #include <envz.h><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <br \/> main(int argc, char *argv[], char *envp[]) <br \/> { <br \/> int e_len = 0; <br \/> char *str;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">for (int i = 0; envp[i] != NULL; i++) <br \/> e_len += strlen(envp[i]) + 1;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">str = envz_entry(*envp, e_len, &#8220;HOME&#8221;); <br \/> printf(&#8220;%sn&#8221;, str); <br \/> str = envz_get(*envp, e_len, &#8220;HOME&#8221;); <br \/> printf(&#8220;%sn&#8221;, str); <br \/> exit(EXIT_SUCCESS); <br \/> }<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>argz_add<\/b>(3)<\/p>\n<h2>COLOPHON <a name=\"COLOPHON\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This page is part of release 5.10 of the Linux <i>man-pages<\/i> project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https:\/\/www.kernel.org\/doc\/man\u2212pages\/.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  envz_add, envz_entry, envz_get, envz_merge, envz_remove, envz_strip \u2212 environment string support <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,3493,3007],"class_list":["post-7158","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-envz_add","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7158"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7158\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}