int is_pike_master = 0;
// This integer variable should exist in any object that aspires to be// the master. It gets set to 1 when the master is installed, and is// therefore set in any object that is or has been the master. That// makes the Encoder class encode references to the master and all// ex-masters as references to the current master object.

//! The master filesystem defaults to the system filesystem,//! but additional mountpoints may be added via//! @[add_filesystem_handler()].//!//! All file I/O performed by the @[MasterObject] is performed//! via this function and its related functions.//!//! @seealso//! @[add_filesystem_handler()], @[find_handler_for_path()],//! @[master_get_dir()], @[master_file_stat()]

//! mount a filesystem handler to be used by the resolver. on its own does noting,//! but may be used with @[add_module_path] and friends to enable modules to be loaded//! from Filesystem objects.//!//! @param mountpoint//! the location in the filesystem to mount the handler//!//! @param filesystem//! a filesystem object that will handle requests for the given mountpoint.//!//! @example//! master()->add_filesystem_handler("/foo/bar.zip", Filesystem.Zip("/foo/bar.zip"));//! master()->add_module_path("/foo/bar.zip/lib");//!

//! Queries the environment variables.//!//! @param force_update//! A cached copy of the real environment is kept to make this//! function quicker. If the optional flag @[force_update] is nonzero//! then the real environment is queried and the cache is updated from//! it. That can be necessary if the environment changes through other//! means than @[putenv], typically from a C-level library.

//! Compile the Pike code contained in the file @[filename] into a program.//!//! This function will compile the file @[filename] to a Pike program that can//! later be instantiated. It is the same as doing

// Do not treat errors from dlopen(3) as exceptions since in// a dist we can have .so files that are dynamically linked// against libraries that don't exist on the system, and in// that case we should just treat the module as nonexisting.//// What we really want is to do this only for errors that// are due to nonexisting files, but the error reporting// from dlerror(3) doesn't allow us to tell those from other// errors.
call_compile_warning (handler, fname,

//! This function is called when the driver wants to cast a string//! to a program, this might be because of an explicit cast, an inherit//! or a implict cast. In the future it might receive more arguments,//! to aid the master finding the right program.

//! This function is called in runtime check_types mode (@tt{-rt@}),//! when encountering a soft cast to an attributed type.//!//! @param value//! Value that is about to receive the attribute.//!//! @param attribute//! Type attribute to validate.//!//! @returns//! Returns one of://! @int//! @value 1//! If the attribute is valid for the value.//! @value 0//! If the attribute is not valid for the value.//! @value UNDEFINED//! If the attribute is unsupported.//! @endint//!//! The default master implements validation of the @expr{"utf8"@}//! attribute.
optional int(0..1) handle_attribute(mixed value, string attribute){switch(attribute){#if constant(validate_utf8)
case"utf8":
return stringp(value) && validate_utf8(value, 3);
#endif
}return UNDEFINED;
}

//! This function is called whenever a inherit is called for.//! It is supposed to return the program to inherit.//! The first argument is the argument given to inherit, and the second//! is the file name of the program currently compiling. Note that the//! file name can be changed with #line, or set by compile_string, so//! it can not be 100% trusted to be a filename.//! previous_object(), can be virtually anything in this function, as it//! is called from the compiler.

// findmodule() failed. This can occur due to circularities// between encode_value()'ed programs.// The error will then typically be:// "Cannot call functions in unfinished objects."// Pretend not to exist for now...

}
resolv_debug("dirnode(%O)->ind(%O) casting (object)%O\n",
dirname, index, fname);
// FIXME: cast_to_program() and cast_to_object()// have lots of overhead to guess the proper// filename. This overhead isn't needed in// our cases, so we could make do with// low_findprog() and the caches.mixed ret;

// Note: Cannot index cache at all here to filter out the// ZERO_TYPE values since that can change the order in the// mapping, and _indices() has to return the elements in the same// order as a nearby _values() call.return filter (indices (cache), map (values (cache), `!=, ZERO_TYPE));

// Note: Cannot index cache at all here to filter out the// ZERO_TYPE values since that can change the order in the// mapping, and _indices() has to return the elements in the same// order as a nearby _values() call.return filter (indices (cache), map (values (cache), `!=, ZERO_TYPE));

//! Add a directory to search for include files.//!//! This is the same as the command line option @tt{-I@}.//!//! @note//! Note that the added directory will only be searched when using//! < > to quote the included file.//!//! @seealso//! @[remove_include_path()]//!

