/**********************************************************************
Common module

$Id: common.h,v 1.4 2003/01/19 23:17:09 purnhage Exp $

Header file: common.h

(c) Heiko Purnhagen 1996-2003
e-mail: purnhage@tnt.uni-hannover.de
WWW:    http://www.tnt.uni-hannover.de/~purnhage/

This module is available under the terms of the GNU Lesser General
Public License. See file COPYING-LGPL for further details. All usual
disclaimers apply!

Authors:
HP    Heiko Purnhagen, Uni Hannover <purnhage@tnt.uni-hannover.de>

Changes:
06-jun-96   HP    new module based on ErrorMsg() from cmdline module
25-jun-96   HP    added CommonFreeAlloc()
04-jul-96   HP    added stdlib.h
26-aug-96   HP    CVS
25-jun-97   HP    added random()
11-feb-98   HP    renamed random() to random1()
15-feb-00   HP    added random1init()
**********************************************************************/


#ifndef _common_h_
#define _common_h_

#include <stdlib.h>		/* typedef size_t */


/* ---------- declarations ---------- */

#define RND_MAX 0x7fffffff


/* ---------- functions ---------- */

#ifdef __cplusplus
extern "C" {
#endif


/* CommonFreeAlloc() */
/* Free previously allocated memory if present, then allocate new memory. */

void *CommonFreeAlloc (
  void **ptr,			/* in/out: addr of memory pointer */
  size_t size);			/* in: memory size */
				/* returns: memory pointer */
				/*          or NULL if error*/


/* CommonProgName() */
/* Set program name for error/warning message. */

void CommonProgName (
  char *progName);		/* in: program name */


/* CommonWarning() */
/* Print program name and warning message to stderr. */

void CommonWarning (
  char *message,		/* in: warning message */
  ...);				/* in: args as for printf */


/* CommonExit() */
/* Print program name and error message to stderr and exit program. */

void CommonExit (
  int errorCode,		/* in: error code for exit() */
  char *message,		/* in: error message */
  ...);				/* in: args as for printf */


/* random1() */
/* Generate random long (uniform distribution 0..RND_MAX). */

long random1 (void);


/* random1init() */
/* Init seed / period of random1(). */

void random1init (
  long seed,		/* in: random seed */
  long period);		/* in: period of rand. sequence (0=+inf) */


#ifdef __cplusplus
}
#endif

#endif	/* #ifndef _common_h_ */

/* end of common.h */

