libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit 06fd29d5b078fef57cad7cf0037c12e4d91226d1
parent 9270c5d4ed028ef2a9158dd51d46d89c6be9e8bc
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 14 Aug 2010 15:09:49 +0000

dead code elimination

Diffstat:
Msrc/common/pack.c | 212-------------------------------------------------------------------------------
Msrc/common/pack.h | 3---
2 files changed, 0 insertions(+), 215 deletions(-)

diff --git a/src/common/pack.c b/src/common/pack.c @@ -35,218 +35,6 @@ typedef signed short shalf; 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, ...) diff --git a/src/common/pack.h b/src/common/pack.h @@ -45,9 +45,6 @@ MODIFICATIONS. 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 {