|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T s
Length: 2516 (0x9d4)
Types: TextFile
Names: »str2spkt.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
└─⟦eba4602b1⟧ »./isode-5.0.tar.Z«
└─⟦d3ac74d73⟧
└─⟦this⟧ »isode-5.0/ssap/str2spkt.c«
/* str2spkt.c - read/write a SPDU thru a string */
#ifndef lint
static char *rcsid = "$Header: /f/osi/ssap/RCS/str2spkt.c,v 6.0 89/03/18 23:44:12 mrose Rel $";
#endif
/*
* $Header: /f/osi/ssap/RCS/str2spkt.c,v 6.0 89/03/18 23:44:12 mrose Rel $
*
*
* $Log: str2spkt.c,v $
* Revision 6.0 89/03/18 23:44:12 mrose
* Release 5.0
*
*/
/*
* 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 "spkt.h"
#include "tailor.h"
/* \f
*/
char *spkt2str (s)
struct ssapkt *s;
{
int i,
len;
char *base,
*dp;
static char buffer[(CONNECT_MAX + BUFSIZ) * 2 + 1];
if (spkt2tsdu (s, &base, &len) == NOTOK)
return NULLCP;
if (s -> s_udata)
switch (s -> s_code) {
case SPDU_DT:
if (s -> s_mask & SMASK_SPDU_GT)
break; /* else fall */
case SPDU_EX:
case SPDU_TD:
if ((dp = realloc (base, (unsigned) (i = len + s -> s_ulen)))
== NULL) {
free (base);
return NULLCP;
}
bcopy (s -> s_udata, (base = dp) + len, s -> s_ulen);
len = i;
break;
default:
break;
}
buffer[explode (buffer, (u_char *) base, len)] = NULL;
if (len > 0)
free (base);
#ifdef DEBUG
if (ssap_log -> ll_events & LLOG_PDUS) {
LLOG (ssap_log, LLOG_PDUS,
("write %d bytes, \"%s\"", strlen (buffer), buffer));
spkt2text (ssap_log, s, 0);
}
#endif
return buffer;
}
/* \f
*/
struct ssapkt *str2spkt (buffer)
char *buffer;
{
int cc;
char packet[CONNECT_MAX + BUFSIZ];
register struct ssapkt *s;
struct qbuf qbs;
register struct qbuf *qb = &qbs,
*qp;
bzero ((char *) qb, sizeof *qb);
qb -> qb_forw = qb -> qb_back = qb;
cc = implode ((u_char *) packet, buffer, strlen (buffer));
if ((qp = (struct qbuf *) malloc (sizeof *qp + (unsigned) cc)) == NULL)
s = NULLSPKT;
else {
bcopy (packet, qp -> qb_data = qp -> qb_base, qp -> qb_len = cc);
insque (qp, qb -> qb_back);
s = tsdu2spkt (qb, cc, NULLIP);
for (qp = qb -> qb_forw; qp != qb; qp = qp -> qb_forw) {/* never! */
remque (qp);
free ((char *) qp);
}
}
#ifdef DEBUG
if (ssap_log -> ll_events & LLOG_PDUS) {
LLOG (ssap_log, LLOG_PDUS,
("read %d bytes, \"%s\"", strlen (buffer), buffer));
spkt2text (ssap_log, s, 1);
}
#endif
return s;
}