prop_logic.c

tmi2_fluffos_v2/lib/std/object/prop_logic.c · 1.5 KB

From the archive tmi2_fluffos_v2.zip

Download the archive   « Back to the archive contents

// This file is a part of the standard object system devised by Buddha.
// Currently under development. 

// This file is part of the TMI mudlib distribution.
// Please include this header if you use this code.
// Written by Buddha@TMI, modularized and revised (92-05-01)
// Expanded to use a superior security system by Buddha (92-05-31)
// Temporary flag attribute system added by Watcher (93-02-21)
// Altered by Pallando @ Tabor (93-03-17)

static nomask private mixed _query( mapping map, string *parts )
{
  mixed value;
  int i, s;

  value = map;
  s = sizeof( parts );
  for( i = 0 ; i < s ; i++ )
  {
    if( undefinedp( value = value[parts[i]] ) )
      break;
    if( !mapp( value ) )
      break;
  }
  return value;
}

static nomask private int _delete( mapping map, string *parts )
{
  if( sizeof( parts ) == 1 )
  {
    map_delete( map, parts[0] );
    return 1;
  }
  if( !map[parts[0]] || !mapp( map[parts[0]] ) )
    return 0;
  return _delete( map[parts[0]], parts[1..sizeof( parts )-1] );
}

static nomask private mixed _set( mapping map, string *parts, mixed value )
{
  mixed old_value;

// Leto 21-01-95 An old security hole closed (again?)
 // added following to stop any possible setting of '/'
        if (sizeof(parts) == 0) return;
  if( sizeof( parts ) == 1 )
  {
    old_value = map[parts[0]];
    map[parts[0]] = value;
    return old_value;
  }
  if( !map[parts[0]] || !mapp( map[parts[0]] ) )
    map[parts[0]] = ([ parts[1] : 0 ]);
  return _set( map[parts[0]], parts[1..<1], value );
}

Site Stats

Snippets: 1791
Codebases: 571