{
resolv_debug ("%O->get_default_module()\n", this);
/* This is an ugly kluge to avoid an infinite recursion. The
* infinite recursion occurs because this function is called for
* every file when the compat_major/minor is set. This kluge
* could cause problems with threads if the compiler was
* threaded. -Hubbe
*/int saved_compat_minor=compat_minor;
int saved_compat_major=compat_major;
compat_minor=-1;
compat_major=-1;
mixed x;
mixed err =catch{

//! @class __dirnode//! @decl inherit MasterObject.dirnode//! @endclass//! @class __joinnode//! @decl inherit MasterObject.joinnode//! @endclass//! @decl void add_include_path(string tmp)//! Add a directory to search for include files.//!//! This is the same as the command line option @tt{-I@}.//!//! @note//! Note that the added directory will only be searched when using//! < > to quote the included file.//!//! @seealso//! @[remove_include_path()]//!//! @decl void remove_include_path(string tmp)//! Remove a directory to search for include files.//!//! This function performs the reverse operation of @[add_include_path()].//!//! @seealso//! @[add_include_path()]//!//! @decl void add_module_path(string path, string|void subpath)//! Add a directory to search for modules.//!//! This is the same as the command line option @tt{-M@}.//!//! @seealso//! @[remove_module_path()]//!//! @param path//! a string containing a path to search for Pike modules. May be a//! directory, or a path to a ZIP archive. If a ZIP archive path is//! provided, modules will be loaded from a directory, "modules" within//! the ZIP archive (see the subpath argument).//!//! @param subpath//! if path is a ZIP archive, this argument will determine the path within//! the archive to be searched.//!//! @decl void remove_module_path(string tmp)//! Remove a directory to search for modules.//!//! This function performs the reverse operation of @[add_module_path()].//!//! @seealso//! @[add_module_path()]//!//! @decl void add_program_path(string tmp)//! Add a directory to search for programs.//!//! This is the same as the command line option @tt{-P@}.//!//! @seealso//! @[remove_program_path()]//!//! @decl void remove_program_path(string tmp)//! Remove a directory to search for programs.//!//! This function performs the reverse operation of @[add_program_path()].//!//! @seealso//! @[add_program_path()]//!

// TODO: this seems like a backward approach. The debugger should register its completer on startup.// callback for completing breakpoint registration for programs which weren't loaded// at the time of the breakpoint's creation.function deferred_breakpoint_completer;
mixed program_loaded(string fn, mixed c){if(deferred_breakpoint_completer) deferred_breakpoint_completer(fn, c); return c;}

"Pike comes with ABSOLUTELY NO WARRANTY; This is free software and you are\n""welcome to redistribute it under certain conditions; read the files\n""COPYING and COPYRIGHT in the Pike distribution for more details.\n"));

mixed ret;
mixed err = catch{// One reason for this catch is to get a new call to// eval_instruction in interpret.c so that the debug and// trace levels set above take effect in the bytecode// evaluator.

mixed err = catch{// The main reason for this catch is actually to get a new call// to eval_instruction in interpret.c so that the debug and// trace levels set above take effect in the bytecode evaluator.

//! Set the compile error, warning and exception behaviour.//!//! @param behaviour//! The desired behaviour. One of://! @mixed//! @type int(0..0)//! Output compilation errors and warnings to @tt{stderr@}.//! This is the default behaviour.//! @type int(1..1)//! Inhibit output of compilator diagnostics.//! @type function(string, int, string:void)//! Function to call for compilation errors. Compilation//! warnings and exceptions are inhibited.//!//! The function will be called with the same arguments//! as those passed to @[compile_error()].//! @type CompilationHandler//! Compilation handler to use for diagnostics.//! @endmixed//!//! @note//! Note that the behaviour is thread local, and is not copied//! to new threads when they are created.//!//! @seealso//! @[get_inhibit_compile_errors()]void set_inhibit_compile_errors(mixed behaviour)

/* getcwd() can fail, but since this is called from handle_error(),
* we don't want to fail, so we don't care about that.
*/catch{string cwd=getcwd();
if(sizeof(cwd) && (cwd[-1] != '/')){
cwd += "/";
}

if(objectp (trace) && ([object]trace)->is_cpp_or_compilation_error)// Errors thrown by cpp(), compile() or a compile callback should// be reported as a normal compile error, so let the caller do// just that.

//! Called for every runtime warning. The first argument identifies//! where the warning comes from, the second identifies the specific//! message, and the rest depends on that. See code below for currently//! implemented warnings.

// Ensure that we don't lose any relevant ident assignments// due to the clipping.//// Note that this means that we may get duplicate assignments// for the same value and/or unused ident numbers, but this// is better than getting getting references to ident numbers// without any assignent. Cf [PIKE-141].
ident = saved_ident;