/*	swap.cpp
 *
 *		Swap utilities allow me to swap around the order of a 2 byte
 *	and 4 byte integer
 */

/*  RCompile - UNIX Resource compiler for YAAF Library
 *  Copyright (C) 1998 William Edward Woody
 *  
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 *  02111-1307, USA.
 *  
 *  To contact the author, either e-mail me at woody@pandawave.com, 
 *	or write to
 *  
 *          William Edward Woody
 *          In Phase Consulting
 *          1545 Ard Eevin Avenue
 *          Glendale, CA 91202
 *
 *	Or visit us on the web at http://www.pandawave.com
 */

#include "swap.h"

/************************************************************************/
/*																		*/
/*	Byte Swap Utilities													*/
/*																		*/
/************************************************************************/

/*	SwapWord
 *
 *		Swap this 2 byte word
 */

unsigned short SwapWord(unsigned short c)
{
	unsigned char tmp;
	unsigned char *ptr = (unsigned char *)&c;
	
	tmp = ptr[0];
	ptr[0] = ptr[1];
	ptr[1] = tmp;
	
	return c;
}

/*	SwapLong
 *
 *		Swap this four byte word
 */

unsigned long SwapLong(unsigned long c)
{
	unsigned char tmp;
	unsigned char *ptr = (unsigned char *)&c;
	
	tmp = ptr[0];
	ptr[0] = ptr[3];
	ptr[3] = tmp;
	tmp = ptr[1];
	ptr[1] = ptr[2];
	ptr[2] = tmp;
	
	return c;
}
