/**********************************************************************
 
	Copyright (C) 2003 Hirohisa MORI <joshua@nichibun.ac.jp>
 
	This program is free software; you can redistribute it 
	and/or modify it under the terms of the GLOBALBASE 
	Library General Public License (G-LGPL) as published by 

	http://www.globalbase.org/
 
	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.

**********************************************************************/


#ifndef ___ENDIAN_H___
#define ___ENDIAN_H___

extern char endian_flag;

#define change_endian(data) \
    if ( !endian_flag );else{\
        char tmp___;\
        int i___;\
        char *ptr___;\
        ptr___ = (char*)&(data);\
        for(i___=0 ;i___<sizeof(data)/2; ++i___){\
            tmp___ = *(ptr___+i___);\
            *(ptr___+i___) = *(ptr___+sizeof(data)-i___-1);\
            *(ptr___+sizeof(data)-i___-1) = tmp___;\
        }\
    }

#define change_endian_f change_endian
#define change_endian_d change_endian
#define change_endian_s change_endian
#define change_endian_i change_endian

#endif
