/* **********************************************************************
 * *	                                                               *
 * *             Miscellaneous Antenna Driver Routines                  *
 * *                                                                    *
 * **********************************************************************
 * File: libs/antenna/antsim_misc.c
 *
 *                   COPYRIGHT (c) 1989, 1991, 1994, 1999  BY
 *         SIGMET INCORPORATED, WESTFORD MASSACHUSETTS, U.S.A.
 *  
 * THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
 * ONLY  IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
 * INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE  OR  ANY OTHER
 * COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
 * OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
 * TRANSFERED.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "sigtypes.h"
#include "setup.h"
#include "user_lib.h"
#include "antenna_lib.h"
#include "antenna_int.h"

#define ANTSIM_GLOBAL_ALLOCATE 1
#include "antsim_global.h"

/* ------------------------------
 * Map the Antenna simulator global section if it has not been done already
 * by this process.
 *   jmh   18 Oct 1991   Init
 */
MESSAGE antsim_global_init
  (UINT2 *lcreated_a)
{
  MESSAGE istatus;
  static UINT2 lmapped = FALSE;

  *lcreated_a = FALSE;

  if( lmapped )
    {
      istatus = SS_NORMAL ;
    } 
  else
    {
      istatus = sig_shmem_map
	( sizeof(struct antsim_global), "iris_antsim", -1,
	 (void *)&pantsim_c, &antsim_size_c, &antsim_id_c, lcreated_a ) ;

      if( istatus == SS_NORMAL )
	{
	  lmapped = TRUE ;

	  if( *lcreated_a ) memset( (void *)pantsim_c, 0, antsim_size_c );
	}
    }

  return( istatus ) ;
}
