From ea90ffba3ae77092b24d79b8e110fdbaaadb5a7d Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Sun, 22 Jan 2006 19:52:33 +0000 Subject: [PATCH] Added unsigned short endian swap --- lib/endian.c | 11 ++++++++++- lib/mbselib.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/endian.c b/lib/endian.c index 6df3913a..1b86b16c 100644 --- a/lib/endian.c +++ b/lib/endian.c @@ -4,7 +4,7 @@ * Purpose ...............: Change integer value CPU endian independant * ***************************************************************************** - * Copyright (C) 1997-2004 + * Copyright (C) 1997-2006 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -47,4 +47,13 @@ int le_int(int val) } +unsigned short le_us(unsigned short val) +{ +#ifdef WORDS_BIGENDIAN + return ((val & 0xff) << 8) | ((val >> 8) & 0xff); +#else + return val; +#endif +} + diff --git a/lib/mbselib.h b/lib/mbselib.h index 91c88a14..9985a093 100644 --- a/lib/mbselib.h +++ b/lib/mbselib.h @@ -4,7 +4,7 @@ * Purpose ...............: MBSE BBS main library header * ***************************************************************************** - * Copyright (C) 1997-2005 + * Copyright (C) 1997-2006 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -2203,6 +2203,7 @@ struct termios tbufs, tbufsavs; /* Structure for raw mode */ * From endian.c */ int le_int(int); +unsigned short le_us(unsigned short);