Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / lib / libc / gen / fts.3
1 .\" Copyright (c) 1989, 1991, 1993, 1994
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)fts.3       8.5 (Berkeley) 4/16/94
29 .\" $FreeBSD: src/lib/libc/gen/fts.3,v 1.24 2008/01/26 17:09:40 yar Exp $
30 .\" $DragonFly: src/lib/libc/gen/fts.3,v 1.4 2007/07/30 22:11:32 swildner Exp $
31 .\"
32 .Dd January 26, 2008
33 .Dt FTS 3
34 .Os
35 .Sh NAME
36 .Nm fts
37 .Nd traverse a file hierarchy
38 .Sh LIBRARY
39 .Lb libc
40 .Sh SYNOPSIS
41 .In sys/types.h
42 .In sys/stat.h
43 .In fts.h
44 .Ft FTS *
45 .Fn fts_open "char * const *path_argv" "int options" "int (*compar)(const FTSENT * const *, const FTSENT * const *)"
46 .Ft FTSENT *
47 .Fn fts_read "FTS *ftsp"
48 .Ft FTSENT *
49 .Fn fts_children "FTS *ftsp" "int options"
50 .Ft int
51 .Fn fts_set "FTS *ftsp" "FTSENT *f" "int options"
52 .Ft void
53 .Fn fts_set_clientptr "FTS *ftsp" "void *clientdata"
54 .Ft void *
55 .Fn fts_get_clientptr "FTS *ftsp"
56 .Ft FTS *
57 .Fn fts_get_stream "FTSENT *f"
58 .Ft int
59 .Fn fts_close "FTS *ftsp"
60 .Sh DESCRIPTION
61 The
62 .Nm
63 functions are provided for traversing
64 .Ux
65 file hierarchies.
66 A simple overview is that the
67 .Fn fts_open
68 function returns a
69 .Dq handle
70 on a file hierarchy, which is then supplied to
71 the other
72 .Nm
73 functions.
74 The function
75 .Fn fts_read
76 returns a pointer to a structure describing one of the files in the file
77 hierarchy.
78 The function
79 .Fn fts_children
80 returns a pointer to a linked list of structures, each of which describes
81 one of the files contained in a directory in the hierarchy.
82 In general, directories are visited two distinguishable times; in pre-order
83 (before any of their descendants are visited) and in post-order (after all
84 of their descendants have been visited).
85 Files are visited once.
86 It is possible to walk the hierarchy
87 .Dq logically
88 (ignoring symbolic links)
89 or physically (visiting symbolic links), order the walk of the hierarchy or
90 prune and/or re-visit portions of the hierarchy.
91 .Pp
92 Two structures are defined (and typedef'd) in the include file
93 .In fts.h .
94 The first is
95 .Vt FTS ,
96 the structure that represents the file hierarchy itself.
97 The second is
98 .Vt FTSENT ,
99 the structure that represents a file in the file
100 hierarchy.
101 Normally, an
102 .Vt FTSENT
103 structure is returned for every file in the file
104 hierarchy.
105 In this manual page,
106 .Dq file
107 and
108 .Dq Vt FTSENT No structure
109 are generally
110 interchangeable.
111 .Pp
112 The
113 .Vt FTS
114 structure contains space for a single pointer, which may be used to
115 store application data or per-hierarchy state.
116 The
117 .Fn fts_set_clientptr
118 and
119 .Fn fts_get_clientptr
120 functions may be used to set and retrieve this pointer.
121 This is likely to be useful only when accessed from the sort
122 comparison function, which can determine the original
123 .Vt FTS
124 stream of its arguments using the
125 .Fn fts_get_stream
126 function.
127 The two
128 .Li get
129 functions are also available as macros of the same name.
130 .Pp
131 The
132 .Vt FTSENT
133 structure contains at least the following fields, which are
134 described in greater detail below:
135 .Bd -literal
136 typedef struct _ftsent {
137         int fts_info;                   /* status for FTSENT structure */
138         char *fts_accpath;              /* access path */
139         char *fts_path;                 /* root path */
140         size_t fts_pathlen;             /* strlen(fts_path) */
141         char *fts_name;                 /* file name */
142         size_t fts_namelen;             /* strlen(fts_name) */
143         long fts_level;                 /* depth (\-1 to N) */
144         int fts_errno;                  /* file errno */
145         long long fts_number;           /* local numeric value */
146         void *fts_pointer;              /* local address value */
147         struct ftsent *fts_parent;      /* parent directory */
148         struct ftsent *fts_link;        /* next file structure */
149         struct ftsent *fts_cycle;       /* cycle structure */
150         struct stat *fts_statp;         /* stat(2) information */
151 } FTSENT;
152 .Ed
153 .Pp
154 These fields are defined as follows:
155 .Bl -tag -width "fts_namelen"
156 .It Fa fts_info
157 One of the following values describing the returned
158 .Vt FTSENT
159 structure and
160 the file it represents.
161 With the exception of directories without errors
162 .Pq Dv FTS_D ,
163 all of these
164 entries are terminal, that is, they will not be revisited, nor will any
165 of their descendants be visited.
166 .Bl  -tag -width FTS_DEFAULT
167 .It Dv FTS_D
168 A directory being visited in pre-order.
169 .It Dv FTS_DC
170 A directory that causes a cycle in the tree.
171 (The
172 .Fa fts_cycle
173 field of the
174 .Vt FTSENT
175 structure will be filled in as well.)
176 .It Dv FTS_DEFAULT
177 Any
178 .Vt FTSENT
179 structure that represents a file type not explicitly described
180 by one of the other
181 .Fa fts_info
182 values.
183 .It Dv FTS_DNR
184 A directory which cannot be read.
185 This is an error return, and the
186 .Fa fts_errno
187 field will be set to indicate what caused the error.
188 .It Dv FTS_DOT
189 A file named
190 .Ql .\&
191 or
192 .Ql ..\&
193 which was not specified as a file name to
194 .Fn fts_open
195 (see
196 .Dv FTS_SEEDOT ) .
197 .It Dv FTS_DP
198 A directory being visited in post-order.
199 The contents of the
200 .Vt FTSENT
201 structure will be unchanged from when
202 it was returned in pre-order, i.e., with the
203 .Fa fts_info
204 field set to
205 .Dv FTS_D .
206 .It Dv FTS_ERR
207 This is an error return, and the
208 .Fa fts_errno
209 field will be set to indicate what caused the error.
210 .It Dv FTS_F
211 A regular file.
212 .It Dv FTS_NS
213 A file for which no
214 .Xr stat 2
215 information was available.
216 The contents of the
217 .Fa fts_statp
218 field are undefined.
219 This is an error return, and the
220 .Fa fts_errno
221 field will be set to indicate what caused the error.
222 .It Dv FTS_NSOK
223 A file for which no
224 .Xr stat 2
225 information was requested.
226 The contents of the
227 .Fa fts_statp
228 field are undefined.
229 .It Dv FTS_SL
230 A symbolic link.
231 .It Dv FTS_SLNONE
232 A symbolic link with a non-existent target.
233 The contents of the
234 .Fa fts_statp
235 field reference the file characteristic information for the symbolic link
236 itself.
237 .El
238 .It Fa fts_accpath
239 A path for accessing the file from the current directory.
240 .It Fa fts_path
241 The path for the file relative to the root of the traversal.
242 This path contains the path specified to
243 .Fn fts_open
244 as a prefix.
245 .It Fa fts_pathlen
246 The length of the string referenced by
247 .Fa fts_path .
248 .It Fa fts_name
249 The name of the file.
250 .It Fa fts_namelen
251 The length of the string referenced by
252 .Fa fts_name .
253 .It Fa fts_level
254 The depth of the traversal, numbered from \-1 to N, where this file
255 was found.
256 The
257 .Vt FTSENT
258 structure representing the parent of the starting point (or root)
259 of the traversal is numbered
260 .Dv FTS_ROOTPARENTLEVEL
261 (\-1), and the
262 .Vt FTSENT
263 structure for the root
264 itself is numbered
265 .Dv FTS_ROOTLEVEL
266 (0).
267 .It Fa fts_errno
268 Upon return of a
269 .Vt FTSENT
270 structure from the
271 .Fn fts_children
272 or
273 .Fn fts_read
274 functions, with its
275 .Fa fts_info
276 field set to
277 .Dv FTS_DNR ,
278 .Dv FTS_ERR
279 or
280 .Dv FTS_NS ,
281 the
282 .Fa fts_errno
283 field contains the value of the external variable
284 .Va errno
285 specifying the cause of the error.
286 Otherwise, the contents of the
287 .Fa fts_errno
288 field are undefined.
289 .It Fa fts_number
290 This field is provided for the use of the application program and is
291 not modified by the
292 .Nm
293 functions.
294 It is initialized to 0.
295 .It Fa fts_pointer
296 This field is provided for the use of the application program and is
297 not modified by the
298 .Nm
299 functions.
300 It is initialized to
301 .Dv NULL .
302 .It Fa fts_parent
303 A pointer to the
304 .Vt FTSENT
305 structure referencing the file in the hierarchy
306 immediately above the current file, i.e., the directory of which this
307 file is a member.
308 A parent structure for the initial entry point is provided as well,
309 however, only the
310 .Fa fts_level ,
311 .Fa fts_bignum ,
312 .Fa fts_number
313 and
314 .Fa fts_pointer
315 fields are guaranteed to be initialized.
316 .It Fa fts_link
317 Upon return from the
318 .Fn fts_children
319 function, the
320 .Fa fts_link
321 field points to the next structure in the NULL-terminated linked list of
322 directory members.
323 Otherwise, the contents of the
324 .Fa fts_link
325 field are undefined.
326 .It Fa fts_cycle
327 If a directory causes a cycle in the hierarchy (see
328 .Dv FTS_DC ) ,
329 either because
330 of a hard link between two directories, or a symbolic link pointing to a
331 directory, the
332 .Fa fts_cycle
333 field of the structure will point to the
334 .Vt FTSENT
335 structure in the hierarchy that references the same file as the current
336 .Vt FTSENT
337 structure.
338 Otherwise, the contents of the
339 .Fa fts_cycle
340 field are undefined.
341 .It Fa fts_statp
342 A pointer to
343 .Xr stat 2
344 information for the file.
345 .El
346 .Pp
347 A single buffer is used for all of the paths of all of the files in the
348 file hierarchy.
349 Therefore, the
350 .Fa fts_path
351 and
352 .Fa fts_accpath
353 fields are guaranteed to be
354 .Dv NUL Ns -terminated
355 .Em only
356 for the file most recently returned by
357 .Fn fts_read .
358 To use these fields to reference any files represented by other
359 .Vt FTSENT
360 structures will require that the path buffer be modified using the
361 information contained in that
362 .Vt FTSENT
363 structure's
364 .Fa fts_pathlen
365 field.
366 Any such modifications should be undone before further calls to
367 .Fn fts_read
368 are attempted.
369 The
370 .Fa fts_name
371 field is always
372 .Dv NUL Ns -terminated .
373 .Pp
374 Note that the use of
375 .Fa fts_bignum
376 is mutually exclusive with the use of
377 .Fa fts_number
378 or
379 .Fa fts_pointer .
380 .Sh FTS_OPEN
381 The
382 .Fn fts_open
383 function takes a pointer to an array of character pointers naming one
384 or more paths which make up a logical file hierarchy to be traversed.
385 The array must be terminated by a
386 .Dv NULL
387 pointer.
388 .Pp
389 There are
390 a number of options, at least one of which (either
391 .Dv FTS_LOGICAL
392 or
393 .Dv FTS_PHYSICAL )
394 must be specified.
395 The options are selected by
396 .Em or Ns 'ing
397 the following values:
398 .Bl -tag -width "FTS_PHYSICAL"
399 .It Dv FTS_COMFOLLOW
400 This option causes any symbolic link specified as a root path to be
401 followed immediately whether or not
402 .Dv FTS_LOGICAL
403 is also specified.
404 .It Dv FTS_LOGICAL
405 This option causes the
406 .Nm
407 routines to return
408 .Vt FTSENT
409 structures for the targets of symbolic links
410 instead of the symbolic links themselves.
411 If this option is set, the only symbolic links for which
412 .Vt FTSENT
413 structures
414 are returned to the application are those referencing non-existent files.
415 Either
416 .Dv FTS_LOGICAL
417 or
418 .Dv FTS_PHYSICAL
419 .Em must
420 be provided to the
421 .Fn fts_open
422 function.
423 .It Dv FTS_NOCHDIR
424 As a performance optimization, the
425 .Nm
426 functions change directories as they walk the file hierarchy.
427 This has the side-effect that an application cannot rely on being
428 in any particular directory during the traversal.
429 The
430 .Dv FTS_NOCHDIR
431 option turns off this optimization, and the
432 .Nm
433 functions will not change the current directory.
434 Note that applications should not themselves change their current directory
435 and try to access files unless
436 .Dv FTS_NOCHDIR
437 is specified and absolute
438 pathnames were provided as arguments to
439 .Fn fts_open .
440 .It Dv FTS_NOSTAT
441 By default, returned
442 .Vt FTSENT
443 structures reference file characteristic information (the
444 .Fa statp
445 field) for each file visited.
446 This option relaxes that requirement as a performance optimization,
447 allowing the
448 .Nm
449 functions to set the
450 .Fa fts_info
451 field to
452 .Dv FTS_NSOK
453 and leave the contents of the
454 .Fa statp
455 field undefined.
456 .It Dv FTS_PHYSICAL
457 This option causes the
458 .Nm
459 routines to return
460 .Vt FTSENT
461 structures for symbolic links themselves instead
462 of the target files they point to.
463 If this option is set,
464 .Vt FTSENT
465 structures for all symbolic links in the
466 hierarchy are returned to the application.
467 Either
468 .Dv FTS_LOGICAL
469 or
470 .Dv FTS_PHYSICAL
471 .Em must
472 be provided to the
473 .Fn fts_open
474 function.
475 .It Dv FTS_SEEDOT
476 By default, unless they are specified as path arguments to
477 .Fn fts_open ,
478 any files named
479 .Ql .\&
480 or
481 .Ql ..\&
482 encountered in the file hierarchy are ignored.
483 This option causes the
484 .Nm
485 routines to return
486 .Vt FTSENT
487 structures for them.
488 .It Dv FTS_XDEV
489 This option prevents
490 .Nm
491 from descending into directories that have a different device number
492 than the file from which the descent began.
493 .El
494 .Pp
495 The argument
496 .Fn compar
497 specifies a user-defined function which may be used to order the traversal
498 of the hierarchy.
499 It
500 takes two pointers to pointers to
501 .Vt FTSENT
502 structures as arguments and
503 should return a negative value, zero, or a positive value to indicate
504 if the file referenced by its first argument comes before, in any order
505 with respect to, or after, the file referenced by its second argument.
506 The
507 .Fa fts_accpath ,
508 .Fa fts_path
509 and
510 .Fa fts_pathlen
511 fields of the
512 .Vt FTSENT
513 structures may
514 .Em never
515 be used in this comparison.
516 If the
517 .Fa fts_info
518 field is set to
519 .Dv FTS_NS
520 or
521 .Dv FTS_NSOK ,
522 the
523 .Fa fts_statp
524 field may not either.
525 If the
526 .Fn compar
527 argument is
528 .Dv NULL ,
529 the directory traversal order is in the order listed in
530 .Fa path_argv
531 for the root paths, and in the order listed in the directory for
532 everything else.
533 .Sh FTS_READ
534 The
535 .Fn fts_read
536 function returns a pointer to an
537 .Vt FTSENT
538 structure describing a file in
539 the hierarchy.
540 Directories (that are readable and do not cause cycles) are visited at
541 least twice, once in pre-order and once in post-order.
542 All other files are visited at least once.
543 (Hard links between directories that do not cause cycles or symbolic
544 links to symbolic links may cause files to be visited more than once,
545 or directories more than twice.)
546 .Pp
547 If all the members of the hierarchy have been returned,
548 .Fn fts_read
549 returns
550 .Dv NULL
551 and sets the external variable
552 .Va errno
553 to 0.
554 If an error unrelated to a file in the hierarchy occurs,
555 .Fn fts_read
556 returns
557 .Dv NULL
558 and sets
559 .Va errno
560 appropriately.
561 If an error related to a returned file occurs, a pointer to an
562 .Vt FTSENT
563 structure is returned, and
564 .Va errno
565 may or may not have been set (see
566 .Fa fts_info ) .
567 .Pp
568 The
569 .Vt FTSENT
570 structures returned by
571 .Fn fts_read
572 may be overwritten after a call to
573 .Fn fts_close
574 on the same file hierarchy stream, or, after a call to
575 .Fn fts_read
576 on the same file hierarchy stream unless they represent a file of type
577 directory, in which case they will not be overwritten until after a call to
578 .Fn fts_read
579 after the
580 .Vt FTSENT
581 structure has been returned by the function
582 .Fn fts_read
583 in post-order.
584 .Sh FTS_CHILDREN
585 The
586 .Fn fts_children
587 function returns a pointer to an
588 .Vt FTSENT
589 structure describing the first entry in a NULL-terminated linked list of
590 the files in the directory represented by the
591 .Vt FTSENT
592 structure most recently returned by
593 .Fn fts_read .
594 The list is linked through the
595 .Fa fts_link
596 field of the
597 .Vt FTSENT
598 structure, and is ordered by the user-specified comparison function, if any.
599 Repeated calls to
600 .Fn fts_children
601 will recreate this linked list.
602 .Pp
603 As a special case, if
604 .Fn fts_read
605 has not yet been called for a hierarchy,
606 .Fn fts_children
607 will return a pointer to the files in the logical directory specified to
608 .Fn fts_open ,
609 i.e., the arguments specified to
610 .Fn fts_open .
611 Otherwise, if the
612 .Vt FTSENT
613 structure most recently returned by
614 .Fn fts_read
615 is not a directory being visited in pre-order,
616 or the directory does not contain any files,
617 .Fn fts_children
618 returns
619 .Dv NULL
620 and sets
621 .Va errno
622 to zero.
623 If an error occurs,
624 .Fn fts_children
625 returns
626 .Dv NULL
627 and sets
628 .Va errno
629 appropriately.
630 .Pp
631 The
632 .Vt FTSENT
633 structures returned by
634 .Fn fts_children
635 may be overwritten after a call to
636 .Fn fts_children ,
637 .Fn fts_close
638 or
639 .Fn fts_read
640 on the same file hierarchy stream.
641 .Pp
642 .Em Option
643 may be set to the following value:
644 .Bl -tag -width FTS_NAMEONLY
645 .It Dv FTS_NAMEONLY
646 Only the names of the files are needed.
647 The contents of all the fields in the returned linked list of structures
648 are undefined with the exception of the
649 .Fa fts_name
650 and
651 .Fa fts_namelen
652 fields.
653 .El
654 .Sh FTS_SET
655 The function
656 .Fn fts_set
657 allows the user application to determine further processing for the
658 file
659 .Fa f
660 of the stream
661 .Fa ftsp .
662 The
663 .Fn fts_set
664 function
665 returns 0 on success, and \-1 if an error occurs.
666 .Em Option
667 must be set to one of the following values:
668 .Bl -tag -width FTS_PHYSICAL
669 .It Dv FTS_AGAIN
670 Re-visit the file; any file type may be re-visited.
671 The next call to
672 .Fn fts_read
673 will return the referenced file.
674 The
675 .Fa fts_stat
676 and
677 .Fa fts_info
678 fields of the structure will be reinitialized at that time,
679 but no other fields will have been changed.
680 This option is meaningful only for the most recently returned
681 file from
682 .Fn fts_read .
683 Normal use is for post-order directory visits, where it causes the
684 directory to be re-visited (in both pre and post-order) as well as all
685 of its descendants.
686 .It Dv FTS_FOLLOW
687 The referenced file must be a symbolic link.
688 If the referenced file is the one most recently returned by
689 .Fn fts_read ,
690 the next call to
691 .Fn fts_read
692 returns the file with the
693 .Fa fts_info
694 and
695 .Fa fts_statp
696 fields reinitialized to reflect the target of the symbolic link instead
697 of the symbolic link itself.
698 If the file is one of those most recently returned by
699 .Fn fts_children ,
700 the
701 .Fa fts_info
702 and
703 .Fa fts_statp
704 fields of the structure, when returned by
705 .Fn fts_read ,
706 will reflect the target of the symbolic link instead of the symbolic link
707 itself.
708 In either case, if the target of the symbolic link does not exist the
709 fields of the returned structure will be unchanged and the
710 .Fa fts_info
711 field will be set to
712 .Dv FTS_SLNONE .
713 .Pp
714 If the target of the link is a directory, the pre-order return, followed
715 by the return of all of its descendants, followed by a post-order return,
716 is done.
717 .It Dv FTS_SKIP
718 No descendants of this file are visited.
719 The file may be one of those most recently returned by either
720 .Fn fts_children
721 or
722 .Fn fts_read .
723 .El
724 .Sh FTS_CLOSE
725 The
726 .Fn fts_close
727 function closes a file hierarchy stream
728 .Fa ftsp
729 and restores the current directory to the directory from which
730 .Fn fts_open
731 was called to open
732 .Fa ftsp .
733 The
734 .Fn fts_close
735 function
736 returns 0 on success, and \-1 if an error occurs.
737 .Sh ERRORS
738 The function
739 .Fn fts_open
740 may fail and set
741 .Va errno
742 for any of the errors specified for the library functions
743 .Xr open 2
744 and
745 .Xr malloc 3 .
746 .Pp
747 The function
748 .Fn fts_close
749 may fail and set
750 .Va errno
751 for any of the errors specified for the library functions
752 .Xr chdir 2
753 and
754 .Xr close 2 .
755 .Pp
756 The functions
757 .Fn fts_read
758 and
759 .Fn fts_children
760 may fail and set
761 .Va errno
762 for any of the errors specified for the library functions
763 .Xr chdir 2 ,
764 .Xr malloc 3 ,
765 .Xr opendir 3 ,
766 .Xr readdir 3
767 and
768 .Xr stat 2 .
769 .Pp
770 In addition,
771 .Fn fts_children ,
772 .Fn fts_open
773 and
774 .Fn fts_set
775 may fail and set
776 .Va errno
777 as follows:
778 .Bl -tag -width Er
779 .It Bq Er EINVAL
780 The options were invalid.
781 .El
782 .Sh SEE ALSO
783 .Xr find 1 ,
784 .Xr chdir 2 ,
785 .Xr stat 2 ,
786 .Xr ftw 3 ,
787 .Xr qsort 3
788 .Sh HISTORY
789 The
790 .Nm
791 interface was first introduced in
792 .Bx 4.4 .
793 The
794 .Fn fts_get_clientptr ,
795 .Fn fts_get_stream ,
796 and
797 .Fn fts_set_clientptr
798 functions were introduced in
799 .Fx 5.0 ,
800 principally to provide for alternative interfaces to the
801 .Nm
802 functionality using different data structures.