Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / rmvb.9f
bloba239da322ed693056a63f8af6b24fe41620337a6
1 '\" te
2 .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH RMVB 9F "Jan 16, 2006"
8 .SH NAME
9 rmvb \- remove a message block from a message
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <sys/stream.h>
17 \fBmblk_t *\fR\fBrmvb\fR(\fBmblk_t *\fR\fImp\fR, \fBmblk_t *\fR\fIbp\fR);
18 .fi
20 .SH INTERFACE LEVEL
21 .sp
22 .LP
23 Architecture independent level 1 (DDI/DKI).
24 .SH PARAMETERS
25 .sp
26 .ne 2
27 .na
28 \fB\fImp\fR\fR
29 .ad
30 .RS 6n
31 Message from which a block is to be removed. \fBmblk_t\fR is an instance of the
32 \fBmsgb\fR(9S) structure.
33 .RE
35 .sp
36 .ne 2
37 .na
38 \fB\fIbp\fR\fR
39 .ad
40 .RS 6n
41 Message block to be removed.
42 .RE
44 .SH DESCRIPTION
45 .sp
46 .LP
47 The \fBrmvb()\fR function removes a message block (\fIbp\fR) from a message
48 (\fImp\fR), and returns a pointer to the altered message. The message block is
49 not freed, merely removed from the message. It is the module or driver's
50 responsibility to free the message block.
51 .SH RETURN VALUES
52 .sp
53 .LP
54 If successful, a pointer to the message (minus the removed block) is returned.
55 The pointer is \fBNULL\fR if \fIbp\fR was the only block of the message before
56 \fBrmvb()\fR was called. If the designated message block (\fIbp\fR) does not
57 exist, \fB-1\fR is returned.
58 .SH CONTEXT
59 .sp
60 .LP
61 The \fBrmvb()\fR function can be called from user, interrupt, or kernel
62 context.
63 .SH EXAMPLES
64 .sp
65 .LP
66 This routine removes all zero-length \fBM_DATA\fR message blocks from the given
67 message. For each message block in the message, save the next message block
68 (line 10). If the current message block is of type \fBM_DATA\fR and has no data
69 in its buffer (line 11), then remove it from the message (line 12) and free it
70 (line 13). In either case, continue with the next message block in the message
71 (line 16).
72 .sp
73 .in +2
74 .nf
75 1  void
76  2  xxclean(mp)
77  3      mblk_t *mp;
78  4  {
79  5             mblk_t *tmp;
80  6             mblk_t *nmp;
81  7
82  8             tmp = mp;
83  9             while (tmp) {
84 10                         nmp = tmp->b_cont;
85 11                         if ((tmp->b_datap->db_type == M_DATA) &&
86                                  (tmp->b_rptr == tmp->b_wptr)) {
87 12                                 (void) rmvb(mp, tmp);
88 13                                 freeb(tmp);
89 14                         }
90 15                         tmp = nmp;
91 16             }
92 17  }
93 .fi
94 .in -2
96 .SH SEE ALSO
97 .sp
98 .LP
99 \fBfreeb\fR(9F), \fBmsgb\fR(9S)
102 \fIWriting Device Drivers\fR
105 \fISTREAMS Programming Guide\fR