blob: c3a8cc8bf9a5a8bc11cbedfabd059b8aaf3d6357 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/* qb2str.c - qbuf to string */
/*
* isode/psap/qb2str.c
*/
/*
* NOTICE
*
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
* this agreement.
*
*/
/* LINTLIBRARY */
#include <stdio.h>
#include "psap.h"
/* */
char *qb2str (q)
register struct qbuf *q;
{
register int len;
register char *b,
*d;
register struct qbuf *p;
p = q -> qb_forw, len = 0;
do {
len += p -> qb_len;
p = p -> qb_forw;
}
while (p != q);
q -> qb_len = len;
if ((b = d = malloc ((unsigned) (len + 1))) == NULL)
return NULLCP;
p = q -> qb_forw;
do {
memcpy (d, p -> qb_data, p -> qb_len);
d += p -> qb_len;
p = p -> qb_forw;
}
while (p != q);
*d = NULL;
return b;
}
|