/**********************************************************************
 *
 *   FreeDoko a Doppelkopf-Game
 *    
 *   Copyright (C) 2001-2004  by Diether Knof and Borg Enders
 *
 *   This program is free software; you can redistribute it and/or 
 *   modify it under the terms of the GNU General Public License as 
 *   published by the Free Software Foundation; either version 2 of 
 *   the License, or (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details. 
 *   You can find this license in the file 'gpl.txt'.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 *   MA  02111-1307  USA
 *
 *  Contact:
 *    Diether Knof dknof@gmx.de
 *    Borg Enders  borg@borgsoft.de
 *
 **********************************************************************/

#ifndef HEADER_UTILS
#define HEADER_UTILS

// some utils
// D.K.

#include "class/readconfig/readconfig.h"
#include "utils/private.h"

#define QUAD(x) ((x) * (x))

#undef VOID
#define VOID

#define PSEUDO_RAND_MAX 279840
// sets the seed of the pseudo random function
unsigned pseudo_rand_set(unsigned const pseudo_seed);
// gets the next pseudo random number
// the function is: r = (a * r + c) % m (see definition)
unsigned pseudo_rand_next();


unsigned
RAND(unsigned const x);

#ifdef MS_VISUAL_C
template<typename T>
inline T const& max(T const& a, T const& b)
{
  return ((a > b) ? a : b);
}
template<typename T>
inline T const& min(T const& a, T const& b)
{
  return ((a < b) ? a : b);
}
#endif

inline unsigned
MARK(char const* const string = NULL, bool increase = true)
{
  static unsigned int mark_nr = 0;
  if (increase)
    mark_nr += 1;

  if (string != NULL)
    cerr << mark_nr << ": " << string << endl;
  else
    cerr << mark_nr << endl;

  return mark_nr;
} // MARK()


// file-utils


// all things written into this stream are ignored
class Null_Str : public std::ostream {
  public:
    Null_Str() : std::ostream(NULL) {}

    template <class T>
      const Null_Str& operator<<(T const& t) const
      { return *this; }
  private:
};
extern const Null_Str null_str;


// generate an error
void generate_error(std::string const error_message = "generated error");

#endif // #ifndef HEADER_UTILS
