'\"macro stdmacro
.if n .pH ddi_dki.rmvb @(#)rmvb	40.8 of 12/19/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} rmvb D3DK "STREAMS" "DDI/DKI" "\&"
.if \nX=1 .ds x} rmvb D3DK "STREAMS" "DDI/DKI"
.if \nX=2 .ds x} rmvb D3DK "" "\&"
.if \nX=3 .ds x} rmvb "" "" "\&"
.TH \*(x}
.IX "\f4rmvb\fP(D3DK)"
.SH NAME
\f4rmvb\f1 \- remove a message block from a message
.SH SYNOPSIS
.nf
.na
\f4#include <sys/stream.h>
.sp 0.5
mblk_t *rmvb(mblk_t *\f2mp\f4, mblk_t *\f2bp\f4);\f1
.ad
.fi
.SH ARGUMENTS
.RS 0n 10
.IP "\f2*mp\f1" 10n
Message from which a block is to be removed.
\f4mblk_t\f1 is an instance of the \f4msgb\f1(D4DK)
structure.
.IP "\f2bp\f1" 10n
Message block to be removed.
.RE
.SH DESCRIPTION
\f4rmvb\f1 removes a message block (\f2bp\f1) from a message (\f2mp\f1), and
returns a pointer to the altered message.
The message block is not freed, merely removed from the message.
It is the module or driver's responsibility to free the message block.
.SH RETURN VALUE
If successful, a pointer to the message (minus the removed block) is returned.
The pointer is \f4NULL\f1 if \f2bp\f1 was the only
block of the message before \f4rmvb\f1 was called.
If the designated message block (\f2bp\f1) does not exist, \f4-1\f1 is
returned.
.SH LEVEL
Base or Interrupt
.SH EXAMPLE
.IX "\f4freeb\fP(D3DK), example"
.IX "\f4rmvb\fP(D3DK), example"
.IX "\f4msgb\fP(D4DK), example"
.P
This routine removes all zero-length \f4M_DATA\f1 message blocks
from the given message.  For each message block in the message,
save the next message block (line 10).
If the current message block is
of type \f4M_DATA\f1 and has no data in its buffer (line 11), then remove
it from the message (line 12) and free it (line 13).
In either case, continue with
the next message block in the message (line 16).
.ne 4
.P
.nf
.ft 4
.ps 7
 1  void
 2  xxclean(mp)
 3      mblk_t *mp;
 4  {
 5	mblk_t *tmp;
 6	mblk_t *nmp;
 7
 8	tmp = mp;
 9	while (tmp) {
10		nmp = tmp->b_next;
11		if ((tmp->b_datap->db_type == M_DATA) &&
		    (tmp->b_rptr == tmp->b_wptr)) {
12			rmvb(mp, tmp);
13			freeb(tmp);
14		}
15		tmp = nmp;
16	}
17  }
.ps
.ft 1
.fi
