'\"macro stdmacro
.if n .pH ddi_dki.flushq @(#)flushq	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} flushq D3DK "STREAMS" "DDI/DKI" "\&"
.if \nX=1 .ds x} flushq D3DK "STREAMS" "DDI/DKI"
.if \nX=2 .ds x} flushq D3DK "" "\&"
.if \nX=3 .ds x} flushq "" "" "\&"
.TH \*(x}
.IX "\f4flushq\fP(D3DK)"
.IX "STREAMS messages"
.SH NAME
\f4flushq\f1 \- remove messages from a queue
.SH SYNOPSIS
.nf
.na
\f4#include <sys/stream.h>
.sp 0.5
void flushq(queue_t *\f2q, \f4int\f2 flag\f4);\f1
.ad
.fi
.SH ARGUMENTS
.RS 0n 10
.IP "\f2*q\f1" 10n
Pointer to the queue to be flushed.
.IP "\f2flag\f1" 10n
Valid \f2flag\f1 values are:
.P
.RS 12
.TP 12
\f4FLUSHDATA\f1
Flush only data messages (types \f4M_DATA, M_DELAY, M_PROTO, \f1and 
\f4M_PCPROTO\f1).
.TP
\f4FLUSHALL\f1
Flush all messages.
.RE
.RE
.SH DESCRIPTION
\f4flushq\f1 frees messages and their associated data structures by calling
\f4freemsg\f1(D3DK).
If the queue's count falls below the low water mark and \f4QWANTW\f1 
is set, the nearest upstream service procedure is enabled.
.SH RETURN VALUE
None
.SH LEVEL
Base or Interrupt
.SH SEE ALSO
\f2BCI Driver Development Guide\f1, Chapter 7, ``STREAMS''
.P
.na
\f4freemsg\f1(D3DK),
\f4putq\f1(D3DK)
.ad
.SH EXAMPLE
.IX "\f4put\fP(D2DK), example"
.IX "\f4flushq\fP(D3DK), example"
.IX "\f4putnext\fP(D3DK), example"
.IX "\f4queue\fP(D4DK), example"
.IX "\f4RD\fP(D3DK), example"
This example depicts the canonical flushing code for
STREAMS modules.  The module has a write service procedure
and potentially has messages on the queue.  If it receives
an \f4M_FLUSH\f1 message, and if the \f4FLUSHR\f1 bit is on in the
first byte of the message (line 10),
then the read queue is flushed (line 11).
If the \f4FLUSHW\f1 bit is on (line 12), then the 
write queue is flushed (line 13).
Then the message is passed along to the next entity in the
stream (line 14).  See the example for \f4qreply\f1(D3DK) for the canonical
flushing code for drivers.
.ne 4
.P
.nf
.ft 4
.ps 7
 1  /*
 2   * Module write-side put procedure.
 3   */
 4  xxxwput(q, mp)
 5      queue_t *q;
 6      mblk_t *mp;
 7  {
 8	switch(mp->b_datap->db_type) {
 9	case M_FLUSH:
10		if (*mp->b_rptr & FLUSHR)
11			flushq(RD(q), FLUSHALL);
12		if (*mp->b_rptr & FLUSHW)
13			flushq(q, FLUSHALL);
14		putnext(q, mp);
15		break;
		. . .
16	}
17  }
.ps
.ft 1
.fi
.P
.FG "flushq \- flush messages from a queue"
