OSDN Git Service

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