Lines Matching refs:code

9 operate on arbitrary regions of storage; for example, the @code{memcpy}
13 by duplicating this functionality in their own code, but it pays to
18 lines of C code, but if you use the built-in @code{strcmp} function,
55 A @dfn{string} is a null-terminated array of bytes of type @code{char},
57 variables are usually declared to be pointers of type @code{char *}.
74 sequence of @code{wchar_t} objects. A wide-string variable is usually
75 declared to be a pointer of type @code{wchar_t *}, by analogy with
76 string variables and @code{char *}. @xref{Extended Char Intro}.
80 By convention, the @dfn{null byte}, @code{'\0'},
82 @code{L'\0'}, marks the end of a wide string. For example, in
83 testing to see whether the @code{char *} variable @var{p} points to a
85 @code{!*@var{p}} or @code{*@var{p} == '\0'}.
88 although both are represented by the integer constant @code{0}.
94 @samp{L} (ell) character (as in @code{L"foo"}), it is a wide string
96 concatenation}: @code{"a" "b"} is the same as @code{"ab"}.
98 @code{L"a" L"b"} or @code{L"a" "b"}. Modification of string literals is
102 Arrays that are declared @code{const} cannot be modified
104 pointers to be of type @code{const char *}, since this often allows the
123 string than fit in its allocated size. When writing code that extends
144 @code{memcpy} could cut a multibyte character in the middle and put an
177 beginning with @samp{mem} and @samp{wmem} (such as @code{memcpy} and
178 @code{wmemcpy}) and invariably take an argument which specifies the size
181 have type @code{void *} or @code{wchar_t}. As a matter of style, the
184 and the @code{sizeof} operator is useful in computing the value for the
186 @code{wchar_t *}. These functions are not really usable with anything
191 respectively (such as @code{strcpy} and @code{wcscpy}) and look for a
196 functions have type @code{char *} and @code{wchar_t *} respectively, and
213 arguments. Since a value of type @code{char} is automatically promoted
214 into a value of type @code{int} when used as a parameter, the functions
215 are declared with @code{int} as the type of the parameter in question.
217 parameter type for a single wide character is @code{wint_t} and not
218 @code{wchar_t}. This would for many implementations not be necessary
219 since @code{wchar_t} is large enough to not be automatically
221 choice of types the @code{wint_t} type is used.
226 You can get the length of a string using the @code{strlen} function.
233 The @code{strlen} function returns the length of the
243 When applied to an array, the @code{strlen} function returns
246 the @code{sizeof} operator:
274 characters and @code{wcslen} can be used or something like the following
275 code can be used:
278 /* @r{The input is in @code{string}.}
279 @r{The length is expected in @code{n}.} */
299 The @code{wcslen} function is the wide character equivalent to
300 @code{strlen}. The return value is the number of wide characters in the
315 the @code{strnlen} function returns the length of the string @var{s} in
318 @code{(strlen (@var{s}) < @var{maxlen} ? strlen (@var{s}) : @var{maxlen})}
337 @code{wcsnlen} is the wide character equivalent to @code{strnlen}. The
376 section, there are a few others like @code{sprintf} (@pxref{Formatted
377 Output Functions}) and @code{scanf} (@pxref{Formatted Input
383 The @code{memcpy} function copies @var{size} bytes from the object
386 @var{from} overlap; use @code{memmove} instead if overlapping is possible.
388 The value returned by @code{memcpy} is the value of @var{to}.
390 Here is an example of how you might use @code{memcpy} to copy the
404 The @code{wmemcpy} function copies @var{size} wide characters from the object
407 @var{wfrom} overlap; use @code{wmemmove} instead if overlapping is possible.
409 The following is a possible implementation of @code{wmemcpy} but there
421 The value returned by @code{wmemcpy} is the value of @var{wto}.
429 The @code{mempcpy} function is nearly identical to the @code{memcpy}
431 @code{from} into the object pointed to by @var{to}. But instead of
434 I.e., the value is @code{((void *) ((char *) @var{to} + @var{size}))}.
456 The @code{wmempcpy} function is nearly identical to the @code{wmemcpy}
458 beginning at @code{wfrom} into the object pointed to by @var{wto}. But
461 beginning at @var{wto}. I.e., the value is @code{@var{wto} + @var{size}}.
466 The following is a possible implementation of @code{wmemcpy} but there
484 @code{memmove} copies the @var{size} bytes at @var{from} into the
486 overlap. In the case of overlap, @code{memmove} is careful to copy the
490 The value returned by @code{memmove} is the value of @var{to}.
496 @code{wmemmove} copies the @var{size} wide characters at @var{wfrom}
498 blocks of space overlap. In the case of overlap, @code{wmemmove} is
503 The following is a possible implementation of @code{wmemcpy} but there
515 The value returned by @code{wmemmove} is the value of @var{wto}.
534 @code{unsigned char}) into each of the first @var{size} bytes of the
551 @code{memcpy}, this function has undefined results if the strings
560 @var{wto}. Like @code{wmemcpy}, this function has undefined results if
568 allocated string. The string is allocated using @code{malloc}; see
569 @ref{Unconstrained Allocation}. If @code{malloc} cannot allocate space
570 for the new string, @code{strdup} returns a null pointer. Otherwise it
579 @code{malloc}; see @ref{Unconstrained Allocation}. If @code{malloc}
580 cannot allocate space for the new string, @code{wcsdup} returns a null
589 This function is like @code{strcpy}, except that it returns a pointer to
591 null byte @code{to + strlen (from)}) rather than the beginning.
593 For example, this program uses @code{stpcpy} to concatenate @samp{foo}
611 This function is like @code{wcscpy}, except that it returns a pointer to
613 null wide character @code{wto + wcslen (wfrom)}) rather than the beginning.
618 The behavior of @code{wcpcpy} is undefined if the strings overlap.
620 @code{wcpcpy} is a GNU extension and is declared in @file{wchar.h}.
626 This macro is similar to @code{strdup} but allocates the new string
627 using @code{alloca} instead of @code{malloc} (@pxref{Variable Size
629 limitations as any block of memory allocated using @code{alloca}.
631 For obvious reasons @code{strdupa} is implemented only as a macro;
633 it is a useful function. The following code shows a situation where
634 using @code{malloc} would be a lot more expensive.
640 Please note that calling @code{strtok} using @var{path} directly is
641 invalid. It is also not allowed to call @code{strdupa} in the argument
642 list of @code{strtok} since @code{strdupa} uses @code{alloca}
652 This is a partially obsolete alternative for @code{memmove}, derived from
653 BSD. Note that it is not quite equivalent to @code{memmove}, because the
660 This is a partially obsolete alternative for @code{memset}, derived from
661 BSD. Note that it is not as general as @code{memset}, because the only
681 The @code{strcat} function is similar to @code{strcpy}, except that the
686 An equivalent definition for @code{strcat} would be:
705 The @code{wcscat} function is similar to @code{wcscpy}, except that the
710 An equivalent definition for @code{wcscat} would be:
726 Programmers using the @code{strcat} or @code{wcscat} function (or the
727 @code{strncat} or @code{wcsncat} functions defined in
734 to use @code{strcat}/@code{wcscat}. A lot of time is wasted finding the
741 @r{parameter must be @code{NULL}.} */
837 we don't use @code{strcat} anymore. We always keep track of the length
839 end of the string and use @code{mempcpy}. Please note that we also
840 don't use @code{stpcpy} which might seem more natural since we are handling
845 Whenever a programmer feels the need to use @code{strcat} she or he
846 should think twice and look through the program to see whether the code cannot
848 is almost always unnecessary to use @code{strcat}.
865 This function is similar to @code{strcpy} but always copies exactly
869 bytes, @code{strncpy} copies just the first @var{size} bytes. In this
873 @var{size}. In this case @code{strncpy} copies all of @var{from},
876 The behavior of @code{strncpy} is undefined if the strings overlap.
888 This function is similar to @code{wcscpy} but always copies exactly
892 @var{size} wide characters, then @code{wcsncpy} copies just the first
897 @var{size}. In this case @code{wcsncpy} copies all of @var{wfrom},
901 The behavior of @code{wcsncpy} is undefined if the strings overlap.
903 This function is the wide-character counterpart of @code{strncpy} and
904 suffers from most of the problems that @code{strncpy} does. For
912 This function is similar to @code{strdup} but always copies at most
915 If the length of @var{s} is more than @var{size}, then @code{strndup}
919 This function differs from @code{strncpy} in that it always terminates
925 @code{strndup} is a GNU extension.
931 This function is similar to @code{strndup} but like @code{strdupa} it
932 allocates the new string using @code{alloca} @pxref{Variable Size
933 Automatic}. The same advantages and limitations of @code{strdupa} are
934 valid for @code{strndupa}, too.
936 This function is implemented only as a macro, just like @code{strdupa}.
937 Just as @code{strdupa} this macro also must not be used inside the
943 @code{strndupa} is only available if GNU CC is used.
949 This function is similar to @code{stpcpy} but copies always exactly
952 If the length of @var{from} is more than @var{size}, then @code{stpncpy}
957 If the length of @var{from} is less than @var{size}, then @code{stpncpy}
961 @code{strncpy} is used. @code{stpncpy} returns a pointer to the
977 This function is similar to @code{wcpcpy} but copies always exactly
981 @code{wcpncpy} copies just the first @var{size} wide characters and
986 If the length of @var{wfrom} is less than @var{size}, then @code{wcpncpy}
990 @code{wcsncpy} is used. @code{wcpncpy} returns a pointer to the
1001 @code{wcpncpy} is a GNU extension.
1007 This function is like @code{strcat} except that not more than @var{size}
1011 allocated size of @var{to} must be at least @code{@var{size} + 1} bytes
1014 The @code{strncat} function could be implemented like this:
1029 The behavior of @code{strncat} is undefined if the strings overlap.
1031 As a companion to @code{strncpy}, @code{strncat} was designed for
1041 This function is like @code{wcscat} except that not more than @var{size}
1045 size of @var{to} must be at least @code{wcsnlen (@var{wfrom},
1048 The @code{wcsncat} function could be implemented like this:
1064 The behavior of @code{wcsncat} is undefined if the strings overlap.
1097 such as @code{strdup} or @code{asprintf} to construct strings.
1129 The function @code{memcmp} compares the @var{size} bytes of memory
1132 between the first differing pair of bytes (interpreted as @code{unsigned
1133 char} objects, then promoted to @code{int}).
1135 If the contents of the two blocks are equal, @code{memcmp} returns
1136 @code{0}.
1142 The function @code{wmemcmp} compares the @var{size} wide characters
1148 If the contents of the two blocks are equal, @code{wmemcmp} returns
1149 @code{0}.
1152 On arbitrary arrays, the @code{memcmp} function is mostly useful for
1159 @code{wmemcmp} is really only useful to compare arrays of type
1160 @code{wchar_t} since the function looks at @code{sizeof (wchar_t)} bytes
1163 You should also be careful about using @code{memcmp} to compare objects
1189 @code{struct foo} objects instead of comparing them with @code{memcmp}.
1194 The @code{strcmp} function compares the string @var{s1} against
1197 @code{unsigned char} objects, then promoted to @code{int}).
1199 If the two strings are equal, @code{strcmp} returns @code{0}.
1201 A consequence of the ordering used by @code{strcmp} is that if @var{s1}
1205 @code{strcmp} does not take sorting conventions of the language the
1207 @code{strcoll}.
1214 The @code{wcscmp} function compares the wide string @var{ws1}
1219 If the two strings are equal, @code{wcscmp} returns @code{0}.
1221 A consequence of the ordering used by @code{wcscmp} is that if @var{ws1}
1225 @code{wcscmp} does not take sorting conventions of the language the
1227 @code{wcscoll}.
1237 This function is like @code{strcmp}, except that differences in case are
1240 determined by the currently selected locale. In the standard @code{"C"}
1245 @code{strcasecmp} is derived from BSD.
1253 This function is like @code{wcscmp}, except that differences in case are
1255 determined by the currently selected locale. In the standard @code{"C"}
1260 @code{wcscasecmp} is a GNU extension.
1266 This function is the similar to @code{strcmp}, except that no more than
1275 This function is similar to @code{wcscmp}, except that no more than
1284 This function is like @code{strncmp}, except that differences in case
1287 Like @code{strcasecmp}, it is locale dependent how
1291 @code{strncasecmp} is a GNU extension.
1297 This function is like @code{wcsncmp}, except that differences in case
1298 are ignored. Like @code{wcscasecmp}, it is locale dependent how
1302 @code{wcsncasecmp} is a GNU extension.
1305 Here are some examples showing the use of @code{strcmp} and
1306 @code{strncmp} (equivalent examples can be constructed for the wide
1318 @result{} -15 /* @r{The byte @code{'h'} comes before @code{'w'}.} */
1331 The @code{strverscmp} function compares the string @var{s1} against
1334 @code{strcmp} function. In fact, if @var{s1} and @var{s2} contain no
1335 digits, @code{strverscmp} behaves like @code{strcmp}
1338 The comparison algorithm which the @code{strverscmp} function implements
1347 string. Digits are determined by the @code{isdigit} function and are
1404 @code{strverscmp} is a GNU extension.
1410 This is an obsolete alias for @code{memcmp}, derived from BSD.
1426 You can use the functions @code{strcoll} and @code{strxfrm} (declared in
1427 the headers file @file{string.h}) and @code{wcscoll} and @code{wcsxfrm}
1431 for the @code{LC_COLLATE} category; see @ref{Locales}.
1435 In the standard C locale, the collation sequence for @code{strcoll} is
1436 the same as that for @code{strcmp}. Similarly, @code{wcscoll} and
1437 @code{wcscmp} are the same in this situation.
1446 The functions @code{strcoll} and @code{wcscoll} perform this translation
1447 implicitly, in order to do one comparison. By contrast, @code{strxfrm}
1448 and @code{wcsxfrm} perform the mapping explicitly. If you are making
1450 likely to be more efficient to use @code{strxfrm} or @code{wcsxfrm} to
1452 transformed strings with @code{strcmp} or @code{wcscmp}.
1459 The @code{strcoll} function is similar to @code{strcmp} but uses the
1461 @code{LC_COLLATE} locale). The arguments are multibyte strings.
1468 The @code{wcscoll} function is similar to @code{wcscmp} but uses the
1470 @code{LC_COLLATE} locale).
1473 Here is an example of sorting an array of strings, using @code{strcoll}
1475 comes from @code{qsort} (@pxref{Array Sort Function}). The job of the
1476 code shown here is to say how to compare the strings while sorting them.
1478 efficiently using @code{strxfrm}.)
1481 /* @r{This is the comparison function used with @code{qsort}.} */
1498 /* @r{Sort @code{temp_array} by comparing the strings.} */
1508 The function @code{strxfrm} transforms the multibyte string
1523 string, call @code{strxfrm} again with a bigger output array.
1529 case, @code{strxfrm} simply returns the number of bytes that would
1538 The function @code{wcsxfrm} transforms wide string @var{wfrom}
1553 @code{wcsxfrm} again with a bigger output array.
1559 case, @code{wcsxfrm} simply returns the number of wide characters that
1562 to multiply with @code{sizeof (wchar_t)}). It does not matter what
1566 Here is an example of how you can use @code{strxfrm} when
1576 /* @r{This is the comparison function used with @code{qsort}}
1577 @r{to sort an array of @code{struct sorter}.} */
1597 /* @r{Set up @code{temp_array}. Each element contains}
1610 /* @r{Transform @code{array[i]}.} */
1618 @r{@code{'\0'} byte.} */
1631 /* @r{Sort @code{temp_array} by comparing transformed strings.} */
1646 The interesting part of this code for the wide character version would
1654 /* @r{Transform @code{array[i]}.} */
1662 @r{@code{L'\0'} wide character.} */
1676 Note the additional multiplication with @code{sizeof (wchar_t)} in the
1677 @code{realloc} call.
1698 to an @code{unsigned char}) in the initial @var{size} bytes of the
1715 Often the @code{memchr} function is used with the knowledge that the
1721 The @code{rawmemchr} function exists for just this situation which is
1722 surprisingly frequent. The interface is similar to @code{memchr} except
1745 The function @code{memrchr} is like @code{memchr}, except that it searches
1755 The @code{strchr} function finds the first occurrence of the byte
1756 @var{c} (converted to a @code{char}) in the string
1772 When @code{strchr} returns a null pointer, it does not let you know
1775 @code{strchrnul} than to search for it a second time.
1781 The @code{wcschr} function finds the first occurrence of the wide
1790 to use @code{wcschrnul} in this case, though.
1796 @code{strchrnul} is the same as @code{strchr} except that if it does
1806 @code{wcschrnul} is the same as @code{wcschr} except that if it does not
1813 One useful, but unusual, use of the @code{strchr}
1823 the work already done in the @code{strlen} function. A better solution
1830 There is no restriction on the second parameter of @code{strchr} so it
1832 hard about this might now point out that the @code{strchr} function is
1833 more expensive than the @code{strlen} function since we have two abort
1835 @code{strchr} is optimized in a special way so that @code{strchr}
1841 The function @code{strrchr} is like @code{strchr}, except that it searches
1855 The function @code{wcsrchr} is like @code{wcschr}, except that it searches
1863 This is like @code{strchr}, except that it searches @var{haystack} for a
1881 This is like @code{wcschr}, except that it searches @var{haystack} for a
1891 @code{wcswcs} is a deprecated alias for @code{wcsstr}. This is the
1902 This is like @code{strstr}, except that it ignores case in searching for
1903 the substring. Like @code{strcasecmp}, it is locale dependent how
1921 This is like @code{strstr}, but @var{needle} and @var{haystack} are byte
1932 The @code{strspn} (``string span'') function returns the length of the
1951 The @code{wcsspn} (``wide character string span'') function returns the
1961 The @code{strcspn} (``string complement span'') function returns the length
1981 The @code{wcscspn} (``wide character string complement span'') function
1992 The @code{strpbrk} (``string pointer break'') function is related to
1993 @code{strcspn}, except that it returns a pointer to the first byte
2015 The @code{wcspbrk} (``wide character string pointer break'') function is
2016 related to @code{wcscspn}, except that it returns a pointer to the first
2028 @code{index} is another name for @code{strchr}; they are exactly the same.
2029 New code should always use @code{strchr} since this name is defined in
2030 @w{ISO C} while @code{index} is a BSD invention which never was available
2037 @code{rindex} is another name for @code{strrchr}; they are exactly the same.
2038 New code should always use @code{strrchr} since this name is defined in
2039 @w{ISO C} while @code{rindex} is a BSD invention which never was available
2051 into tokens. You can do this with the @code{strtok} function, declared
2059 function @code{strtok}.
2062 the first call only. The @code{strtok} function uses this to set up
2065 the @var{newstring} argument. Calling @code{strtok} with another
2067 It is guaranteed that no other library function ever calls @code{strtok}
2079 On the next call to @code{strtok}, the searching begins at the next
2082 same on every call in a series of calls to @code{strtok}.
2085 string consists only of delimiter bytes, @code{strtok} returns
2097 function @code{wcstok}.
2100 the first call only. The @code{wcstok} function uses this to set up
2118 On the next call to @code{wcstok}, the searching begins at the next
2121 same on every call in a series of calls to @code{wcstok}.
2125 @code{wcstok} returns a null pointer.
2128 @strong{Warning:} Since @code{strtok} and @code{wcstok} alter the string
2130 before parsing it with @code{strtok}/@code{wcstok} (@pxref{Copying Strings
2131 and Arrays}). If you allow @code{strtok} or @code{wcstok} to modify
2134 @code{strtok} or @code{wcstok} has modified it, and it would not have
2138 when @code{strtok} or @code{wcstok} tries to modify it, your program
2140 Error Signals}. Even if the operation of @code{strtok} or @code{wcstok}
2150 The function @code{strtok} is not reentrant, whereas @code{wcstok} is.
2154 Here is a simple example showing the use of @code{strtok}.
2186 Just like @code{strtok}, this function splits the string into several
2187 tokens which can be accessed by successive calls to @code{strtok_r}.
2188 The difference is that, as in @code{wcstok}, the information about the
2191 @code{strtok_r} with a null pointer for @var{newstring} and leaving
2202 This function has a similar functionality as @code{strtok_r} with the
2205 Successive calls to @code{strsep} move the pointer along the tokens
2210 One difference between @code{strsep} and @code{strtok_r} is that if the
2212 row @code{strsep} returns an empty string for each pair of bytes
2214 for @code{strsep} returning an empty string before processing it.
2219 Here is how the above example looks like when @code{strsep} is used.
2253 The GNU version of the @code{basename} function returns the last
2256 respects trailing slashes. The prototype for @code{basename} can be
2260 Example of using GNU @code{basename}:
2288 This is the standard XPG defined @code{basename}. It is similar in
2292 @code{NULL} or an empty string, then "." is returned. The prototype for
2295 Example of using XPG @code{basename}:
2323 The @code{dirname} function is the compliment to the XPG version of
2324 @code{basename}. It returns the parent directory of the file specified
2325 by @var{path}. If @var{path} is @code{NULL}, an empty string, or
2337 code, because no @emph{correct} program could access the variable or
2342 The function @code{explicit_bzero} erases a block of memory, and
2366 In this example, if @code{memset}, @code{bzero}, or a hand-written
2369 @strong{Warning:} @code{explicit_bzero} does not guarantee that
2372 ``scratch'' stack space; since these are invisible to the source code,
2375 Also, @code{explicit_bzero} only operates on RAM. If a sensitive data
2377 @code{explicit_bzero}, it might be stored entirely in CPU registers
2378 @emph{until} the call to @code{explicit_bzero}. Then it will be
2385 Declaring sensitive variables as @code{volatile} will make both the
2386 above problems @emph{worse}; a @code{volatile} variable will be stored
2390 @code{volatile}-qualified pointer doesn't work at all---because the
2391 variable itself is not @code{volatile}, some compilers will ignore the
2394 Having said all that, in most situations, using @code{explicit_bzero}
2398 @code{explicit_bzero} and take appropriate steps to erase all the
2405 @code{explicit_bzero} writes zero into @var{len} bytes of memory
2406 beginning at @var{block}, just as @code{bzero} would. The zeroes are
2410 @strong{Note:} The @emph{only} optimization that @code{explicit_bzero}
2413 @code{memset}. For instance, it may replace the function call with
2419 functionality under a different name, such as @code{explicit_memset},
2420 @code{memset_s}, or @code{SecureZeroMemory}.
2432 This is not a difficult thing to code for oneself, but the authors of
2435 To @emph{erase} data, use @code{explicit_bzero} (@pxref{Erasing
2436 Sensitive Data}); to obfuscate it reversibly, use @code{memfrob}
2444 @code{strfry} performs an in-place shuffle on @var{string}. Each
2449 Calling @code{strfry} will not disturb any of the random number
2452 The return value of @code{strfry} is always @var{string}.
2463 The @code{memfrob} function reversibly obfuscates an array of binary
2476 @code{explicit_bzero} (@pxref{Erasing Sensitive Data}), or possibly
2477 @code{strfry} (@pxref{Shuffling Bytes}).
2483 The function @code{memfrob} obfuscates @var{length} bytes of data
2488 @code{memfrob} a second time on the same data returns it to
2517 value of @code{l64a} is undefined if @var{n} is negative. In the GNU
2518 implementation, @code{l64a} treats its argument as unsigned, so it will
2522 To encode a large buffer @code{l64a} must be called in a loop, once for
2576 To decode data produced with @code{l64a} the following function should be
2583 a call to @code{l64a}. The function processes at least 6 bytes of
2586 rather like @code{atoi}; if you have a buffer which has been broken into
2589 The decoded number is returned as a @code{long int} value.
2592 The @code{l64a} and @code{a64l} functions use a base 64 encoding, in
2598 @item 0 @tab @code{.} @tab @code{/} @tab @code{0} @tab @code{1}
2599 @tab @code{2} @tab @code{3} @tab @code{4} @tab @code{5}
2600 @item 8 @tab @code{6} @tab @code{7} @tab @code{8} @tab @code{9}
2601 @tab @code{A} @tab @code{B} @tab @code{C} @tab @code{D}
2602 @item 16 @tab @code{E} @tab @code{F} @tab @code{G} @tab @code{H}
2603 @tab @code{I} @tab @code{J} @tab @code{K} @tab @code{L}
2604 @item 24 @tab @code{M} @tab @code{N} @tab @code{O} @tab @code{P}
2605 @tab @code{Q} @tab @code{R} @tab @code{S} @tab @code{T}
2606 @item 32 @tab @code{U} @tab @code{V} @tab @code{W} @tab @code{X}
2607 @tab @code{Y} @tab @code{Z} @tab @code{a} @tab @code{b}
2608 @item 40 @tab @code{c} @tab @code{d} @tab @code{e} @tab @code{f}
2609 @tab @code{g} @tab @code{h} @tab @code{i} @tab @code{j}
2610 @item 48 @tab @code{k} @tab @code{l} @tab @code{m} @tab @code{n}
2611 @tab @code{o} @tab @code{p} @tab @code{q} @tab @code{r}
2612 @item 56 @tab @code{s} @tab @code{t} @tab @code{u} @tab @code{v}
2613 @tab @code{w} @tab @code{x} @tab @code{y} @tab @code{z}
2628 (@code{'\0'}).
2633 name-value pair, separated by a @code{'='} byte (as in a Unix
2645 type @code{char *}, and a size, of type @code{size_t}, both of which can
2646 be initialized to @code{0} to represent an empty argz vector. All argz
2650 The argz functions use @code{malloc}/@code{realloc} to allocate/grow
2652 be freed by using @code{free}; conversely, any argz function that may
2654 @code{malloc} (those argz functions that only examine their arguments or
2659 @code{error_t}, and return @code{0} for success, and @code{ENOMEM} if an
2668 The @code{argz_create} function converts the Unix-style argument vector
2670 @code{(char *)0}; @pxref{Program Arguments}) into an argz vector with
2677 The @code{argz_create_sep} function converts the string
2693 The @code{argz_extract} function converts the argz vector @var{argz} and
2696 positions in @var{argv}, followed by a terminator of @code{0}.
2698 elements in @var{argz} plus the terminating @code{(char *)0}
2699 (@code{(argz_count (@var{argz}, @var{argz_len}) + 1) * sizeof (char *)}
2710 The @code{argz_stringify} converts @var{argz} into a normal string with
2712 @code{'\0'} inside @var{argz} (except the last one, which terminates the
2721 The @code{argz_add} function adds the string @var{str} to the end of the
2722 argz vector @code{*@var{argz}}, and updates @code{*@var{argz}} and
2723 @code{*@var{argz_len}} accordingly.
2729 The @code{argz_add_sep} function is similar to @code{argz_add}, but
2733 a value of @code{':'} for @var{delim}.
2739 The @code{argz_append} function appends @var{buf_len} bytes starting at
2740 @var{buf} to the argz vector @code{*@var{argz}}, reallocating
2741 @code{*@var{argz}} to accommodate it, and adding @var{buf_len} to
2742 @code{*@var{argz_len}}.
2750 argz vector @code{*@var{argz}}, the @code{argz_delete} function will
2751 remove this entry and reallocate @code{*@var{argz}}, modifying
2752 @code{*@var{argz}} and @code{*@var{argz_len}} accordingly. Note that as
2761 The @code{argz_insert} function inserts the string @var{entry} into the
2762 argz vector @code{*@var{argz}} at a point just before the existing
2763 element pointed to by @var{before}, reallocating @code{*@var{argz}} and
2764 updating @code{*@var{argz}} and @code{*@var{argz_len}}. If @var{before}
2765 is @code{0}, @var{entry} is added to the end instead (as if by
2766 @code{argz_add}). Since the first element is in fact the same as
2767 @code{*@var{argz}}, passing in @code{*@var{argz}} as the value of
2774 The @code{argz_next} function provides a convenient way of iterating
2777 @code{0} if there are no elements following @var{entry}. If @var{entry}
2778 is @code{0}, the first element of @var{argz} is returned.
2789 about what they consider a questionable @code{while}-test) and:
2799 Note that the latter depends on @var{argz} having a value of @code{0} if
2809 @var{replace_count} is non-zero, @code{*@var{replace_count}} will be
2820 Each element in an envz vector is a name-value pair, separated by a @code{'='}
2821 byte; if multiple @code{'='} bytes are present in an element, those
2823 non-@code{'\0'} bytes.
2825 If @emph{no} @code{'='} bytes are present in an element, that element is
2827 empty value: @code{envz_get} will return @code{0} if given the name of null
2829 @code{""}; @code{envz_entry} will still find such entries, however. Null
2830 entries can be removed with the @code{envz_strip} function.
2833 fail) have a return type of @code{error_t}, and return either @code{0} or
2834 @code{ENOMEM}.
2842 The @code{envz_entry} function finds the entry in @var{envz} with the name
2844 element which begins with @var{name} followed by a @code{'='} byte. If
2845 there is no entry with that name, @code{0} is returned.
2851 The @code{envz_get} function finds the entry in @var{envz} with the name
2852 @var{name} (like @code{envz_entry}), and returns a pointer to the value
2853 portion of that entry (following the @code{'='}). If there is no entry with
2854 that name (or only a null entry), @code{0} is returned.
2861 @c argz_add or equivalent code that reallocs and appends name=value.
2862 The @code{envz_add} function adds an entry to @code{*@var{envz}}
2863 (updating @code{*@var{envz}} and @code{*@var{envz_len}}) with the name
2866 @code{0}, then the new entry will be the special null type of entry
2873 The @code{envz_merge} function adds each entry in @var{envz2} to @var{envz},
2874 as if with @code{envz_add}, updating @code{*@var{envz}} and
2875 @code{*@var{envz_len}}. If @var{override} is true, then values in @var{envz2}
2886 The @code{envz_strip} function removes any null entries from @var{envz},
2887 updating @code{*@var{envz}} and @code{*@var{envz_len}}.
2893 The @code{envz_remove} function removes an entry named @var{name} from
2894 @var{envz}, updating @code{*@var{envz}} and @code{*@var{envz_len}}.