copymsg man page on IRIX

Man page or keyword search:  
man Server   31559 pages
apropos Keyword Search (all sections)
Output format
IRIX logo
[printable version]



copymsg(D3)							   copymsg(D3)

NAME
     copymsg - copy a message

SYNOPSIS
     #include <sys/stream.h>
     #include <sys/ddi.h>
     mblk_t *copymsg(mblk_t *mp);

   Arguments
     mp	       Pointer to the message to be copied.

DESCRIPTION
     copymsg forms a new message by allocating new message blocks, copies the
     contents of the message referred to by mp (using the copyb(D3) function),
     and returns a pointer to the new message.

   Return Values
     On success, copymsg returns a pointer to the new message.	On failure, it
     returns a NULL pointer.

USAGE
   Level
     Base or Interrupt.

   Synchronization Constraints
     Does not sleep.

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

   Examples
     The routine lctouc converts all the lower case ASCII characters in the
     message to upper case.  If the reference count is greater than one (line
     8), then the message is shared, and must be copied before changing the
     contents of the data buffer.  If the call to copymsg fails (line 9), we
     return NULL (line 10).  Otherwise, we free the original message (line
     11).  If the reference count was equal to one, the message can be
     modified.	For each character (line 16) in each message block (line 15),
     if it is a lower case letter, we convert it to an upper case letter (line
     18).  When done, we return a pointer to the converted message (line 21).

      1	 mblk_t *lctouc(mp)
      2	  mblk_t *mp;
      3	 {
      4	  mblk_t *cmp;
      5	  mblk_t *tmp;
      6	  uchar_t *cp;
      7
      8	  if (mp->b_datap->db_ref > 1) {
      9	       if ((cmp = copymsg(mp)) == NULL)
     10		    return(NULL);
     11	       freemsg(mp);

									Page 1

copymsg(D3)							   copymsg(D3)

     12	  } else {
     13	       cmp = mp;
     14	  }
     15	  for (tmp = cmp; tmp; tmp = tmp->b_next) {
     16	       for (cp = tmp->b_rptr; cp < tmp->b_wptr; cp++) {
     17		    if ((*cp <= 'z') && (*cp >= 'a'))
     18			 *cp -= 0x20;
     19	       }
     20	  }
     21	  return(cmp);
     22	 }

REFERENCES
     allocb(D3), copyb(D3), msgb(D4)

									Page 2

[top]

List of man pages available for IRIX

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net