386BSD 0.1 development
[unix-history] / usr / othersrc / contrib / isode / psap / str2qb.c
CommitLineData
cf908fd1
WJ
1/* str2qb.c - string to qbuf */
2
3#ifndef lint
4static char *rcsid = "$Header: /f/osi/psap/RCS/str2qb.c,v 7.3 91/02/22 09:37:10 mrose Interim $";
5#endif
6
7/*
8 * $Header: /f/osi/psap/RCS/str2qb.c,v 7.3 91/02/22 09:37:10 mrose Interim $
9 *
10 *
11 * $Log: str2qb.c,v $
12 * Revision 7.3 91/02/22 09:37:10 mrose
13 * Interim 6.8
14 *
15 * Revision 7.2 90/04/18 08:51:02 mrose
16 * touch-up
17 *
18 * Revision 7.1 90/02/19 13:09:48 mrose
19 * update
20 *
21 * Revision 7.0 89/11/23 22:13:49 mrose
22 * Release 6.0
23 *
24 */
25
26/*
27 * NOTICE
28 *
29 * Acquisition, use, and distribution of this module and related
30 * materials are subject to the restrictions of a license agreement.
31 * Consult the Preface in the User's Manual for the full terms of
32 * this agreement.
33 *
34 */
35
36
37/* LINTLIBRARY */
38
39#include <stdio.h>
40#include "psap.h"
41
42/* \f */
43
44struct qbuf *str2qb (s, len, head)
45char *s;
46int len,
47 head;
48{
49 register struct qbuf *qb,
50 *pb;
51
52 if ((pb = (struct qbuf *) malloc ((unsigned) (sizeof *pb + len))) == NULL)
53 return NULL;
54
55 if (head) {
56 if ((qb = (struct qbuf *) malloc (sizeof *qb)) == NULL) {
57 free ((char *) pb);
58 return NULL;
59 }
60 qb -> qb_forw = qb -> qb_back = qb;
61 qb -> qb_data = NULL, qb -> qb_len = len;
62 insque (pb, qb);
63 }
64 else {
65 pb -> qb_forw = pb -> qb_back = pb;
66 qb = pb;
67 }
68
69 pb -> qb_data = pb -> qb_base;
70 if ((pb -> qb_len = len) > 0 && s)
71 bcopy (s, pb -> qb_data, len);
72
73 return qb;
74}