xref: /openbsd-src/share/man/man9/hook_establish.9 (revision 8afa056bfb6ecb7445f049d0ff152545c50622b3)
1*8afa056bSmpi.\"	$OpenBSD: hook_establish.9,v 1.12 2015/12/12 11:26:32 mpi Exp $
2ec1f6c03Sniklas.\"
3ec1f6c03Sniklas.\" Copyright (c) 2001 Niklas Hallqvist.
4ec1f6c03Sniklas.\" All rights reserved.
5ec1f6c03Sniklas.\"
6ec1f6c03Sniklas.\" Redistribution and use in source and binary forms, with or without
7ec1f6c03Sniklas.\" modification, are permitted provided that the following conditions
8ec1f6c03Sniklas.\" are met:
9ec1f6c03Sniklas.\" 1. Redistributions of source code must retain the above copyright
10ec1f6c03Sniklas.\"    notice, this list of conditions and the following disclaimer.
11ec1f6c03Sniklas.\" 2. Redistributions in binary form must reproduce the above copyright
12ec1f6c03Sniklas.\"    notice, this list of conditions and the following disclaimer in the
13ec1f6c03Sniklas.\"    documentation and/or other materials provided with the distribution.
14ec1f6c03Sniklas.\" 3. The name of the author may not be used to endorse or promote products
15ec1f6c03Sniklas.\"    derived from this software without specific prior written permission
16ec1f6c03Sniklas.\"
17ec1f6c03Sniklas.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18ec1f6c03Sniklas.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19ec1f6c03Sniklas.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20ec1f6c03Sniklas.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21ec1f6c03Sniklas.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22ec1f6c03Sniklas.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23ec1f6c03Sniklas.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24ec1f6c03Sniklas.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25ec1f6c03Sniklas.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26ec1f6c03Sniklas.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27ec1f6c03Sniklas.\"
28*8afa056bSmpi.Dd $Mdocdate: December 12 2015 $
29ec1f6c03Sniklas.Dt HOOK_ESTABLISH 9
30ec1f6c03Sniklas.Os
31ec1f6c03Sniklas.Sh NAME
32ec1f6c03Sniklas.Nm hook_establish ,
33ec1f6c03Sniklas.Nm hook_disestablish
3456c3138dSjmc.Nd add or remove a hook from a specified list
35ec1f6c03Sniklas.Sh SYNOPSIS
36dddd2645Sschwarze.In sys/types.h
37dddd2645Sschwarze.In sys/systm.h
38ec1f6c03Sniklas.Ft void *
39ec1f6c03Sniklas.Fn hook_establish "struct hook_desc_head *head" "int tail" "void (*fn)(void *)" "void *arg"
40ec1f6c03Sniklas.Ft void
41ec1f6c03Sniklas.Fn hook_disestablish "struct hook_desc_head *head" "void *cookie"
42ec1f6c03Sniklas.Sh DESCRIPTION
43ec1f6c03SniklasThe
44ec1f6c03Sniklas.Fn hook_establish
45ec1f6c03Sniklasfunction adds
46ec1f6c03Sniklas.Fa fn
47ec1f6c03Sniklasto the list of hooks invoked by
48ec1f6c03Sniklas.Xr dohooks 9 .
49ec1f6c03SniklasIf
50ec1f6c03Sniklas.Fa tail
51ec1f6c03Sniklasis non-zero, the hook is added to the tail of the list
52ec1f6c03Sniklasdenoted by the TAILQ_HEAD pointer
53ec1f6c03Sniklas.Fa head ,
54ec204a03Smpechotherwise to the front.
55ec204a03SmpechThe
56ec1f6c03Sniklas.Xr dohooks 9
57ec1f6c03Sniklasfunction will at its invocation call each hook from the front of this
58ec1f6c03Sniklaslist.
59ec1f6c03SniklasWhen invoked, the hook function
60ec1f6c03Sniklas.Fa fn
61ec1f6c03Sniklaswill be passed
62ec1f6c03Sniklas.Fa arg
63ec1f6c03Sniklasas its only argument.
64ec1f6c03Sniklas.Pp
65ec1f6c03SniklasThe
66ec1f6c03Sniklas.Fn hook_disestablish
67ec1f6c03Sniklasfunction removes the hook described by the opaque pointer
68ec1f6c03Sniklas.Fa cookie
69ec1f6c03Sniklasfrom the list of hooks denoted by the TAILQ_HEAD pointer
70ec1f6c03Sniklas.Fa head .
71ec1f6c03SniklasIf
72ec1f6c03Sniklas.Fa cookie
73ec1f6c03Sniklasis invalid, the result of
74ec1f6c03Sniklas.Fn hook_disestablish
75ec1f6c03Sniklasis undefined.
76ec1f6c03Sniklas.Pp
776eb325beSmikebThe startup and mountroot systems use this API for their
78ec1f6c03Sniklasimplementation.
79ec1f6c03Sniklas.Sh RETURN VALUES
80ec1f6c03SniklasIf successful,
81ec1f6c03Sniklas.Fn hook_establish
82ec1f6c03Sniklasreturns an opaque pointer describing the newly established
83ec1f6c03Sniklashook.
84ec1f6c03SniklasOtherwise, it returns
85ec1f6c03Sniklas.Dv NULL .
86ec1f6c03Sniklas.Sh SEE ALSO
87ec1f6c03Sniklas.Xr dohooks 9 ,
88ec1f6c03Sniklas.Xr dostartuphooks 9 ,
89b83af188Sjmc.Xr startuphook_establish 9
90