Kernel Functions for Drivers putctl(9F)
NAME
putctl - send a control message to a queue
SYNOPSIS
#include
int putctl(queuet *q, int type);
INTERFACE LEVEL
Architecture independent level 1 (DI/DKI).
PARAMETERS
q Queue to which the message is to be sent.
type Message type (must be control, not data type).
DESCRIPTION
The putctl() function tests the type argument to make sure a
data type has not been specified, and then attempts to allo-
cate a message block. putctl() fails if type is MDATA,
MPROTO, or MPCPROTO, or if a message block cannot be allo-
cated. If successful, putctl() calls the put(9E) routine of
the queue pointed to by q with the newly allocated and ini-
tialized messages.
RETURN VALUES
On success, 1 is returned. If type is a data type, or if a
message block cannot be allocated, 0 is returned.
CONTEXT
The putctl() function can be called from user, interrupt, or
kernel context.
EXAMPLES
Example 1 Using putctl()
The sendctl() routine is used to pass control messages
downstream. MBREAK messages are handled with putctl() (line
11). putctl1(9F) (line 16) is used for MDELAY messages, so
that parm can be used to specify the length of the delay. In
either case, if a message block cannot be allocated a vari-
able recording the number of allocation failures is incre-
mented (lines 12, 17). If an invalid message type is
detected, cmnerr(9F) panics the system (line 21).
SunOS 5.11 Last change: 16 Jan 2006 1
Kernel Functions for Drivers putctl(9F)
1 void
2 sendctl(wrq, type, parm)
3 queuet *wrq;
4 uchart type;
5 uchart parm;
6 {
7 extern int numallocfail;
8
9 switch (type) {
10 case MBREAK:
11 if (!putctl(wrq->qnext, MBREAK))
12 numallocfail];
13 break;
14
15 case MDELAY:
16 if (!putctl1(wrq->qnext, MDELAY, parm))
17 numallocfail];
18 break;
19
20 default:
21 cmnerr(CEPANIC, "sendctl: bad message type passed");
22 break;
23 }
24 }
SEE ALSO
put(9E), cmnerr(9F), datamsg(9F), putctl1(9F),
putnextctl(9F)
Writing Device Drivers
STREAMS Programming Guide
SunOS 5.11 Last change: 16 Jan 2006 2
|