tfe-1.0/area/
tfe-1.0/files/
tfe-1.0/logs/
tfe-1.0/logs/immortal/
tfe-1.0/logs/mob/
tfe-1.0/logs/object/
tfe-1.0/logs/player/
tfe-1.0/logs/room/
tfe-1.0/notes/clans/
tfe-1.0/player/
tfe-1.0/prev/
tfe-1.0/prev/area/
tfe-1.0/prev/player/
tfe-1.0/prev/rooms/
tfe-1.0/rooms/
tfe-1.0/src-gc/
tfe-1.0/src-msvc/
tfe-1.0/src-unix/
tfe-1.0/www/
tfe-1.0/www/html/
#include <ctype.h>
#include <sys/types.h>
#include <stdio.h>
#include <syslog.h>
#include "define.h"
#include "struct.h"


/*
 *   BIT ROUTINES
 */



const char* true_false( int* array, int bit )
{
  int i = bit/32;
  int j = bit-32*i;

  if( ( array[i] & ( 1 << j ) ) != 0 )
    return "true";

  return "false";
}


const char* yes_no( int* array, int bit )
{
  int i = bit/32;
  int j = bit-32*i;

  if( ( array[i] & ( 1 << j ) ) != 0 )
    return "yes";

  return "no";
}


const char* on_off( int* array, int bit )
{
  int i = bit/32;
  int j = bit-32*i;

  if( ( array[i] & ( 1 << j ) ) != 0 )
    return "on";

  return "off";
}


/*
 *  INTEGER PACKING
 */


int pack_int( int* value )
{
  int byte;

  byte = value[0]+( value[1] << 8 )+( value[2] << 16 )
    +( value[3] << 24 ); 
  
  return byte;
}


int* unpack_int( int byte )
{
  static int value [4];

  value[0] = ( byte & 0xff );
  value[1] = ( ( byte >> 8 ) & 0xff ); 
  value[2] = ( ( byte >> 16 ) & 0xff );
  value[3] = ( ( byte >> 24 ) & 0xff );

  return value;
}


/*
 *   SEARCHES
 */


int search( int* list, int max, int value )
{
  int      min  = 0;
  int      mid;

  if( list == NULL )
    return -1;

  max--;

  for( ; ; ) {
    if( max < min )
      return -min-1;

    mid = (max+min)/2;

    if( value == list[mid] )
      break;
    if( value < list[mid] )
      min = mid+1;
    else 
      max = mid-1;
    }

  return mid;
}