From 413f560bf6f6c38fe141e3cab3c81996db83045b Mon Sep 17 00:00:00 2001 From: midipix Date: Thu, 3 Dec 2015 23:20:19 -0500 Subject: internal headers: rename perk_impl.h to perk_reader_impl.h --- project/headers.mk | 4 +-- src/internal/perk_impl.h | 50 ------------------------------------ src/internal/perk_reader_impl.h | 50 ++++++++++++++++++++++++++++++++++++ src/logic/pe_get_image_meta.c | 2 +- src/reader/pe_read_coff_header.c | 2 +- src/reader/pe_read_dos_header.c | 2 +- src/reader/pe_read_export_header.c | 2 +- src/reader/pe_read_import_header.c | 2 +- src/reader/pe_read_optional_header.c | 2 +- src/reader/pe_read_section_header.c | 2 +- 10 files changed, 59 insertions(+), 59 deletions(-) delete mode 100644 src/internal/perk_impl.h create mode 100644 src/internal/perk_reader_impl.h diff --git a/project/headers.mk b/project/headers.mk index 3f25fc3..57b9443 100644 --- a/project/headers.mk +++ b/project/headers.mk @@ -8,7 +8,7 @@ API_HEADERS = \ INTERNAL_HEADERS = \ $(PROJECT_DIR)/src/internal/argv/argv.h \ - $(PROJECT_DIR)/src/internal/$(PACKAGE)_impl.h \ - $(PROJECT_DIR)/src/internal/$(PACKAGE)_output_impl.h + $(PROJECT_DIR)/src/internal/$(PACKAGE)_output_impl.h \ + $(PROJECT_DIR)/src/internal/$(PACKAGE)_reader_impl.h \ ALL_HEADERS = $(API_HEADERS) $(INTERNAL_HEADERS) diff --git a/src/internal/perk_impl.h b/src/internal/perk_impl.h deleted file mode 100644 index bda7581..0000000 --- a/src/internal/perk_impl.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef PERK_IMPL_H -#define PERK_IMPL_H - -#include -#include - -#if (BYTE_ORDER == LITTLE_ENDIAN) - -static inline uint16_t pe_read_short(const unsigned char * raw) -{ - return *(uint16_t *)raw; -} - -static inline uint32_t pe_read_long(const unsigned char * raw) -{ - return *(uint32_t *)raw; -} - -static inline uint64_t pe_read_quad(const unsigned char * raw) -{ - return *(uint64_t *)raw; -} - -#else - -static inline uint16_t pe_read_short(const unsigned char * raw) -{ - uint16_t x = *(uint16_t *)raw; - return x<<8 | x>>8; -} - -static inline uint32_t pe_swap_long(uint32_t x) -{ - return x<<24 | (x<<8) & 0xff0000 | (x>>8) & 0xff00 | x>>24; -} - -static inline uint32_t pe_read_long(const unsigned char * raw) -{ - return pe_swap_long(*(uint32_t *)raw); -} - -static inline uint64_t pe_read_quad(const unsigned char * raw) -{ - uint64_t x = *(uint64_t *)raw; - return ((uint64_t)pe_swap_long(x)<<32) | pe_swap_long(x>>32); -} - -#endif - -#endif diff --git a/src/internal/perk_reader_impl.h b/src/internal/perk_reader_impl.h new file mode 100644 index 0000000..bda7581 --- /dev/null +++ b/src/internal/perk_reader_impl.h @@ -0,0 +1,50 @@ +#ifndef PERK_IMPL_H +#define PERK_IMPL_H + +#include +#include + +#if (BYTE_ORDER == LITTLE_ENDIAN) + +static inline uint16_t pe_read_short(const unsigned char * raw) +{ + return *(uint16_t *)raw; +} + +static inline uint32_t pe_read_long(const unsigned char * raw) +{ + return *(uint32_t *)raw; +} + +static inline uint64_t pe_read_quad(const unsigned char * raw) +{ + return *(uint64_t *)raw; +} + +#else + +static inline uint16_t pe_read_short(const unsigned char * raw) +{ + uint16_t x = *(uint16_t *)raw; + return x<<8 | x>>8; +} + +static inline uint32_t pe_swap_long(uint32_t x) +{ + return x<<24 | (x<<8) & 0xff0000 | (x>>8) & 0xff00 | x>>24; +} + +static inline uint32_t pe_read_long(const unsigned char * raw) +{ + return pe_swap_long(*(uint32_t *)raw); +} + +static inline uint64_t pe_read_quad(const unsigned char * raw) +{ + uint64_t x = *(uint64_t *)raw; + return ((uint64_t)pe_swap_long(x)<<32) | pe_swap_long(x>>32); +} + +#endif + +#endif diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c index 6d90b37..acf377f 100644 --- a/src/logic/pe_get_image_meta.c +++ b/src/logic/pe_get_image_meta.c @@ -4,7 +4,7 @@ #include #include -#include "perk_impl.h" +#include "perk_reader_impl.h" static int pe_free_image_meta_impl(struct pe_image_meta * meta, int status) { diff --git a/src/reader/pe_read_coff_header.c b/src/reader/pe_read_coff_header.c index cc466be..79ed730 100644 --- a/src/reader/pe_read_coff_header.c +++ b/src/reader/pe_read_coff_header.c @@ -2,7 +2,7 @@ #include #include -#include "perk_impl.h" +#include "perk_reader_impl.h" int pe_read_coff_header(const struct pe_coff_file_hdr * p, struct pe_meta_coff_file_hdr * m) { diff --git a/src/reader/pe_read_dos_header.c b/src/reader/pe_read_dos_header.c index 5f8b14a..078cf56 100644 --- a/src/reader/pe_read_dos_header.c +++ b/src/reader/pe_read_dos_header.c @@ -2,7 +2,7 @@ #include #include -#include "perk_impl.h" +#include "perk_reader_impl.h" int pe_read_dos_header(const struct pe_image_dos_hdr * p, struct pe_meta_image_dos_hdr * m) { diff --git a/src/reader/pe_read_export_header.c b/src/reader/pe_read_export_header.c index 97272f4..a2ab19a 100644 --- a/src/reader/pe_read_export_header.c +++ b/src/reader/pe_read_export_header.c @@ -2,7 +2,7 @@ #include #include -#include "perk_impl.h" +#include "perk_reader_impl.h" int pe_read_export_header(const struct pe_export_hdr * p, struct pe_meta_export_hdr * m) { diff --git a/src/reader/pe_read_import_header.c b/src/reader/pe_read_import_header.c index 885adf6..de5730b 100644 --- a/src/reader/pe_read_import_header.c +++ b/src/reader/pe_read_import_header.c @@ -2,7 +2,7 @@ #include #include -#include "perk_impl.h" +#include "perk_reader_impl.h" int pe_read_import_header(const struct pe_import_hdr * p, struct pe_meta_import_hdr * m) { diff --git a/src/reader/pe_read_optional_header.c b/src/reader/pe_read_optional_header.c index 73443c6..7770e06 100644 --- a/src/reader/pe_read_optional_header.c +++ b/src/reader/pe_read_optional_header.c @@ -2,7 +2,7 @@ #include #include -#include "perk_impl.h" +#include "perk_reader_impl.h" int pe_read_optional_header(const union pe_opt_hdr * p, struct pe_meta_opt_hdr * m) { diff --git a/src/reader/pe_read_section_header.c b/src/reader/pe_read_section_header.c index e6a1d19..280c611 100644 --- a/src/reader/pe_read_section_header.c +++ b/src/reader/pe_read_section_header.c @@ -2,7 +2,7 @@ #include #include -#include "perk_impl.h" +#include "perk_reader_impl.h" int pe_read_section_header(const struct pe_sec_hdr * p, struct pe_meta_sec_hdr * m) { -- cgit v1.2.3