xref: /freebsd/share/examples/mdoc/example.9 (revision 496ff35d1e5efed92187a8b7eec4e86b040f228b)
1496ff35dSGiorgos Keramidas.\" Copyright (c) [year] [your name]
2496ff35dSGiorgos Keramidas.\" All rights reserved.
3496ff35dSGiorgos Keramidas.\"
4496ff35dSGiorgos Keramidas.\" Redistribution and use in source and binary forms, with or without
5496ff35dSGiorgos Keramidas.\" modification, are permitted provided that the following conditions
6496ff35dSGiorgos Keramidas.\" are met:
7496ff35dSGiorgos Keramidas.\" 1. Redistributions of source code must retain the above copyright
8496ff35dSGiorgos Keramidas.\"    notice, this list of conditions and the following disclaimer.
9496ff35dSGiorgos Keramidas.\" 2. Redistributions in binary form must reproduce the above copyright
10496ff35dSGiorgos Keramidas.\"    notice, this list of conditions and the following disclaimer in the
11496ff35dSGiorgos Keramidas.\"    documentation and/or other materials provided with the distribution.
12496ff35dSGiorgos Keramidas.\"
13496ff35dSGiorgos Keramidas.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14496ff35dSGiorgos Keramidas.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15496ff35dSGiorgos Keramidas.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16496ff35dSGiorgos Keramidas.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17496ff35dSGiorgos Keramidas.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18496ff35dSGiorgos Keramidas.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19496ff35dSGiorgos Keramidas.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20496ff35dSGiorgos Keramidas.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21496ff35dSGiorgos Keramidas.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22496ff35dSGiorgos Keramidas.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23496ff35dSGiorgos Keramidas.\" SUCH DAMAGE.
24496ff35dSGiorgos Keramidas.\"
25496ff35dSGiorgos Keramidas.\" $FreeBSD$
26496ff35dSGiorgos Keramidas.\"
27496ff35dSGiorgos Keramidas.\" Note: The date here should be updated whenever a non-trivial
28496ff35dSGiorgos Keramidas.\" change is made to the manual page.
29496ff35dSGiorgos Keramidas.Dd January 12, 2005
30496ff35dSGiorgos Keramidas.Dt EXAMPLE 9
31496ff35dSGiorgos Keramidas.Os
32496ff35dSGiorgos Keramidas.Sh NAME
33496ff35dSGiorgos Keramidas.Nm example
34496ff35dSGiorgos Keramidas.Nd "example kernel interface manual page"
35496ff35dSGiorgos Keramidas.Sh SYNOPSIS
36496ff35dSGiorgos Keramidas.In example.h
37496ff35dSGiorgos Keramidas.Ft int
38496ff35dSGiorgos Keramidas.Fn example "char *ptr" "int mode"
39496ff35dSGiorgos Keramidas.Sh DESCRIPTION
40496ff35dSGiorgos KeramidasThis is an example library function manual page for the
41496ff35dSGiorgos Keramidas.Fn example
42496ff35dSGiorgos Keramidaskernel function.
43496ff35dSGiorgos KeramidasIt is intended that this example can be used as a template
44496ff35dSGiorgos Keramidaswhen writing a new manual page.
45496ff35dSGiorgos Keramidas.Pp
46496ff35dSGiorgos KeramidasThe
47496ff35dSGiorgos Keramidas.Fn example
48496ff35dSGiorgos Keramidasfunction takes two arguments:
49496ff35dSGiorgos Keramidas.Fa ptr
50496ff35dSGiorgos Keramidasand
51496ff35dSGiorgos Keramidas.Fa mode .
52496ff35dSGiorgos KeramidasThe argument
53496ff35dSGiorgos Keramidas.Fa mode
54496ff35dSGiorgos Keramidasmay have one of the following values:
55496ff35dSGiorgos Keramidas.Bl -tag -width ".Dv EXAMPLE_ONE"
56496ff35dSGiorgos Keramidas.It Dv EXAMPLE_ONE
57496ff35dSGiorgos KeramidasFirst example of a defined variable.
58496ff35dSGiorgos Keramidas.Dv EXAMPLE_ONE
59496ff35dSGiorgos Keramidasis described below.
60496ff35dSGiorgos Keramidas.It Dv EXAMPLE_TWO
61496ff35dSGiorgos KeramidasSecond example.
62496ff35dSGiorgos Keramidas.El
63496ff35dSGiorgos Keramidas.Pp
64496ff35dSGiorgos KeramidasThe above values are defined in
65496ff35dSGiorgos Keramidas.In example.h
66496ff35dSGiorgos Keramidasas follows:
67496ff35dSGiorgos Keramidas.Bd -literal
68496ff35dSGiorgos Keramidas#define EXAMPLE_ONE  1
69496ff35dSGiorgos Keramidas#define EXAMPLE_TWO  2
70496ff35dSGiorgos Keramidas.Ed
71496ff35dSGiorgos Keramidas.Sh IMPLEMENTATION NOTES
72496ff35dSGiorgos KeramidasThe
73496ff35dSGiorgos Keramidas.Fn example
74496ff35dSGiorgos Keramidasfunction is not actually implemented.
75496ff35dSGiorgos Keramidas.Sh RETURN VALUES
76496ff35dSGiorgos KeramidasThe
77496ff35dSGiorgos Keramidas.Fn example
78496ff35dSGiorgos Keramidasfunction returns the value 0 if successful;
79496ff35dSGiorgos Keramidasotherwise one of the values listed in the
80496ff35dSGiorgos Keramidas.Sx ERRORS
81496ff35dSGiorgos Keramidassection is returned, to indicate the error.
82496ff35dSGiorgos Keramidas.Sh EXAMPLES
83496ff35dSGiorgos Keramidas.Bd -literal
84496ff35dSGiorgos Keramidas	int val;
85496ff35dSGiorgos Keramidas
86496ff35dSGiorgos Keramidas	if ((val = example(NULL, EXAMPLE_ONE)) != 0)
87496ff35dSGiorgos Keramidas		return (val);
88496ff35dSGiorgos Keramidas.Ed
89496ff35dSGiorgos Keramidas.Sh COMPATIBILITY
90496ff35dSGiorgos KeramidasThe
91496ff35dSGiorgos Keramidas.Fn example
92496ff35dSGiorgos Keramidasfunction has no known compatibility issues.
93496ff35dSGiorgos Keramidas.Sh ERRORS
94496ff35dSGiorgos Keramidas.\" Delete any errno's that are not returned by your
95496ff35dSGiorgos Keramidas.\" function or system call and then tailor the
96496ff35dSGiorgos Keramidas.\" remaining text as needed.
97496ff35dSGiorgos KeramidasThe
98496ff35dSGiorgos Keramidas.Fn example
99496ff35dSGiorgos Keramidasfunction will fail if:
100496ff35dSGiorgos Keramidas.Bl -tag -width Er
101496ff35dSGiorgos Keramidas.It Bq Er EPERM
102496ff35dSGiorgos KeramidasOperation not permitted.
103496ff35dSGiorgos Keramidas.It Bq Er ENOENT
104496ff35dSGiorgos KeramidasNo such file or directory.
105496ff35dSGiorgos Keramidas.It Bq Er ESRCH
106496ff35dSGiorgos KeramidasNo such process.
107496ff35dSGiorgos Keramidas.It Bq Er EINTR
108496ff35dSGiorgos KeramidasInterrupted system call.
109496ff35dSGiorgos Keramidas.It Bq Er EIO
110496ff35dSGiorgos KeramidasInput/output error.
111496ff35dSGiorgos Keramidas.It Bq Er ENXIO
112496ff35dSGiorgos KeramidasDevice not configured.
113496ff35dSGiorgos Keramidas.It Bq Er E2BIG
114496ff35dSGiorgos KeramidasArgument list too long.
115496ff35dSGiorgos Keramidas.It Bq Er ENOEXEC
116496ff35dSGiorgos KeramidasExec format error.
117496ff35dSGiorgos Keramidas.It Bq Er EBADF
118496ff35dSGiorgos KeramidasBad file descriptor.
119496ff35dSGiorgos Keramidas.It Bq Er ECHILD
120496ff35dSGiorgos KeramidasNo child processes.
121496ff35dSGiorgos Keramidas.It Bq Er EDEADLK
122496ff35dSGiorgos KeramidasResource deadlock avoided.
123496ff35dSGiorgos Keramidas.It Bq Er ENOMEM
124496ff35dSGiorgos KeramidasCannot allocate memory.
125496ff35dSGiorgos Keramidas.It Bq Er EACCES
126496ff35dSGiorgos KeramidasPermission denied.
127496ff35dSGiorgos Keramidas.It Bq Er EFAULT
128496ff35dSGiorgos KeramidasBad address.
129496ff35dSGiorgos Keramidas.It Bq Er ENOTBLK
130496ff35dSGiorgos KeramidasBlock device required.
131496ff35dSGiorgos Keramidas.It Bq Er EBUSY
132496ff35dSGiorgos KeramidasDevice busy.
133496ff35dSGiorgos Keramidas.It Bq Er EEXIST
134496ff35dSGiorgos KeramidasFile exists.
135496ff35dSGiorgos Keramidas.It Bq Er EXDEV
136496ff35dSGiorgos KeramidasCross-device link.
137496ff35dSGiorgos Keramidas.It Bq Er ENODEV
138496ff35dSGiorgos KeramidasOperation not supported by device.
139496ff35dSGiorgos Keramidas.It Bq Er ENOTDIR
140496ff35dSGiorgos KeramidasNot a directory.
141496ff35dSGiorgos Keramidas.It Bq Er EISDIR
142496ff35dSGiorgos KeramidasIs a directory.
143496ff35dSGiorgos Keramidas.It Bq Er EINVAL
144496ff35dSGiorgos KeramidasInvalid argument.
145496ff35dSGiorgos Keramidas.It Bq Er ENFILE
146496ff35dSGiorgos KeramidasToo many open files in system.
147496ff35dSGiorgos Keramidas.It Bq Er EMFILE
148496ff35dSGiorgos KeramidasToo many open files.
149496ff35dSGiorgos Keramidas.It Bq Er ENOTTY
150496ff35dSGiorgos KeramidasInappropriate ioctl for device.
151496ff35dSGiorgos Keramidas.It Bq Er ETXTBSY
152496ff35dSGiorgos KeramidasText file busy.
153496ff35dSGiorgos Keramidas.It Bq Er EFBIG
154496ff35dSGiorgos KeramidasFile too large.
155496ff35dSGiorgos Keramidas.It Bq Er ENOSPC
156496ff35dSGiorgos KeramidasNo space left on device.
157496ff35dSGiorgos Keramidas.It Bq Er ESPIPE
158496ff35dSGiorgos KeramidasIllegal seek.
159496ff35dSGiorgos Keramidas.It Bq Er EROFS
160496ff35dSGiorgos KeramidasRead-only file system.
161496ff35dSGiorgos Keramidas.It Bq Er EMLINK
162496ff35dSGiorgos KeramidasToo many links.
163496ff35dSGiorgos Keramidas.It Bq Er EPIPE
164496ff35dSGiorgos KeramidasBroken pipe.
165496ff35dSGiorgos Keramidas.It Bq Er EDOM
166496ff35dSGiorgos KeramidasNumerical argument out of domain.
167496ff35dSGiorgos Keramidas.It Bq Er ERANGE
168496ff35dSGiorgos KeramidasResult too large.
169496ff35dSGiorgos Keramidas.It Bq Er EAGAIN
170496ff35dSGiorgos KeramidasResource temporarily unavailable.
171496ff35dSGiorgos Keramidas.It Bq Er EWOULDBLOCK
172496ff35dSGiorgos KeramidasOperation would block.
173496ff35dSGiorgos Keramidas.It Bq Er EINPROGRESS
174496ff35dSGiorgos KeramidasOperation now in progress.
175496ff35dSGiorgos Keramidas.It Bq Er EALREADY
176496ff35dSGiorgos KeramidasOperation already in progress.
177496ff35dSGiorgos Keramidas.It Bq Er ENOTSOCK
178496ff35dSGiorgos KeramidasSocket operation on non-socket.
179496ff35dSGiorgos Keramidas.It Bq Er EDESTADDRREQ
180496ff35dSGiorgos KeramidasDestination address required.
181496ff35dSGiorgos Keramidas.It Bq Er EMSGSIZE
182496ff35dSGiorgos KeramidasMessage too long.
183496ff35dSGiorgos Keramidas.It Bq Er EPROTOTYPE
184496ff35dSGiorgos KeramidasProtocol wrong type for socket.
185496ff35dSGiorgos Keramidas.It Bq Er ENOPROTOOPT
186496ff35dSGiorgos KeramidasProtocol not available.
187496ff35dSGiorgos Keramidas.It Bq Er EPROTONOSUPPORT
188496ff35dSGiorgos KeramidasProtocol not supported.
189496ff35dSGiorgos Keramidas.It Bq Er ESOCKTNOSUPPORT
190496ff35dSGiorgos KeramidasSocket type not supported.
191496ff35dSGiorgos Keramidas.It Bq Er EOPNOTSUPP
192496ff35dSGiorgos KeramidasOperation not supported.
193496ff35dSGiorgos Keramidas.It Bq Er EPFNOSUPPORT
194496ff35dSGiorgos KeramidasProtocol family not supported.
195496ff35dSGiorgos Keramidas.It Bq Er EAFNOSUPPORT
196496ff35dSGiorgos KeramidasAddress family not supported by protocol family.
197496ff35dSGiorgos Keramidas.It Bq Er EADDRINUSE
198496ff35dSGiorgos KeramidasAddress already in use.
199496ff35dSGiorgos Keramidas.It Bq Er EADDRNOTAVAIL
200496ff35dSGiorgos KeramidasCannot assign requested address.
201496ff35dSGiorgos Keramidas.It Bq Er ENETDOWN
202496ff35dSGiorgos KeramidasNetwork is down.
203496ff35dSGiorgos Keramidas.It Bq Er ENETUNREACH
204496ff35dSGiorgos KeramidasNetwork is unreachable.
205496ff35dSGiorgos Keramidas.It Bq Er ENETRESET
206496ff35dSGiorgos KeramidasNetwork dropped connection on reset.
207496ff35dSGiorgos Keramidas.It Bq Er ECONNABORTED
208496ff35dSGiorgos KeramidasSoftware causes connection abort.
209496ff35dSGiorgos Keramidas.It Bq Er ENOBUFS
210496ff35dSGiorgos KeramidasNo buffer space available.
211496ff35dSGiorgos Keramidas.It Bq Er EISCONN
212496ff35dSGiorgos KeramidasSocket is already connected.
213496ff35dSGiorgos Keramidas.It Bq Er ENOTCONN
214496ff35dSGiorgos KeramidasSocket is not connected.
215496ff35dSGiorgos Keramidas.It Bq Er ESHUTDOWN
216496ff35dSGiorgos KeramidasCannot send after socket shutdown.
217496ff35dSGiorgos Keramidas.It Bq Er ETOOMANYREFS
218496ff35dSGiorgos KeramidasToo many references: cannot splice.
219496ff35dSGiorgos Keramidas.It Bq Er ETIMEDOUT
220496ff35dSGiorgos KeramidasOperation timed out.
221496ff35dSGiorgos Keramidas.It Bq Er ECONNREFUSED
222496ff35dSGiorgos KeramidasConnection refused.
223496ff35dSGiorgos Keramidas.It Bq Er ELOOP
224496ff35dSGiorgos KeramidasToo many levels of symbolic links.
225496ff35dSGiorgos Keramidas.It Bq Er ENAMETOOLONG
226496ff35dSGiorgos KeramidasFile name too long.
227496ff35dSGiorgos Keramidas.It Bq Er EHOSTDOWN
228496ff35dSGiorgos KeramidasHost is down.
229496ff35dSGiorgos Keramidas.It Bq Er EHOSTUNREACH
230496ff35dSGiorgos KeramidasNo route to host.
231496ff35dSGiorgos Keramidas.It Bq Er ENOTEMPTY
232496ff35dSGiorgos KeramidasDirectory not empty.
233496ff35dSGiorgos Keramidas.It Bq Er EPROCLIM
234496ff35dSGiorgos KeramidasToo many processes.
235496ff35dSGiorgos Keramidas.It Bq Er EUSERS
236496ff35dSGiorgos KeramidasToo many users.
237496ff35dSGiorgos Keramidas.It Bq Er EDQUOT
238496ff35dSGiorgos KeramidasDisc quota exceeded.
239496ff35dSGiorgos Keramidas.It Bq Er ESTALE
240496ff35dSGiorgos KeramidasStale NFS file handle.
241496ff35dSGiorgos Keramidas.It Bq Er EREMOTE
242496ff35dSGiorgos KeramidasToo many levels of remote in path.
243496ff35dSGiorgos Keramidas.It Bq Er EBADRPC
244496ff35dSGiorgos KeramidasRPC struct is bad.
245496ff35dSGiorgos Keramidas.It Bq Er ERPCMISMATCH
246496ff35dSGiorgos KeramidasRPC version wrong.
247496ff35dSGiorgos Keramidas.It Bq Er EPROGUNAVAIL
248496ff35dSGiorgos KeramidasRPC program not available.
249496ff35dSGiorgos Keramidas.It Bq Er EPROGMISMATCH
250496ff35dSGiorgos KeramidasProgram version wrong.
251496ff35dSGiorgos Keramidas.It Bq Er EPROCUNAVAIL
252496ff35dSGiorgos KeramidasBad procedure for program.
253496ff35dSGiorgos Keramidas.It Bq Er ENOLCK
254496ff35dSGiorgos KeramidasNo locks available.
255496ff35dSGiorgos Keramidas.It Bq Er ENOSYS
256496ff35dSGiorgos KeramidasFunction not implemented.
257496ff35dSGiorgos Keramidas.It Bq Er EFTYPE
258496ff35dSGiorgos KeramidasInappropriate file type or format.
259496ff35dSGiorgos Keramidas.It Bq Er EAUTH
260496ff35dSGiorgos KeramidasAuthentication error.
261496ff35dSGiorgos Keramidas.It Bq Er ENEEDAUTH
262496ff35dSGiorgos KeramidasNeed authenticator.
263496ff35dSGiorgos Keramidas.It Bq Er EIDRM
264496ff35dSGiorgos KeramidasIdentifier removed.
265496ff35dSGiorgos Keramidas.It Bq Er ENOMSG
266496ff35dSGiorgos KeramidasNo message of desired type.
267496ff35dSGiorgos Keramidas.It Bq Er EOVERFLOW
268496ff35dSGiorgos KeramidasValue too large to be stored in data type.
269496ff35dSGiorgos Keramidas.It Bq Er ECANCELED
270496ff35dSGiorgos KeramidasOperation canceled.
271496ff35dSGiorgos Keramidas.It Bq Er EILSEQ
272496ff35dSGiorgos KeramidasIllegal byte sequence.
273496ff35dSGiorgos Keramidas.It Bq Er ENOATTR
274496ff35dSGiorgos KeramidasAttribute not found.
275496ff35dSGiorgos Keramidas.It Bq Er EDOOFUS
276496ff35dSGiorgos KeramidasProgramming error.
277496ff35dSGiorgos Keramidas.El
278496ff35dSGiorgos Keramidas.Sh LOCKING
279496ff35dSGiorgos KeramidasThe
280496ff35dSGiorgos Keramidas.Dv example_lock
281496ff35dSGiorgos Keramidaslock must be held before
282496ff35dSGiorgos Keramidas.Fn example
283496ff35dSGiorgos Keramidasis called.
284496ff35dSGiorgos Keramidas.Pp
285496ff35dSGiorgos KeramidasSince
286496ff35dSGiorgos Keramidas.Fn example_lock
287496ff35dSGiorgos Keramidasis a
288496ff35dSGiorgos Keramidas.Xr mutex 9 ,
289496ff35dSGiorgos Keramidasno sleepable locks (i.e.,
290496ff35dSGiorgos Keramidas.Xr sx 9
291496ff35dSGiorgos Keramidaslocks) can be acquired in
292496ff35dSGiorgos Keramidas.Fn example .
293496ff35dSGiorgos Keramidas.Sh SEE ALSO
294496ff35dSGiorgos Keramidas.Xr example 1 ,
295496ff35dSGiorgos Keramidas.Xr example 3 ,
296496ff35dSGiorgos Keramidas.Xr example 4 ,
297496ff35dSGiorgos Keramidas.Xr mdoc 7
298496ff35dSGiorgos Keramidas.Rs
299496ff35dSGiorgos Keramidas.%A "A. B. Author"
300496ff35dSGiorgos Keramidas.%T "Example RFC Title"
301496ff35dSGiorgos Keramidas.%O RFC0000
302496ff35dSGiorgos Keramidas.Re
303496ff35dSGiorgos Keramidas.Rs
304496ff35dSGiorgos Keramidas.%A "A. B. Author"
305496ff35dSGiorgos Keramidas.%B "Example Book Title"
306496ff35dSGiorgos Keramidas.%O ISBN-0-000-00000-0
307496ff35dSGiorgos Keramidas.Re
308496ff35dSGiorgos Keramidas.Rs
309496ff35dSGiorgos Keramidas.%A "A. B. Author"
310496ff35dSGiorgos Keramidas.%D "January 1997"
311496ff35dSGiorgos Keramidas.%J "Example Journal Name"
312496ff35dSGiorgos Keramidas.%T "Example Article Title"
313496ff35dSGiorgos Keramidas.Re
314496ff35dSGiorgos Keramidas.Sh HISTORY
315496ff35dSGiorgos KeramidasThe
316496ff35dSGiorgos Keramidas.Nm
317496ff35dSGiorgos Keramidasmanual page example first appeared in
318496ff35dSGiorgos Keramidas.Fx 6.0 .
319496ff35dSGiorgos Keramidas.Pp
320496ff35dSGiorgos KeramidasSome other common
321496ff35dSGiorgos Keramidas.Sx HISTORY
322496ff35dSGiorgos Keramidassection examples are:
323496ff35dSGiorgos Keramidas.Pp
324496ff35dSGiorgos KeramidasThe
325496ff35dSGiorgos Keramidas.Nm
326496ff35dSGiorgos Keramidasmanual page example first appeared in
327496ff35dSGiorgos Keramidas.Bx 4.4 .
328496ff35dSGiorgos Keramidas.Pp
329496ff35dSGiorgos KeramidasThe
330496ff35dSGiorgos Keramidas.Nm
331496ff35dSGiorgos Keramidasmanual page example first appeared in
332496ff35dSGiorgos Keramidas.At v6 .
333496ff35dSGiorgos Keramidas.Sh AUTHORS
334496ff35dSGiorgos KeramidasThis
335496ff35dSGiorgos Keramidasmanual page was written by
336496ff35dSGiorgos Keramidas.An Giorgos Keramidas Aq keramida@FreeBSD.org .
337496ff35dSGiorgos Keramidas.Sh BUGS
338496ff35dSGiorgos KeramidasThe actual code for this function is vaporware.
339