1
0
Files
irix-657m-src/eoe/man/manD/copymsg.d3
2022-09-29 17:59:04 +03:00

94 lines
2.2 KiB
Plaintext

.if n .pH ddi.rm/d3/gen/copymsg @(#)copymsg 43.10 of 11/27/92
.\" Copyright 1992, 1991 UNIX System Laboratories, Inc.
.TH copymsg D3
.IX "\f4copymsg\fP(D3)"
.SH NAME
\f4copymsg\f1 \- copy a message
.IX "STREAMS messages"
.SH "SYNOPSIS"
.nf
.na
.ft 4
#include <sys/stream.h>
#include <sys/ddi.h>
.sp 0.4
mblk_t *copymsg(mblk_t *\f2mp\fP);
.ft 1
.ad
.fi
.SS Arguments
.RS 0
.IP "\f2mp\f1" 10n
Pointer to the message to be copied.
.RE
.SH "DESCRIPTION"
\f4copymsg\f1 forms a new message by allocating new message blocks, copies
the contents of the message referred to by
\f2mp\f1 (using the \f4copyb\f1(D3) function),
and returns a pointer to the new message.
.SS "Return Values"
On success, \f4copymsg\f1 returns a pointer to the new message.
On failure, it returns a \f4NULL\f1 pointer.
.SH USAGE
.SS Level
Base or Interrupt.
.SS "Synchronization Constraints"
Does not sleep.
.P
Driver-defined basic locks, read/write locks, and sleep locks
may be held across calls to this function.
.SS Examples
.IX "\f4copymsg\fP(D3), example"
.IX "\f4freemsg\fP(D3), example"
.P
The routine \f4lctouc\f1 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 \f4copymsg\f1 fails (line 9), we
return \f4NULL\fP (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).
.ne 4
.P
.nf
.ft 4
.ps -1
.vs -1
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);
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 }
.ps
.vs
.ft 1
.fi
.SH REFERENCES
.na
\f4allocb\fP(D3),
\f4copyb\fP(D3),
\f4msgb\fP(D4)
.ad