X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=common-src%2Fpacket.c;h=c161f95c9f3a7c1019d555e6a6590138815f3684;hb=422c17cad7cd7473d9a3b0888ba5a02dd931262c;hp=e8e20d4b42e935837a06672c0ab27da91092ddea;hpb=71325c297e0436e9930a3e129a26696e78c27f62;p=debian%2Famanda diff --git a/common-src/packet.c b/common-src/packet.c index e8e20d4..c161f95 100644 --- a/common-src/packet.c +++ b/common-src/packet.c @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: packet.c,v 1.8.2.1 2006/09/22 11:02:12 martinea Exp $ + * $Id: packet.c,v 1.8 2006/05/25 01:47:12 johnfranks Exp $ * * Routines for modifying the amanda protocol packet type */ @@ -50,6 +50,20 @@ static const struct { /* * Initialize a packet */ +void pkt_init_empty( + pkt_t *pkt, + pktype_t type) +{ + assert(pkt != NULL); + assert(strcmp(pkt_type2str(type), "BOGUS") != 0); + + pkt->type = type; + pkt->packet_size = 1000; + pkt->body = alloc(pkt->packet_size); + pkt->body[0] = '\0'; + pkt->size = strlen(pkt->body); +} + printf_arglist_function2(void pkt_init, pkt_t *, pkt, pktype_t, type, const char *, fmt) { @@ -58,16 +72,17 @@ printf_arglist_function2(void pkt_init, pkt_t *, pkt, pktype_t, type, assert(pkt != NULL); assert(strcmp(pkt_type2str(type), "BOGUS") != 0); - assert(fmt != NULL); + if(fmt == NULL) + fmt = ""; pkt->type = type; pkt->packet_size = 1000; pkt->body = alloc(pkt->packet_size); while(1) { arglist_start(argp, fmt); - len = vsnprintf(pkt->body, pkt->packet_size, fmt, argp); + len = g_vsnprintf(pkt->body, pkt->packet_size, fmt, argp); arglist_end(argp); - if (len < (int)(pkt->packet_size - 1)) + if (len > -1 && len < (int)(pkt->packet_size - 1)) break; pkt->packet_size *= 2; amfree(pkt->body); @@ -93,9 +108,9 @@ printf_arglist_function1(void pkt_cat, pkt_t *, pkt, const char *, fmt) while(1) { arglist_start(argp, fmt); - lenX = vsnprintf(pkt->body + len, pkt->packet_size - len, fmt,argp); + lenX = g_vsnprintf(pkt->body + len, pkt->packet_size - len, fmt,argp); arglist_end(argp); - if (lenX < (int)(pkt->packet_size - len - 1)) + if (lenX > -1 && lenX < (int)(pkt->packet_size - len - 1)) break; pkt->packet_size *= 2; pktbody = alloc(pkt->packet_size);