00001 // Copyright (C) 2004 Pablo Mejia 00002 00003 00004 #ifndef ENDIAN_H 00005 #define ENDIAN_H 00006 00007 00008 namespace endian 00009 { 00010 typedef unsigned short u16_t; 00011 typedef short s16_t; 00012 typedef unsigned int u32_t; 00013 typedef int s32_t; 00014 00015 template <typename T> T letoh (void const *f) 00016 { 00017 return (*((T *) f)); 00018 } 00019 00020 template <typename T> void htole (T f, void const *t) 00021 { 00022 *((T *) t) = f; 00023 } 00024 }; 00025 00026 00027 #endif