MODIFIED.C
LIB3/SECURE/SIMUL_EF/MODIFIED.C · 3.5 KB
From the archive nm4dos.zip
Download the archive « Back to the archive contents
#define MAX_SIZE 50000
void exec( object from, object to )
{
if( !objectp( from ) || !objectp( to ) )
return;
if( "/secure/master"->valid_exec( file_name( previous_object() ) ) )
efun::exec( from, to );
return;
} /* exec() */
varargs void say( string str, mixed avoid )
{
if( !pointerp( avoid ) )
avoid = ({ this_player(), previous_object() })+({ avoid });
else
avoid += ({ this_player(), previous_object() });
if( !environment( previous_object() ) )
if( this_player() && environment( this_player() ) )
event( environment( this_player() ), "say", str, avoid );
else
event( previous_object(), "say", str, avoid );
else
{
if( environment( environment( previous_object() ) ) )
event( environment( environment( previous_object() ) ), "say", str, avoid );
else
event( environment( previous_object() ), "say", str, avoid );
}
} /* say() */
varargs void tell_room( object ob, string str, mixed avoid )
{
if( !ob || !objectp( ob ) )
return;
event( ob, "say", str, avoid );
} /* tell_room() */
void tell_object( object ob, string str )
{
if( objectp( ob ) )
ob->event_write( previous_object(), str );
} /* tell_object() */
object find_living( string str )
{
string nick;
object ob;
if( this_player() && (nick = (string)this_player()->
expand_nickname( str )) )
str = nick;
if( (ob = efun::find_living( str )) )
if( (int)ob->query_invis() == 2 )
{
if( member_array( this_player()->query_name(),
(object *)ob->query_allowed() ) == -1 )
return 0;
}
return ob;
} /* find_living() */
object find_player( string str )
{
object ob;
if( (ob = efun::find_player( str )) )
if( (int)ob->query_invis() == 2 )
if( member_array( this_player()->query_name(),
(object *)ob->query_allowed() ) == -1 )
return 0;
return ob;
} /* find_player() */
void log_file( string name, string mess )
{
if( !stringp( name ) || !stringp( mess ) )
return; // syntax error
#ifdef ORGLIB
if( -1 != strsrch( name, ".." ) )
return; // security error
#endif
if( file_size( "/log/" + name ) > MAX_SIZE )
{
seteuid( "Root" );
rm( "/log/" + name + ".old" );
rename( "/log/" + name, "/log/" + name + ".old" );
}
seteuid( "Root" );
write_file( "/log/" + name, mess );
seteuid( 0 );
} /* log_file() */
#ifdef MUD_NAME
string mud_name()
{
return capitalize( MUD_NAME );
} /* mud_name() */
#endif
void cat( string file, int start_line, int number )
{
string text;
seteuid( geteuid( previous_object() ) );
text = read_file( file, start_line, number );
seteuid( 0 );
if( text )
printf( "%s", text );
} /* cat() */
#define TB(x) if(find_player("bannor")) tell_object(find_player("bannor"),x)
int indent( string file )
{
string junk1, junk2;
TB( "indent: file= " + file + "\n" );
if( !file || !stringp( file ) )
return 0;
TB( "indent: file & stringp\n" );
/* disallow wild cards, or multiple file names */
if( sscanf( file, "%s*%s", junk1, junk2 ) == 2 )
return 0;
if( sscanf( file, "%s?%s", junk1, junk2 ) == 2 )
return 0;
if( sscanf( file, "%s %s", junk1, junk2 ) == 2 )
return 0;
TB( "indent: calling efun::indent\n" );
TB( "indent: file= \"" + file + "\"\n" );
#ifdef ORGLIB
return efun::indent( file );
#else
return 0;
#endif
} /* indent() */