Commit 6a5a515820052986e28c53f794ab4f54c2736cb6

Guillem Jover 2017-06-07T05:00:34

man: Add missing man pages This adds man pages for byteorder(3), errc(3) and fpurge(3), including all their aliases.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
diff --git a/COPYING b/COPYING
index 2e42383..3b943fd 100644
--- a/COPYING
+++ b/COPYING
@@ -93,9 +93,11 @@ Files:
  include/bsd/timeconv.h
  include/bsd/vis.h
  man/bitstring.3bsd
+ man/errc.3bsd
  man/explicit_bzero.3bsd
  man/fgetln.3bsd
  man/fgetwln.3bsd
+ man/fpurge.3bsd
  man/funopen.3bsd
  man/getbsize.3bsd
  man/heapsort.3bsd
@@ -278,8 +280,9 @@ License: BSD-2-clause-NetBSD
 
 Files:
  include/bsd/sys/endian.h
- man/expand_number.3bsd
+ man/byteorder.3bsd
  man/closefrom.3bsd
+ man/expand_number.3bsd
  man/flopen.3bsd
  man/getpeereid.3bsd
  man/pidfile.3bsd
@@ -302,6 +305,9 @@ Copyright:
  Copyright © 2002 Thomas Moestl <tmm@FreeBSD.org>
  All rights reserved.
  .
+ Copyright © 2002 Mike Barcroft <mike@FreeBSD.org>
+ All rights reserved.
+ .
  Copyright © 2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
  All rights reserved.
  .
diff --git a/man/Makefile.am b/man/Makefile.am
index b531dea..19c5c78 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -137,6 +137,12 @@ dist_man_MANS = \
 	arc4random_buf.3bsd \
 	arc4random_stir.3bsd \
 	arc4random_uniform.3bsd \
+	be16dec.3bsd \
+	be16enc.3bsd \
+	be32dec.3bsd \
+	be32enc.3bsd \
+	be64dec.3bsd \
+	be64enc.3bsd \
 	bit_alloc.3bsd \
 	bit_clear.3bsd \
 	bit_decl.3bsd \
@@ -148,8 +154,10 @@ dist_man_MANS = \
 	bit_test.3bsd \
 	bitstr_size.3bsd \
 	bitstring.3bsd \
+	byteorder.3bsd \
 	closefrom.3bsd \
 	dehumanize_number.3bsd \
+	errc.3bsd \
 	expand_number.3bsd \
 	explicit_bzero.3bsd \
 	fgetln.3bsd \
@@ -157,6 +165,7 @@ dist_man_MANS = \
 	flopen.3bsd \
 	fmtcheck.3bsd \
 	fparseln.3bsd \
+	fpurge.3bsd \
 	funopen.3bsd \
 	getbsize.3bsd \
 	getmode.3bsd \
@@ -164,6 +173,12 @@ dist_man_MANS = \
 	getprogname.3bsd \
 	heapsort.3bsd \
 	humanize_number.3bsd \
+	le16dec.3bsd \
+	le16enc.3bsd \
+	le32dec.3bsd \
+	le32enc.3bsd \
+	le64dec.3bsd \
+	le64enc.3bsd \
 	md5.3bsd \
 	mergesort.3bsd \
 	nlist.3bsd \
