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 ARGZ_ADD 3 2007-05-18 "" "Linux Programmer's Manual"
13 .\"O argz_add, argz_add_sep, argz_append, argz_count, argz_create,
14 .\"O argz_create_sep, argz_delete, argz_extract, argz_insert,
15 .\"O argz_next, argz_replace, argz_stringify \- functions to handle an argz list
16 argz_add, argz_add_sep, argz_append, argz_count, argz_create,
17 argz_create_sep, argz_delete, argz_extract, argz_insert,
18 argz_next, argz_replace, argz_stringify \- argz ¥ê¥¹¥È¤òÁàºî¤¹¤ë¤¿¤á¤Î´Ø¿ô·²
22 .B "#include <argz.h>"
24 .BI "error_t argz_add(char **" argz ", size_t *" argz_len \
25 ", const char *" str );
27 .BI "error_t argz_add_sep(char **" argz ", size_t *" argz_len ,
29 .BI "const char *" str ", int " delim );
31 .BI "error_t argz_append(char **" argz ", size_t *" argz_len ,
33 .BI "const char *" buf ", size_t " buf_len );
35 .BI "size_t argz_count(const char *" argz ", size_t " argz_len );
37 .BI "error_t argz_create(char * const " argv "[], char **" argz ,
39 .BI "size_t *" argz_len );
41 .BI "error_t argz_create_sep(const char *" str ", int " sep ", char **" argz ,
43 .BI "size_t *" argz_len );
45 .BI "error_t argz_delete(char **" argz ", size_t *" argz_len ", char *" entry );
47 .BI "void argz_extract(char *" argz ", size_t " argz_len ", char **" argv );
49 .BI "error_t argz_insert(char **" argz ", size_t *" argz_len ", char *" before ,
51 .BI "const char *" entry );
53 .BI "char *argz_next(char *" argz ", size_t " argz_len ", const char *" entry );
55 .BI "error_t argz_replace(char **" argz ", size_t *" argz_len \
56 ", const char *" str ,
58 .BI "const char *" with ", unsigned int *" replace_count );
60 .BI "void argz_stringify(char *" argz ", size_t " len ", int " sep );
64 .\"O These functions are glibc-specific.
65 ¤³¤ì¤é¤Î´Ø¿ô¤Ï glibc ¸ÇͤǤ¢¤ë¡£
67 .\"O An argz vector is a pointer to a character buffer together with a length.
68 .\"O The intended interpretation of the character buffer is an array
69 .\"O of strings, where the strings are separated by null bytes (\\(aq\\0\\(aq).
70 .\"O If the length is nonzero, the last byte of the buffer must be a null byte.
71 argz vector ¤ÏŤµ¾ðÊóÉÕ¤¤Îʸ»ú¥Ð¥Ã¥Õ¥¡¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
72 ʸ»ú¥Ð¥Ã¥Õ¥¡¤Ç¤Ï¡¢Ê£¿ô¤Îʸ»úÎó¤¬ NULL ¥Ð¥¤¥È (\\(aq\\0\\(aq) ¤Ç¶èÀÚ¤é¤ì¤Æ¤ª¤ê¡¢
73 ʸ»úÎó¤ÎÇÛÎó¤È¤·¤Æ²ò¼á¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
74 Ťµ¤¬ 0 ¤Ç¤Ê¤¤¾ì¹ç¡¢¥Ð¥Ã¥Õ¥¡¤ÎºÇ¸å¤Î¥Ð¥¤¥È¤Ï NULL ¥Ð¥¤¥È¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
76 .\"O These functions are for handling argz vectors.
77 .\"O The pair (NULL,0) is an argz vector, and, conversely,
78 .\"O argz vectors of length 0 must have NULL pointer.
79 .\"O Allocation of nonempty argz vectors is done using
83 .\"O can be used to dispose of them again.
84 ¤³¤ì¤é¤Î´Ø¿ô¤Ï argz vector ¤òÁàºî¤¹¤ë¤¿¤á¤Î¤â¤Î¤Ç¤¢¤ë¡£
85 ¥Ú¥¢ (NULL,0) ¤Ï argz vector ¤Ç¤¢¤ê¡¢µÕ¤Ë¸À¤¨¤Ð
86 Ťµ 0 ¤Î argz vector¤Ï NULL ¥Ý¥¤¥ó¥¿¤ò»ý¤¿¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
87 ¶õ¤Ç¤Ê¤¤ argz vector ¤Î³ä¤êÅö¤Æ¤Ï
89 ¤ò»È¤Ã¤Æ¹Ô¤ï¤ì¤ë¡£¤·¤¿¤¬¤Ã¤Æ¡¢argz vector ¤ò²òÊü¤¹¤ë¤Î¤Ë
96 .\"O at the end of the array
113 .\"O .BR argz_add_sep ()
114 .\"O is similar, but splits the string
116 .\"O into substrings separated by the delimiter
118 .\"O For example, one might use this on a Unix search path with
119 .\"O delimiter \\(aq:\\(aq.
121 ¤âƱÍͤÎÆ°ºî¤ò¤¹¤ë¤¬¡¢¶èÀÚ¤êʸ»ú
125 ¤òÊ£¿ô¤Îʸ»úÎó¤Ëʬ³ä¤¹¤ëÅÀ¤¬°Û¤Ê¤ë¡£
126 Î㤨¤Ð¡¢¶èÀÚ¤êʸ»ú \\(aq:\\(aq ¤ò»ØÄꤷ¤Æ¡¢Unix ¥µ¡¼¥Á¡¦¥Ñ¥¹¤ËÂФ·¤Æ
127 ¤³¤Î´Ø¿ô¤ò»È¤¦¤³¤È¤¬¤Ç¤¤ë¤À¤í¤¦¡£
129 .\"O .BR argz_append ()
130 .\"O appends the argz vector
131 .\"O .RI ( buf ,\ buf_len )
133 .\"O .RI (* argz ,\ *argz_len )
140 .\"O will be increased by
144 .RI ( buf ,\ buf_len )
146 .RI (* argz ,\ *argz_len )
158 .\"O .BR argz_count ()
159 .\"O counts the number of strings, that is,
160 .\"O the number of null bytes (\\(aq\\0\\(aq), in
161 .\"O .RI ( argz ,\ argz_len ).
164 .RI ( argz ,\ argz_len )
165 Æâ¤Îʸ»úÎó¤Î¿ô¤ò¿ô¤¨¤ë¡£¼ÂºÝ¤Ë¤Ï NULL ¥Ð¥¤¥È (\\(aq\\0\\(aq) ¤Î¿ô¤ò¿ô¤¨¤Æ¤¤¤ë¡£
167 .\"O .BR argz_create ()
168 .\"O converts a Unix-style argument vector
171 .\"O .IR "(char *) 0" ,
172 .\"O into an argz vector
173 .\"O .RI ( *argz ,\ *argz_len ).
175 ¤Ï¡¢Unix ή¤Î°ú¤¿ô¥Ù¥¯¥È¥ë¤Ç¤¢¤ë
180 .RI ( *argz ,\ *argz_len )
183 .\"O .BR argz_create_sep ()
184 .\"O converts the null-terminated string
186 .\"O into an argz vector
187 .\"O .RI (* argz ,\ *argz_len )
188 .\"O by breaking it up at every occurrence of the separator
190 .BR argz_create_sep ()
191 ¤Ï¡¢NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó
195 ¤¬¸½¤ì¤ëËè¤Ëʬ³ä¤·¤Ê¤¬¤é¡¢argz vector
196 .RI (* argz ,\ *argz_len )
199 .\"O .BR argz_delete ()
200 .\"O removes the substring pointed to by
202 .\"O from the argz vector
203 .\"O .RI ( *argz ,\ *argz_len )
211 ¤Ç»Ø¤·¼¨¤µ¤ì¤¿Ê¸»úÎó¤ò argz vector
212 .RI ( *argz ,\ *argz_len )
219 .\"O .BR argz_extract ()
220 .\"O is the opposite of
221 .\"O .BR argz_create ().
222 .\"O It takes the argz vector
223 .\"O .RI ( argz ,\ argz_len )
224 .\"O and fills the array starting at
226 .\"O with pointers to the substrings, and a final NULL,
227 .\"O making a Unix-style argv vector.
230 .\"O must have room for
231 .\"O .IR argz_count ( argz , argz_len ") + 1"
236 ¤ÎÈ¿ÂФÎÁàºî¤ò¹Ô¤¦¡£argz vector
237 .RI ( argz ,\ argz_len )
240 ¤«¤é»Ï¤Þ¤ëÇÛÎó¤ò¥µ¥Öʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤ÇËä¤á¤Æ¤¤¤¡¢
241 °ìÈֺǸå¤Ë NULL ¤òÆþ¤ì¤Æ¡¢Unix ή¤Î argv ¥Ù¥¯¥È¥ë¤òºîÀ®¤¹¤ë¡£
245 .IR argz_count ( argz , argz_len ") + 1"
246 ¸Ä¤Î¥Ý¥¤¥ó¥¿¤ò¼ýÍƤǤ¤ë¶õ´Ö¤ò»ý¤Ã¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
248 .\"O .BR argz_insert ()
249 .\"O is the opposite of
250 .\"O .BR argz_delete ().
251 .\"O It inserts the argument
255 .\"O into the argz vector
256 .\"O .RI ( *argz ,\ *argz_len )
265 .\"O will inserted at the end.
269 ¤ÎÈ¿ÂФÎÁàºî¤ò¹Ô¤¦¡£argz vector
270 .RI ( *argz ,\ *argz_len )
285 .\"O .BR argz_next ()
286 .\"O is a function to step trough the argz vector.
289 .\"O is NULL, the first entry is returned.
290 .\"O Otherwise, the entry
291 .\"O following is returned.
292 .\"O It returns NULL if there is no following entry.
294 ¤Ï argz vector ¤ò½çÈÖ¤ËÄ´¤Ù¤ë¤¿¤á¤Î´Ø¿ô¤Ç¤¢¤ë¡£
296 ¤¬ NULL ¤Î¾ì¹ç¡¢ºÇ½é¤Î¥¨¥ó¥È¥ê¤òÊÖ¤¹¡£
297 ¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¡¢¼¡¤Î¥¨¥ó¥È¥ê¤òÊÖ¤¹¡£
298 ¼¡¤Î¥¨¥ó¥È¥ê¤¬¤Ê¤¤¾ì¹ç¡¢NULL ¤òÊÖ¤¹¡£
300 .\"O .BR argz_replace ()
301 .\"O replaces each occurrence of
305 .\"O reallocating argz as necessary.
307 .\"O .I replace_count
309 .\"O .I *replace_count
310 .\"O will be incremented by the number of replacements.
316 ¤ÇÃÖ¤´¹¤¨¤ë (ɬÍפ˱þ¤¸¤Æ argz ¤ÎºÆ³ä¤êÅö¤Æ¤ò¹Ô¤¦)¡£
320 ¤òÃÖ¤´¹¤¨¤ò¹Ô¤Ã¤¿¿ô¤À¤±Áý¤ä¤¹¡£
322 .\"O .BR argz_stringify ()
323 .\"O is the opposite of
324 .\"O .BR argz_create_sep ().
325 .\"O It transforms the argz vector into a normal string by replacing
326 .\"O all null bytes (\\(aq\\0\\(aq) except the last by
328 .BR argz_stringify ()
330 .BR argz_create_sep ()
332 ËöÈø¤Î NULL ¥Ð¥¤¥È°Ê³°¤ÎÁ´¤Æ¤Î NULL ¥Ð¥¤¥È (\\(aq\\0\\(aq) ¤ò
335 argz vector ¤òÄ̾ï¤Îʸ»úÎó¤ËÊÑ´¹¤¹¤ë¡£
336 .\"O .SH "RETURN VALUE"
338 .\"O All argz functions that do memory allocation have a return type of
339 .\"O \fIerror_t\fP, and return 0 for success, and \fBENOMEM\fP
340 .\"O if an allocation error occurs.
341 ¥á¥â¥ê³ä¤êÅö¤Æ¤ò¹Ô¤¦ argz ´Ø¿ô·²¤Ï¤¹¤Ù¤Æ \fIerror_t\fP ·¿¤ÎÊÖ¤êÃͤò»ý¤Ä¡£
342 À®¸ù¤·¤¿¾ì¹ç¤Ï 0 ¤òÊÖ¤·¡¢³ä¤êÅö¤Æ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï
343 \fBENOMEM\fP ¤òÊÖ¤¹¡£
344 .\"O .SH CONFORMING TO
346 .\"O These functions are a GNU extension.
347 .\"O Handle with care.
348 ¤³¤ì¤é¤Î´Ø¿ô¤Ï GNU ¤Ë¤è¤ë³ÈÄ¥¤Ç¤¢¤ë¡£Ãí°Õ¤·¤Æ»ÈÍѤ¹¤ë¤³¤È¡£
351 .\"O Argz vectors without a terminating null byte may lead to
352 .\"O Segmentation Faults.
353 NULL ¥Ð¥¤¥È¤Ç½ªÃ¼¤µ¤ì¤Æ¤¤¤Ê¤¤ argz vector ¤ò»ÈÍѤ·¤¿¾ì¹ç¡¢
354 segmentation fault ¤òµ¯¤³¤¹¤«¤â¤·¤ì¤Ê¤¤¡£