'\"macro stdmacro
.if n .pH ddi_dki.getq @(#)getq	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} getq D3DK "STREAMS" "DDI/DKI" "\&"
.if \nX=1 .ds x} getq D3DK "STREAMS" "DDI/DKI"
.if \nX=2 .ds x} getq D3DK "" "\&"
.if \nX=3 .ds x} getq "" "" "\&"
.TH \*(x}
.IX "\f4getq\fP(D3DK)"
.SH NAME
\f4getq\f1 \- get the next message from a queue
.SH SYNOPSIS 
.nf
.na
\f4#include <sys/stream.h>
.sp 0.5
mblk_t *getq(queue_t *\f2q\f4);\f1
.ad
.fi
.SH ARGUMENTS 
.RS 0n 10
.IP "\f2q\f1" 10n
Pointer to the queue from which the message is to be retrieved.
.RE
.SH DESCRIPTION 
\f4getq\f1 is used by a service (\f4srv\f1(D2DK)) routine to
retrieve its enqueued messages.
.P
A module or driver may include a service routine 
to process enqueued messages.
Once the STREAMS scheduler calls \f4srv\f1 it must process
all enqueued messages, unless prevented by flow control.
\f4getq\f1 gets the next available message from
the top of the queue pointed to by \f2q\f1.
It should be called in a \f4while\f1 loop that should be exited
only when there are no more messages.
.P
\f4getq\f1 turns the \f4QWANTR\f1 flag off when a queue is being read,
and turns \f4QWANTR\f1 on when there are no more messages.
When \f4QWANTW\f1 is set it means an attempt has been made to
write to the queue while it was blocked by
flow control.  If this is the case, \f4getq\f1 back-enables 
(restarts) the
service routine once it falls below the low water mark.
.SH "RETURN VALUE" 
If there is a message to retrieve, \f4getq\f1 returns a pointer to it.
If no message is queued, \f4getq\f1 returns a \f4NULL\f1 pointer.
.SH "LEVEL" 
Base or Interrupt
.SH "SEE ALSO" 
\f2BCI Driver Development Guide\f1, Chapter 7, ``STREAMS''
.P
\f2STREAMS Programmer's Guide\f1, Chapter 5, ``Messages''
.P
.na
\f4bcanput\f1(D3DK),
\f4canput\f1(D3DK),
\f4putbq\f1(D3DK),
\f4putq\f1(D3DK),
\f4qenable\f1(D3DK),
\f4srv\f1(D2DK)
.ad
.SH "EXAMPLE" 
See the \f4dupb\f1(D3DK) function page for an example of \f4getq\f1.
