<?php
/**
 * The Zoo
 *
 * @copyright  (c) 2007 OSI
 * @author     Frédéric G. MARAND
 * @license    Licensed under the CeCILL 2.0
 * @version    CVS: $Id: misc.php,v 1.3 2007-06-10 16:30:30 marand Exp $
 * @link       http://drupal.org/project/offload
 * @since      Not applicable yet
 * @package    default
 */

interface Comparable_Interface
  {
  /**
   * Compare the current instance
   *
   * @param Comparable_Interface $other
   * @return int
   */
  public function cmp(Comparable_Interface $other);
  }

function _debug($msg)
  {
  global $_debug_active ;

  if ($_debug_active)
    echo $msg;
  }

function __autoload($name)
  {
  _debug("Autoloading $name\n");
  require_once("$name.php");
  }

function get_temp_dir()
  {
  return 'e:/src/OsinetOffice/tmp';
  }

/**
 * @link http://blog.riff.org/2006_11_19_console_encoding_in_php_gtk_apps
 *
 * @param string $s
 * @return string
 */
function output_encoder($s)
  {
  return iconv('UTF-8', 'IBM850', $s);
  }

// Activate the OB handler:
ob_start("output_encoder", 2);

/**
 * automatically find the glade file for a class file
 *
 */
function load_glade()
  {
  return new GladeXML(basename($_SERVER['PHP_SELF'], 'php') . 'glade');
  }

/**
 * returns the name of the invoking function/method
 * if it's a method, it is prefixed by the class name
 *
 * @return string
 */
function func_name()
  {
  $trace = debug_backtrace();
  $func = $trace[1]['function'];
  if (isset($trace[1]['class']))
    $func = $trace[1]['class'] . '::' . $func;
  return $func;
  }