/*
 * This file is part of "VirtuaMUnstaz Demo Distribution".
 *
 * This 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, or (at your option)
 * any later version.
 *
 * "VirtuaMUnstaz Demo Distribution" 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 software; see the file COPYING.  If not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

/* $Id: util.h,v 2.5 2000/03/02 06:52:10 leo Exp $ */

#ifndef _UTIL_H_
#define _UTIL_H_

#define E_VMI_NOT_FOUND		1
#define E_VMS_NOT_FOUND		2
#define E_VMI_WRONG_EXTENSION	3
#define E_VMI_WRONG_FILESIZE	4
#define E_VMI_RESOURCE_NIL	5
#define E_VMI_FILE_NIL		6
#define E_VMS_IS_VMI		7
#define E_VMS_IS_LCD		8

#define E_FATAL_ERROR		99

#ifdef BIG_ENDIAN
  /* convert a 2 byte array to int */
  #define C2TOI(c) (((c[0] & 0xff) << 8) + (c[1] & 0xffff))
  #define ITOC2(c,i) ((c[0] = ((i) >> 8) & 0xff), (c[1] = (i) & 0xff), c)
  /* convert a 4 byte array to int */
  #define C4TOI(c) ((((c[0] & 0xff) << 24) + \
                     ((c[1] & 0xff) << 16) + \
	             ((c[2] & 0xff) <<  8) + (c[3] & 0xff)) & 0xffffffff)
#else
  /* convert a 2 byte array to int */
  #define C2TOI(c) ((((c[1] & 0xff) << 8) + (c[0] & 0xff)) & 0xffff)
  #define ITOC2(c,i) ((c[1] = ((i) >> 8) & 0xff), (c[0] = (i) & 0xff), c)
  /* convert a 4 byte array to int */
  #define C4TOI(c) ((((c[3] & 0xff) << 24) + \
                     ((c[2] & 0xff) << 16) + \
	             ((c[1] & 0xff) <<  8) + (c[0] & 0xff)) & 0xffffffff)
#endif


#endif _UTIL_H_
