From 3340a3e603389aa80b7fc1c18372d0a749730c5f Mon Sep 17 00:00:00 2001 From: wessels <> Date: Sat, 7 Mar 1998 07:54:49 +0000 Subject: [PATCH] WIP --- src/htcp.cc | 65 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 8 deletions(-) diff --git a/src/htcp.cc b/src/htcp.cc index 379f8c38a1..1cf2735df6 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -88,14 +88,63 @@ enum { }; -char * -htpcBuildAuth(u_short * len) +size_t +htpcBuildAuth(char *buf, size_t buflen) { - static char buf[2]; - u_short n_len; + htcpAuthHeader auth; + size_t copy_sz = 0; assert(2 == sizeof(u_short)); - *len = (u_short) 2; - n_len = htons(*len); - xmemcpy(buf, &n_len, 2); - return buf; + auth.length = htons(2); + copy_sz += 2; + assert(buflen >= copy_sz); + xmemcpy(buf, &auth, copy_sz); + return copy_sz; +} + +Specifier * +htcpBuildSpecifier(char *buf, size_t buflen, HtcpStuff *stuff) +{ + off_t off = 0; + ... +} + +size_t +htcpBuildTstOpData(char *buf, size_t buflen, HtcpStuff *stuff) +{ + return htcpBuildSpecifier(buf, buflen, stuff); +} + +size_t +htcpBuildOpData(char *buf, size_t buflen, HtcpStuff *stuff) +{ + off_t off = 0; + switch(stuff->op) { + case HTCP_TST: + off = htcpBuildTstOpData(buf + off, buflen, stuff); + break: + default: + assert(0); + break; + } + return off; +} + +size_t +htcpBuildData(char *buf, size_t buflen, HtcpStuff *stuff) +{ + off_t off = 0; + off += sizeof(htcpDataHeader); /* skip! */ + htcpBuildOpData(buf + off, buflen - off, stuff); + ... +} + +htcpBuildPacket(HtcpStuff *stuff) +{ + size_t buflen = 8192; + off_t off = 0; + char *buf = xcalloc(buflen, 1); + /* skip the header -- we don't know the overall length */ + off += sizeof(htcpHeader); + off += htcpBuildData(buf + off, buflen-off, stuff); + ... } -- 2.47.3