Experimenting with making pretty man pages on paper.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.1 KiB

  1. .\" Copyright 1995 Jim Van Zandt <jrv@vanzandt.mv.com>
  2. .\"
  3. .\" %%%LICENSE_START(VERBATIM)
  4. .\" Permission is granted to make and distribute verbatim copies of this
  5. .\" manual provided the copyright notice and this permission notice are
  6. .\" preserved on all copies.
  7. .\"
  8. .\" Permission is granted to copy and distribute modified versions of this
  9. .\" manual under the conditions for verbatim copying, provided that the
  10. .\" entire resulting derived work is distributed under the terms of a
  11. .\" permission notice identical to this one.
  12. .\"
  13. .\" Since the Linux kernel and libraries are constantly changing, this
  14. .\" manual page may be incorrect or out-of-date. The author(s) assume no
  15. .\" responsibility for errors or omissions, or for damages resulting from
  16. .\" the use of the information contained herein. The author(s) may not
  17. .\" have taken the same level of care in the production of this manual,
  18. .\" which is licensed free of charge, as they might when working
  19. .\" professionally.
  20. .\"
  21. .\" Formatted or processed versions of this manual, if unaccompanied by
  22. .\" the source, must acknowledge the copyright and authors of this work.
  23. .\" %%%LICENSE_END
  24. .\"
  25. .\" Corrected prototype and include, aeb, 990927
  26. .TH LSEARCH 3 2017-09-15 "GNU" "Linux Programmer's Manual"
  27. .SH NAME
  28. lfind, lsearch \- linear search of an array
  29. .SH SYNOPSIS
  30. .nf
  31. .B #include <search.h>
  32. .PP
  33. .BI "void *lfind(const void *" key ", const void *" base ", size_t *" nmemb ,
  34. .BI " size_t " size ", int(*" compar ")(const void *, const void *));"
  35. .PP
  36. .BI "void *lsearch(const void *" key ", void *" base ", size_t *" nmemb ,
  37. .BI " size_t " size ", int(*" compar ")(const void *, const void *));"
  38. .fi
  39. .SH DESCRIPTION
  40. .BR lfind ()
  41. and
  42. .BR lsearch ()
  43. perform a linear search for
  44. .I key
  45. in the array
  46. .IR base
  47. which has
  48. .I *nmemb
  49. elements of
  50. .I size
  51. bytes each.
  52. The comparison function referenced by
  53. .I compar
  54. is expected to have two arguments which point to the
  55. .I key
  56. object and to an array member, in that order, and which
  57. returns zero if the
  58. .I key
  59. object matches the array member, and
  60. nonzero otherwise.
  61. .PP
  62. If
  63. .BR lsearch ()
  64. does not find a matching element, then the
  65. .I key
  66. object is inserted at the end of the table, and
  67. .I *nmemb
  68. is
  69. incremented.
  70. In particular, one should know that a matching element
  71. exists, or that more room is available.
  72. .SH RETURN VALUE
  73. .BR lfind ()
  74. returns a pointer to a matching member of the array, or
  75. NULL if no match is found.
  76. .BR lsearch ()
  77. returns a pointer to
  78. a matching member of the array, or to the newly added member if no
  79. match is found.
  80. .SH ATTRIBUTES
  81. For an explanation of the terms used in this section, see
  82. .BR attributes (7).
  83. .TS
  84. allbox;
  85. lbw18 lb lb
  86. l l l.
  87. Interface Attribute Value
  88. T{
  89. .BR lfind (),
  90. .BR lsearch ()
  91. T} Thread safety MT-Safe
  92. .TE
  93. .sp 1
  94. .SH CONFORMING TO
  95. POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
  96. Present in libc since libc-4.6.27.
  97. .SH BUGS
  98. The naming is unfortunate.
  99. .SH SEE ALSO
  100. .BR bsearch (3),
  101. .BR hsearch (3),
  102. .BR tsearch (3)
  103. .SH COLOPHON
  104. This page is part of release 5.05 of the Linux
  105. .I man-pages
  106. project.
  107. A description of the project,
  108. information about reporting bugs,
  109. and the latest version of this page,
  110. can be found at
  111. \%https://www.kernel.org/doc/man\-pages/.