OSDN Git Service

(split) LDP: Update POT and ja.po to LDP v3.54
[linuxjm/LDP_man-pages.git] / po4a / search / po / search.pot
1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 #
6 #, fuzzy
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2013-09-28 04:06+0900\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
14 "Language: \n"
15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=CHARSET\n"
17 "Content-Transfer-Encoding: 8bit\n"
18
19 #. type: TH
20 #: build/C/man3/bsearch.3:31
21 #, no-wrap
22 msgid "BSEARCH"
23 msgstr ""
24
25 #. type: TH
26 #: build/C/man3/bsearch.3:31
27 #, no-wrap
28 msgid "2003-11-01"
29 msgstr ""
30
31 #. type: TH
32 #: build/C/man3/bsearch.3:31 build/C/man3/hsearch.3:35 build/C/man3/insque.3:36 build/C/man3/lsearch.3:26 build/C/man3/qsort.3:37 build/C/man3/tsearch.3:25
33 #, no-wrap
34 msgid "Linux Programmer's Manual"
35 msgstr ""
36
37 #. type: SH
38 #: build/C/man3/bsearch.3:32 build/C/man3/hsearch.3:36 build/C/man3/insque.3:37 build/C/man3/lsearch.3:27 build/C/man3/qsort.3:38 build/C/man3/tsearch.3:26
39 #, no-wrap
40 msgid "NAME"
41 msgstr ""
42
43 #. type: Plain text
44 #: build/C/man3/bsearch.3:34
45 msgid "bsearch - binary search of a sorted array"
46 msgstr ""
47
48 #. type: SH
49 #: build/C/man3/bsearch.3:34 build/C/man3/hsearch.3:39 build/C/man3/insque.3:39 build/C/man3/lsearch.3:29 build/C/man3/qsort.3:40 build/C/man3/tsearch.3:28
50 #, no-wrap
51 msgid "SYNOPSIS"
52 msgstr ""
53
54 #. type: Plain text
55 #: build/C/man3/bsearch.3:37 build/C/man3/qsort.3:43
56 #, no-wrap
57 msgid "B<#include E<lt>stdlib.hE<gt>>\n"
58 msgstr ""
59
60 #. type: Plain text
61 #: build/C/man3/bsearch.3:41
62 #, no-wrap
63 msgid ""
64 "B<void *bsearch(const void *>I<key>B<, const void *>I<base>B<,>\n"
65 "B<              size_t >I<nmemb>B<, size_t >I<size>B<,>\n"
66 "B<              int (*>I<compar>B<)(const void *, const void *));>\n"
67 msgstr ""
68
69 #. type: SH
70 #: build/C/man3/bsearch.3:42 build/C/man3/hsearch.3:60 build/C/man3/insque.3:61 build/C/man3/lsearch.3:39 build/C/man3/qsort.3:61 build/C/man3/tsearch.3:51
71 #, no-wrap
72 msgid "DESCRIPTION"
73 msgstr ""
74
75 #. type: Plain text
76 #: build/C/man3/bsearch.3:56
77 msgid ""
78 "The B<bsearch>()  function searches an array of I<nmemb> objects, the "
79 "initial member of which is pointed to by I<base>, for a member that matches "
80 "the object pointed to by I<key>.  The size of each member of the array is "
81 "specified by I<size>."
82 msgstr ""
83
84 #. type: Plain text
85 #: build/C/man3/bsearch.3:70
86 msgid ""
87 "The contents of the array should be in ascending sorted order according to "
88 "the comparison function referenced by I<compar>.  The I<compar> routine is "
89 "expected to have two arguments which point to the I<key> object and to an "
90 "array member, in that order, and should return an integer less than, equal "
91 "to, or greater than zero if the I<key> object is found, respectively, to be "
92 "less than, to match, or be greater than the array member."
93 msgstr ""
94
95 #. type: SH
96 #: build/C/man3/bsearch.3:70 build/C/man3/hsearch.3:174 build/C/man3/lsearch.3:72 build/C/man3/qsort.3:91 build/C/man3/tsearch.3:167
97 #, no-wrap
98 msgid "RETURN VALUE"
99 msgstr ""
100
101 #. type: Plain text
102 #: build/C/man3/bsearch.3:77
103 msgid ""
104 "The B<bsearch>()  function returns a pointer to a matching member of the "
105 "array, or NULL if no match is found.  If there are multiple elements that "
106 "match the key, the element returned is unspecified."
107 msgstr ""
108
109 #. type: SH
110 #: build/C/man3/bsearch.3:77 build/C/man3/hsearch.3:246 build/C/man3/insque.3:99 build/C/man3/lsearch.3:80 build/C/man3/qsort.3:100 build/C/man3/tsearch.3:190
111 #, no-wrap
112 msgid "CONFORMING TO"
113 msgstr ""
114
115 #. type: Plain text
116 #: build/C/man3/bsearch.3:79
117 msgid "SVr4, 4.3BSD, POSIX.1-2001, C89, C99."
118 msgstr ""
119
120 #. type: SH
121 #: build/C/man3/bsearch.3:79 build/C/man3/hsearch.3:293 build/C/man3/insque.3:134 build/C/man3/qsort.3:116 build/C/man3/tsearch.3:212
122 #, no-wrap
123 msgid "EXAMPLE"
124 msgstr ""
125
126 #. type: Plain text
127 #: build/C/man3/bsearch.3:84
128 msgid ""
129 "The example below first sorts an array of structures using B<qsort>(3), then "
130 "retrieves desired elements using B<bsearch>()."
131 msgstr ""
132
133 #. type: Plain text
134 #: build/C/man3/bsearch.3:89 build/C/man3/qsort.3:127
135 #, no-wrap
136 msgid ""
137 "#include E<lt>stdio.hE<gt>\n"
138 "#include E<lt>stdlib.hE<gt>\n"
139 "#include E<lt>string.hE<gt>\n"
140 msgstr ""
141
142 #. type: Plain text
143 #: build/C/man3/bsearch.3:98
144 #, no-wrap
145 msgid ""
146 "struct mi {\n"
147 "    int nr;\n"
148 "    char *name;\n"
149 "} months[] = {\n"
150 "    { 1, \"jan\" }, { 2, \"feb\" }, { 3, \"mar\" }, { 4, \"apr\" },\n"
151 "    { 5, \"may\" }, { 6, \"jun\" }, { 7, \"jul\" }, { 8, \"aug\" },\n"
152 "    { 9, \"sep\" }, {10, \"oct\" }, {11, \"nov\" }, {12, \"dec\" }\n"
153 "};\n"
154 msgstr ""
155
156 #. type: Plain text
157 #: build/C/man3/bsearch.3:100
158 #, no-wrap
159 msgid "#define nr_of_months (sizeof(months)/sizeof(months[0]))\n"
160 msgstr ""
161
162 #. type: Plain text
163 #: build/C/man3/bsearch.3:108
164 #, no-wrap
165 msgid ""
166 "static int\n"
167 "compmi(const void *m1, const void *m2)\n"
168 "{\n"
169 "    struct mi *mi1 = (struct mi *) m1;\n"
170 "    struct mi *mi2 = (struct mi *) m2;\n"
171 "    return strcmp(mi1-E<gt>name, mi2-E<gt>name);\n"
172 "}\n"
173 msgstr ""
174
175 #. type: Plain text
176 #: build/C/man3/bsearch.3:113
177 #, no-wrap
178 msgid ""
179 "int\n"
180 "main(int argc, char **argv)\n"
181 "{\n"
182 "    int i;\n"
183 msgstr ""
184
185 #. type: Plain text
186 #: build/C/man3/bsearch.3:127
187 #, no-wrap
188 msgid ""
189 "    qsort(months, nr_of_months, sizeof(struct mi), compmi);\n"
190 "    for (i = 1; i E<lt> argc; i++) {\n"
191 "        struct mi key, *res;\n"
192 "        key.name = argv[i];\n"
193 "        res = bsearch(&key, months, nr_of_months,\n"
194 "                      sizeof(struct mi), compmi);\n"
195 "        if (res == NULL)\n"
196 "            printf(\"\\(aq%s\\(aq: unknown month\\en\", argv[i]);\n"
197 "        else\n"
198 "            printf(\"%s: month #%d\\en\", res-E<gt>name, res-E<gt>nr);\n"
199 "    }\n"
200 "    exit(EXIT_SUCCESS);\n"
201 "}\n"
202 msgstr ""
203
204 #. type: SH
205 #: build/C/man3/bsearch.3:129 build/C/man3/hsearch.3:343 build/C/man3/lsearch.3:85 build/C/man3/qsort.3:155 build/C/man3/tsearch.3:289
206 #, no-wrap
207 msgid "SEE ALSO"
208 msgstr ""
209
210 #. type: Plain text
211 #: build/C/man3/bsearch.3:134
212 msgid "B<hsearch>(3), B<lsearch>(3), B<qsort>(3), B<tsearch>(3)"
213 msgstr ""
214
215 #. type: SH
216 #: build/C/man3/bsearch.3:134 build/C/man3/hsearch.3:348 build/C/man3/insque.3:244 build/C/man3/lsearch.3:89 build/C/man3/qsort.3:160 build/C/man3/tsearch.3:294
217 #, no-wrap
218 msgid "COLOPHON"
219 msgstr ""
220
221 #. type: Plain text
222 #: build/C/man3/bsearch.3:141 build/C/man3/hsearch.3:355 build/C/man3/insque.3:251 build/C/man3/lsearch.3:96 build/C/man3/qsort.3:167 build/C/man3/tsearch.3:301
223 msgid ""
224 "This page is part of release 3.54 of the Linux I<man-pages> project.  A "
225 "description of the project, and information about reporting bugs, can be "
226 "found at \\%http://www.kernel.org/doc/man-pages/."
227 msgstr ""
228
229 #. type: TH
230 #: build/C/man3/hsearch.3:35
231 #, no-wrap
232 msgid "HSEARCH"
233 msgstr ""
234
235 #. type: TH
236 #: build/C/man3/hsearch.3:35
237 #, no-wrap
238 msgid "2013-07-22"
239 msgstr ""
240
241 #. type: TH
242 #: build/C/man3/hsearch.3:35 build/C/man3/lsearch.3:26 build/C/man3/tsearch.3:25
243 #, no-wrap
244 msgid "GNU"
245 msgstr ""
246
247 #. type: Plain text
248 #: build/C/man3/hsearch.3:39
249 msgid ""
250 "hcreate, hdestroy, hsearch, hcreate_r, hdestroy_r, hsearch_r - hash table "
251 "management"
252 msgstr ""
253
254 #. type: Plain text
255 #: build/C/man3/hsearch.3:42 build/C/man3/hsearch.3:52 build/C/man3/insque.3:42 build/C/man3/lsearch.3:32 build/C/man3/tsearch.3:31 build/C/man3/tsearch.3:48
256 #, no-wrap
257 msgid "B<#include E<lt>search.hE<gt>>\n"
258 msgstr ""
259
260 #. type: Plain text
261 #: build/C/man3/hsearch.3:44
262 #, no-wrap
263 msgid "B<int hcreate(size_t >I<nel>B<);>\n"
264 msgstr ""
265
266 #. type: Plain text
267 #: build/C/man3/hsearch.3:46
268 #, no-wrap
269 msgid "B<ENTRY *hsearch(ENTRY >I<item>B<, ACTION >I<action>B<);>\n"
270 msgstr ""
271
272 #. type: Plain text
273 #: build/C/man3/hsearch.3:48
274 #, no-wrap
275 msgid "B<void hdestroy(void);>\n"
276 msgstr ""
277
278 #. type: Plain text
279 #: build/C/man3/hsearch.3:50 build/C/man3/tsearch.3:46
280 #, no-wrap
281 msgid "B<#define _GNU_SOURCE>         /* See feature_test_macros(7) */\n"
282 msgstr ""
283
284 #. type: Plain text
285 #: build/C/man3/hsearch.3:54
286 #, no-wrap
287 msgid "B<int hcreate_r(size_t >I<nel>B<, struct hsearch_data *>I<htab>B<);>\n"
288 msgstr ""
289
290 #. type: Plain text
291 #: build/C/man3/hsearch.3:57
292 #, no-wrap
293 msgid ""
294 "B<int hsearch_r(ENTRY >I<item>B<, ACTION >I<action>B<, ENTRY "
295 "**>I<retval>B<,>\n"
296 "B<              struct hsearch_data *>I<htab>B<);>\n"
297 msgstr ""
298
299 #. type: Plain text
300 #: build/C/man3/hsearch.3:59
301 #, no-wrap
302 msgid "B<void hdestroy_r(struct hsearch_data *>I<htab>B<);>\n"
303 msgstr ""
304
305 #. type: Plain text
306 #: build/C/man3/hsearch.3:69
307 msgid ""
308 "The three functions B<hcreate>(), B<hsearch>(), and B<hdestroy>()  allow the "
309 "caller to create and manage a hash search table containing entries "
310 "consisting of a key (a string) and associated data.  Using these functions, "
311 "only one hash table can be used at a time."
312 msgstr ""
313
314 #. type: Plain text
315 #: build/C/man3/hsearch.3:83
316 msgid ""
317 "The three functions B<hcreate_r>(), B<hsearch_r>(), B<hdestroy_r>()  are "
318 "reentrant versions that allow a program to use more than one hash search "
319 "table at the same time.  The last argument, I<htab>, points to a structure "
320 "that describes the table on which the function is to operate.  The "
321 "programmer should treat this structure as opaque (i.e., do not attempt to "
322 "directly access or modify the fields in this structure)."
323 msgstr ""
324
325 #.  e.g., in glibc it is raised to the next higher prime number
326 #. type: Plain text
327 #: build/C/man3/hsearch.3:92
328 msgid ""
329 "First a hash table must be created using B<hcreate>().  The argument I<nel> "
330 "specifies the maximum number of entries in the table.  (This maximum cannot "
331 "be changed later, so choose it wisely.)  The implementation may adjust this "
332 "value upward to improve the performance of the resulting hash table."
333 msgstr ""
334
335 #. type: Plain text
336 #: build/C/man3/hsearch.3:103
337 msgid ""
338 "The B<hcreate_r>()  function performs the same task as B<hcreate>(), but for "
339 "the table described by the structure I<*htab>.  The structure pointed to by "
340 "I<htab> must be zeroed before the first call to B<hcreate_r>()."
341 msgstr ""
342
343 #. type: Plain text
344 #: build/C/man3/hsearch.3:118
345 msgid ""
346 "The function B<hdestroy>()  frees the memory occupied by the hash table that "
347 "was created by B<hcreate>().  After calling B<hdestroy>()  a new hash table "
348 "can be created using B<hcreate>().  The B<hdestroy_r>()  function performs "
349 "the analogous task for a hash table described by I<*htab>, which was "
350 "previously created using B<hcreate_r>()."
351 msgstr ""
352
353 #. type: Plain text
354 #: build/C/man3/hsearch.3:125
355 msgid ""
356 "The B<hsearch>()  function searches the hash table for an item with the same "
357 "key as I<item> (where \"the same\" is determined using B<strcmp>(3)), and if "
358 "successful returns a pointer to it."
359 msgstr ""
360
361 #. type: Plain text
362 #: build/C/man3/hsearch.3:128
363 msgid ""
364 "The argument I<item> is of type I<ENTRY>, which is defined in "
365 "I<E<lt>search.hE<gt>> as follows:"
366 msgstr ""
367
368 #. type: Plain text
369 #: build/C/man3/hsearch.3:135
370 #, no-wrap
371 msgid ""
372 "typedef struct entry {\n"
373 "    char *key;\n"
374 "    void *data;\n"
375 "} ENTRY;\n"
376 msgstr ""
377
378 #. type: Plain text
379 #: build/C/man3/hsearch.3:141
380 msgid ""
381 "The field I<key> points to a null-terminated string which is the search "
382 "key.  The field I<data> points to data that is associated with that key."
383 msgstr ""
384
385 #. type: Plain text
386 #: build/C/man3/hsearch.3:160
387 msgid ""
388 "The argument I<action> determines what B<hsearch>()  does after an "
389 "unsuccessful search.  This argument must either have the value B<ENTER>, "
390 "meaning insert a copy of I<item> (and return a pointer to the new hash table "
391 "entry as the function result), or the value B<FIND>, meaning that NULL "
392 "should be returned.  (If I<action> is B<FIND>, then I<data> is ignored.)"
393 msgstr ""
394
395 #. type: Plain text
396 #: build/C/man3/hsearch.3:174
397 msgid ""
398 "The B<hsearch_r>()  function is like B<hsearch>()  but operates on the hash "
399 "table described by I<*htab>.  The B<hsearch_r>()  function differs from "
400 "B<hsearch>()  in that a pointer to the found item is returned in I<*retval>, "
401 "rather than as the function result."
402 msgstr ""
403
404 #. type: Plain text
405 #: build/C/man3/hsearch.3:182
406 msgid ""
407 "B<hcreate>()  and B<hcreate_r>()  return nonzero on success.  They return 0 "
408 "on error, with I<errno> set to indicate the cause of the error."
409 msgstr ""
410
411 #. type: Plain text
412 #: build/C/man3/hsearch.3:196
413 msgid ""
414 "On success, B<hsearch>()  returns a pointer to an entry in the hash table.  "
415 "B<hsearch>()  returns NULL on error, that is, if I<action> is B<ENTER> and "
416 "the hash table is full, or I<action> is B<FIND> and I<item> cannot be found "
417 "in the hash table.  B<hsearch_r>()  returns nonzero on success, and 0 on "
418 "error.  In the event of an error, these two functions set I<errno> to "
419 "indicate the cause of the error."
420 msgstr ""
421
422 #. type: SH
423 #: build/C/man3/hsearch.3:196
424 #, no-wrap
425 msgid "ERRORS"
426 msgstr ""
427
428 #. type: Plain text
429 #: build/C/man3/hsearch.3:202
430 msgid "B<hcreate_r>()  and B<hdestroy_r>()  can fail for the following reasons:"
431 msgstr ""
432
433 #. type: TP
434 #: build/C/man3/hsearch.3:202
435 #, no-wrap
436 msgid "B<EINVAL>"
437 msgstr ""
438
439 #. type: Plain text
440 #: build/C/man3/hsearch.3:206
441 msgid "I<htab> is NULL."
442 msgstr ""
443
444 #. type: Plain text
445 #: build/C/man3/hsearch.3:211
446 msgid "B<hsearch>()  and B<hsearch_r>()  can fail for the following reasons:"
447 msgstr ""
448
449 #. type: TP
450 #: build/C/man3/hsearch.3:211
451 #, no-wrap
452 msgid "B<ENOMEM>"
453 msgstr ""
454
455 #. type: Plain text
456 #: build/C/man3/hsearch.3:219
457 msgid ""
458 "I<action> was B<ENTER>, I<key> was not found in the table, and there was no "
459 "room in the table to add a new entry."
460 msgstr ""
461
462 #. type: TP
463 #: build/C/man3/hsearch.3:219
464 #, no-wrap
465 msgid "B<ESRCH>"
466 msgstr ""
467
468 #. type: Plain text
469 #: build/C/man3/hsearch.3:227
470 msgid "I<action> was B<FIND>, and I<key> was not found in the table."
471 msgstr ""
472
473 #. type: Plain text
474 #: build/C/man3/hsearch.3:231
475 msgid "POSIX.1-2001 specifies only the B<ENOMEM> error."
476 msgstr ""
477
478 #. type: SH
479 #: build/C/man3/hsearch.3:231
480 #, no-wrap
481 msgid "ATTRIBUTES"
482 msgstr ""
483
484 #. type: SS
485 #: build/C/man3/hsearch.3:232
486 #, no-wrap
487 msgid "Multithreading (see pthreads(7))"
488 msgstr ""
489
490 #. type: Plain text
491 #: build/C/man3/hsearch.3:239
492 msgid ""
493 "The B<hcreate>(), B<hsearch>(), and B<hdestroy>()  functions use a global "
494 "space for storing the table, so they are not thread-safe."
495 msgstr ""
496
497 #. type: Plain text
498 #: build/C/man3/hsearch.3:246
499 msgid ""
500 "The B<hcreate_r>(), B<hsearch_r>(), and B<hdestroy_r>()  functions are "
501 "thread-safe."
502 msgstr ""
503
504 #. type: Plain text
505 #: build/C/man3/hsearch.3:259
506 msgid ""
507 "The functions B<hcreate>(), B<hsearch>(), and B<hdestroy>()  are from SVr4, "
508 "and are described in POSIX.1-2001.  The functions B<hcreate_r>(), "
509 "B<hsearch_r>(), and B<hdestroy_r>()  are GNU extensions."
510 msgstr ""
511
512 #. type: SH
513 #: build/C/man3/hsearch.3:259 build/C/man3/insque.3:101 build/C/man3/qsort.3:104 build/C/man3/tsearch.3:195
514 #, no-wrap
515 msgid "NOTES"
516 msgstr ""
517
518 #. type: Plain text
519 #: build/C/man3/hsearch.3:266
520 msgid ""
521 "Hash table implementations are usually more efficient when the table "
522 "contains enough free space to minimize collisions.  Typically, this means "
523 "that I<nel> should be at least 25% larger than the maximum number of "
524 "elements that the caller expects to store in the table."
525 msgstr ""
526
527 #. type: Plain text
528 #: build/C/man3/hsearch.3:284
529 msgid ""
530 "The B<hdestroy>()  and B<hdestroy_r>()  functions do not free the buffers "
531 "pointed to by the I<key> and I<data> elements of the hash table entries.  "
532 "(It can't do this because it doesn't know whether these buffers were "
533 "allocated dynamically.)  If these buffers need to be freed (perhaps because "
534 "the program is repeatedly creating and destroying hash tables, rather than "
535 "creating a single table whose lifetime matches that of the program), then "
536 "the program must maintain bookkeeping data structures that allow it to free "
537 "them."
538 msgstr ""
539
540 #. type: SH
541 #: build/C/man3/hsearch.3:284 build/C/man3/insque.3:127 build/C/man3/lsearch.3:83
542 #, no-wrap
543 msgid "BUGS"
544 msgstr ""
545
546 #. type: Plain text
547 #: build/C/man3/hsearch.3:291
548 msgid ""
549 "SVr4 and POSIX.1-2001 specify that I<action> is significant only for "
550 "unsuccessful searches, so that an B<ENTER> should not do anything for a "
551 "successful search.  In libc and glibc (before version 2.3), the "
552 "implementation violates the specification, updating the I<data> for the "
553 "given I<key> in this case."
554 msgstr ""
555
556 #. type: Plain text
557 #: build/C/man3/hsearch.3:293
558 msgid "Individual hash table entries can be added, but not deleted."
559 msgstr ""
560
561 #. type: Plain text
562 #: build/C/man3/hsearch.3:297
563 msgid ""
564 "The following program inserts 24 items into a hash table, then prints some "
565 "of them."
566 msgstr ""
567
568 #. type: Plain text
569 #: build/C/man3/hsearch.3:302
570 #, no-wrap
571 msgid ""
572 "#include E<lt>stdio.hE<gt>\n"
573 "#include E<lt>stdlib.hE<gt>\n"
574 "#include E<lt>search.hE<gt>\n"
575 msgstr ""
576
577 #. type: Plain text
578 #: build/C/man3/hsearch.3:309
579 #, no-wrap
580 msgid ""
581 "char *data[] = { \"alpha\", \"bravo\", \"charlie\", \"delta\",\n"
582 "     \"echo\", \"foxtrot\", \"golf\", \"hotel\", \"india\", \"juliet\",\n"
583 "     \"kilo\", \"lima\", \"mike\", \"november\", \"oscar\", \"papa\",\n"
584 "     \"quebec\", \"romeo\", \"sierra\", \"tango\", \"uniform\",\n"
585 "     \"victor\", \"whisky\", \"x-ray\", \"yankee\", \"zulu\"\n"
586 "};\n"
587 msgstr ""
588
589 #. type: Plain text
590 #: build/C/man3/hsearch.3:315
591 #, no-wrap
592 msgid ""
593 "int\n"
594 "main(void)\n"
595 "{\n"
596 "    ENTRY e, *ep;\n"
597 "    int i;\n"
598 msgstr ""
599
600 #. type: Plain text
601 #: build/C/man3/hsearch.3:317
602 #, no-wrap
603 msgid "    hcreate(30);\n"
604 msgstr ""
605
606 #. type: Plain text
607 #: build/C/man3/hsearch.3:330
608 #, no-wrap
609 msgid ""
610 "    for (i = 0; i E<lt> 24; i++) {\n"
611 "        e.key = data[i];\n"
612 "        /* data is just an integer, instead of a\n"
613 "           pointer to something */\n"
614 "        e.data = (void *) i;\n"
615 "        ep = hsearch(e, ENTER);\n"
616 "        /* there should be no failures */\n"
617 "        if (ep == NULL) {\n"
618 "            fprintf(stderr, \"entry failed\\en\");\n"
619 "            exit(EXIT_FAILURE);\n"
620 "        }\n"
621 "    }\n"
622 msgstr ""
623
624 #. type: Plain text
625 #: build/C/man3/hsearch.3:342
626 #, no-wrap
627 msgid ""
628 "    for (i = 22; i E<lt> 26; i++) {\n"
629 "        /* print two entries from the table, and\n"
630 "           show that two are not in the table */\n"
631 "        e.key = data[i];\n"
632 "        ep = hsearch(e, FIND);\n"
633 "        printf(\"%9.9s -E<gt> %9.9s:%d\\en\", e.key,\n"
634 "               ep ? ep-E<gt>key : \"NULL\", ep ? (int)(ep-E<gt>data) : 0);\n"
635 "    }\n"
636 "    hdestroy();\n"
637 "    exit(EXIT_SUCCESS);\n"
638 "}\n"
639 msgstr ""
640
641 #. type: Plain text
642 #: build/C/man3/hsearch.3:348
643 msgid "B<bsearch>(3), B<lsearch>(3), B<malloc>(3), B<tsearch>(3)"
644 msgstr ""
645
646 #. type: TH
647 #: build/C/man3/insque.3:36
648 #, no-wrap
649 msgid "INSQUE"
650 msgstr ""
651
652 #. type: TH
653 #: build/C/man3/insque.3:36
654 #, no-wrap
655 msgid "2010-09-09"
656 msgstr ""
657
658 #. type: Plain text
659 #: build/C/man3/insque.3:39
660 msgid "insque, remque - insert/remove an item from a queue"
661 msgstr ""
662
663 #. type: Plain text
664 #: build/C/man3/insque.3:44
665 #, no-wrap
666 msgid "B<void insque(void *>I<elem>B<, void *>I<prev>B<);>\n"
667 msgstr ""
668
669 #. type: Plain text
670 #: build/C/man3/insque.3:46
671 #, no-wrap
672 msgid "B<void remque(void *>I<elem>B<);>\n"
673 msgstr ""
674
675 #. type: Plain text
676 #: build/C/man3/insque.3:51 build/C/man3/qsort.3:55
677 msgid "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
678 msgstr ""
679
680 #. type: Plain text
681 #: build/C/man3/insque.3:56
682 msgid "B<insque>(), B<remque>():"
683 msgstr ""
684
685 #. type: Plain text
686 #: build/C/man3/insque.3:59
687 msgid ""
688 "_SVID_SOURCE || _XOPEN_SOURCE\\ E<gt>=\\ 500 || _XOPEN_SOURCE\\ &&\\ "
689 "_XOPEN_SOURCE_EXTENDED"
690 msgstr ""
691
692 #. type: Plain text
693 #: build/C/man3/insque.3:73
694 msgid ""
695 "The B<insque>()  and B<remque>()  functions manipulate doubly-linked lists.  "
696 "Each element in the list is a structure of which the first two elements are "
697 "a forward and a backward pointer.  The linked list may be linear (i.e., NULL "
698 "forward pointer at the end of the list and NULL backward pointer at the "
699 "start of the list)  or circular."
700 msgstr ""
701
702 #. type: Plain text
703 #: build/C/man3/insque.3:78
704 msgid ""
705 "The B<insque>()  function inserts the element pointed to by I<elem> "
706 "immediately after the element pointed to by I<prev>."
707 msgstr ""
708
709 #. type: Plain text
710 #: build/C/man3/insque.3:85
711 msgid ""
712 "If the list is linear, then the call I<insque(elem, NULL)> can be used to "
713 "insert the initial list element, and the call sets the forward and backward "
714 "pointers of I<elem> to NULL."
715 msgstr ""
716
717 #. type: Plain text
718 #: build/C/man3/insque.3:94
719 msgid ""
720 "If the list is circular, the caller should ensure that the forward and "
721 "backward pointers of the first element are initialized to point to that "
722 "element, and the I<prev> argument of the B<insque>()  call should also point "
723 "to the element."
724 msgstr ""
725
726 #. type: Plain text
727 #: build/C/man3/insque.3:99
728 msgid ""
729 "The B<remque>()  function removes the element pointed to by I<elem> from the "
730 "doubly-linked list."
731 msgstr ""
732
733 #. type: Plain text
734 #: build/C/man3/insque.3:101
735 msgid "POSIX.1-2001."
736 msgstr ""
737
738 #. type: Plain text
739 #: build/C/man3/insque.3:105
740 msgid ""
741 "Traditionally (e.g., SunOS, Linux libc 4 and libc 5), the arguments of these "
742 "functions were of type I<struct qelem *>, defined as:"
743 msgstr ""
744
745 #. type: Plain text
746 #: build/C/man3/insque.3:113
747 #, no-wrap
748 msgid ""
749 "struct qelem {\n"
750 "    struct qelem *q_forw;\n"
751 "    struct qelem *q_back;\n"
752 "    char          q_data[1];\n"
753 "};\n"
754 msgstr ""
755
756 #. type: Plain text
757 #: build/C/man3/insque.3:120
758 msgid ""
759 "This is still what you will get if B<_GNU_SOURCE> is defined before "
760 "including I<E<lt>search.hE<gt>>."
761 msgstr ""
762
763 #. type: Plain text
764 #: build/C/man3/insque.3:127
765 msgid ""
766 "The location of the prototypes for these functions differs among several "
767 "versions of UNIX.  The above is the POSIX version.  Some systems place them "
768 "in I<E<lt>string.hE<gt>>.  Linux libc4 and libc 5 placed them in "
769 "I<E<lt>stdlib.hE<gt>>."
770 msgstr ""
771
772 #. type: Plain text
773 #: build/C/man3/insque.3:134
774 msgid ""
775 "In glibc 2.4 and earlier, it was not possible to specify I<prev> as NULL.  "
776 "Consequently, to build a linear list, the caller had to build a list using "
777 "an initial call that contained the first two elements of the list, with the "
778 "forward and backward pointers in each element suitably initialized."
779 msgstr ""
780
781 #. type: Plain text
782 #: build/C/man3/insque.3:138
783 msgid ""
784 "The program below demonstrates the use of B<insque>().  Here is an example "
785 "run of the program:"
786 msgstr ""
787
788 #. type: Plain text
789 #: build/C/man3/insque.3:147
790 #, no-wrap
791 msgid ""
792 "$ B<./a.out -c a b c>\n"
793 "Traversing completed list:\n"
794 "    a\n"
795 "    b\n"
796 "    c\n"
797 "That was a circular list\n"
798 msgstr ""
799
800 #. type: SS
801 #: build/C/man3/insque.3:149
802 #, no-wrap
803 msgid "Program source"
804 msgstr ""
805
806 #. type: Plain text
807 #: build/C/man3/insque.3:156
808 #, no-wrap
809 msgid ""
810 "#include E<lt>stdio.hE<gt>\n"
811 "#include E<lt>stdlib.hE<gt>\n"
812 "#include E<lt>unistd.hE<gt>\n"
813 "#include E<lt>search.hE<gt>\n"
814 msgstr ""
815
816 #. type: Plain text
817 #: build/C/man3/insque.3:162
818 #, no-wrap
819 msgid ""
820 "struct element {\n"
821 "    struct element *forward;\n"
822 "    struct element *backward;\n"
823 "    char *name;\n"
824 "};\n"
825 msgstr ""
826
827 #. type: Plain text
828 #: build/C/man3/insque.3:167
829 #, no-wrap
830 msgid ""
831 "static struct element *\n"
832 "new_element(void)\n"
833 "{\n"
834 "    struct element *e;\n"
835 msgstr ""
836
837 #. type: Plain text
838 #: build/C/man3/insque.3:173
839 #, no-wrap
840 msgid ""
841 "    e = malloc(sizeof(struct element));\n"
842 "    if (e == NULL) {\n"
843 "        fprintf(stderr, \"malloc() failed\\en\");\n"
844 "        exit(EXIT_FAILURE);\n"
845 "    }\n"
846 msgstr ""
847
848 #. type: Plain text
849 #: build/C/man3/insque.3:176
850 #, no-wrap
851 msgid ""
852 "    return e;\n"
853 "}\n"
854 msgstr ""
855
856 #. type: Plain text
857 #: build/C/man3/insque.3:182
858 #, no-wrap
859 msgid ""
860 "int\n"
861 "main(int argc, char *argv[])\n"
862 "{\n"
863 "    struct element *first, *elem, *prev;\n"
864 "    int circular, opt, errfnd;\n"
865 msgstr ""
866
867 #. type: Plain text
868 #: build/C/man3/insque.3:185
869 #, no-wrap
870 msgid ""
871 "    /* The \"-c\" command-line option can be used to specify that the\n"
872 "       list is circular */\n"
873 msgstr ""
874
875 #. type: Plain text
876 #: build/C/man3/insque.3:198
877 #, no-wrap
878 msgid ""
879 "    errfnd = 0;\n"
880 "    circular = 0;\n"
881 "    while ((opt = getopt(argc, argv, \"c\")) != -1) {\n"
882 "        switch (opt) {\n"
883 "        case 'c':\n"
884 "            circular = 1;\n"
885 "            break;\n"
886 "        default:\n"
887 "            errfnd = 1;\n"
888 "            break;\n"
889 "        }\n"
890 "    }\n"
891 msgstr ""
892
893 #. type: Plain text
894 #: build/C/man3/insque.3:203
895 #, no-wrap
896 msgid ""
897 "    if (errfnd || optind E<gt>= argc) {\n"
898 "        fprintf(stderr,  \"Usage: %s [-c] string...\\en\", argv[0]);\n"
899 "        exit(EXIT_FAILURE);\n"
900 "    }\n"
901 msgstr ""
902
903 #. type: Plain text
904 #: build/C/man3/insque.3:205
905 #, no-wrap
906 msgid "    /* Create first element and place it in the linked list */\n"
907 msgstr ""
908
909 #. type: Plain text
910 #: build/C/man3/insque.3:208
911 #, no-wrap
912 msgid ""
913 "    elem = new_element();\n"
914 "    first = elem;\n"
915 msgstr ""
916
917 #. type: Plain text
918 #: build/C/man3/insque.3:210
919 #, no-wrap
920 msgid "    elem-E<gt>name = argv[optind];\n"
921 msgstr ""
922
923 #. type: Plain text
924 #: build/C/man3/insque.3:218
925 #, no-wrap
926 msgid ""
927 "    if (circular) {\n"
928 "        elem-E<gt>forward = elem;\n"
929 "        elem-E<gt>backward = elem;\n"
930 "        insque(elem, elem);\n"
931 "    } else {\n"
932 "        insque(elem, NULL);\n"
933 "    }\n"
934 msgstr ""
935
936 #. type: Plain text
937 #: build/C/man3/insque.3:220
938 #, no-wrap
939 msgid "    /* Add remaining command-line arguments as list elements */\n"
940 msgstr ""
941
942 #. type: Plain text
943 #: build/C/man3/insque.3:223
944 #, no-wrap
945 msgid ""
946 "    while (++optind E<lt> argc) {\n"
947 "        prev = elem;\n"
948 msgstr ""
949
950 #. type: Plain text
951 #: build/C/man3/insque.3:228
952 #, no-wrap
953 msgid ""
954 "        elem = new_element();\n"
955 "        elem-E<gt>name = argv[optind];\n"
956 "        insque(elem, prev);\n"
957 "    }\n"
958 msgstr ""
959
960 #. type: Plain text
961 #: build/C/man3/insque.3:230
962 #, no-wrap
963 msgid "    /* Traverse the list from the start, printing element names */\n"
964 msgstr ""
965
966 #. type: Plain text
967 #: build/C/man3/insque.3:237
968 #, no-wrap
969 msgid ""
970 "    printf(\"Traversing completed list:\\en\");\n"
971 "    elem = first;\n"
972 "    do {\n"
973 "        printf(\"    %s\\en\", elem-E<gt>name);\n"
974 "        elem = elem-E<gt>forward;\n"
975 "    } while (elem != NULL && elem != first);\n"
976 msgstr ""
977
978 #. type: Plain text
979 #: build/C/man3/insque.3:240
980 #, no-wrap
981 msgid ""
982 "    if (elem == first)\n"
983 "        printf(\"That was a circular list\\en\");\n"
984 msgstr ""
985
986 #. type: Plain text
987 #: build/C/man3/insque.3:243
988 #, no-wrap
989 msgid ""
990 "    exit(EXIT_SUCCESS);\n"
991 "}\n"
992 msgstr ""
993
994 #. type: TH
995 #: build/C/man3/lsearch.3:26
996 #, no-wrap
997 msgid "LSEARCH"
998 msgstr ""
999
1000 #. type: TH
1001 #: build/C/man3/lsearch.3:26
1002 #, no-wrap
1003 msgid "1999-09-27"
1004 msgstr ""
1005
1006 #. type: Plain text
1007 #: build/C/man3/lsearch.3:29
1008 msgid "lfind, lsearch - linear search of an array"
1009 msgstr ""
1010
1011 #. type: Plain text
1012 #: build/C/man3/lsearch.3:35
1013 #, no-wrap
1014 msgid ""
1015 "B<void *lfind(const void *>I<key>B<, const void *>I<base>B<, size_t "
1016 "*>I<nmemb>B<,>\n"
1017 "B<         size_t >I<size>B<, int(*>I<compar>B<)(const void *, const void "
1018 "*));>\n"
1019 msgstr ""
1020
1021 #. type: Plain text
1022 #: build/C/man3/lsearch.3:38
1023 #, no-wrap
1024 msgid ""
1025 "B<void *lsearch(const void *>I<key>B<, void *>I<base>B<, size_t "
1026 "*>I<nmemb>B<,>\n"
1027 "B<         size_t >I<size>B<, int(*>I<compar>B<)(const void *, const void "
1028 "*));>\n"
1029 msgstr ""
1030
1031 #. type: Plain text
1032 #: build/C/man3/lsearch.3:61
1033 msgid ""
1034 "B<lfind>()  and B<lsearch>()  perform a linear search for I<key> in the "
1035 "array I<base> which has I<*nmemb> elements of I<size> bytes each.  The "
1036 "comparison function referenced by I<compar> is expected to have two "
1037 "arguments which point to the I<key> object and to an array member, in that "
1038 "order, and which returns zero if the I<key> object matches the array member, "
1039 "and nonzero otherwise."
1040 msgstr ""
1041
1042 #. type: Plain text
1043 #: build/C/man3/lsearch.3:72
1044 msgid ""
1045 "If B<lsearch>()  does not find a matching element, then the I<key> object is "
1046 "inserted at the end of the table, and I<*nmemb> is incremented.  In "
1047 "particular, one should know that a matching element exists, or that more "
1048 "room is available."
1049 msgstr ""
1050
1051 #. type: Plain text
1052 #: build/C/man3/lsearch.3:80
1053 msgid ""
1054 "B<lfind>()  returns a pointer to a matching member of the array, or NULL if "
1055 "no match is found.  B<lsearch>()  returns a pointer to a matching member of "
1056 "the array, or to the newly added member if no match is found."
1057 msgstr ""
1058
1059 #. type: Plain text
1060 #: build/C/man3/lsearch.3:83
1061 msgid "SVr4, 4.3BSD, POSIX.1-2001.  Present in libc since libc-4.6.27."
1062 msgstr ""
1063
1064 #. type: Plain text
1065 #: build/C/man3/lsearch.3:85
1066 msgid "The naming is unfortunate."
1067 msgstr ""
1068
1069 #. type: Plain text
1070 #: build/C/man3/lsearch.3:89
1071 msgid "B<bsearch>(3), B<hsearch>(3), B<tsearch>(3)"
1072 msgstr ""
1073
1074 #. type: TH
1075 #: build/C/man3/qsort.3:37
1076 #, no-wrap
1077 msgid "QSORT"
1078 msgstr ""
1079
1080 #. type: TH
1081 #: build/C/man3/qsort.3:37
1082 #, no-wrap
1083 msgid "2012-03-08"
1084 msgstr ""
1085
1086 #. type: Plain text
1087 #: build/C/man3/qsort.3:40
1088 msgid "qsort, qsort_r - sort an array"
1089 msgstr ""
1090
1091 #. type: Plain text
1092 #: build/C/man3/qsort.3:46
1093 #, no-wrap
1094 msgid ""
1095 "B<void qsort(void *>I<base>B<, size_t >I<nmemb>B<, size_t >I<size>B<,>\n"
1096 "B<           int (*>I<compar>B<)(const void *, const void *));>\n"
1097 msgstr ""
1098
1099 #. type: Plain text
1100 #: build/C/man3/qsort.3:50
1101 #, no-wrap
1102 msgid ""
1103 "B<void qsort_r(void *>I<base>B<, size_t >I<nmemb>B<, size_t >I<size>B<,>\n"
1104 "B<           int (*>I<compar>B<)(const void *, const void *, void *),>\n"
1105 "B<           void *>I<arg>B<);>\n"
1106 msgstr ""
1107
1108 #. type: Plain text
1109 #: build/C/man3/qsort.3:60
1110 msgid "B<qsort_r>(): _GNU_SOURCE"
1111 msgstr ""
1112
1113 #. type: Plain text
1114 #: build/C/man3/qsort.3:68
1115 msgid ""
1116 "The B<qsort>()  function sorts an array with I<nmemb> elements of size "
1117 "I<size>.  The I<base> argument points to the start of the array."
1118 msgstr ""
1119
1120 #. type: Plain text
1121 #: build/C/man3/qsort.3:72
1122 msgid ""
1123 "The contents of the array are sorted in ascending order according to a "
1124 "comparison function pointed to by I<compar>, which is called with two "
1125 "arguments that point to the objects being compared."
1126 msgstr ""
1127
1128 #. type: Plain text
1129 #: build/C/man3/qsort.3:78
1130 msgid ""
1131 "The comparison function must return an integer less than, equal to, or "
1132 "greater than zero if the first argument is considered to be respectively "
1133 "less than, equal to, or greater than the second.  If two members compare as "
1134 "equal, their order in the sorted array is undefined."
1135 msgstr ""
1136
1137 #. type: Plain text
1138 #: build/C/man3/qsort.3:91
1139 msgid ""
1140 "The B<qsort_r>()  function is identical to B<qsort>()  except that the "
1141 "comparison function I<compar> takes a third argument.  A pointer is passed "
1142 "to the comparison function via I<arg>.  In this way, the comparison function "
1143 "does not need to use global variables to pass through arbitrary arguments, "
1144 "and is therefore reentrant and safe to use in threads."
1145 msgstr ""
1146
1147 #. type: Plain text
1148 #: build/C/man3/qsort.3:97
1149 msgid "The B<qsort>()  and B<qsort_r>()  functions return no value."
1150 msgstr ""
1151
1152 #. type: SH
1153 #: build/C/man3/qsort.3:97
1154 #, no-wrap
1155 msgid "VERSIONS"
1156 msgstr ""
1157
1158 #. type: Plain text
1159 #: build/C/man3/qsort.3:100
1160 msgid "B<qsort_r>()  was added to glibc in version 2.8."
1161 msgstr ""
1162
1163 #. type: Plain text
1164 #: build/C/man3/qsort.3:104
1165 msgid "The B<qsort>()  function conforms to SVr4, 4.3BSD, C89, C99."
1166 msgstr ""
1167
1168 #. type: Plain text
1169 #: build/C/man3/qsort.3:116
1170 msgid ""
1171 "Library routines suitable for use as the I<compar> argument to B<qsort>()  "
1172 "include B<alphasort>(3)  and B<versionsort>(3).  To compare C strings, the "
1173 "comparison function can call B<strcmp>(3), as shown in the example below."
1174 msgstr ""
1175
1176 #. type: Plain text
1177 #: build/C/man3/qsort.3:119
1178 msgid "For one example of use, see the example under B<bsearch>(3)."
1179 msgstr ""
1180
1181 #. type: Plain text
1182 #: build/C/man3/qsort.3:122
1183 msgid ""
1184 "Another example is the following program, which sorts the strings given in "
1185 "its command-line arguments:"
1186 msgstr ""
1187
1188 #. type: Plain text
1189 #: build/C/man3/qsort.3:134
1190 #, no-wrap
1191 msgid ""
1192 "static int\n"
1193 "cmpstringp(const void *p1, const void *p2)\n"
1194 "{\n"
1195 "    /* The actual arguments to this function are \"pointers to\n"
1196 "       pointers to char\", but strcmp(3) arguments are \"pointers\n"
1197 "       to char\", hence the following cast plus dereference */\n"
1198 msgstr ""
1199
1200 #. type: Plain text
1201 #: build/C/man3/qsort.3:137
1202 #, no-wrap
1203 msgid ""
1204 "    return strcmp(* (char * const *) p1, * (char * const *) p2);\n"
1205 "}\n"
1206 msgstr ""
1207
1208 #. type: Plain text
1209 #: build/C/man3/qsort.3:142
1210 #, no-wrap
1211 msgid ""
1212 "int\n"
1213 "main(int argc, char *argv[])\n"
1214 "{\n"
1215 "    int j;\n"
1216 msgstr ""
1217
1218 #. type: Plain text
1219 #: build/C/man3/qsort.3:147
1220 #, no-wrap
1221 msgid ""
1222 "    if (argc E<lt> 2) {\n"
1223 "\tfprintf(stderr, \"Usage: %s E<lt>stringE<gt>...\\en\", argv[0]);\n"
1224 "\texit(EXIT_FAILURE);\n"
1225 "    }\n"
1226 msgstr ""
1227
1228 #. type: Plain text
1229 #: build/C/man3/qsort.3:149
1230 #, no-wrap
1231 msgid "    qsort(&argv[1], argc - 1, sizeof(char *), cmpstringp);\n"
1232 msgstr ""
1233
1234 #. type: Plain text
1235 #: build/C/man3/qsort.3:154
1236 #, no-wrap
1237 msgid ""
1238 "    for (j = 1; j E<lt> argc; j++)\n"
1239 "        puts(argv[j]);\n"
1240 "    exit(EXIT_SUCCESS);\n"
1241 "}\n"
1242 msgstr ""
1243
1244 #. type: Plain text
1245 #: build/C/man3/qsort.3:160
1246 msgid "B<sort>(1), B<alphasort>(3), B<strcmp>(3), B<versionsort>(3)"
1247 msgstr ""
1248
1249 #. type: TH
1250 #: build/C/man3/tsearch.3:25
1251 #, no-wrap
1252 msgid "TSEARCH"
1253 msgstr ""
1254
1255 #. type: TH
1256 #: build/C/man3/tsearch.3:25
1257 #, no-wrap
1258 msgid "2012-08-03"
1259 msgstr ""
1260
1261 #. type: Plain text
1262 #: build/C/man3/tsearch.3:28
1263 msgid "tsearch, tfind, tdelete, twalk, tdestroy - manage a binary tree"
1264 msgstr ""
1265
1266 #. type: Plain text
1267 #: build/C/man3/tsearch.3:34
1268 #, no-wrap
1269 msgid ""
1270 "B<void *tsearch(const void *>I<key>B<, void **>I<rootp>B<,>\n"
1271 "B<                int (*>I<compar>B<)(const void *, const void *));>\n"
1272 msgstr ""
1273
1274 #. type: Plain text
1275 #: build/C/man3/tsearch.3:37
1276 #, no-wrap
1277 msgid ""
1278 "B<void *tfind(const void *>I<key>B<, const void **>I<rootp>B<,>\n"
1279 "B<                int (*>I<compar>B<)(const void *, const void *));>\n"
1280 msgstr ""
1281
1282 #. type: Plain text
1283 #: build/C/man3/tsearch.3:40
1284 #, no-wrap
1285 msgid ""
1286 "B<void *tdelete(const void *>I<key>B<, void **>I<rootp>B<,>\n"
1287 "B<                int (*>I<compar>B<)(const void *, const void *));>\n"
1288 msgstr ""
1289
1290 #. type: Plain text
1291 #: build/C/man3/tsearch.3:44
1292 #, no-wrap
1293 msgid ""
1294 "B<void twalk(const void *>I<root>B<, void (*>I<action>B<)(const void "
1295 "*>I<nodep>B<,>\n"
1296 "B<                                   const VISIT >I<which>B<,>\n"
1297 "B<                                   const int >I<depth>B<));>\n"
1298 msgstr ""
1299
1300 #. type: Plain text
1301 #: build/C/man3/tsearch.3:50
1302 #, no-wrap
1303 msgid ""
1304 "B<void tdestroy(void *>I<root>B<, void (*>I<free_node>B<)(void "
1305 "*>I<nodep>B<));>\n"
1306 msgstr ""
1307
1308 #. type: Plain text
1309 #: build/C/man3/tsearch.3:69
1310 msgid ""
1311 "B<tsearch>(), B<tfind>(), B<twalk>(), and B<tdelete>()  manage a binary "
1312 "tree.  They are generalized from Knuth (6.2.2) Algorithm T.  The first field "
1313 "in each node of the tree is a pointer to the corresponding data item.  (The "
1314 "calling program must store the actual data.)  I<compar> points to a "
1315 "comparison routine, which takes pointers to two items.  It should return an "
1316 "integer which is negative, zero, or positive, depending on whether the first "
1317 "item is less than, equal to, or greater than the second."
1318 msgstr ""
1319
1320 #. type: Plain text
1321 #: build/C/man3/tsearch.3:88
1322 msgid ""
1323 "B<tsearch>()  searches the tree for an item.  I<key> points to the item to "
1324 "be searched for.  I<rootp> points to a variable which points to the root of "
1325 "the tree.  If the tree is empty, then the variable that I<rootp> points to "
1326 "should be set to NULL.  If the item is found in the tree, then B<tsearch>()  "
1327 "returns a pointer to it.  If it is not found, then B<tsearch>()  adds it, "
1328 "and returns a pointer to the newly added item."
1329 msgstr ""
1330
1331 #. type: Plain text
1332 #: build/C/man3/tsearch.3:96
1333 msgid ""
1334 "B<tfind>()  is like B<tsearch>(), except that if the item is not found, then "
1335 "B<tfind>()  returns NULL."
1336 msgstr ""
1337
1338 #. type: Plain text
1339 #: build/C/man3/tsearch.3:101
1340 msgid ""
1341 "B<tdelete>()  deletes an item from the tree.  Its arguments are the same as "
1342 "for B<tsearch>()."
1343 msgstr ""
1344
1345 #. type: Plain text
1346 #: build/C/man3/tsearch.3:136
1347 msgid ""
1348 "B<twalk>()  performs depth-first, left-to-right traversal of a binary tree.  "
1349 "I<root> points to the starting node for the traversal.  If that node is not "
1350 "the root, then only part of the tree will be visited.  B<twalk>()  calls the "
1351 "user function I<action> each time a node is visited (that is, three times "
1352 "for an internal node, and once for a leaf).  I<action>, in turn, takes three "
1353 "arguments.  The first argument is a pointer to the node being visited.  The "
1354 "structure of the node is unspecified, but it is possible to cast the pointer "
1355 "to a pointer-to-pointer-to-element in order to access the element stored "
1356 "within the node.  The application must not modify the structure pointed to "
1357 "by this argument.  The second argument is an integer which takes one of the "
1358 "values B<preorder>, B<postorder>, or B<endorder> depending on whether this "
1359 "is the first, second, or third visit to the internal node, or the value "
1360 "B<leaf> if this is the single visit to a leaf node.  (These symbols are "
1361 "defined in I<E<lt>search.hE<gt>>.)  The third argument is the depth of the "
1362 "node; the root node has depth zero."
1363 msgstr ""
1364
1365 #. type: Plain text
1366 #: build/C/man3/tsearch.3:152
1367 msgid ""
1368 "(More commonly, B<preorder>, B<postorder>, and B<endorder> are known as "
1369 "B<preorder>, B<inorder>, and B<postorder>: before visiting the children, "
1370 "after the first and before the second, and after visiting the children.  "
1371 "Thus, the choice of name B<post\\%order> is rather confusing.)"
1372 msgstr ""
1373
1374 #. type: Plain text
1375 #: build/C/man3/tsearch.3:167
1376 msgid ""
1377 "B<tdestroy>()  removes the whole tree pointed to by I<root>, freeing all "
1378 "resources allocated by the B<tsearch>()  function.  For the data in each "
1379 "tree node the function I<free_node> is called.  The pointer to the data is "
1380 "passed as the argument to the function.  If no such work is necessary, "
1381 "I<free_node> must point to a function doing nothing."
1382 msgstr ""
1383
1384 #. type: Plain text
1385 #: build/C/man3/tsearch.3:177
1386 msgid ""
1387 "B<tsearch>()  returns a pointer to a matching item in the tree, or to the "
1388 "newly added item, or NULL if there was insufficient memory to add the item.  "
1389 "B<tfind>()  returns a pointer to the item, or NULL if no match is found.  If "
1390 "there are multiple elements that match the key, the element returned is "
1391 "unspecified."
1392 msgstr ""
1393
1394 #. type: Plain text
1395 #: build/C/man3/tsearch.3:181
1396 msgid ""
1397 "B<tdelete>()  returns a pointer to the parent of the item deleted, or NULL "
1398 "if the item was not found."
1399 msgstr ""
1400
1401 #. type: Plain text
1402 #: build/C/man3/tsearch.3:190
1403 msgid ""
1404 "B<tsearch>(), B<tfind>(), and B<tdelete>()  also return NULL if I<rootp> was "
1405 "NULL on entry."
1406 msgstr ""
1407
1408 #. type: Plain text
1409 #: build/C/man3/tsearch.3:195
1410 msgid "SVr4, POSIX.1-2001.  The function B<tdestroy>()  is a GNU extension."
1411 msgstr ""
1412
1413 #. type: Plain text
1414 #: build/C/man3/tsearch.3:199
1415 msgid ""
1416 "B<twalk>()  takes a pointer to the root, while the other functions take a "
1417 "pointer to a variable which points to the root."
1418 msgstr ""
1419
1420 #. type: Plain text
1421 #: build/C/man3/tsearch.3:204
1422 msgid ""
1423 "B<tdelete>()  frees the memory required for the node in the tree.  The user "
1424 "is responsible for freeing the memory for the corresponding data."
1425 msgstr ""
1426
1427 #. type: Plain text
1428 #: build/C/man3/tsearch.3:212
1429 msgid ""
1430 "The example program depends on the fact that B<twalk>()  makes no further "
1431 "reference to a node after calling the user function with argument "
1432 "\"endorder\" or \"leaf\".  This works with the GNU library implementation, "
1433 "but is not in the System V documentation."
1434 msgstr ""
1435
1436 #. type: Plain text
1437 #: build/C/man3/tsearch.3:216
1438 msgid ""
1439 "The following program inserts twelve random numbers into a binary tree, "
1440 "where duplicate numbers are collapsed, then prints the numbers in order."
1441 msgstr ""
1442
1443 #. type: Plain text
1444 #: build/C/man3/tsearch.3:223
1445 #, no-wrap
1446 msgid ""
1447 "#define _GNU_SOURCE     /* Expose declaration of tdestroy() */\n"
1448 "#include E<lt>search.hE<gt>\n"
1449 "#include E<lt>stdlib.hE<gt>\n"
1450 "#include E<lt>stdio.hE<gt>\n"
1451 "#include E<lt>time.hE<gt>\n"
1452 msgstr ""
1453
1454 #. type: Plain text
1455 #: build/C/man3/tsearch.3:225
1456 #, no-wrap
1457 msgid "void *root = NULL;\n"
1458 msgstr ""
1459
1460 #. type: Plain text
1461 #: build/C/man3/tsearch.3:236
1462 #, no-wrap
1463 msgid ""
1464 "void *\n"
1465 "xmalloc(unsigned n)\n"
1466 "{\n"
1467 "    void *p;\n"
1468 "    p = malloc(n);\n"
1469 "    if (p)\n"
1470 "        return p;\n"
1471 "    fprintf(stderr, \"insufficient memory\\en\");\n"
1472 "    exit(EXIT_FAILURE);\n"
1473 "}\n"
1474 msgstr ""
1475
1476 #. type: Plain text
1477 #: build/C/man3/tsearch.3:246
1478 #, no-wrap
1479 msgid ""
1480 "int\n"
1481 "compare(const void *pa, const void *pb)\n"
1482 "{\n"
1483 "    if (*(int *) pa E<lt> *(int *) pb)\n"
1484 "        return -1;\n"
1485 "    if (*(int *) pa E<gt> *(int *) pb)\n"
1486 "        return 1;\n"
1487 "    return 0;\n"
1488 "}\n"
1489 msgstr ""
1490
1491 #. type: Plain text
1492 #: build/C/man3/tsearch.3:251
1493 #, no-wrap
1494 msgid ""
1495 "void\n"
1496 "action(const void *nodep, const VISIT which, const int depth)\n"
1497 "{\n"
1498 "    int *datap;\n"
1499 msgstr ""
1500
1501 #. type: Plain text
1502 #: build/C/man3/tsearch.3:267
1503 #, no-wrap
1504 msgid ""
1505 "    switch (which) {\n"
1506 "    case preorder:\n"
1507 "        break;\n"
1508 "    case postorder:\n"
1509 "        datap = *(int **) nodep;\n"
1510 "        printf(\"%6d\\en\", *datap);\n"
1511 "        break;\n"
1512 "    case endorder:\n"
1513 "        break;\n"
1514 "    case leaf:\n"
1515 "        datap = *(int **) nodep;\n"
1516 "        printf(\"%6d\\en\", *datap);\n"
1517 "        break;\n"
1518 "    }\n"
1519 "}\n"
1520 msgstr ""
1521
1522 #. type: Plain text
1523 #: build/C/man3/tsearch.3:273
1524 #, no-wrap
1525 msgid ""
1526 "int\n"
1527 "main(void)\n"
1528 "{\n"
1529 "    int i, *ptr;\n"
1530 "    void *val;\n"
1531 msgstr ""
1532
1533 #. type: Plain text
1534 #: build/C/man3/tsearch.3:288
1535 #, no-wrap
1536 msgid ""
1537 "    srand(time(NULL));\n"
1538 "    for (i = 0; i E<lt> 12; i++) {\n"
1539 "        ptr = xmalloc(sizeof(int));\n"
1540 "        *ptr = rand() & 0xff;\n"
1541 "        val = tsearch((void *) ptr, &root, compare);\n"
1542 "        if (val == NULL)\n"
1543 "            exit(EXIT_FAILURE);\n"
1544 "        else if ((*(int **) val) != ptr)\n"
1545 "            free(ptr);\n"
1546 "    }\n"
1547 "    twalk(root, action);\n"
1548 "    tdestroy(root, free);\n"
1549 "    exit(EXIT_SUCCESS);\n"
1550 "}\n"
1551 msgstr ""
1552
1553 #. type: Plain text
1554 #: build/C/man3/tsearch.3:294
1555 msgid "B<bsearch>(3), B<hsearch>(3), B<lsearch>(3), B<qsort>(3)"
1556 msgstr ""