'\"macro stdmacro
.if n .pH ddi_dki.putctl @(#)putctl	40.6 of 10/10/89
.\" Copyright 1989 AT&T
.de IX
.ie '\\n(.z'' .tm .Index: \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9	\\n%
.el \\!.IX \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
..
.nr X
.if \nX=0 .ds x} putctl D3DK "STREAMS" "DDI/DKI" "\&"
.if \nX=1 .ds x} putctl D3DK "STREAMS" "DDI/DKI"
.if \nX=2 .ds x} putctl D3DK "" "\&"
.if \nX=3 .ds x} putctl "" "" "\&"
.TH \*(x}
.IX "\f4putctl\fP(D3DK)"
.SH NAME
\f4putctl\f1 \- send a control message to a queue
.SH SYNOPSIS
.nf
.na
\f4#include <sys/stream.h>
.sp 0.5
int putctl(queue_t *\f2q, \f4int\f2 type\f4);\f1
.ad
.fi
.SH ARGUMENTS
.RS 0n 10
.IP "\f2q\f1" 10n
Queue to which the message is to be sent.
.IP "\f2type\f1" 10n
Message type (must be control, not data type).
.RE
.SH DESCRIPTION
\f4putctl\f1 tests the \f2type\f1 argument to make sure a data type has
not been specified, and then attempts to allocate a message block.
\f4putctl\f1 fails if \f2type\f1 is \f4M_DATA\f1,\f4M_DELAY\f1,
\f4M_PROTO\f1,
or \f4M_PCPROTO\f1, or if a message block cannot be allocated.
If successful, \f4putctl\f1 calls the \f4put\f1(D2DK) routine of the queue
pointed to by \f2q\f1.
.SH RETURN VALUE
On success, \f41\f1 is returned.
If \f2type\f1 is a
data type, or if a message block cannot be allocated,
\f40\f1 is returned.
.SH LEVEL
Base or Interrupt
.SH SEE ALSO
\f2BCI Driver Development Guide\f1, Chapter 7, ``STREAMS''
.P
.na
\f4datamsg\f1(D3DK),
\f4putctl1\f1(D3DK)
.ad
.SH EXAMPLE
.IX "\f4cmn_err\fP(D3DK), example"
.IX "\f4putctl\fP(D3DK), example"
.IX "\f4putctl1\fP(D3DK), example"
.IX "\f4queue\fP(D4DK), example"
.P
The \f4send_ctl\f1 routine is used to pass control messages downstream.
\f4M_BREAK\f1 messages are handled with \f4putctl\f1 (line 11).
\f4putctl1\f1 (line 16) is used for \f4M_DELAY\f1 messages, 
so that \f2parm\f1 can be
used to specify the length of the delay.
In either case, if a message block cannot be allocated  a 
variable recording the number of allocation failures 
is incremented (lines 12, 17).
If an invalid message type is detected, \f4cmn_err\f1(D3DK) panics 
the system (line 21).
.ne 4
.P
.nf
.ft 4
.ps 7
 1  void
 2  send_ctl(wrq, type, parm)
 3      queue_t *wrq;
 4      unchar type;
 5      unchar parm;
 6  {
 7	extern int num_alloc_fail;
 8
 9	switch (type) {
10	case M_BREAK:
11		if (!putctl(wrq->q_next, M_BREAK))
12			num_alloc_fail++;
13		break;
14
15	case M_DELAY:
16		if (!putctl1(wrq->q_next, M_DELAY, parm))
17			num_alloc_fail++;
18		break;
19
20	default:
21		cmn_err(CE_PANIC, "send_ctl: bad message type passed");
22		break;
23	}
24  }
.ps
.ft 1
.fi
.P
.FG "putctl \- pass control messages"
