Fix sample code:

- Put single space around binary operator or after a comma.
- Lineup case label with switch().
- ANSIfy.
- Use \e to print \.
- Deref the pointer to get a value.
This commit is contained in:
enami 2002-04-22 08:44:05 +00:00
parent 3e139496d2
commit d60499e75b
1 changed files with 17 additions and 16 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ioctl.9,v 1.13 2002/02/13 08:18:42 ross Exp $ .\" $NetBSD: ioctl.9,v 1.14 2002/04/22 08:44:05 enami Exp $
.\" .\"
.\" Copyright (c) 1999 The NetBSD Foundation, Inc. .\" Copyright (c) 1999 The NetBSD Foundation, Inc.
.\" All rights reserved. .\" All rights reserved.
@ -244,30 +244,31 @@ In order for the new ioctl to be known to the system it is installed
in either \*[Lt]sys/ioctl.h\*[Gt] or one of the files that are reached from in either \*[Lt]sys/ioctl.h\*[Gt] or one of the files that are reached from
\*[Lt]sys/ioctl.h\*[Gt]. \*[Lt]sys/ioctl.h\*[Gt].
.Sh EXAMPLES .Sh EXAMPLES
.Bd -literal .Bd -literal -offset indent
#define FOOIOCTL _IOWR('i',23,int) #define FOOIOCTL _IOWR('i', 23, int)
int a=3; int a = 3;
error = ioctl(s,FOOICTL, \*[Am]a); error = ioctl(s, FOOICTL, \*[Am]a);
.Ed .Ed
.Pp .Pp
Within the ioctl()-routine of the driver, it can be then accessed like Within the ioctl()-routine of the driver, it can be then accessed like
.Bd -literal .Bd -literal -offset indent
driver_ioctl(..,cmd,data) driver_ioctl(..., u_long cmd, caddr_t data)
u_long cmd; {
caddr_t data; ...
switch (cmd) {
... case FOOIOCTL:
switch(cmd) { int *a = (int *)data;
case FOOIOCTL: printf(" Value passed: %d\en", *a);
int *a = (int *)data; break;
printf(" Value passed: %d\n",a); }
} }
.Ed .Ed
.Sh NOTES .Sh NOTES
Note that if you e.g. try to read information from e.g. a ethernet Note that if you e.g. try to read information from e.g. a ethernet
driver where the name of the card is included in the third argument driver where the name of the card is included in the third argument
(e.g. ioctl(s,READFROMETH,struct ifreq *)), then you have to use (e.g. ioctl(s, READFROMETH, struct ifreq *)), then you have to use
the _IOWR() form not the _IOR(), as passing the name of the card to the the _IOWR() form not the _IOR(), as passing the name of the card to the
kernel already consists of writing data. kernel already consists of writing data.
.Sh SEE ALSO .Sh SEE ALSO