DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SVR5 and SCO OpenServer 5

rmvb(D3str)


rmvb -- remove a message block from a message

Synopsis

   #include <sys/stream.h>
   #include <sys/ddi.h>
   

mblk_t *rmvb(mblk_t *mp, mblk_t *bp);

Description

rmvb removes the message block specified by bp from the message specified mp and returns a pointer to the altered message.

Arguments


mp
Pointer to the message from which a message block is to be removed.

bp
Pointer to the message block to be removed.

Return values

On success, a pointer to the message (minus the removed block) is returned. If bp was the only block in the message before rmvb was called, NULL is returned. If the designated message block (bp) was not in the message, -1 is returned.

Usage

The message block is not freed, merely removed from the message. It is the caller's responsibility to free the message block.

Context

Base or Interrupt.

Synchronization constraints

Does not block.

Driver-defined basic locks, read/write locks, and sleep locks may be held across calls to this function.

Hardware applicability

All

Version applicability

ddi: 1, 2, 3, 4, 5, 5mp, 6, 6mp, 7, 7mp, 7.1, 7.1mp, 8, 8mp
oddi: 1, 2, 2mp, 3, 3mp, 4, 4mp, 5, 5mp, 6, 6mp

Examples

This routine removes all zero-length M_DATA(D7str) message blocks from the given message. For each message block in the message, we save the next message block (line 9). If the current message block is of type M_DATA and has no data in its buffer (lines 10-11), then we remove the message block from the message (line 12) and free it (line 13). In either case, we continue with the next message block (line 15), until we have checked every message block in the message.
    1  void
    2  xxclean(mp)
    3	mblk_t *mp;
    4  {
    5	mblk_t *tmp;
    6	mblk_t *nmp;
    7	tmp = mp;
    8	while (tmp) {
    9		nmp = tmp->b_next;
   10		if ((tmp->b_datap->db_type == M_DATA) &&
   11		   (tmp->b_rptr == tmp->b_wptr)) {
   12			mp = rmvb(mp, tmp);
   13			freeb(tmp);
   14		}
   15		tmp = nmp;
   16	}
   17  }

19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005