OSDN Git Service

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