diff --git a/man/be16dec.3bsd b/man/be16dec.3bsd
new file mode 100644
index 0000000..bce31af
--- /dev/null
+++ b/man/be16dec.3bsd
@@ -0,0 +1 @@
+.so man3/byteorder.3bsd
diff --git a/man/be16enc.3bsd b/man/be16enc.3bsd
new file mode 100644
index 0000000..bce31af
--- /dev/null
+++ b/man/be16enc.3bsd
@@ -0,0 +1 @@
+.so man3/byteorder.3bsd
diff --git a/man/be32dec.3bsd b/man/be32dec.3bsd
new file mode 100644
index 0000000..bce31af
--- /dev/null
+++ b/man/be32dec.3bsd
@@ -0,0 +1 @@
+.so man3/byteorder.3bsd
diff --git a/man/be32enc.3bsd b/man/be32enc.3bsd
new file mode 100644
index 0000000..bce31af
--- /dev/null
+++ b/man/be32enc.3bsd
@@ -0,0 +1 @@
+.so man3/byteorder.3bsd
diff --git a/man/be64dec.3bsd b/man/be64dec.3bsd
new file mode 100644
index 0000000..bce31af
--- /dev/null
+++ b/man/be64dec.3bsd
@@ -0,0 +1 @@
+.so man3/byteorder.3bsd
diff --git a/man/be64enc.3bsd b/man/be64enc.3bsd
new file mode 100644
index 0000000..bce31af
--- /dev/null
+++ b/man/be64enc.3bsd
@@ -0,0 +1 @@
+.so man3/byteorder.3bsd
diff --git a/man/byteorder.3bsd b/man/byteorder.3bsd
new file mode 100644
index 0000000..ddb010f
--- /dev/null
+++ b/man/byteorder.3bsd
@@ -0,0 +1,83 @@
+.\" Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd April 29, 2002
+.Dt BYTEORDER 3
+.Os
+.Sh NAME
+.Nm be16enc , be16dec , be32enc , be32dec , be64enc , be64dec ,
+.Nm le16enc , le16dec , le32enc , le32dec , le64enc , le64dec
+.Nd byte order operations
+.Sh SYNOPSIS
+.In sys/endian.h
+.Ft uint16_t
+.Fn be16dec "const void *"
+.Ft uint32_t
+.Fn be32dec "const void *"
+.Ft uint64_t
+.Fn be64dec "const void *"
+.Ft uint16_t
+.Fn le16dec "const void *"
+.Ft uint32_t
+.Fn le32dec "const void *"
+.Ft uint64_t
+.Fn le64dec "const void *"
+.Ft void
+.Fn be16enc "void *" uint16_t
+.Ft void
+.Fn be32enc "void *" uint32_t
+.Ft void
+.Fn be64enc "void *" uint64_t
+.Ft void
+.Fn le16enc "void *" uint16_t
+.Ft void
+.Fn le32enc "void *" uint32_t
+.Ft void
+.Fn le64enc "void *" uint64_t
+.Sh DESCRIPTION
+.Pp
+The
+.Fn be16enc ,
+.Fn be16dec ,
+.Fn be32enc ,
+.Fn be32dec ,
+.Fn be64enc ,
+.Fn be64dec ,
+.Fn le16enc ,
+.Fn le16dec ,
+.Fn le32enc ,
+.Fn le32dec ,
+.Fn le64enc ,
+and
+.Fn le64dec
+functions encode and decode integers to/from byte strings on any alignment
+in big/little endian format.
+.Sh SEE ALSO
+.Xr byteorder 3
+.Sh HISTORY
+.Pp
+The encode/decode functions first appeared in
+.Fx 5.1 .
diff --git a/man/errc.3bsd b/man/errc.3bsd
new file mode 100644
index 0000000..1b1579f
--- /dev/null
+++ b/man/errc.3bsd
@@ -0,0 +1,175 @@
+.\"	$OpenBSD: err.3,v 1.20 2014/04/23 16:26:33 jmc Exp $
+.\"
+.\" Copyright (c) 1993
+.\"	The Regents of the University of California.  All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd $Mdocdate: April 23 2014 $
+.Dt ERRC 3
+.Os
+.Sh NAME
+.Nm errc ,
+.Nm verrc ,
+.Nm warnc ,
+.Nm vwarnc
+.Nd formatted error messages
+.Sh LIBRARY
+.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
+.Lb libbsd
+.Sh SYNOPSIS
+.In err.h
+.Ft void
+.Fn errc "int status" "int code" "const char *fmt" "..."
+.Ft void
+.Fn verrc "int status" "int code" "const char *fmt" "va_list args"
+.Ft void
+.Fn warnc "int code" "const char *fmt" "..."
+.Ft void
+.Fn vwarnc "int code" "const char *fmt" "va_list args"
+.Sh DESCRIPTION
+The
+.Fn err
+and
+.Fn warn
+family of functions display a formatted error message on the standard
+error output.
+In all cases, the last component of the program name, followed by
+a colon
+.Pq Sq \&:
+character and a space, are output.
+The text that follows depends on the function being called.
+The
+.Fa fmt
+specification (and associated arguments) may be any format allowed by
+.Xr printf 3
+or
+.Dv NULL .
+If the
+.Fa fmt
+argument is not
+.Dv NULL ,
+the formatted error message is output.
+.Pp
+The functions all output an error message string affiliated with
+an error value (see
+.Xr strerror 3 ) ,
+preceded by a colon character and a space if
+.Fa fmt
+is not
+.Dv NULL .
+That is, the output is as follows:
+.Bd -literal -offset indent
+progname: fmt: error message string
+.Ed
+.Pp
+if
+.Fa fmt
+is not
+.Dv NULL ,
+or:
+.Bd -literal -offset indent
+progname: error message string
+.Ed
+.Pp
+if it is.
+.Pp
+The argument
+.Fa code
+is used as the error value instead of the current value of the global variable
+.Va errno .
+.Pp
+In all cases, the output is followed by a newline character.
+.Pp
+The
+.Fn errc ,
+and
+.Fn verrc
+functions do not return, but exit with the value of the argument
+.Fa status .
+.Sh EXAMPLES
+Display the current
+.Va errno
+information string and exit:
+.Bd -literal -offset indent
+if ((p = malloc(size)) == NULL)
+	err(1, NULL);
+if ((fd = open(file_name, O_RDONLY, 0)) == -1)
+	err(1, "%s", file_name);
+.Ed
+.Pp
+Display an error message and exit:
+.Bd -literal -offset indent
+if (tm.tm_hour < START_TIME)
+	errx(1, "too early, wait until %s", start_time_string);
+.Ed
+.Pp
+Warn of an error:
+.Bd -literal -offset indent
+if ((fd = open(raw_device, O_RDONLY, 0)) == -1)
+	warnx("%s: %s: trying the block device",
+	    raw_device, strerror(errno));
+if ((fd = open(block_device, O_RDONLY, 0)) == -1)
+	err(1, "%s", block_device);
+.Ed
+.Sh SEE ALSO
+.Xr err 3
+.Xr exit 3 ,
+.Xr perror 3 ,
+.Xr printf 3 ,
+.Xr strerror 3
+.Sh HISTORY
+The functions
+.Fn errc ,
+.Fn verrc ,
+.Fn warnc ,
+and
+.Fn vwarnc
+first appeared in
+.Fx 3.0 ,
+.Nx 7.0
+and
+.Ox 5.6 .
+.Sh CAVEATS
+It is important never to pass a string with user-supplied data as a
+format without using
+.Ql %s .
+An attacker can put format specifiers in the string to mangle the stack,
+leading to a possible security hole.
+This holds true even if the string has been built
+.Dq by hand
+using a function like
+.Fn snprintf ,
+as the resulting string may still contain user-supplied conversion specifiers
+for later interpolation by the
+.Fn err
+and
+.Fn warn
+family of functions.
+.Pp
+Always be sure to use the proper secure idiom:
+.Bd -literal -offset indent
+errc(1, 0, "%s", string);
+.Ed
diff --git a/man/fpurge.3bsd b/man/fpurge.3bsd
new file mode 100644
index 0000000..d4d0b89
--- /dev/null
+++ b/man/fpurge.3bsd
@@ -0,0 +1,79 @@
+.\"	$OpenBSD: fflush.3,v 1.12 2015/11/04 21:30:13 tedu Exp $
+.\"
+.\" Copyright (c) 1990, 1991, 1993
+.\"	The Regents of the University of California.  All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" Chris Torek and the American National Standards Committee X3,
+.\" on Information Processing Systems.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd $Mdocdate: November 4 2015 $
+.Dt FPURGE 3
+.Os
+.Sh NAME
+.Nm fpurge
+.Nd flush a stream
+.Sh LIBRARY
+.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
+.Lb libbsd
+.Sh SYNOPSIS
+.In stdio.h
+.Ft int
+.Fn fpurge "FILE *stream"
+.Sh DESCRIPTION
+The function
+.Fn fpurge
+erases any input or output buffered in the given
+.Fa stream .
+For output streams this discards any unwritten output.
+For input streams this discards any input read from the underlying object
+but not yet obtained via
+.Xr getc 3 ;
+this includes any text pushed back via
+.Xr ungetc 3 .
+.Sh RETURN VALUES
+Upon successful completion 0 is returned.
+Otherwise,
+.Dv EOF
+is returned and the global variable
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+.Bl -tag -width Er
+.It Bq Er EBADF
+.Fa stream
+is not an open stream.
+.El
+.Sh SEE ALSO
+.Xr fclose 3 ,
+.Xr fopen 3 ,
+.Xr setvbuf 3
+.Sh HISTORY
+The
+.Fn fpurge
+function first appeared in
+.Bx 4.4 Lite .
diff --git a/man/le16dec.3bsd b/man/le16dec.3bsd
new file mode 100644
index 0000000..bce31af
--- /dev/null
+++ b/man/le16dec.3bsd
@@ -0,0 +1 @@
+.so man3/byteorder.3bsd
diff --git a/man/le16enc.3bsd b/man/le16enc.3bsd
new file mode 100644
index 0000000..bce31af
--- /dev/null
+++ b/man/le16enc.3bsd
@@ -0,0 +1 @@
+.so man3/byteorder.3bsd
diff --git a/man/le32dec.3bsd b/man/le32dec.3bsd
new file mode 100644
index 0000000..bce31af
--- /dev/null
+++ b/man/le32dec.3bsd
@@ -0,0 +1 @@
+.so man3/byteorder.3bsd
diff --git a/man/le32enc.3bsd b/man/le32enc.3bsd
new file mode 100644
index 0000000..bce31af
--- /dev/null
+++ b/man/le32enc.3bsd
@@ -0,0 +1 @@
+.so man3/byteorder.3bsd
diff --git a/man/le64dec.3bsd b/man/le64dec.3bsd
new file mode 100644
index 0000000..bce31af
--- /dev/null
+++ b/man/le64dec.3bsd
@@ -0,0 +1 @@
+.so man3/byteorder.3bsd
diff --git a/man/le64enc.3bsd b/man/le64enc.3bsd
new file mode 100644
index 0000000..bce31af
--- /dev/null
+++ b/man/le64enc.3bsd
@@ -0,0 +1 @@
+.so man3/byteorder.3bsd