[Extractor-gtk-cvslog] SF.net SVN: extractor-gtk:[88] trunk/extractor
Extract files from unusual archive formats
Brought to you by:
someone-guy
From: <som...@us...> - 2008-08-22 16:04:25
|
Revision: 88 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=88&view=rev Author: someone-guy Date: 2008-08-22 16:04:22 +0000 (Fri, 22 Aug 2008) Log Message: ----------- Inline several speed-relevant functions Modified Paths: -------------- trunk/extractor/helpers.c trunk/extractor/helpers.h trunk/extractor/solid.c Modified: trunk/extractor/helpers.c =================================================================== --- trunk/extractor/helpers.c 2008-08-22 16:03:53 UTC (rev 87) +++ trunk/extractor/helpers.c 2008-08-22 16:04:22 UTC (rev 88) @@ -33,41 +33,6 @@ return name; } -//! read a 32 bit little-endian value from file -uint32_t read_le32(FILE *f) { - unsigned char t[4]; - fread(t, 4, 1, f); - return (t[3] << 8 | t[2]) << 16 | (t[1] << 8 | t[0]); -} - -//! as read_le32 but do not advance file pointer -uint32_t peek_le32(FILE *f) { - uint32_t res = read_le32(f); - fseek(f, -4, SEEK_CUR); - return res; -} - -//! read a 32 bit big-endian value from file -uint32_t read_be32(FILE *f) { - unsigned char t[4]; - fread(t, 4, 1, f); - return (t[0] << 8 | t[1]) << 16 | (t[2] << 8 | t[3]); -} - -//! read a 16 bit little-endian value from file -uint16_t read_le16(FILE *f) { - unsigned char t[2]; - fread(t, 2, 1, f); - return t[1] << 8 | t[0]; -} - -//! read a 16 bit big-endian value from file -uint16_t read_be16(FILE *f) { - unsigned char t[2]; - fread(t, 2, 1, f); - return t[0] << 8 | t[1]; -} - /** * \brief append a new entry to a file list * \param list file list to append to Modified: trunk/extractor/helpers.h =================================================================== --- trunk/extractor/helpers.h 2008-08-22 16:03:53 UTC (rev 87) +++ trunk/extractor/helpers.h 2008-08-22 16:04:22 UTC (rev 88) @@ -1,11 +1,42 @@ #ifndef HELPERS_H #define HELPERS_H char *read_cstring(FILE *f); -uint16_t read_le16(FILE *f); -uint32_t read_le32(FILE *f); -uint32_t peek_le32(FILE *f); -uint32_t read_be32(FILE *f); -uint16_t read_be16(FILE *f); + +//! read a 32 bit little-endian value from file +static inline uint32_t read_le32(FILE *f) { + unsigned char t[4]; + fread(t, 4, 1, f); + return (t[3] << 8 | t[2]) << 16 | (t[1] << 8 | t[0]); +} + +//! as read_le32 but do not advance file pointer +static inline uint32_t peek_le32(FILE *f) { + uint32_t res = read_le32(f); + fseek(f, -4, SEEK_CUR); + return res; +} + +//! read a 32 bit big-endian value from file +static inline uint32_t read_be32(FILE *f) { + unsigned char t[4]; + fread(t, 4, 1, f); + return (t[0] << 8 | t[1]) << 16 | (t[2] << 8 | t[3]); +} + +//! read a 16 bit little-endian value from file +static inline uint16_t read_le16(FILE *f) { + unsigned char t[2]; + fread(t, 2, 1, f); + return t[1] << 8 | t[0]; +} + +//! read a 16 bit big-endian value from file +static inline uint16_t read_be16(FILE *f) { + unsigned char t[2]; + fread(t, 2, 1, f); + return t[0] << 8 | t[1]; +} + int fcopy(FILE *in, FILE *out, int len); #define TAG(a, b, c, d) ((uint32_t)((a) << 8 | (b)) << 16 | ((c) << 8 | (d))) #define HUGETAG(a, b, c, d, e, f, g, h) (((uint64_t)(TAG(a, b, c, d)) << 32) | TAG(e, f, g, h)) Modified: trunk/extractor/solid.c =================================================================== --- trunk/extractor/solid.c 2008-08-22 16:03:53 UTC (rev 87) +++ trunk/extractor/solid.c 2008-08-22 16:04:22 UTC (rev 88) @@ -60,7 +60,7 @@ return "bin"; } -static int read_block_header(FILE *in, int *lang, int *type, uint32_t *len) { +static inline int read_block_header(FILE *in, int *lang, int *type, uint32_t *len) { *lang = read_be16(in); *type = read_be16(in); *len = read_be32(in); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |