'\"macro stdmacro
.if n .pH ddi_dki.insq @(#)insq	40.7 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} insq D3DK "STREAMS" "DDI/DKI" "\&"
.if \nX=1 .ds x} insq D3DK "STREAMS" "DDI/DKI"
.if \nX=2 .ds x} insq D3DK "" "\&"
.if \nX=3 .ds x} insq "" "" "\&"
.TH \*(x}
.IX "\f4insq\fP(D3DK)"
.SH NAME 
\f4insq\f1 \- insert a message into a queue
.SH SYNOPSIS 
.nf
.na
\f4#include <sys/stream.h>
.sp 0.5
int insq(queue_t *\f2q, \f4mblk_t *\f2emp, \f4mblk_t *\f2nmp\f4);\f1
.ad
.fi
.SH ARGUMENTS 
.RS 0n 10
.IP "\f2q\f1" 10n
Pointer to the queue containing message \f2emp\f1.
.IP "\f2emp\f1" 10n
Enqueued message before which the new message is to be inserted
(\f4mblk_t\f1 is an instance of the \f4msgb\f1(D4DK)
structure).
.IP "\f2nmp\f1" 10n
Message to be inserted.
.RE
.SH DESCRIPTION 
\f4insq\f1 inserts a message into a queue.  The message to be inserted,
\f2nmp\f1, is placed in \f2q\f1 immediately before the message \f2emp\f1.  If
\f2emp\f1 is \f4NULL\f1, the new message is placed at the end of the queue.
The queue class of the new message is ignored. All flow control parameters are
updated.
The service procedure is enabled unless \f4QNOENB\f1 is set.
.P
\f3CAUTION:\f1
If \f2emp\f1 is non-\f4NULL\f1, it must point to a
message on \f2q\f1 or a system panic could result.
.SH "RETURN VALUE" 
\f4insq\f1 returns \f41\f1 on success, and \f40\f1 on failure.
.SH LEVEL 
Base or Interrupt
.SH "SEE ALSO" 
\f2BCI Driver Development Guide\f1, Chapter 7, ``STREAMS''
.SH EXAMPLE 
.IX "\f4putq\fP(D3DK), example"
.IX "\f4insq\fP(D3DK), example"
This routine illustrates the steps a transport provider
may take to place expedited data ahead of normal data on
a queue (assume all \f4M_DATA\f1 messages are converted into
\f4M_PROTO T_DATA_REQ\f1 messages).  Normal \f4T_DATA_REQ\f1 messages
are just placed on the end of the queue (line 14).
However,
expedited \f4T_EXDATA_REQ\f1 messages are inserted before any
normal messages already on the queue (line 28).
If there are
no normal messages on the queue, \f4bp\f1 will be \f4NULL\f1
and we will fall out of the \f4for\f1 loop (line 21).
\f4insq\f1 will act like \f4putq\f1(D3DK) in this case.
.P
.ne 4
.P
.nf
.ft 4
.ps 7
 1  #include <sys/tihdr.h>
 2
 3  xxxwput(q, mp)
 4      queue_t *q;
 5      mblk_t *mp;
 6  {
 7	union T_primitives *tp;
 8
 9	switch (mp->b_datap->db_type) {
10	case M_PROTO:
11		tp = (union T_primitives *)mp->b_rptr;
12		switch (tp->type) {
13		case T_DATA_REQ:
14		        putq(q, mp);
15		        break;
16
17		case T_EXDATA_REQ:
19		        mblk_t *bp;
20		        union T_primitives *ntp;
21
22		        for (bp = q->q_first; bp; bp = bp->b_next) {
23	                  if (bp->b_datap->db_type == M_PROTO) {
24		             ntp = (union T_primitives *)bp->b_rptr;
25		             if (ntp->type != T_EXDATA_REQ)
26		                 break;
27		          }
28		        }
29		        insq(q, bp, mp);
30		        break;
		. . .
32              }
33	}
34  }
.ps
.ft 1
.fi
.P
.FG "insq \- insert a message into a STREAMS queue"
