[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r12528 - Extractor/src/common
From: |
gnunet |
Subject: |
[GNUnet-SVN] r12528 - Extractor/src/common |
Date: |
Sat, 14 Aug 2010 17:09:49 +0200 |
Author: grothoff
Date: 2010-08-14 17:09:49 +0200 (Sat, 14 Aug 2010)
New Revision: 12528
Modified:
Extractor/src/common/pack.c
Extractor/src/common/pack.h
Log:
dead code elimination
Modified: Extractor/src/common/pack.c
===================================================================
--- Extractor/src/common/pack.c 2010-08-14 14:55:23 UTC (rev 12527)
+++ Extractor/src/common/pack.c 2010-08-14 15:09:49 UTC (rev 12528)
@@ -35,220 +35,8 @@
typedef signed int sword;
-/*
- "bhwAcslxPBHWCSLX"
- Small letters: do not convert (not implemented for arrays and P)
- Captial letters: convert from network byte order to host byte order
-
- b - byte
- h - half-word
- w - word
- a - array (32-byte unsigned long + that many bytes)
- c - signed 8 bit value
- s - signed 16 bit value
- l - signed 32 bit value
- x - signed 64 bit value
- p - (unpack only) value is a pointer to a pointer. Generate the buffer
- to hold the data.
-
- prefixing with a number K means that the argument will be an array of K
- of the arguments specified by the letter
- */
-
int
-EXTRACTOR_common_cat_pack (void *buf, const char *fmt, ...)
-{
- va_list ap;
- word blen, val;
- int npacked;
- unsigned int nreps, i;
- byte *bp, *bytep;
- half *halfp;
- word *wordp;
- void *arr;
- struct cat_bvec *cbvp;
- char *cp;
-
- va_start (ap, fmt);
-
- npacked = 0;
- bp = (byte *) buf;
-
- while (*fmt)
- {
- nreps = 0;
-
- if (isdigit ( (unsigned char) *fmt))
- {
- /* We use cp instead of fmt to keep the 'const' qualifier of fmt */
- nreps = strtoul (fmt, &cp, 0);
- fmt = cp;
- }
-
- switch (*fmt)
- {
- case 'B':
- case 'b':
- case 'C':
- case 'c':
- if (!nreps)
- {
- *bp++ = va_arg (ap, int);
- npacked += 1;
- }
- else
- {
- bytep = va_arg (ap, byte *);
- for (i = 0; i < nreps; ++i)
- {
- *bp++ = bytep[i];
- npacked += 1;
- }
- }
- break;
-
- case 'h':
- case 's':
- if (!nreps)
- {
- val = va_arg (ap, int);
- *bp++ = val & 0xFF;
- *bp++ = val >> 8;
- npacked += 2;
- }
- else
- {
- halfp = va_arg (ap, half *);
- for (i = 0; i < nreps; ++i)
- {
- val = halfp[i];
- *bp++ = val & 0xFF;
- *bp++ = val >> 8;
- npacked += 2;
- }
- }
- break;
-
- case 'H':
- case 'S':
- if (!nreps)
- {
- val = va_arg (ap, int);
- *bp++ = val >> 8;
- *bp++ = val & 0xFF;
- npacked += 2;
- }
- else
- {
- halfp = va_arg (ap, half *);
- for (i = 0; i < nreps; ++i)
- {
- val = halfp[i];
- *bp++ = val >> 8;
- *bp++ = val & 0xFF;
- npacked += 2;
- }
- }
- break;
-
- case 'l':
- case 'w':
- if (!nreps)
- {
- val = va_arg (ap, word);
- *bp++ = val & 0xFF;
- *bp++ = val >> 8;
- *bp++ = val >> 16;
- *bp++ = val >> 24;
- npacked += 4;
- }
- else
- {
- wordp = va_arg (ap, word *);
- for (i = 0; i < nreps; ++i)
- {
- val = wordp[i];
- *bp++ = val & 0xFF;
- *bp++ = val >> 8;
- *bp++ = val >> 16;
- *bp++ = val >> 24;
- npacked += 4;
- }
- }
- break;
-
- case 'L':
- case 'W':
- if (!nreps)
- {
- val = va_arg (ap, word);
- *bp++ = val >> 24;
- *bp++ = val >> 16;
- *bp++ = val >> 8;
- *bp++ = val & 0xFF;
- npacked += 4;
- }
- else
- {
- wordp = va_arg (ap, word *);
- for (i = 0; i < nreps; ++i)
- {
- val = wordp[i];
- *bp++ = val >> 24;
- *bp++ = val >> 16;
- *bp++ = val >> 8;
- *bp++ = val & 0xFF;
- npacked += 4;
- }
- }
- break;
-
- case 'A':
- if (!nreps)
- {
- blen = va_arg (ap, word);
- arr = va_arg (ap, void *);
- *bp++ = blen >> 24;
- *bp++ = blen >> 16;
- *bp++ = blen >> 8;
- *bp++ = blen & 0xFF;
- memmove (bp, arr, blen);
- bp += blen;
- npacked += blen + 4; /* +4 for the 32 bits of length field
*/
- }
- else
- {
- cbvp = va_arg (ap, struct cat_bvec *);
- for (i = 0; i < nreps; ++i)
- {
- blen = cbvp[i].len;
- arr = cbvp[i].data;
- *bp++ = blen >> 24;
- *bp++ = blen >> 16;
- *bp++ = blen >> 8;
- *bp++ = blen & 0xFF;
- memmove (bp, arr, blen);
- bp += blen;
- npacked += blen + 4; /* see above */
- }
- }
- break;
-
- default:
- va_end (ap);
- return -1;
- }
- ++fmt;
- }
-
- va_end (ap);
- return npacked;
-}
-
-
-
-int
EXTRACTOR_common_cat_unpack (const void *buf, const char *fmt, ...)
{
va_list ap;
Modified: Extractor/src/common/pack.h
===================================================================
--- Extractor/src/common/pack.h 2010-08-14 14:55:23 UTC (rev 12527)
+++ Extractor/src/common/pack.h 2010-08-14 15:09:49 UTC (rev 12528)
@@ -45,9 +45,6 @@
p - (unpack only) value is a pointer to a pointer. Generate the buffer
to hold the data.
*/
-
-int EXTRACTOR_common_cat_pack(void * buf, const char *fmt, ... );
-
int EXTRACTOR_common_cat_unpack(const void * buf, const char *fmt, ... );
struct cat_bvec {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r12528 - Extractor/src/common,
gnunet <=