/*-------------------------------------------------------------------------
 * Name:   static.h
 * Author: ITEX C-Code Generator
 *
 * Copyright 1999-2000 Telelogic AB, All rights reserved.
 * 
 * This Program is owned by Telelogic and is protected by national
 * copyright laws and international copyright treaties. Telelogic
 * grants you the right to use this Program on one computer or in one
 * local computer network at any one time.  Under this License you may
 * only modify the source code for the purpose of adapting it to your
 * environment. You must reproduce and include any copyright and
 * trademark notices on all copies of the source code.  You may not
 * use, copy, merge, modify or transfer the Program except as provided
 * in this License.  Telelogic does not warrant that the Program will
 * meet your requirements or that the operation of the Program will be
 * uninterrupted and error free. You are solely responsible that the
 * selection of the Program and the modification of the source code
 * will achieve your intended results and that the results are
 * actually obtained.
 */
#ifndef STATIC_H
#define STATIC_H

#include "gcidefs.h"

#include <stdio.h>
#include <limits.h>

/*-------------------------------------------------------------------------
   OS WRAPPERS 
---------------------------------------------------------------------------*/

#define VCREALLOC realloc

char *VCSTRCPY( char *strDestination, const char *strSource );
int VCSTRLEN( const char *string );
int VCSTRCMP( const char *string1, const char *string2 );
char *VCSTRCAT( char *strDestination, const char *strSource );

/*-------------------------------------------------------------------------
  Constants definitions
---------------------------------------------------------------------------*/

#ifndef VcPLUS_INFINITY
#define VcPLUS_INFINITY  INT_MAX
#endif
#ifndef VcMINUS_INFINITY
#define VcMINUS_INFINITY INT_MIN
#endif
#ifndef VcMAX
#define VcMAX            INT_MAX
#endif
#ifndef VcMIN
#define VcMIN            INT_MIN
#endif


/* The amount of elements a SET/SEQUENCE grows in case of overrrun */ 
#define vc_growth_size 10
#define VcNULL 0

#define MAX_HEXSTRING_LENGTH  48
#define MAX_BITSTRING_LENGTH  96

#define NO_MORE_LINES -1
#define RUN_DEFAULTS  -2

/* The identifier for "all timers in this context". */
#define GcANY_TIMERD -1

/* The identifier for "use default duration for timer". */
#define GcDEFAULT_DURATION (long) (-1)

/* The identifier for "all PTCs when DONE" */
#define GcALL_PTCs -1

/* Definitions for runtime debugging */
#define ICDEBUGQUEUES 1
#define ICDEBUGTIMERS 2

/*-------------------------------------------------------------------------
  This is used to denote the end of a TTCN default list.
*/
#define GciNO_MORE_DEFAULTS -1

/*-------------------------------------------------------------------------
  Mapping of old basetype identifiers to new 
---------------------------------------------------------------------------*/

#define GcNUMERICSTRINGD    GcNumericStringD
#define GcPRINTABLESTRINGD  GcPrintableStringD 
#define GcTELETEXSTRINGD    GcTeletexStringD   
#define GcT61STRINGD        GcT61StringD       
#define GcVIDEOTEXSTRINGD   GcVideotexStringD  
#define GcVISIBLESTRINGD    GcVisibleStringD   
#define GcISO646STRINGD     GcISO646StringD    
#define GcIA5STRINGD        GcIA5StringD       
#define GcGRAPHICSTRINGD    GcGraphicStringD   
#define GcGENERALSTRINGD    GcGeneralStringD   
#define GcOBJECTDESCRIPTORD GcObjectDescriptorD
#define GcUTCTIMED          GcUTCTimeD         
#define GcGENERALIZEDTIMED  GcGeneralizedTimeD 
/*x-seanpo ---begin--- BUG=ccg_1009683 (Part 2)*/
/*-------------------------------------------------------------------------
  Bit flags for TestStep functions 
---------------------------------------------------------------------------*/
#define GcIS_PTC							1
#define GcIS_REPEAT						2
/*x-seanpo ---end---*/

/*-------------------------------------------------------------------------
  Forward declarations of types used by value operations 
---------------------------------------------------------------------------*/
typedef struct GciValueRestriction GciValueRestriction;
typedef struct VcLogType* VcLogType;
typedef struct VcNameType VcNameType;
typedef struct VcRTContext VcRTContext;
typedef int VcTypeID;
typedef int GciDefaultPosition;

/*-------------------------------------------------------------------------
  External Constants definitions
---------------------------------------------------------------------------*/
extern const unsigned VcTypeTableSize;
extern const unsigned VcByRefSize;
extern const unsigned VcTagTableSize;
extern VcRTContext*   _master;
extern const int NUM_TS_PARAMETERS;
extern const int NUM_TS_CONSTANTS;
extern const int NUM_TS_VARIABLES;
extern const int NUM_TC_VARIABLES;
extern const int NUM_TIMERS;
extern const int NUM_PCOS;
extern const int NUM_CPS;
extern const int VcANY_PCOD;

/***************************************************************************
  Type declarations
****************************************************************************/

GciValue *GciReadTSPar(char*, char*);


/*-------------------------------------------------------------------------------------------------
  @enum Value restrictions | Identifiers for the various matching restriction types.
 */
typedef enum 
{ VcCOMPLEMENT,   /* @emem Value must differ from specified. */
  VcOMIT,         /* @emem Value does not need to be present. */
  VcANYVALUE,     /* @emem Any value will do. */
  VcANYOROMIT,    /* @emem Any or even no value is just fine. */
  VcVALUELIST,    /* @emem These values are allowed. */
  VcVALUERANGE,   /* @emem The values in this interval are allowed. */
  VcSUPERSET,     /* @emem At least these values must be present. */
  VcSUBSET,       /* @emem At least one of these values must be present. */
  VcPERMUTATION  /* @emem Any combination of these values will do. */
} VcInsteadOfValueType;

/*-------------------------------------------------------------------------------------------------
  @struct VcNameValue | A name and integer value pair. This structure is used by the VcTypeEnumerated 
*/
typedef struct VcNameValue
{
  char* name;         /* @field name */
  int   value;        /* @field An integer value */
} VcNameValue;

/*-------------------------------------------------------------------------------------------------
  @struct VcNameType | This structure is used in the VcTypeChoice. It
                       contains a name, a tag and a type id. 
*/
struct VcNameType {
  const char*     name;             /* @field name */
  VcTypeID        type;             /* @field type identifier */
};

typedef struct VcTagTable
{
  int _class;       /* FIX this! */
  int tag;          /* Since this typedef is included from another C file */
  VcTypeID type_id; /* Lint can't find it's usage. This is a bit unorthodox */
} VcTagTable;       /* but sometimes even a .c file can masquerade itself as .h */


/*-------------------------------------------------------------------------------------------------
  @struct GciValueList | A linked list of value pointers 
*/

/*x-seanpo ---begin--- BUG=ccg_1009683 (Part 2)*/
typedef GciTestResult (*GciDefaultFunction)(GciValue**, VcRTContext*, Bool*);
/*x-seanpo ---end---*/

typedef struct GciValueList
{
  GciValue*			      value; /* @field pointer to the value */
  struct GciValueList	*next; /* @field pointer to the next element in the list */
} GciValueList;

typedef struct ttcn_default {
  GciDefaultFunction  function;             /* @field Pointer to the generated default function. */
  int                 number_of_arguments;  /* @field Number of actual parameters to the function. */
  GciValue**          actual_args;          /* @field Array of parameters to the function. */
} GciDefault;

typedef struct GciDefaultList {
  int             number_of_defaults; /* @field The number of defaults in the list. */
  GciDefault*     elements;           /* @field Array of defaults. */
} GciDefaultList;

/*x-seanpo ---begin--- BUG=ccg_1009683 (Part 2)*/
/*typedef GciTestResult (*GciTestStepFunction)(GciValue**, GciDefaultList *, VcRTContext*, Bool );*/
typedef GciTestResult (*GciTestStepFunction)(GciValue**, GciDefaultList *, VcRTContext*, int, Bool* );
/*x-seanpo ---end--- */
typedef GciTestResult (*GciTestCaseOrGroupFunction)(VcRTContext* );
typedef Bool (*GciSelectionFunction)(VcRTContext*);

/*-------------------------------------------------------------------------
  @struct Contains the mapping from a test case/group name to function
          pointers for the generated function itself, and its associated
          selection expression.
*/
typedef struct IcTCData {
  char* tc_name;                          /* @field Name of test case/group. */
  GciTestCaseOrGroupFunction tc_function; /* @field Pointer to its function. */
  GciSelectionFunction tc_selexpr;        /* @field Pointer to selection expression. */
  int config_reference;                   /* @field Offset to configuration data in the configuration table */
} IcTCData;


/*-------------------------------------------------------------------------
  @struct Contains the mapping from a test step name to function
          pointers for the generated function itself.
*/
typedef struct IcTSData {
  char* ts_name;                   /* @field Name of test step. */
  GciTestStepFunction ts_function; /* @field Pointer to its function. */
} IcTSData;


/*--------------------------------------------------------------------------
  Type declaration of function pointers.
----------------------------------------------------------------------------*/

/* Constructor function definition for creating a value */
typedef GciStatus (*GciValueBuild_Func)  (GciValue*); 
/* Destructor function definition for destroing a value */
typedef void      (*GciValueFree_Func)   (GciValue*); 
/* Assignment function definition for a value of a specific type */
typedef GciStatus (*GciValueAssign_Func) (GciValue*, GciValue*, Bool);
/* Copy function for of a value of a specific type */
typedef GciStatus (*GciValueCopy_Func)(GciValue*,GciValue**, Bool);
/* Function pointer declarations for type restriction functions for base types.*/
typedef Bool (*VcTypeRestrCheck)(GciValue*, VcRTContext*);

typedef unsigned (*GciPadding_Func)();

/******************************************************************
 * Structure for keeping track of imported ASN.1 type names.
 */

typedef struct VcByRefTable
{
  VcTypeID ttcn_type_id;
  const char *asn1_module_name;
  const char *asn1_type_name;
} VcByRefTable;

/******************************************************************
@struct The "abstract" type definition. The VcType is the union of 
all base types. This Structure should not be used by 
itself it should only be used in values and this type will
not be accessable outside this file scope.
*/
typedef struct VcType
{
  struct VcType       *parent;                /* @field Pointer to it's parent type. NULL if this is a basetype. */ 
  VcTypeID            type_id;                /* @field Type identifier. Each type has an unique id. */
  const char*         name;                   /* @field The name of the type in string form */
  
  VcTypeRestrCheck    restriction_function;   /* @field Pointer to a restriction function */
  
  int                 is_pdu;                 /* @0 no PDU, 1 PDU, 2 CM */
  GciTagClass         tag_class;              /* @field can take the values UNIVERSAL, APPLICATION, CONTEXT  and PRIVATE */
  int                 tag;
  Bool                is_explicit;            /* @field IMPLICIT/EXPLICIT flag */
  Bool                is_really_a_type;       /* If this is a noname type only because of a tag, it is not really a type. 
                                                 This information is primarily (only) used when GciGetType is called. */

  GciValueBuild_Func  constructor;            /* @field A function pointer to this types constructor. */
  GciValueFree_Func   destructor;             /* @field A function pointer to this types destroys */
  GciValueAssign_Func assign;                 /* @field A function pointer to this types assignmen
                                               operator. */
  GciValueCopy_Func   copy;                   /* @field A function pointer to this types copy constructor */
  char*               encoding_definition;    /* @field Encoding rules used for pdu types. */
  unsigned int        number_of_members;      /* @field Number of defined items used in enum types. */
  VcNameValue*        named_members;          /* @field The members of the enum */ 
  VcNameType*         choice_members;
  VcTypeID            underlying_type;        /* @field Used for SETOF and SEQUENCEOF to indicate the type of the members */
  GciPadding_Func     padding_function;                                     
} VcType;

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

/*********************
  Error handling 
**********************/

/* Enum stolen from errorhandling.h */
#ifndef __E_CLASSES_DEF
#define __E_CLASSES_DEF

/* Stolen from errorhandling.h */
typedef enum {
  E_INT, /* An unexpected error of the internal implementation. */
  E_EXT, /* An error most likely due to usage of the GCI API or similar. */
  E_NONE /* Any kind of error. */
} E_CLASSES;

const char*     EBM(const char* fmt, ...);

#define EGciSetLastError(eclass, errmsg) \
VcAddError((eclass), (errmsg), __FILE__, __LINE__);

/* Stolen declaration from errorhandling.h */
void VcAddError(E_CLASSES eclass, const char* errmsg, const char* name, int num);

#endif

#define E_STR(s) (((s) != NULL) ? (s) : "<unknown>")

#define E_ILLEGAL_SIZE(name, size)     EBM("Illegal size (%d) value (for '%s').", (size), E_STR(name))
#define E_NULL_PARAMETER(par)          EBM("Parameter %d may not be NULL.", par)
#define E_NEGATIVE_PARAMETER(par, val) EBM("Parameter '%s' may not be negative (%d).", E_STR(par), (val))

#define E_OUT_OF_MEMORY(size, tmp)     EBM("Failed to allocate %d bytes of %s memory.", (size), ((tmp) == GcFALSE) ? "permanent" : "temporary")
#define E_DIFFERENT_MEMORY_TYPES()     EBM("The values has been allocated using different memory strategies.")
#define E_BAD_LINE_NUMBER(line, tab)   EBM("Bad line number %d in table '%s'.", (line), E_STR(tab))
/*x-seanpo ---begin--- BUG=ccg_1009683 (Part 2)*/
#define E_NO_MATCHED_ALTERNATIVES(line, tab)   EBM("None of the set of alternatives can ever match. (Line: %d Table: '%s')", (line), E_STR(tab))
/*x-seanpo ---end---*/


/*********************
  Type api functions
**********************/

/*-------------------------------------------------------------------------------------------------
  @func Returns the parent to this type
  
  @parm   const VcType | *type | Pointer to the type structure.

  @rdesc  Pointer to the parent type structure.
*/
VcType* VcTypeGetParent(const VcType* type);

/*-------------------------------------------------------------------------------------------------
  @func Returns the type id of this type

  @parm const VcType | *type | Pointer to the type structure,

  @rdesc VcTypeID
*/
VcTypeID VcTypeGetTypeID(const VcType* type);
VcTypeID VcTypeGetTypeIDSkipNotRealTypes(const VcType* type);

/*-------------------------------------------------------------------------------------------------
  @func Returns the name of the type

  @parm const VcType | *type | Pointer to the type structure

  @rdesc The name of the type as a null terminated string
*/
const char* VcTypeGetName(const VcType *type);

/*-------------------------------------------------------------------------------------------------
  @func Access method to the type restriction function.

  @parm const VcType | *type | Pointer to the type structure

  @rdesc Pointer to the restriction check function.
*/
VcTypeRestrCheck VcTypeGetRestrictionFunction(const VcType* type);

/*-------------------------------------------------------------------------------------------------
  @func Returns a flag GcTRUE/GcFALSE if the type is a pdu type.

  @parm const VcType | *type | Pointer to type structure.

  @rdesc GcTRUE/GcFALSE
*/
Bool VcTypeGetIsPdu(const VcType *type);

/*--------------------------------------------------------------------------------
  @func Sets the is_pdu field
  @parm const VcType | *type | Pointer to type structure.

*/
void VcTypeSetIsPdu(VcType *type, Bool is_pdu);

/*-----------------------------------------------------------------------
@func Check whether the attached value has the PDU ability.

  @parm GciValue | *value | Pointer to the value.
  
    @rdesc  GcTRUE if the value has the PDU ability.
*/

Bool VcIsPDU(GciValue* value);

/*-------------------------------------------------------------------------------------------------
  @func Returns type tag class of the type. A tag class is one of the following values
        GcUNIVERSAL, GcAPPLICATION, GcCONTEXT or GcPRIVATE

  @parm const VcType | *type | Pointer to type structure.

  @rdesc The tag class of the type.
*/
GciTagClass VcTypeGetTagClass(const VcType *type);

/*-------------------------------------------------------------------------------------------------
  @func Returns type tag value of the class.

  @parm const VcType | *type | Pointer to type structure.

  @rdesc The tag value of the type.
*/
int VcTypeGetTag(const VcType *type);

/*-------------------------------------------------------------------------------------------------
  @func  Access method for the is_explicit field in the type
         structure

  @parm  const VcType | *type | Pointer to the type structure
  @parm  Bool | *flag | Output parameter GcTRUE/GcFALSE

  @rdesc GciOk if the function succeeds and GciNotOk if an
         error occurs. */
Bool VcTypeGetExplicit(const VcType* value);

/*-------------------------------------------------------------------------------------------------
  @func  Accessmetod for the constructor function.

  @parm  const VcType | *type | Pointer to the type structure

  @rdesc pointer to the constructor function, NULL if no constructor found.
*/
GciValueBuild_Func VcTypeGetConstructor(const VcType* type);

/*-------------------------------------------------------------------------------------------------
  @func   Accessmethod for the destructor function

  @parm   const VcType | *type | Pointer to the type structure

  @rdesc  Pointer to the destructor function, NULL if no destructor found.
*/
GciValueFree_Func VcTypeGetDestructor(const VcType *type);

/*-------------------------------------------------------------------------------------------------
  @func   Accessmethod for the assignment function.

  @parm   const VcType | *type | Pointer to the type structure

  @rdesc  Pointer to the assignment function
*/
GciValueAssign_Func VcTypeGetAssign(const VcType *type);

/*-------------------------------------------------------------------------------------------------
  @func Accessmethod for the copy function

  @parm const VcType | *type | Pointer to the copy function

  @rdesc Pointer to the copy function, NULL if not function found.
*/
GciValueCopy_Func VcTypeGetCopyConstructor(const VcType *type);

/*-------------------------------------------------------------------------------------------------
  @func Accessmethod for the copy function

  @parm const VcType | *type | Pointer to the copy function

  @rdesc Pointer to the copy function, NULL if not function found.
*/
const char* VcTypeGetEncodingDefinition(const VcType *type);

/*-------------------------------------------------------------------------------------------------
  @func Access method for the retreiving the number of members. It coud be members of
        an ENUM, Named numbers etc.

  @parm const VcType | *type | Pointer to the type structure.

  @rdesc number of members.
*/
unsigned int VcTypeGetNumberOfMembers(const VcType *type);

/*-------------------------------------------------------------------------------------------------
  @func Access method for the named members list.

  @parm VcType | *type | Pointer to the type structure.

  @rdesc Pointer to the name value list. NULL if no name value list found.
*/
VcNameValue* VcTypeGetNamedMembers(const VcType *type);

/*-------------------------------------------------------------------------------------------------
  @func   Access method for the choice member list. This is a list of Name and types.

  @parm   const VcType | *type | Pointer to the type structure.

  @rdesc  Pointer to the name type list. NULL if the choice does not have any defined 
          "members".
*/
VcNameType* VcTypeGetChoiceMembers(const VcType *type);

/*-------------------------------------------------------------------------------------------------
  @func Queries the CHOICE type for a list of all allowed types in this instance.

  @parm GciValue*     | value        |  Pointer to the CHOICE.
  @parm VcNameType** | allowed_types| [out] A list of all allowed types.

  @rdesc GciOk on success.
*/
GciStatus VcGetAllowedTypes(GciValue* value, VcNameType** allowed_types);

/*-------------------------------------------------------------------------------------------------
  @func   Access method for the underlying type member. Used for SETOF and SEQUENCEOF 
          types.
  
  @parm   const VcType | *type | Pointer to the type structure.
  
  @rdesc  underlying type id. GcUNDEFINEDD if not used.
*/
VcTypeID VcTypeGetUnderlyingType(const VcType *type);

/*-------------------------------------------------------------------------------------------------
  @func   Because of the old gci interface we need this function. It
          returns the type name for a given type identifier;

  @parm   VcTypeID | type_id | Unique type identifier.

  @rdesc  The name of the type.
*/
const char* VcGetTypeNameFromId(VcTypeID type_id);

/*-------------------------------------------------------------------------------------------------
  @func   Access method that returns the type object of a value.

  @parm   const GciValue* | value | Pointer to the value structure.
  
  @rdesc  Pointer to the type object. If an error occurred
          This pointer will be NULL. 
*/
VcType* VcGetType(const GciValue* value);

/*-------------------------------------------------------------------------------------------------
  @func Access method that returns the unique type id for a value.
  
  @parm GciValue | *value  | Pointer to the value structure. If null ths function will raise 
                             an error.
  @parm VcTypeID | *output | [out] returns Unique type id. 
  
  @rdesc GciOk on success and GciNotOk on error 
*/
GciStatus VcGetTypeID(GciValue* value, VcTypeID *output);

/*------------------------------------------------------------------------------------------------
  @func  Returns the name of the type for the value.
  
  @parm  const GciValue | *value | Pointer to the value
  
  @rdesc The name of the type of the value
*/
const char* VcGetTypeName(const GciValue *value);

/*-------------------------------------------------------------------------------------------------
  @func   This function returns the type id of the members in a setof or sequenceof types. If the
          value isn't of type setof or sequenceof the function will return GciNotOk. 

  @parm   GciValue | *value  | Pointer to value.
  @parm   int      | *output | The returned type id value,

  @rdesc  GciOk on success and GciNotOk on error.
*/
GciStatus VcGetUnderlyingTypeID(GciValue *value, VcTypeID *output);


/*-------------------------------------------------------------------------------------------------
  @func  Returns the type id from a type name string. GcUNDEFINEDD if the type couldn't be found.
  
  @parm  const char | *name | Name of the type.

  @rdesc The type id or GcUNDEFINEDD if not found
*/
VcTypeID VcGetTypeIdFromName(const char *type_name);


/* @func Checks if the type is a no name type (inlined or tagged) */

Bool VcTypeIsNoName(const VcType *type);

/* @func Checks if the type is a base type. */
Bool VcTypeIsBaseType(const VcType *type);

/*-------------------------------------------------------------------------------------------------
  @func Access method for the name field in the name type structure

  @parm const VcNameType | *list | Pointer to the name and type structure

  @rdesc The name as a null terminated string.
*/
const char* VcNameTypeGetName(const VcNameType *list);

/*-------------------------------------------------------------------------------------------------
  @func Access method for the type field in the name type structure

  @parm const VcNameType | *list | Pointer to the name and type structure

  @rdesc The type identifier associated with the name.
*/
VcTypeID VcNameTypeGetType(const VcNameType *list);

/*-------------------------------------------------------------------------------------------------
  @func Access method for the name field in the name value structure.

  @parm const VcNameValue | *list | Pointer to the name value structure.

  @rdesc The name as a null terminated string.
*/
const char* VcNameValueGetName(const VcNameValue *list);

/*-------------------------------------------------------------------------------------------------
  @func Access method for the value part of a name value structure.

  @parm const VcNameValue | *list | Pointer to the name value structure.

  @rdesc The value associated with the name.
*/
int VcNameValueGetValue(const VcNameValue *list);


/*********************
  Value api functions
**********************/

/*-------------------------------------------------------------------------------------------------
  @func Generic constructor for GciValues. This method creates a permanent
        value. For temporary allocated values use the VcMkTempValue function
        instead.

  @parm VcTypeID | type | An value of the type id. This denotes what type of
                     value that should be created.

  @rdesc A pointer to the newly created value. If the return value is NULL
         an error has occured.
*/
GciValue* VcMkValue(VcTypeID type);

/*-------------------------------------------------------------------------------------------------
  @func Similar to VcMkValue, but takes a type name instead.

  @parm const char* | type_name | Name of the type of the value to be created.
  
  @rdesc Pointer to the newly created value.
*/
GciValue* VcMkValueFromTypeName(const char* type_name);


/*-------------------------------------------------------------------------------------------------
  @func Constructor function to create a temporary value. Temporary values are using the temporary
        heap to allocate memory. They are intended to be used in the dynamic part of the ets. 
        Typically values that only "lives" on a behaviour line. This function uses the VcMakeValue
        function to do the actual creation of the value.
  
  @parm VcTypeID | type | The type of the value to be created.
  
  @rdesc Pointer to the newly created value.
*/
GciValue* VcMkTempValue(VcTypeID type);


/*-------------------------------------------------------------------------------------------------
  @func Similar to VcMkTempValue, but takes a type name instead.
  @parm const char* | type_name | Name of the type of the value to be created.
  @rdesc Pointer to the newly created value.
*/
GciValue* VcMkTempValueFromTypeName(const char* type_name);


/*-------------------------------------------------------------------------------------------------
  @func Generic constructor for GciValues. This function will can be used directly
        but it is prefered that the VcMkTempValue or VcMkValue is used instead.
        This function is the top level constructor. It will allocate the value structure and initalize
        the generic fields in the value structure. It will then retreive the type specific constructor
        and call that constructor that will initalize the type specific fields.

  @parm VcTypeID | type       | Type identifier. This denotes what type of value that should be created.
  @parm Bool     | temp_value | Allocation flag. If temp_value is GcTRUE then a temporary value will be 
                                created. If temp_value is GcFALSE a premanent value will be created.
  
  @rdesc A pointer to the newly created value. If the return value is NULL
   an error has occured.
*/

GciValue* VcMakeValue(VcTypeID type, Bool temp_value);

/*-------------------------------------------------------------------------------------------------
  @func Generic destructor for all value types. This function frees all
        memory allocated by the value structure.

  @parm GciValue* | value | A pointer to the value that will be destroyed.
*/
void VcRmValue(GciValue* value);

/*-------------------------------------------------------------------------------------------------
	@func	Assign the value of source to destination. It is type safe.
        Both input parameters must be defined, or this function will 
        raise an error and return GciNotOk and the assignment will not be done.

	@parm	GciValue* | destination  | Pointer to the destination value. 
  @parm	GciValue* | source       | Pointer to the source value.

	@rdesc	Returns GciOk if the assignment is done, otherwise GciNotOk. 
*/
GciStatus VcAssign(GciValue* destination, GciValue* source, Bool is_insteadofvalue_allowed);

/*-------------------------------------------------------------------------------------------------
  @func   Generic copy constructor. Allocates and makes a copy of a value. The
          caller is responsible for deleting the copy.

  @parm   GciValue*  | value | Pointer to the value that will be copied.
  @parm   GciValue** | output | [out] The returned copy of the source value.
  @parm   Bool       | temp_mem | Memory allocation strategi flag. If the
                                  flag is GcTRUE the new memory will be allocated
                                  on the temporary heap. If GcFALSE the value will
                                  be allocation memory with malloc.
  @rdesc  A pointer to a copy of the value. The return value can be NULL
          if the function fails.
*/
GciStatus VcCpValue(GciValue* source,GciValue** ouput, Bool temp_mem );

/*-------------------------------------------------------------------------------------------------
  @func Sets the type of av value. Given a type id this function looks up the type object in the 
        type table and sets the type pointer in the value struct to point to the type ohject found. 
        Note that this function is only intended to be used by the value constructors. It is not 
        supposed that it should be able to use this function to "retype" values. 

  @parm GciValue* | value   | Handle to the value object that should be retyped.
  @parm VcTypeID  | type_id | Type id of the new type.

  @rdesc  If the function succeeds it return GciOk otherwise
          incase of an error it returns GciNotOk. 
*/
GciStatus VcSetType(GciValue* value, VcTypeID type);


/*-------------------------------------------------------------------------------------------------
  @func Returns the name of a value.

  @parm GciValue* | value | Pointer to the value structure.
  @parm char** | name | Output parameter that will points to the name of the value.
                        Note that this is NOT a copy of the name so the called should 
                        not delete this memory.

  @rdesc  Returns GciOk if the function succeeds and GciNotOk
          if an error occured. 
*/
GciStatus VcGetName(GciValue* value, char** name);

/*-------------------------------------------------------------------------------------------------
  @func Returns the id for a value.
   
  @parm GciValue | *value | Pointer to the value.
  @parm int      | *id    | [out] The id value.
  @rdesc GciOk if the id could be read from the value. GciNotOk on error.
*/
GciStatus VcGetId(GciValue *value, int *id);

/*-------------------------------------------------------------------------------------------------
  @func Sets the id to a value.
  @parm GciValue | *value | Pointer to the value
  @parm int      | id     | The id number.
  @rdesc GciOk on success.
*/
GciStatus VcSetId(GciValue *value, int id);

/*-------------------------------------------------------------------------------------------------
  @func   This is an access method that sets the value is_defined attribute. This attribute tells 
          if the value is defined or not (no asigned value). This method is called by the Assign 
          function, the values set methods and it's constructors.

  @parm   GciValue* | value | Pointer to the value.
  @parm   Bool      | flag  | GcTRUE if the value should be defined and GcFALSE if the value should
                              be undefined (used by the value constructor).
  
  @rdesc  GciOk if the function succeeds and GciNotOk if an error occures. 
*/
GciStatus VcSetDefined(GciValue* value, Bool flag);

/*-------------------------------------------------------------------------------------------------
  @func   Sets the optional attribute. If the flag is GcTRUE than is the value optional. If a value
          is optional it means that it must not be present. It is used by the matching algoritm.

  @parm   GciValue | *value | Pointer to the value.
  @parm   Bool     | flag   | GcTRUE then the value will be optional otherwise not.

  @rdesc GciOk if the function succeeds and GciNotOk if an error occures. 
*/
GciStatus VcSetOptional(GciValue* value, Bool flag);

/*-------------------------------------------------------------------------------------------------
  @func   Sets the default. If the flag is GcTRUE then the value is the default value from the type. 

  @parm   GciValue | *value | Pointer to the value.
  @parm   Bool     | flag   | GcTRUE if the value is the default value otherwise GcFALSE.

  @rdesc GciOk if the function succeeds and GciNotOk if an error occures. 
*/
GciStatus VcSetDefault(GciValue* value, Bool flag);

/*-------------------------------------------------------------------------------------------------
  @func   Predicate that returns GcTRUE if the value is explicit and GcFALSE if implicit.

  @parm   GciValue | *value | Pointer to the value.
  @parm   Bool     | *flag  | [out] GcTRUE if value is Explicit and GcFALE otherwise
  @rdesc  GciOk if the function succeeds and GciNotOk if an error occurs. 
*/
GciStatus VcIsExplicit(GciValue* value, Bool* flag);

/*-------------------------------------------------------------------------------------------------
  @func  Access method that returns out the value restriction structure for a constraint value. 
         If the value does not have any value constraints (it is not a constraint or a constraint 
         without restrictions) it returns null.

  @parm  GciValue | *value | Pointer to the value structure.
  
  @rdesc Pointer to the value restriction. Null if the value does not have any restriction. 
         The returned value restriction is a reference to the restructuion stored in the 
         value so the caller should not delete it after use. 
*/
GciValueRestriction* VcGetRestriction(GciValue* value);

/*-------------------------------------------------------------------------------------------------
  @func   Set a value restriction to the value. A value restriction is ONLY used in constrains. 
          The value restriction structure is not copied so the calller is responsible for 
          creating and allocating the structure that is given as parameter 2.

  @parm GciValue            | *value       | Pointer to the value.
  @parm GciValueRestriction | *restriction | pointer to the restriction structure.

  @rdesc  Returns GciOk if the function Succeeds and GciNotOk if an error occurs. 
*/
GciStatus VcSetRestriction(GciValue* value, GciValueRestriction* restriction);
 
/*-------------------------------------------------------------------------------------------------
  @func Predicate that checks if a constraint is a Instead of value.

  @parm GciValue | *value  | Pointer to the constraint.
  @parm Bool     | *output | [out] Returned flag.

  @rdesc GciOk if the output could be returned.
*/
GciStatus VcIsInsteadOfValue(GciValue* value, Bool* output);

GciStatus VcMkInsteadOfValue(GciValue* value, VcInsteadOfValueType type);

GciStatus VcGetInsteadOfValue(GciValue* value, unsigned int pos, GciValue** output);

/*-----------------------------------------------------------------------------------------------
  @func  Retreives the value list of a Instead of value of type Complement.
  
  @parm  GciValue     | *value | The value structure.
  @parm  GciValueList |** list | [out] The return value.

  @rdesc GciOk if the value could be retreived.
*/
GciStatus VcGetComplementRestrictionList(GciValue* value, GciValueList** list);
/*-----------------------------------------------------------------------------------------------
  @func  Retreives the value list of a Instead of value of type Value list.
  
  @parm  GciValue     | *value | The value structure.
  @parm  GciValueList |** list | [out] The return value.

  @rdesc GciOk if the value could be retreived.
*/
GciStatus VcGetValueListRestrictionList(GciValue* value, GciValueList** list);

/*-------------------------------------------------------------------------------------------------
  @func Predicate that returns GcTRUE if a value constraint has a size attribute.
  
  @parm GciValue | *value | Pointer to the value constraint.
  @parm Bool | *output | [out] The return value.

  @rdesc GciOk on success and GciNotOk on error.
*/
GciStatus GciValueHasSizeAttribute(GciValue* value, Bool * output);


/*-------------------------------------------------------------------------------------------------
  @func Internal function that returns the number of members contained in the
        specified value.
  @parm GciValue* | value | The value must be of type SET, SETOF, SEQUEMCE or SEQUENCEOF   
                            otherwise it will return an error indicated that it was called by
                            wrong type.
  @parm unsigned int* | number_of_members | [out] The number of members.
*/
GciStatus VcGetNumberOfMembers(GciValue* value, unsigned int* number_of_members);

/*-------------------------------------------------------------------------------------------------
  @func Retrieves the type identifier for a given tag. 

  @parm  GciTagClass | tag_class | Tag class
  @parm  VcTypeId | tag   | The tag to look up
  @parm  VcTypeID | *id   | [out] Output parameter the type identifier
  
  @rdesc GciOk on success.
*/
GciStatus VcLookupTag(GciTagClass tag_class, int tag, VcTypeID *id);



/*-------------------------------------------------------------------------------------------------  
  @func Access method that returns the underlying integer value from the value structure. 
  
  @parm  GciValue | *value  | Pointer to the integer value structure. The function will raise an 
                              error if the value is not of integer type or derived or if the 
                              value is not defined.
  @parm  int      | *output | Will contain the integer value.

  @rdesc GciOk if the function succeeds and GciNotOk if an error occurs. 
*/
GciStatus VcGetINTEGER(GciValue* value, long* output);

/*-------------------------------------------------------------------------------------------------  
  @func  Set method that stores an integer value into the value structure. If the destination 
         parameter isn't of integer type or derived or if it is null an error will be raised and
         the integer value will not be stored.

  @parm GciValue | *destination | Pointer to the integer value structure.
  @parm int      | value        | the integer to be stored.

  @rdesc GciOk if the value is stored and GciNotOk if an error occurs. 
*/
GciStatus VcSetINTEGER(GciValue* destination, long value);


/*-------------------------------------------------------------------------------------------------
  @func Access method that returns the underlying value from the value structure.  
  
  @parm  GciValue | *value  | Pointer to the value structure. The function will raise an error if 
                              the value is not of the correct type or derived or if the value is 
                              not defined.

  @parm  Bool     | *output | [out] Will contain the actual value.
  
  @rdesc GciOk if the function succeeds and GciNotOk if an error occurs. 
*/
GciStatus VcGetBOOLEAN(GciValue* value, Bool* output);

/*-------------------------------------------------------------------------------------------------
  @func Gets the value of NULL type. The only value valid for this type is VcNULL.

  @parm GciValue | *value  | Pointer to the null type structure.
  @parm long     | *output | [out] The null value returned in a parameter.

  @rdesc GciOk on success.
*/
GciStatus VcGetNULL(GciValue* value, long* output);
/*-------------------------------------------------------------------------------------------------  
  @func  Sets a null type to VcNULL

  @parm  GciValue | *destination | Pointer to the null value .
  @parm  int      | value        | Only valid value is VcNULL.

  @rdesc GciOk if the value is stored and GciNotOk if an error occurs. 
*/
GciStatus VcSetNULL(GciValue* destination, long value);

/*-------------------------------------------------------------------------------------------------  
  @func Internal function that returns the number of members contained in the
        specified instance.

  @parm GciValue*  | value             | The instance.
  @parm unsigned int*      | number_of_members | [out] The number of members.

  @rdesc GciOk on success.
  
*/
GciStatus VcGetNumberOfOBJECTIDENTIFIERMembers(GciValue* value, unsigned int* number_of_members);



/*-------------------------------------------------------------------------------------------------  
  @func Equal operator. Checks if two values are equal. This method checks 
        the type and the value, but skips restrictions and other attributes.
  @parm GciValue* | left   | left side value.
  @parm GciValue* | right  | right side value

  @rdesc  True if the values are equal, false otherwise.
*/
Bool VcEqual(GciValue* left, GciValue* right);


/*-------------------------------------------------------------------------------------------------  
  @func  Internal function that retrieves the nth member of a container value.
  
  @parm  GciValue*    | value  | The value to query. The value must be of type SEQUENCE,
                                 SEQUENCEOF, SET or SETOF.
  @parm  unsigned int | pos    | The zero-indexed position.
  @parm  GciValue**   | member | [out] The member at position pos.
  
  @rdesc GciOk if the member could be found.
*/
GciStatus VcGetMember(GciValue* value, unsigned int pos, GciValue** member);

/*-------------------------------------------------------------------------------------------------
  @func Internal function that retrieves the named member of a SEQUENCE,SET or CHOICE.

  @parm GciValue*   | value  | The SEQUENCE/SET or CHOICE to query.
  @parm const char* | name   | The name of the member.
  @parm GciValue**  | member | [out] The member value.

  @rdesc GciOk on success
*/
GciStatus VcGetMemberByName(GciValue* value, const char* name, GciValue** member);

/*-------------------------------------------------------------------------------------------------
  @func Internal function that retrieves the member with given tag of a SEQUENCE,SET or CHOICE.

  @parm GciValue*   | value     | The SEQUENCE/SET or CHOICE to query.
  @parm GciTagClass | tag_class | The tag class of the member.
  @parm int         | tag       | The tag of the member.
  @parm GciValue**  | member    | [out] The member value.

  @rdesc GciOk on success
*/
GciStatus VcGetMemberByTag(GciValue* value, GciTagClass tag_class, int tag, GciValue** result);

/*-------------------------------------------------------------------------------------------------
  @func Internal function that sets the nth member of a value that is one of the types SEQUENCE or SEQUENCEOF .

  @parm GciValue*    | value | The SEQUENCE to query.
  @parm unsigned int | pos   | The zero-indexed position.
  @parm GciValue*    | value | The new value for the member.

  @rdesc GciOk on success.
*/
GciStatus VcSetMember(GciValue* value, unsigned int pos, GciValue* new_value);

/*-------------------------------------------------------------------------------------------------
  @func Internal function that sets the named member of a SEQUENCE orSET.

  @parm GciValue*   | value    | The SEQUENCE/SET to query.
  @parm const char* | name     | The name of the member.
  @parm GciValue*   | source   | The new value for the member.

  @rdesc GciOk on success.
*/
GciStatus VcSetMemberByName(GciValue* value, const char* name, GciValue* source);

/*----------------------------------------------------------------------------
@func Internal function that appends a new member to a SETOF or SEQUENCEOF.
We might also allow this for SET and SEQUENCE but it is not desired.
@parm GciValue | *value | Pointer to the SETOF/SEQUENCEOF value.
@parm GciValue | *member| Pointer to the member that should be added
@rdesc GciOk if the member was appended successfully, GciNotOk if
an error occured.
*/
GciStatus VcAppendMember(GciValue* value, GciValue* member);

/*-------------------------------------------------------------------------------------------------
  @func Internal function that retrieves the nth member.

  @parm GciValue*    |        | The container instance.
  @parm unsigned int |        | The zero-indexed position.
  @parm VcNameValue* | member | [out] The member at the given position.
  
  @rdesc GciOk on success.
*/
GciStatus VcGetOBJECTIDENTIFIERMember(GciValue* value, unsigned int pos, VcNameValue *member);


/*-------------------------------------------------------------------------------------------------
  @func Internal function that returns the actual value of the specified value
        instance.

  @parm GciValue* | value | Pointer to the value instance.
  @parm char**    | str| [out] Pointer to the actual value returned.

  @rdesc GciOk if value could be set, GciNotOk otherwise.
*/
GciStatus VcGetSTRING(GciValue* value, char** str);

/*-------------------------------------------------------------------------------------------------  
  @func  Set method that stores a value into the value structure. if the destination parameter 
         isn't of matching type or derived or if it is null an error will be raised and the 
         new value will not be stored.

  @parm  GciValue    | *destination | Pointer to the value structure.
  @parm  const char* | value        | The new value

  @rdesc GciOk if the value is stored and GciNotOk if an error occurs.
*/
GciStatus VcSetSTRING(GciValue* destination, const char* value);

/*-------------------------------------------------------------------------------------------------
  @func Internal function that retrieves the ENUMERATED instance value.

  @parm GciValue*  | value    | The CHOICE.
  @parm int*      | output   | [out] The member value.

  @rdesc GciOk on success.
*/
GciStatus VcGetENUMERATED(GciValue* value, int* output);

/*-------------------------------------------------------------------------------------------------
  @func Internal function that instantiates the ENUMERATED type to a value.

  @parm GciValue*  | destination | The enumeration.
  @parm int       | value       | The actual integer value.

  @rdesc GicOk if the enumerated value could be set.
  
*/
GciStatus VcSetENUMERATED(GciValue* destination, int value);

/*-------------------------------------------------------------------------------------------------
  @func Internal function that retreives the name of the enumerated value.

  @parm GciValue*  | destination | The enumeration.
  @parm const char*| name        | [out] The name.

  @rdesc GicOk if the enumerated value could be set.
  
*/
GciStatus VcGetENUMERATEDName(GciValue *value, const char **name);

/*-------------------------------------------------------------------------------------------------
  @func Internal function that instantiates the ENUMERATED type to a literal value.
  @parm GciValue*  | destination | The enumeration.
  @parm const char*| value_name  | The literal name corresponding to the integer value.
  @rdesc GciOk if the enumerated value could be set.
  
*/
GciStatus VcSetENUMERATEDByName(GciValue* destination, const char* value_name);

/*-------------------------------------------------------------------------------------------------
  @func Internal function that instantiates the UNTYPED_ENUMERATED type to a literal value.
  @parm const char*| enum_literal  | Literal name.
  @rdesc Pointer to the newly created value.
*/
GciValue*	VcMkUNTYPED_ENUMERATED(const char *enum_literal);

/*-------------------------------------------------------------------------------------------------
  @func Internal function that retrieves the stored literal of the untyped enumerated value.
  @parm GciValue*  | value | The untyped enumerated value.
  @rdesc Stored literal.
*/
char*	    VcGetUNTYPED_ENUMERATED_Literal(GciValue *value);

/*-------------------------------------------------------------------------------------------------
  @func Internal function that checks if value is untyped enumerated.
  @parm GciValue*  | value | Value to test.
  @rdesc GcTRUE if value is untyped enumerated.
*/
Bool	    VcIsUNTYPED_ENUMERATED(GciValue *value);

/*-------------------------------------------------------------------------------------------------  
  @func Set method that stores a value into the value structure. If the destination parameter 
        isn't of matching type or derived or if it is null an error will be raised and the new 
        value  will not be stored.
  
  @parm GciValue | *destination | Pointer to the value structure.
  @parm Bool     | value        | The new value

  @rdesc GciOk if the value is stored and GciNotOk if an error occurs.
*/
GciStatus VcSetBOOLEAN(GciValue* destination, Bool value);

/*-------------------------------------------------------------------------------------------------
  @func Access method that returns the underlying value
        from the value structure. 

  @parm GciValue*    | value | Pointer to the value structure.
                               The function will raise an error if the value
                               is not of the correct type or derived or if the 
                               value is not defined.
  @parm GciVerdict* | output| [out]Will contain the actual value.

  @rdesc GciOk if the function succeeds and GciNotOk if an error occurs. 
*/

GciStatus VcGetRTYPE(GciValue* value, GciVerdict* output);

/*-------------------------------------------------------------------------------------------------
  @func Access method for retreiving the underlying value from an ANY value.

  @parm GciValue | *value   | The ANY value
  @parm GciValue | **output | [out] The instantiated value.
  
  @rdesc GciOk if the value could be returned.
*/
GciStatus VcGetANY(GciValue *value, GciValue **output);

/*-------------------------------------------------------------------------------------------------
  @func Instantiates an ANY value.
  
  @parm GciValue | *destination | The any value.
  @parm GciValue | *value       | The instance value.
  
  @rdesc GciOk if the ANY value could be instantiated.
*/
GciStatus VcSetANY(GciValue* destination, GciValue* value);

/*-------------------------------------------------------------------------------------------------
  @func  Set method that stores a value into the value structure. If the destination parameter 
         isn't of matching type or derived or if it is null an error will be raised and the new 
         value will not be stored.

  @parm  GciValue     | *destination | Pointer to the value structure.
  @parm  GciVerdict   | value        | The new value

  @rdesc GciOk if the value is stored and GciNotOk if an error occurs.
*/
GciStatus VcSetRTYPE(GciValue* destination, GciVerdict value);

/*-------------------------------------------------------------------------
  @func Starts a timer and gives it the current value and the duration.

  @parm GciValue | *timer | Pointer to the timer structre.
  @parm int | value | The current value of the timer.
  @parm int | duration | the duration before timeout.
  
  @rdesc GciOk if the timer was started successfully, otherwise an error
         will be raised.
*/
GciStatus VcStartTimer(GciValue *timer, long value, long duration);

/*-------------------------------------------------------------------------
@func Starts a timer with it's default value. If the the timer does not
have any default value an error will be raised.
@parm GciValue | *timer | Pointer to the timer value.
@rdesc  GciOk if the timer was started successfully, otherwise an error will
be raised.
*/
GciStatus VcStartTimerDefault(GciValue *timer, long value);

/*-------------------------------------------------------------------------------------------------
  @func Set method for the timer value.

  @parm GciValue  | *timer  | Pointer to the timer value.
  @parm long      | value   | The new value that should be stored into the timer
                              structure.

  @rdesc GciOk on success and GciNotOk on error.
*/
GciStatus VcSetTimerValue(GciValue *timer, long value);

/*-------------------------------------------------------------------------------------------------
  @func Set method for the timer default value.

  @parm GciValue  | *timer  | Pointer to the timer value.
  @parm long      | value   | The new value that should be stored into the timer
                              structure.

  @rdesc GciOk on success and GciNotOk on error.
*/
GciStatus VcSetTimerDefaultValue(GciValue *timer, long value);

/*--------------------------------------------------------------------------
  @func Function to notify a timer as expired.
  
  @parm GciValue  | *timer  | Pointer to the timer value.

  @rdesc  GciOk on success and GciNotOk on error.
*/
GciStatus VcSetTimerFired(GciValue *timer);

/*--------------------------------------------------------------------------
@func Predicate that returns GcTRUE if a timer has expired.
@parm GciValue | *timer | Pointer to the timer value.
@parm Bool | *output | [out] Pointer to the returned flag. GcTRUE if
if the timer has expired and GcFALSE if not.
@rdesc  GciOk on success and GciNotOk on error.
*/
GciStatus VcIsTimerFired(GciValue *timer, Bool *output);

/*-------------------------------------------------------------------------
@func Stops a timer.
@parm GciValue | *timer | Pointer to the timer that should be stopped.
@rdesc GciOk if the timer was stopped, otherwise GciNotOk if an error was
raised.
*/
GciStatus VcCancelTimer(GciValue *timer);

/*-------------------------------------------------------------------------------------------------
  @func Internal function that retrieves the CHOICE member instance.

  @parm GciValue*  | value    | The CHOICE.
  @parm GciValue** | member   | [out] The member value.
  
  @descr GciOk on success.
*/
GciStatus VcGetCHOICE(GciValue* value,GciValue** output);

/*-------------------------------------------------------------------------------------------------
  @func  Internal function that instantiates the CHOICE to a value.

  @parm  GciValue*   | destination | The CHOICE
  @parm  GciValue*   | value       | The value instance.
  @parm  const char* | member      | The name of the instance ID.
  
  @rdesc GciOk if the choice could be instantiated with the new instance value.
*/
GciStatus VcSetCHOICE(GciValue* destination, GciValue* value, const char* member);

/*-------------------------------------------------------------------------------------------------

  @func This function is a support function for the code generator in the
        case when a inlined CHOICE type has a default value. This function
        retreives a named member of the choice. If the choice is not instantiated
        this member will be created if it is a member of the allowed types.

  @parm GciValue | *value | Pointer to the choice value.
  @parm const char | *name | The name of the member to retreive
  @parm GciValue | ** member | [out] The choice member (instance)

  @rdesc GciOk on success.
*/
GciStatus VcGetCHOICEMemberByName(GciValue* value, const char* name, GciValue **member);



/*-------------------------------------------------------------------------------------------------
@func Returns the duration of a given timer.
@parm GciValue | *timer   | Pointer to the timer value.
@parm long     | *output  | [out] Pointer to the returned duration value.
@rdesc GciOk on success and GciNotOk on error.
*/
GciStatus VcGetTimerDuration(GciValue* timer, long *output);

/*
  @func Sets the duration to a timer.
  @parm GciValue | *timer | Pointer to the timer value.
  @parm long | value | The new duration value.
  @rdesc GciOk on success and GciNotOk on error.
*/
GciStatus VcSetTimerDuration(GciValue *timer, long value);

/*
  @func Sets the state of the timer. If the flag is GcTRUE then the state 
        is set to RUNNING otherwise the state is set to STOPPED.
  @parm GciValue | *timer | Pointer to the timer value.
  @parm Bool | flag | GcTRUE if the new state should be RUNNING and 
                         GcFALSE if the state should be STOPPED.
  @rdesc  GciOk on success and GciNotOk on error.
*/
GciStatus VcSetTimerRunning(GciValue *timer, Bool flag);

/*
@func Accessmethod that returns the timer unit of a given timer.
@parm GciValue     | *timer  | Pointer to the timer value.
@parm VcTimerUnits | *output | [out] Pointer to the returned unit value.
@rdesc GciOk on success and GciNotOk on error.
*/
GciStatus VcGetTimerUnit(GciValue *timer, VcTimerUnits *output);

/*
@func Sets the timer units. There are at the moment the following number
ps,ns,us,ms,s and min.
@parm GciValue      | *timer  | Pointer to the timer value.
@parm VcTumerUnits  | unit    | The timer unit. 
@rdesc GciOk on success and GciNotOk on error.
*/
GciStatus VcSetTimerUnit(GciValue *timer, VcTimerUnits unit);


/*
  @func Access function that returns the default value of the timer. If
        The timer does not have any default value the returned output 
        will be assigned to -1.
  @parm GciValue | *timer  | Pointer to the timer value.
  @parm long     | *output | [out] Pointer to the returned default value.
  @rdesc GciOk if the function succeeds and GciNotOk if on error.
*/
GciStatus VcGetTimerDefaultValue(GciValue *timer, long *output);

Bool VcIsTempValue(GciValue* value);

/*
  @func  Returns true if the value is optional and false otherwise.

  @parm  GciValue | *value | Pointer to the value.
  @parm  Bool     | *flag | [out] Return output value.

  @rdesc GciOk on ok.
*/
Bool VcIsOptional(GciValue *value);

/*
  @func  Predicate that indicates if a value is defined or not

  @parm  GciValue* | value | Pointer to the value structure
  @parm  Bool*     | flag  | [out] GcTRUE if the value is defined and otherwise GcFALSE.

  @rdesc  Returns GciOk if successful and GciNotOk if an error occured.
*/
Bool VcIsDefined(GciValue* value);

/*
  @func  Predicate that indicates if a value comes from the default value in the type.

  @parm  GciValue* | value | Pointer to the value structure
  @parm  Bool*     | flag  | [out] GcTRUE if the value is the default.

  @rdesc  Returns GciOk if successful and GciNotOk if an error occured.
*/
Bool VcIsDefault(GciValue *value);

/*
  @func  Predicate that indicates if a value is omitted.

  @parm  GciValue* | value | Pointer to the value structure

  @rdesc  Returns GcTRUE if omitted and GcFALSE is not.
*/
Bool VcIsOMIT(GciValue* val);

/*
@func Sets the name of the value. A copy of the name parameter is stored in the value structure, 
        (allocated by this function).
  
  @parm GciValue* | value  | Pointer to the value structure.
  @parm const char* | name | null terminated string of the new name
                             of the value. 

  @rdesc  Return GciOk if the function succeeds and GciNotOk if an error occured  
*/
GciStatus VcSetName(GciValue* value, const char* name);

/*----------------------------------------------------------------------------
@func Internal function that appends an element to the container instance.

  @parm GciValue*   | object_id    | The container instance.
  @parm const char* | name         | Name of the member
  @parm int         | value        | The value to add.

  @rdesc GciOk on success
*/
GciStatus VcAddOBJECTIDENTIFIERMember(GciValue* object_id, const char* name, int value);

/***************************************************************************
@func Adds a member to a set. This function is intended for the sub class
constructors to use. The added member MUST have a name otherwise
this function will raise an error. The function does not test if
the member is NULL. If it is the behavior is undefined.

  @parm GciValue | *destination | The set value where the value will be added.
  @parm GciValue | *member | The member to be added.
  @parm const char | *name | name of the new member.
  @rdesc GciOk if the member was added successfully, GciNotOk if an error is
  raised.
*/
GciStatus VcAddSETMember(GciValue* destination, GciValue* member, const char* name);

/*----------------------------------------------------------------------------
@func Internal function that adds a member last to a SEQUENCE.

  @parm GciValue*  | destination | The SEQUENCE to query.
  @parm GciValue*  | member      | The new member to add.
  @parm const char | *name       | name of the new member
  
*/
GciStatus VcAddSEQUENCEMember(GciValue* destination, GciValue* member, const char* name);

/*-----------------------------------------------------------------------
  @func Not strictly for PDU's, but use to set a value as having
        the PDU ability.

  @parm GciValue | *value | Pointer to the value.
  @parm Bool    | set    | GcTRUE to set the PDU flag, GcFALSE to clear it.

  @rdesc  GciOk on success and GciNotOk on error.
*/

GciStatus VcSetAsPDU(GciValue* value, Bool set);


/*****************************
  Type api functions
******************************/
/*
  @func   Searches in type type table to find the type sturcture
          with the type id as a key.
  
  @parm   VcTypeID | type | The key id for the type. This is used
          as an offset in the type table.
  @rdesc  Returns a pointer to the type structure. 
*/
VcType* VcLookUpTypeObject(VcTypeID type);

/*
  @func Traverses the type hierarchy until it finds a type that has no parent,
        and returns the type id of that type.
  @parm GciValue* | value | A pointer to the value structure.
  @parm VcTypeID | *output | [out] returns Unique type id. 
  @rdesc GciOk on success and GciNotOk on error 
*/
GciStatus VcGetBaseTypeID(GciValue* value, VcTypeID *output);


/*-------------------------------------------------------------------------------------------------
  @func Access method that returns the tag value for a value of a specific type.

  @parm GciValue | *value | Pointer to the value.
  @parm Bool     | *tag   |[out] The returned tag value.

  @rdesc GciOk on success and GciNotOk on error.
*/
GciStatus VcGetTag(GciValue *value, int *tag);

/*-------------------------------------------------------------------------------------------------
  @func Access method that returns the tag class value for a given value.

  @parm GciValue | *value     | Pointer to the value.
  @parm int      | *tag_class | [out] The returned tag class value.

  @rdesc GciOk on success and GciNotOk on error.
*/
GciStatus VcGetTagClass(GciValue *value, int *tag_class);

/*******************************
  Help functions 
********************************/
/*
  @func   Allocates memory and makes a copy of a null terminated string.
  @parm   char* | string |  Pointer to a null terminated string. If the string is not null- 
                            terminated, the behaviour of this function is undefined.
  @parm   Bool  | temp_mem | GcTRUE if the allocated memory should be on the temporary heap.
  @rdesc  pointer to a copy of the string. The user has the responsibility to delete the 
          string copy and free its memory.
*/
char* VcCpString(const char* string, Bool temp_mem);

/*-------------------------------------------------------------------------------------------------
  @func  General string length method. For OCTET STRINGs, it will compensate the length by dividing
         it by 4.

  @parm  GciValue*     | value | Pointer to the value structure. The function will raise an 
                                 error if the value is not of the correct type or derived or if 
                                 the value is not defined.
  @parm  unsigned int* | output| [out] Will contain the length.
  
  @rdesc GciOk if the function succeeds and GciNotOk if an error occurs. 
*/
GciStatus VcGetStringLength(GciValue* value, unsigned int* output);

/*******************************
  Logging functions
********************************/

/*
  @func This function creates and initialises a log value.
  @rdesc A log object.
*/
VcLogType VcLogCreate(void);

/* 
  @func This function frees the memory used by a log value.
  @parm VcLogType | log | The log to delete
 */
void VcLogDelete(VcLogType log);


 /* 
    @func An accessor function that returns the start of the log-string.
    @parm VcLogType | log | the log to begin
    @rdesc Use the return value whenever a string representation is needed for the log contents.
 */
char* VcLogBegin(VcLogType log);

/* @func  The workhorse of the logging functions.  This function handles
          the actual insertion of text into the logstring.  If the
          logstring would overflow because of the addition the
          log-string is reallocated with a bigger size.
        
          The VcLogType contains an "end" pointer which is used here to
          be able to know where to add the new text.  This eliminates a
          search through the log-string for every insertion.
 
 @parm VcLogType    | log  | The log to add to.
 @parm const char*  | text | The text to add.
*/
void VcLogAddText(VcLogType log, const char *text);

/*
  @func Builds the lexical representation of an ENUMERATED value.
 
  @parm VcLogType  | log   | The log to extend.
  @parm GciValue*  | value | The value to add.
*/
void VcLogAddEnumerated(VcLogType log, GciValue * value);

/* @func Builds the lexical representation of an INTEGER value.

   @parm VcLogType  | log     | The log to extend.
  @parm int        | integer | The value to add.
*/
void VcLogAddInteger(VcLogType log, int integer);

/*
  @func Builds the lexical representation of a timer value.
 
  @parm VcLogType  | log   | The log to extend.
  @parm GciValue*  | timer | The value to add.
*/
void VcLogAddTimer(VcLogType log, GciValue* timer);

/*
  @func Builds the lexical representation of an R_TYPE value.
 
 @parm VcLogType  | log     | The log to extend.
 @parm GciVerdict | verdict | The verdict value to add.
*/

void VcLogAddR_Type(VcLogType log, GciVerdict verdict);

/*
  @func  Logs a sequence.  Just adds the sequence delimeters and then
         recursively logs the elements in the sequence.
 
  @parm VcLogType  | log   | The log to extend.
  @parm GciValue*  | value | The value to add.
*/
void VcLogAddSequence(VcLogType log, GciValue * value);

/*
  @func  Logs an OBJECT IDENTIFIER. Adds the curly brace delimeters and 
         then recursively logs the elements in the list.
 
  @parm VcLogType  | log   | The log to extend.
  @parm GciValue*  | value | The value to add.
*/
void VcLogAddOBJECT_IDENTIFIER(VcLogType log, GciValue *value);

/*
  @func  Logs the contents of a PDU. Adds the curly brace delimeters and 
         then recursively logs the elements in the list.
 
  @parm VcLogType  | log   | The log to extend.
  @parm GciValue*  | pdu   | The value to add.
*/
void VcLogAddPDU(VcLogType log, GciValue* pdu);

/*
  @func  Logs the name of the PCO.
 
  @parm VcLogType  | log   | The log to extend.
  @parm GciValue*  | pdu   | The value to add.
*/
void VcLogAddPCO(VcLogType log, GciValue* pco);

/*
 @func This is the top level log function for all GCI values. It calls
       subsequent specialized functions to break down the complex 
       values to printable entities.
 @parm VcLogType  | log   | The log to extend.
 @parm GciValue*  | value | The value to add.
*/
void VcLogAddValueValue(VcLogType, GciValue *);

/*
  @func The topmost value logging function, providing shelter for NULL input.
 
  @parm VcLogType  | log   | The log to extend.
  @parm GciValue*  | value | The value to add.
*/
void VcLogAddValue(VcLogType log, GciValue* value);

/*---------------------------------------------------------------------------
  Memory function declarations
-----------------------------------------------------------------------------*/

typedef struct tmp_mem_mark
{
  void *       heap;
  char *       next_free;
} IcTmpMemMark;

/*
  @func This function allocates new memory on the heap. It is a replacement
        for the system function malloc. The difference with this function is
        that it can allocate "temporary" memory in a preallocated memory 
        buffer. The temporary allocated memory later easily be freed.
  @parm unsigned int | size | The number of bytes to allocate. This will
                              allways be alligned to a even number of 4 
                              bytes blocks. 
  @parm Bool | temporary | If this parameter is GcTRUE the allocated memory 
                           will be placed in the preallocated memory buffer.
                           If it is GcFALSE the system allocation function
                           malloc will be called to create new memory.
  @rdesc Pointer to the beginning of the newly created memory. NULL if 
         no new memory could be allocated.
*/
void* VCMALLOC(unsigned int size, Bool temporary);

/*
  @func Deallocates allocated memory. If the memory is temporary the
        function will do nothing.
  @parm void | *ptr | Pointer to the memory to be freed.
*/
void VCFREE(void* ptr);

/*
  @func Predicate that checks if a pointer is in the temporary heap.
  @parm void | *pointer | Pointer to the "allocated" memory.
  @rdesc GcTRUE if the pointer points to a temporary memory.
*/
Bool IcIsTemporary(void* pointer);

void IcGetTemporaryMemoryStart(IcTmpMemMark *mark);
void IcReleaseTemporaryMemory(IcTmpMemMark pos);
Bool IcEqualTempMemPos(IcTmpMemMark pos1, IcTmpMemMark pos2);

/*--------------------------------------------------------------------------
  GciValueList functions
----------------------------------------------------------------------------*/
/*
  @func Removes and frees all values from a value list. Both the values and the list are freed.

  @parm GciValueList | *list | Pointer to the value list. The list pointer should not be used after 
                               this function have been called.
*/
void VcFreeValueList(GciValueList* list);

/*
  @func  Adds a new value to end of a value list.
  @parm  GciValueList | **list      | handle to the list.
  @parm  GciValue     | *new_value  | Pointer to the new value to be inserted.
  @parm  Bool         | temp_memory | If value list should be allocated on temp memory or not
  @rdesc GciOk on success.
*/
GciStatus VcAppendValueList(GciValueList** list, GciValue* new_value, Bool temp_memory);

/*--------------------------------------------------------------------------
  @func Insert an new_value to the beginning of a value list.
  @parm GciValueList** | list | Handle to the value list.
  @parm GciValue | *new_value | Pointer to the new value.
  @rdesc GciOk on success.
*/
GciStatus VcInsertFirstValueList(GciValueList** list, GciValue* new_value);

/*--------------------------------------------------------------------------
  Context definitions
----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------
@struct VcContextIDList | A mapping between test component ID's and context pointers.
*/
typedef struct VcContextIDList 
{
  VcRTContext* context;         /* @field The context. */
  int tc_id;                    /* @field The TC identifier */
  struct VcContextIDList* next; /* @field The next item in the list. */
} VcContextIDList;

/*-------------------------------------------------------------------------
  @enum Used in a mapping table to indicate the type of a "variable".
*/
typedef enum {
    VcTS_VAR_TYPE,    /* @emem Test suite variable */
    VcTS_CONST_TYPE,  /* @emem Test suite constant */
    VcTS_PAR_TYPE,    /* @emem Test suite parameter */
    VcTC_VAR_TYPE,    /* @emem Test case variable */
    VcTIMER_TYPE,     /* @emem Timers */
    VcPCO_TYPE,       /* @emem PCO and CP types */
    VcNO_TYPE         /* @emem Sentinel for the map. Only to be generated last! */
} VcVariableType;

/*-------------------------------------------------------------------------
  @struct Mapping table to find a variable in it's array. From a unique
          variable id to what type it is and where int the spcific variable
          table it will be found.
*/
typedef struct VcVarIdToPos {
  VcVariableType variable_type;
  int            offset;
} VcVarIdToPos;

/*-------------------------------------------------------------------------
  @enum Used to indicate what type of context it is. 
		 There are some differences when a context is 
		 ised by the MTC or the PTC. For example a PTC 
		 should not have access to Test Suite Variables.
*/
typedef enum {
  VcContextError = -1,  /* @emem Used when the return value could not be deduced. */
	VcMaster,	            /* @emem Master copy of the context, not to be used by a MTC or PTC */
	VcMTC,		            /* @emem Context used by MTC */
	VcPTC		              /* @emem The context variables TSVar should not be accessable */
} VcContextType;

/*---------------------------------------------------------------------
  @func Allocates and Initalizes the Global Master context. The master
        context contains all test suite constants, test suite variables.
        test case variables, timers etc.
  @rdesc  Pointer to the newly created VcRTContext. NULL if fail.
*/
VcRTContext* VcBuildContext(void);

/*----------------------------------------------------------------------
  @func Deallocates and destroys a context. 
  @parm VcRTContext | *context | The context to be destroyed.
*/
void VcDestroyContext(VcRTContext *context);

/*-----------------------------------------------------------------------
  @func Allocates and initalizes a MTC context.
  @parm VcRTContext | *master | Pointer to the "source" context.
  @parm const char* | tc_name| The name of the test component owning this context.
  @parm int         | tc_id  | The identifier of the test component.
  @rdesc Pointer to a newly created MTC context.
*/
VcRTContext* VcCreateMTCContext(VcRTContext *master,
                                int tc_id );

/*-----------------------------------------------------------------------
  @func Allocates and initalizes a PTC context.
  @parm VcRTContext | *master | Pointer to the "source" context.
  @parm int         | tc_id  | The identifier of the test component.
  @rdesc Pointer to a newly created PTC context.
*/
VcRTContext* VcCreatePTCContext(VcRTContext *master,                               
                                int tc_id );


/*-----------------------------------------------------------------------        
  @func Set both final and preliminary verdict to GciNone
  @parm VcRTContext | *context | Pointer to the context. This should always be
                                 the master context.
*/
GciStatus VcResetGlobalVerdicts(VcRTContext *context);

/*------------------------------------------------------------------------
  @func Set Final verdict
  @parm VcRTContext | *context | Context to set the verdict in
  @parm GciVerdict | verdict | The new final verdict
  @rdesc GciOk on success
*/
GciStatus VcSetFinalVerdict(VcRTContext* context, GciVerdict verdict);

/*------------------------------------------------------------------------
  @func Get Final verdict
  @parm const VcRTContext | *context | Context to get verdict from
  @parm GciVerdict | *verdict | [output] Returned output value
  @rdesc  GciOk on success
  */
GciStatus VcGetFinalVerdict(const VcRTContext *context, GciVerdict *verdict);

/*------------------------------------------------------------------------
  @func Reset final verdict
  @parm VcRTContext | *context | Context to set the verdict in
  @parm GciVerdict | verdict | The new final verdict
  @rdesc GciOk on success
*/
GciStatus VcResetFinalVerdict(VcRTContext* context);
/*------------------------------------------------------------------------
  @func Set Preliminary verdict
  @parm VcRTContext | *context | context to set the preliminary verdict.
  @parm GciVerdict | verdict | The new preliminary verdict.
  @rdesc GciOk on success
*/
GciStatus VcSetPreliminaryVerdict(VcRTContext* context, GciVerdict verdict);

        
/*-------------------------------------------------------------------------
  @func Get Preliminary verdict
  @parm const VcRTContext | *context | The context to get the verdict from.
  @parm GciVerdict | *verdict [output] Returned output value
  @rdesc GciOk on success
  */
GciStatus VcGetPreliminaryVerdict(const VcRTContext *context, GciVerdict *verdict);

/*------------------------------------------------------------------------
  @func Given an identifier of a variable this function searches in the context
        to get a pointer to its value structure.
  @parm int | variable_id | Unique identifier to the variable / or constant.
  @parm const VcRTContext | *context | Context to look in.
  @rdesc Pointer to the value, null if not found.
*/
GciValue* VcContextGetValueByID(int variable_id, const VcRTContext* context);

/*------------------------------------------------------------------------
  @func Searches for a variable/constant of a given name in a context.
  @parm const char | *name | Name of the variable.
  @parm const VcRTContext | *context | Context to search in.
  @rdesc Pointer to the value. Null if not found.
*/
GciValue* VcContextGetValueByName(const char* name, const VcRTContext* context);


/*-------------------------------------------------------------------------
  @func Returns a Timer value given it's id.
  @parm int | timer_id | Unique timer id.
  @parm const VcRTContext | *context | Pointer to the context to search in.
  @rdesc Pointer to the timer value, NULL if not found.
*/
GciValue* VcContextGetTimer(int timer_id, const VcRTContext *context);

/*-------------------------------------------------------------------------
  @func Returns a Timer value given its name.
  @parm const char | *name | The name of the timer.
  @parm VcRTContext | *context | Pointer to the context to seach in.
  @rdesc Pointer to the timer value. NULL if not found.
*/
GciValue* VcContextGetTimerByName(const char *name, const VcRTContext *context);

/*-------------------------------------------------------------------------
  @func Returns a Timer value given its zero-indexed position in the list.

  @parm int         | pos     | Zero-indexed position.
  @parm const VcRTContext*| context | Pointer to the context to seach in.

  @rdesc Pointer to the timer value. NULL if erroneous position.
*/
GciValue* VcContextGetTimerByIndex(int pos, const VcRTContext *context);

/*------------------------------------------------------------------------
  @func Returns the context ID.
  @parm const VcRTContext | *context | Context to search in.
  @rdesc The context ID.
*/
int VcContextGetID(const VcRTContext* context);


/*------------------------------------------------------------------------
  @func Returns the context type.
  @parm VcRTContext | *context | Context to search in.
  @rdesc The context type (VcMTC, VcPTC or VcMaster).
*/
VcContextType VcContextGetType(const VcRTContext* context);

/*-------------------------------------------------------------------------
  @func Returns a constant value given its name.
  @parm const char | *name | The name of the timer.
  @parm VcRTContext | *context | Pointer to the context to seach in.
  @rdesc Pointer to the timer value. NULL if not found.
*/
GciValue* VcContextGetTestCaseVariableByName(const char *name, const VcRTContext *context);
GciValue* VcContextGetTestSuiteVariableByName(const char *name, const VcRTContext *context);
GciValue* VcContextGetTestSuiteParameterByName(const char *name, const VcRTContext *context);
GciValue* VcContextGetTestSuiteConstantByName(const char *name, const VcRTContext *context);
GciValue* VcContextGetPCOorCPByName(const char *name, const VcRTContext *context);

int VcGetNumberOfTimers(void);


/*------------------------------------------------------------------------------
  @func returns the name of a timer given its id. This function is called from the
        Gci Layer.
  @parm int | TimerD | The identifier for the timer.
  @rdesc name of the timer or null if not found.
*/
const char* VcGetTimerName(int TimerD);


/*------------------------------------------------------------------------
  @func Every context has a unique identifier. This function returns the context
        identifier.
  @parm const VcRTContext | *context | Pointer to the runtime context.
  @rdesc The context id as an integer.
*/
int VcGetContextID(const VcRTContext* context);

/*---------------------------------------------------------------------------
  @func Name of the test component that is associated with this context.
  @parm const VcRTContext | *context | Pointer to the context
  @rdesc Name of the test component.

*/
const char* VcGetTestComponentName(const VcRTContext *context); 

/*---------------------------------------------------------------------------
  @func Id of the test component that is associated with this context.
  @parm const VcRTContext | *context | Pointer to the context
  @rdesc Id of the test component.

*/
int VcGetTestComponentID(const VcRTContext *context); 



GciValue* VcCreateTSParameter(const char* parameter_name, const char *pics_pixit_ref);

/*---------------------------------------------------------------------------
  @func Query number of declared PCO channels.
  @rdesc Number of PCOs in generated code.
*/
int VcGetNumberOfPCOs(void);
int VcGetNumberOfCPs(void);

/*---------------------------------------------------------------------------
  @func Convert the zero-indexed table entry for a PCO to its ID number.
  @parm int | index | The zero-indexed value.
  @rdesc The ID number as an integer or -1 on failure.
*/
int VcGetPCOIDFromIndex(int index);

/**********************************************************************
  @func Returns the first value in the pco or cp's in queue.
        The value is not removed from the queue. If the in_queue
        is empty this function returns null.
  @parm GciValue | *pco_or_cp | Pointer to the pco or cp.
  @rdesc Pointer to the first value in the in queue. NULL if the
         in queue is empty.
*/
GciValue* VcPeekPCOorCPQueue(GciValue* pco_or_cp, const char* owner);

/*******************************************************************
  @func Gets the first value from a pco or cp in queue and removes the
        value from the queue.
  @parm GciValue | *pco_or_cp | Pointer to the pco or cp value.
  @rdesc The first value in the in queue or NULL if the queue was 
         empty.
*/
GciValue* VcPopPCOorCPQueue(GciValue* pco_or_cp, const char* owner);

/*---------------------------------------------------------------------------
  @func Convert the zero-indexed table entry for a timer to its ID number.
        Note that since timers have different ID numbers depending on which context
        they reside in, we need the current context specified as well.
  @parm int           | index   | The zero-indexed value.
  @parm const VcRTContext*  | context | The run-time context.
  @rdesc The ID number as an integer or -1 on failure.
*/
int VcGetTimerIDFromIndex(int index);


/*--------------------------------------------------------------------
  @func Retrieves the internal zero-based table index for a given PCO.
  @parm int | pcoID | The PCO identifer (such as GcPCO1D).
  @rdesc The zero-based index number, or -1 on failure.
 */
int VcGetPCOIndexFromID(int pcoID);

/*--------------------------------------------------------------------
  @func Retrieves the internal zero-based table index for a given timer.

  @parm const VcRTContext | *context | The context to look in
  @parm int | timerID | The timer identifer (such as GcTimer7013D).

  @rdesc The zero-based index number, or -1 on failure. Note that the 
         identifier will be unique for the active context. The same function
         will return a different value when in another context.
 */
int VcGetTimerIndexFromID(int timerID);

/*--------------------------------------------------------------------
  @func Registers a context as being owned by a certain test component.
  @parm VcRTContext*  | context | The context to look in.
  @parm int           | id      | The test component ID.

  @rdesc GciOk or GciNotOk depending on the result.
 */
GciStatus VcContextRegisterOwner(VcRTContext* context, int id);


/*--------------------------------------------------------------------
  @func Breaks the association between a context and a test component.
  @parm int           | id      | The test component ID.

  @rdesc GciOk or GciNotOk depending on the result.
 */
GciStatus VcContextRemoveOwner(int id);


/*--------------------------------------------------------------------
  @func Returns the owner context given a test component ID.
  @parm int           | id      | The test component ID.

  @rdesc The context, or NULL on error.
 */
VcRTContext* VcContextGetOwner(int id);


/*-------------------------------------------------------------------------------------------------
  Dynamic part related functions
-------------------------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------
  @func Retrieves the names of either the PCOs or CPs used by the given 
        test component. Prepared for TTCN 3 where component configurations
        are dynamic and the owner of a PCO can change over time. Note that
        CPs have two owners, which means that a single CP can appear in two
        different queries.
  @parm GciComponent* | component | The test component.
  @parm VcTypeID      | type      | GcPCOD or GcCPD.
  @parm VcRTContext   | *context  | Pointer to our current context

  @rdesc A string array of channel names.
 */
const char* const* VcGetChannelNames(GciComponent* component, VcTypeID type, VcRTContext* context);

/*---------------------------------------------------------------------------
  @func Internal function to initialize a TTCN default set.
  @rdesc An empty default list, or NULL.
*/
GciDefaultList* IcInitDefaults(void);


/*---------------------------------------------------------------------------
  @func Internal function to destroy a TTCN default set.
  @parm GciDefaultList* | default_list | Pointer to the list to destroy.
  @rdesc GciOk on success.
*/
GciStatus IcDestroyDefaults(GciDefaultList* default_list);


/*---------------------------------------------------------------------------
  @func Internal function to copy a TTCN default set.
  @parm GciDefaultList* | default_list | Pointer to the list to copy.
  @parm GciDefaultList* | result_list  | [out] The resulting list.
  @rdesc GciOk on success.
*/
GciStatus IcCopyDefaults(GciDefaultList* default_list, GciDefaultList** result_list);

/*---------------------------------------------------------------------------
  @func The number of active defaults in the set.
  @parm GciDefaultList* | default_list | Pointer to the list
  @rdesc Number of defaults or -1 on error.
*/
int IcNoOfActiveDefaults(GciDefaultList* default_list);


/*---------------------------------------------------------------------------
  @func The next TTCN default, given a position in the activate list.
        The position variable is then modified to point to the next default function.
  @parm GciDefaultPosition| pos     | [in][out] The position in the list of active defaults.
  @parm GciValue**        | args    | [out] The actual parameters to the default function.
  @parm GciDefaultList*   | context | Pointer to the context

  @rdesc A function pointer to the given default function or NULL on error.
*/
GciDefaultFunction IcGetNextActiveDefault(GciDefaultPosition* pos, 
                                          GciValue*** args,
                                          GciDefaultList* default_list);


/*---------------------------------------------------------------------------
  @func Get the position of the first TTCN default function of the list.
  @parm VcDefaultList*      | default_list | Pointer to the default list.
  @rdesc The position value or VcNO_MORE_DEFAULTS on error or no currently active defaults.
*/
GciDefaultPosition IcGetFirstActiveDefaultPosition(GciDefaultList* default_list);


/*---------------------------------------------------------------------------
  @func Clear the list of active TTCN defaults.
  @parm GciDefaultList*  | default_list | Pointer to the default list.
  @rdesc GciOk if all went fine, GciNotOk otherwise.
*/
GciStatus IcClearActiveDefaultSet(GciDefaultList* default_list);


/*---------------------------------------------------------------------------
  @func Add a default pointer, with arguments to the active default set.
  @parm GciDefault*     | handle        | Pointer to TTCN default function in generated code.
  @parm GciValue**      | args          | The list of arguments to the default function.
  @parm int             | number_of_args| The number of arguments.
  @parm GciDefaultList* | default_list  | [in][out]Pointer to the default list to add to.

  @rdesc GciOk if all went fine, GciNotOk otherwise.
*/
GciStatus IcAddActiveDefault(GciDefaultFunction handle,
                             GciValue** args,
                             int number_of_args,
                             GciDefaultList* default_list);




/*---------------------------------------------------------------------------
  @func Return the currently active context.
 
  @rdesc The runtime context.
*/
VcRTContext* IcGetActiveContext(void);


/*-------------------------------------------------------------------------
  @func Sets the currently running context to the "global" handle. This solution
        is needed because of the currently implementation of the gci interface.

  @parm VcRTContext | *context | Pointer to the context. 
  @rdesc void
*/
GciStatus IcSwitchContext(VcRTContext* context);


/*---------------------------------------------------------------------------
  @func Given a test case or group name, returns the function pointers to 
        the generated test function, and its selection expression.

  @parm IcTCData* | tc_info | [in][out]Contains the name, and the pointer data is filled in.
  @rdesc GciOk if all went fine, GciNotOk otherwise.
*/
GciStatus IcGetTestCaseOrGroupFunctions(IcTCData* tc_info);

/*---------------------------------------------------------------------------
  @func Given a test step name, returns the function pointer to 
        the generated test function.

  @parm IcTSData* | ts_info | [in][out]Contains the name, and the pointer data is filled in.
  @rdesc GciOk if all went fine, GciNotOk otherwise.
*/
GciStatus IcGetTestStepFunction(IcTSData* ts_info);


/*---------------------------------------------------------------------------
  @func Converts a GCI verdict to a string depicting the verdict.
  @parm GciVerdict | verdict | The GciVerdict.
  @rdesc A resulting string, or the empty string if verdict has a bad value.
*/
const char *IcVerdict2Str(GciVerdict verdict);


/*--------------------------------------------------------------------
  @func Returns the internal index of the given test component.
  @parm VcRTContext*  | context | The run-time context of the TC.
  @rdesc The integer value that can be used to look up the component data of the "components" variable.
*/
int IcLocalComponentIndex(VcRTContext* context);

/*--------------------------------------------------------------------
  @func Query whether a test component is executing (non-blocked).
  @parm VcRTContext*  | context | The run-time context of the TC.  
  @rdesc GcTRUE if it is executing.
*/
Bool IcTCExecuting(VcRTContext* context);

/*--------------------------------------------------------------------
  @func Set status of all test components to be executing (non-blocked)
*/

void IcTCSetAllExecuting(void);

/*--------------------------------------------------------------------
  @func Query whether all test components are currently blocked.

  @rdesc GcTRUE if all test components are blocked (waiting for snapshot)
*/
Bool IcTCAllReadyForSnapshot(void);

/*--------------------------------------------------------------------
  @func Set status of this test component to be ready for snapshot.
  @parm VcRTContext*  | context | The run-time context of the TC.  
*/
void IcTCSetReadyForSnapshot(VcRTContext* context);

/*--------------------------------------------------------------------
  @func Set status of this test component to be none (initialised or DONE)
  @parm VcRTContext*  | context | The run-time context of the TC.  
*/
void IcTCSetNone(VcRTContext* context);

/*--------------------------------------------------------------------
 @func Set status of this test component to be executing.
 @parm VcRTContext*  | context | The run-time context of the TC.  
*/
void IcTCSetExecuting(VcRTContext* context);


/********************************************************************************************************************
  @func Internal Send function. This function makes difference of cp's and pco if the concurrency model
        shared memory. If so it calls another interal function IcCPSend. In all other cases it makes a call
        to GciSend and Logs the send operation accorting to the logging standard in TTCN.
  
  @parm const char  | *line_label   | Label of the TTCN row. This should be null if no label.
  @parm int         | line_number   | The number of the behaviour line in the ttcn table.  @parm VcRTContext | *context | Pointer to the runtime context.
  @parm int         | pco_or_cp_id  | Identifier to the pco or cp which to send the "data" on.
  @parm GciValue    | *value        | Pointer to the value to send.

  @rdesc MATCH if successful.
*/
GciTestResult IcSend(const char* line_label, 
                     int line_number,
                     VcRTContext* context, 
                     int pco_or_cp_id, 
                     GciValue *value);


/********************************************************************************************************************
  @func Corresponding to the old "IcReceive" function, this function checks if it is
        possible to receive something on the corresponding PCO/CP that matches
        the given constraint.

  @parm VcRTContext | *context      | Pointer to the runtime context.
  @parm int         | pco_or_cp_id  | Identifier to the pco or cp which to check for data.
  @parm GciValue    | *constraint   | The constraint for the receive to match.

  @rdesc MATCH if successful.
*/
GciTestResult IcCanReceive(VcRTContext* context, 
                           int pco_or_cp_id, 
                           GciValue *constraint,
                           GciValue **received_value);


/********************************************************************************************************************
  @func This function checks if it is possible to remove anything from the given PCO/CP.

  @parm VcRTContext | *context      | Pointer to the runtime context.
  @parm int         | pco_or_cp_id  | Identifier to the pco or cp which to check for incoming data.

  @rdesc MATCH if successful.
*/
GciTestResult IcOtherwise(VcRTContext* context, int pco_or_cp_id, GciValue **received_obj);


/*-------------------------------------------------------------------------
  @func Set final verdict in current context.

  @parm const char  | *line_label   | Label of the TTCN row. This should be null if no label.
  @parm int         | line_number   | The number of the behaviour line in the ttcn table. *  This function is called to set a verdict.
  @parm VcRTContext | *context      | Pointer to the runtime context.
  @parm GciVerdict  | verdict       | The new verdict.

  @rdesc MATCH if OK, ERROR otherwise.
 */

GciTestResult IcSetFinalVerdict(const char* line_label, 
                                int line_number,
                                VcRTContext* context,
                                GciVerdict verdict);


/*-------------------------------------------------------------------------
  @func Set preliminary verdict in current context.

  @parm const char  | *line_label   | Label of the TTCN row. This should be null if no label.
  @parm int         | line_number   | The number of the behaviour line in the ttcn table. *  This function is called to set a verdict.
  @parm VcRTContext | *context      | Pointer to the runtime context.
  @parm GciVerdict  | verdict       | The new verdict.

  @rdesc MATCH if OK, ERROR otherwise.
 */

GciTestResult IcSetPreliminaryVerdict( const char* line_label, 
                                       int line_number,
                                       VcRTContext* context,
                                       GciVerdict verdict);


/*-------------------------------------------------------------------------
 * Name:    IcCreate
 *
 * @func The internal function for CREATE in concurrent TTCN.
 *
 * @parm const char*  | line_label      | Label of current TTCN line.
 * @parm int          | line_number     | Current TTCN line.
 * @parm int          | component       | Test component identifier.
 * @parm const char*  | test_step       | Test step name.
 * @parm GciValue**    | args            | Arguments to test step.
 *
 * @rdesc MATCH on success, ERROR otherwise.
 */

GciTestResult IcCreate(const char* line_label,
                       int line_number,
                       VcRTContext* master_context,
                       int component, 
                       const char* test_step, 
                       GciValue** args);

/*-------------------------------------------------------------------------
  Name:    IcDone
 
  @func The function for DONE. Determines whether one specific, or all started
        PTC's are stopped.

  @parm const char*  | line_label      | Label of current TTCN line.
  @parm int          | line_number     | Current TTCN line.
  @parm const char*  | component_name  | Name of test component.
  @parm int          | component       | Parallel test component identifier.
   
  @rdesc MATCH, NOMATCH or ERROR. MATCH = Yes, the PTC(s) have stopped.
 */

GciTestResult IcDone(const char* line_label,
                     int line_number,
                     const char* component_name,
                     VcRTContext* context,
                     int component);



/*-------------------------------------------------------------------------
  @func The function for IMPLICIT SEND.
 
  @parm VcRTContext*| context | Pointer to the runtime context.
  @parm GciValue*   | value   | Value to send.
 
  @rdesc MATCH on success, ERROR otherwise.
 */
GciTestResult IcImplicitSend(VcRTContext* context, GciValue *value);


/*-------------------------------------------------------------------------
  @func Checks if a given PCO is empty or not.
 
  @parm VcRTContext* | context | Pointer to the runtime context.
  @parm int          | pco     | PCO ID.
 
  @rdesc GcTRUE if the PCO is empty, GcFALSE otherwise.
 */
Bool IcIsPCOEmpty(VcRTContext* context, int pco);


/*-------------------------------------------------------------------------
  @func The function for timeout.
 
  @parm const char*  | line_label | Label of current TTCN line.
  @parm int          | line_number| Current TTCN line.
  @parm VcRTContext* | context    | Pointer to the runtime context.
  @parm int          | TimerD     | Timer ID.
 
  @rdesc MATCH on success, NOMATCH if timeout failed, ERROR otherwise.
 */

GciTestResult IcTimeout( const char* line_label,
                         int line_number,
                         VcRTContext* context, 
                         int timerID);



/*-------------------------------------------------------------------------
  @func Starts a timer by updating the timer object and utilizing the GCI layer.
 
  @parm const char*  | line_label | Label of current TTCN line.
  @parm int          | line_number| Current TTCN line.
  @parm VcRTContext* | context    | Pointer to the runtime context.
  @parm int          | TimerID    | Timer ID.
  @parm long         | duration   | The duration or GcDEFAULT_DURATION in which case the declared default duration of the timer will be used.
 
  @rdesc MATCH on success, ERROR otherwise.
 */

GciTestResult IcStartTimer(const char* line_label,
                           int line_number,
                           VcRTContext* context, 
                           int timerID,
                           long duration);

/*-------------------------------------------------------------------------
  @func Cancel one or more timers by updating the timer object and utilizing the GCI layer.
 
  @parm const char*  | line_label | Label of current TTCN line.
  @parm int          | line_number| Current TTCN line.
  @parm VcRTContext* | context    | Pointer to the runtime context.
  @parm int          | TimerID    | Timer ID or GcANY_TIMERD to cancel all timers.
 
  @rdesc MATCH on success, ERROR otherwise.
 */

GciTestResult IcCancelTimer(const char* line_label,
                            int line_number,
                            VcRTContext* context, 
                            int timerID);

/*-------------------------------------------------------------------------
  @func Reads the current value of a timer from GCI.
 
  @parm const char*  | line_label | Label of current TTCN line.
  @parm int          | line_number| Current TTCN line.
  @parm VcRTContext* | context    | Pointer to the runtime context.
  @parm int          | TimerID    | Timer ID.
  @parm GciValue*    | variable   | The test case or test suite variable to assign the value to.
  
  @rdesc MATCH on success, ERROR otherwise.
 */

GciTestResult IcReadTimer(const char* line_label,
                          int line_number,
                          VcRTContext* context, 
                          int timerID,
                          GciValue* variable);


/*-------------------------------------------------------------------------
  @func Performs and logs an assignment between two values.
 
  @parm const char*  | line_label | Label of current TTCN line.
  @parm int          | line_number| Current TTCN line.
  @parm GciValue*    | source     | The source value               
  @parm GciValue*    | destination| The destination value

  
  @rdesc MATCH on success, ERROR otherwise.
 */
GciTestResult IcAssign(const char* line_label,
                       int line_number,
                       GciValue* source, 
                       GciValue* destination);


/*-------------------------------------------------------------------------
  @func Performs and logs an assignment between two values,
	where the left is the bit reference
 
  @parm const char*  | line_label  | Label of current TTCN line.
  @parm int          | line_number | Current TTCN line.
  @parm GciValue*    | source      | The source value               
  @parm GciValue*    | destination | The destination value
  @parm unsigned int | index number| destination index number.
  @parm Bool         | is_id       | Is destination index present in user's specification as ID.

  
  @rdesc MATCH on success, ERROR otherwise.
 */
GciTestResult IcAssignToBitRef(const char* line_label,
                       int line_number,
                       GciValue* source,
                       GciValue* destination, 
			                 unsigned int index,
											 Bool is_id);
/*-------------------------------------------------------------------------
  @func Performs and logs an assignment between two values,
	where the Right is the bit reference
 
  @parm const char*  | line_label  | Label of current TTCN line.
  @parm int          | line_number | Current TTCN line.
  @parm GciValue*    | source      | The source value               
  @parm unsigned int | index number| source index number.
  @parm GciValue*    | destination | The destination value

  
  @rdesc MATCH on success, ERROR otherwise.
 */
GciTestResult IcAssignFromBitRef(const char* line_label,
                       int line_number,
                       GciValue* source,
			                 unsigned int index,
                       GciValue* destination);
/*-------------------------------------------------------------------------
  @func Performs and logs an assignment between two values,
	where the left and right both are the bit reference
 
  @parm const char*  | line_label  | Label of current TTCN line.
  @parm int          | line_number | Current TTCN line.
  @parm GciValue*    | source      | The source value               
  @parm unsigned int | index number| source index number.
  @parm GciValue*    | destination | The destination value
  @parm unsigned int | index number| destination index number.
  @parm Bool         | is_id       | Is destination index present in user's specification as ID.

  
  @rdesc MATCH on success, ERROR otherwise.
 */
GciTestResult IcAssignBitRef(const char* line_label,
                       int line_number,
                       GciValue* source,
			                 unsigned int source_index,
                       GciValue* destination, 
			                 unsigned int destination_index,
											 Bool is_id);
/* x-seanpo ---begin--- BUG=sim_3001910 */
/*-------------------------------------------------------------------------
  @func The internal function for Attach construction in concurrent TTCN. 
 
  @parm const char*     | line_label      | Label of current TTCN line.
  @parm int             | line_number     | Current TTCN line.
  @parm const char*     | test_step_name  | Test step name.
  @parm function*       | test_step_func  | Test step function.
  @parm GciValue**      | _args           | Arguments to test step.
  @parm GciDefaultList* | _default        | Default to test step.
  @parm VcRTContext*    | _context        | 
  @parm Bool            | _is_ptc         | PTC or MTC
	 
  @rdesc result of test step function.
 */

GciTestResult IcAttach(const char* line_label,
                       int line_number,
                       const char* test_step_name, 
/*x-seanpo ---begin--- BUG=ccg_1009683 (Part 2)*/
		       GciTestStepFunction test_step_func,
/*		       GciTestResult (*test_step_func)(GciValue **,GciDefaultList *, VcRTContext *, Bool),*/
/*x-seanpo ---end----*/
                       GciValue** _args,
                       GciDefaultList * _default,
		       VcRTContext * _context,
/*x-seanpo ---begin--- BUG=ccg_1009683 (Part 2)*/
		       Bool _is_repeat,
		       Bool *snapshot_useless);
/*x-seanpo ---end----*/
/* x-seanpo ---end--- */
/*-------------------------------------------------------------------------------------------------  
  @func Internal function for setting bit reference to a bit value. If the string is not
        defined or the "current" string is shorther than the named bit position
        a new longer string will be allocated.
*/
GciStatus VcSetBitRef(GciValue* value, unsigned int index, Bool bitvalue);
/*-------------------------------------------------------------------------------------------------  
  @func Internal function for geting bit reference to a bit value. If the string is not
        defined or the "current" string is shorther than the named bit position error occure.
*/
GciStatus VcGetBitRef(GciValue* value, unsigned int index, Bool *bitvalue);


/*-------------------------------------------------------------------------
  @func The internal snapshot function.
  @parm VcRTContext* | context    | Pointer to the runtime context.
  @rdesc GciStatus from GciSnapshot..
*/
GciStatus IcSnapshot(VcRTContext* context);


/********************************************************************************************************************
  @func Query whether the given channel identifier depicts a CP or PCO.
  @parm int | pco_or_cp_id  | Identifier to the pco or cp.
  @rdesc GcTRUE if the channel is a CP, GcFALSE otherwise.
*/
Bool IcIsCP(GciValue* pco_or_cp);

/*---------------------------------------------------------------------------
  @func Given a test case or group name, returns the function pointers to 
        the generated test function, and its selection expression as well
        as the reference to the test configuration.

  @parm IcTCData* | tc_info | [in][out]Contains the name, and the pointer data is filled in.
  @rdesc GciOk if all went fine, GciNotOk otherwise.
*/
GciStatus IcGetTestCaseOrGroupData(IcTCData* tc_info);


/********************************************************************************************************************
  @func Cryptic internal CP-send function.

  @parm VcRTContext | *context | Pointer to the runtime context.
  @parm GciValue    | *cp_id   | Identifier for the CP.
  @parm GciValue    | *value   | The value to send.

  @rdesc GciOk upon success.
*/
GciStatus IcCPSend(VcRTContext* context, GciValue* pco_or_cp, GciValue* value);

/********************************************************************************************************************
  @func Returns the name of a component given it's id number.
  @parm int | component_id | The id number of the component.
  @rdesc A null terminated string. 
*/
const char* IcGetComponentName(int component_id);

void IcTaskInit(void);
void IcTaskCleanup(void);

/*-------------------------------------------------------------------------
  @func Retrieve the session verdict, defined as the worst verdict of
        a set of consecutive test case verdicts between a pair of
        GciInit() and GciExit() calls.

  @rdesc A GciVerdict.
 */
GciVerdict IcGetSessionVerdict(void);

/*------------------------------------------------------------------------------------------------
  Gci layer support functions 
--------------------------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------
  @func Support function for GciGetMemberCount. Determines how many children (members)
        a given structured type can have by building a temporary GCI value.
  @parm VcTypeID  | type | Type of the value.
  @rdesc The number of members (which can be zero).
*/
unsigned VcGetMemberCount(VcTypeID type);

/*--------------------------------------------------------------------
  @func Support function for GciGetMemberType. Determines the type of a
        child to a structured type by building a temporary GCI value.
  @parm VcTypeID  | type  | Type of the value.
  @parm unsigned  | index | The zero-based index of the member/child.
  @rdesc The member type or -1 on error.
*/
int VcGetMemberType(VcTypeID type, unsigned index);

/*--------------------------------------------------------------------
  @func Support function for GciGetMemberName. Determines the name of a
        child to a structured type by building a temporary GCI value.
  @parm VcTypeID  | type  | Type of the value.
  @parm unsigned  | index | The zero-based index of the member/child.
  @rdesc The member name or NULL on error.
*/
const char* VcGetMemberName(VcTypeID type, unsigned index);

/*-------------------------------------------------------------------------------------------------
  @func   Constructor function for creating a basetype SEQUENCE value with a give size. This way of
          creating values is only excisting because of the GCI layer and backward compability.
          NOTE: This constructor is NOT called from the VcMakeValue. It is only and SHOULD only
          be used as a help function to the GCI layer function for creating a sequence.
          Usage of this function in the generated code could lead to memory leakage.


  @parm   GciValue | **sequence   | [out] Pointer to a SEQUENCE value struct. 
  @parm   int      | initial_size | Number of members to store in this SEQUENCE.
  
  @rdesc GciOk if the value could be created.
*/
GciStatus VcMkSEQUENCEOfSize(GciValue** sequence, unsigned int initial_size);

/****************************************************************
  @func Adds a new value to the end of the of a pco or cp queue.

  @parm GciValue | *pco_or_cp | Pointer to the pco value.
  @parm GciValue | *value     | Pointer to the value to be added to the 
                                in queue.
  @rdesc GciOk on success.
*/
GciStatus VcAppendToPCOorCPQueue(GciValue* pco_or_cp, GciValue* value);

/*--------------------------------------------------------------------------
  Macro definitions
----------------------------------------------------------------------------*/

/* 
  This macro is used in functions there incoming parameters are not used. 
   Some compilers complains about that and this macro is used to fake that
   the parameter is actually used.
*/
#define VC_NOT_USED(a) /*lint -save -e506 -e774 -e548*/ if(a && !a) ; /*lint -restore */

/*
    Macro for checking pointers. If the pointer is NULL then we sets an error code
    and returns the the third argument.
*/
#define VC_CHECK_NULL(x,error,return_type) \
  if(!(x)) { \
    EGciSetLastError(E_NONE, error); \
    return (return_type); \
  }

/*
    Check two pointers if they are allocated with the same memory 
    model. If both are Temorary or both are permanent this does not 
    return an error. Otherwise the gci_different_memory_types error.
*/
#define VC_CHECK_MEMORY_TYPE(p1, p2) \
  if(IcIsTemporary(p1) != IcIsTemporary(p2)) { \
    EGciSetLastError(E_INT, E_DIFFERENT_MEMORY_TYPES()); \
    return GciNotOk; \
  }

#define VC_CHECK_NULL_NOERROR(x,return_type)         if(!(x)) return (return_type); 

/*
  Checks if a pointer is null. If so it sets an error code specified by
  the second argument.
*/
#define VC_CHECK_NULL_VOID(x,error) \
  if(!(x)) { \
    EGciSetLastError(E_NONE, error); \
    return; \
  }

GciStatus VcMkDefault(GciValue* value);
GciStatus VcMkANY(GciValue* value);
GciStatus VcMkSEQUENCE(GciValue* sequence);
GciStatus VcMkSEQUENCEOF(GciValue* sequenceof);
GciStatus VcMkSET(GciValue* set);
GciStatus VcMkSETOF(GciValue* setof);
GciStatus VcMkCHOICE(GciValue* value );
GciStatus VcMkOBJECTIDENTIFIER(GciValue* obj_id);
GciStatus VcMkTIMER(GciValue* value);
GciStatus VcMkPDU(GciValue* pdu);
GciStatus VcMkPCOorCP(GciValue* value);


GciStatus VcAssignSEQUENCE(GciValue* destination, GciValue* source, Bool is_insteadofvalue_allowed);
GciStatus VcAssignSEQUENCEOF(GciValue *destination, GciValue *source, Bool is_insteadofvalue_allowed);
GciStatus VcAssignSET(GciValue* destination, GciValue* source, Bool is_insteadofvalue_allowed);
GciStatus VcAssignSETOF(GciValue *destination, GciValue *source, Bool is_insteadofvalue_allowed);
GciStatus VcAssignCHOICE(GciValue* destination, GciValue* source, Bool is_insteadofvalue_allowed);
GciStatus VcAssignOBJECTIDENTIFIER(GciValue* destination, GciValue* source, Bool is_insteadofvalue_allowed);
GciStatus VcAssignNULL(GciValue* destination,GciValue* source, Bool is_insteadofvalue_allowed);
GciStatus VcAssignINTEGER(GciValue* destination,GciValue* source, Bool is_insteadofvalue_allowed);
GciStatus VcAssignBOOLEAN(GciValue* destination,GciValue* source, Bool is_insteadofvalue_allowed);
GciStatus VcAssignSTRING(GciValue* destination,GciValue* source, Bool is_insteadofvalue_allowed);
GciStatus VcAssignRTYPE(GciValue* destination,GciValue* source, Bool is_insteadofvalue_allowed);
GciStatus VcAssignENUMERATED(GciValue* destination,GciValue* source, Bool is_insteadofvalue_allowed);
GciStatus VcAssignANY(GciValue* destination, GciValue *source, Bool is_insteadofvalue_allowed);
GciStatus VcAssignOmittedValue(GciValue* destination, GciValue* source, Bool is_insteadofvalue_allowed);

Bool VcSpecialOmitAssign(GciValue* val);
GciVerdict VcDetermineGroupVerdict(GciVerdict old_ver, GciVerdict new_ver );


void VcDefaultRm(GciValue* value);
void VcRmSTRING(GciValue* string);
void VcRmSEQUENCE(GciValue* value);
void VcRmSEQUENCEOF(GciValue* value) ;
void VcRmSET(GciValue* value);
void VcRmSETOF(GciValue* value);
void VcRmCHOICE(GciValue* value);
void VcRmOBJECTIDENTIFIER(GciValue* value);
void VcRmANY(GciValue* value);
void VcRmPCOorCP(GciValue* value);

GciStatus VcCpINTEGER(GciValue *source,GciValue** output, Bool temp_mem );
GciStatus VcCpBOOLEAN(GciValue *source,GciValue** output, Bool temp_mem);
GciStatus VcCpSTRING(GciValue *source,GciValue** output, Bool temp_mem);
GciStatus VcCpNULL(GciValue* source, GciValue** output, Bool temp_mem);
GciStatus VcCpRTYPE(GciValue *source,GciValue** output, Bool temp_mem);
GciStatus VcCpSEQUENCE(GciValue* source, GciValue** output, Bool temp_mem);
GciStatus VcCpSEQUENCEOF(GciValue* source, GciValue** output, Bool temp_mem);
GciStatus VcCpSET(GciValue* source, GciValue** output, Bool temp_mem);
GciStatus VcCpSETOF(GciValue* source, GciValue** output, Bool temp_mem);
GciStatus VcCpCHOICE(GciValue* source, GciValue** output, Bool temp_mem);
GciStatus VcCpENUMERATED(GciValue *source, GciValue** output, Bool temp_mem );
GciStatus VcCpOBJECTIDENTIFIER(GciValue* source, GciValue** output, Bool temp_mem);
GciStatus VcCpTIMER(GciValue *timer, GciValue **output, Bool temp_mem);
GciStatus VcCpANY(GciValue* source, GciValue** output, Bool temp_mem);

/* The predefined operations */

GciValue*     HEX_TO_INT(GciValue* hexvalue[]);
GciValue*     INT_TO_HEX(GciValue* integer[]);
GciValue*     BIT_TO_INT(GciValue* bitstring[]);
GciValue*     INT_TO_BIT(GciValue* integer[]);
GciValue*     IS_PRESENT(GciValue*[]);
GciValue*     IS_CHOSEN (GciValue*[]);
GciValue*     NUMBER_OF_ELEMENTS(GciValue* of_value[]);
GciValue*     LENGTH_OF         (GciValue* string[]);

/***************************************************************************
  The heap could be built up in several pices. This because if the heap should
  be full we have to allocate more memory. But we can't use realloc because it 
  could move the "heap" and then all pointer in the heap should point to wrong
  memory. Instead we use a list of heaps.
*/
typedef struct heap_list
{
  char* heap;               /* Start of the heap */
  unsigned int heap_size;   /* Size of the heap */
  char* next_free;          /* Pointer to the next free heap memory   */
  struct heap_list* next;   /* Pointer to the next heap. */
} IcHeapList;

typedef struct ic_mem_context {
  IcHeapList*  first_heap_blk;    /* Pointer to the heal list.              */
  unsigned int initial_size;      /* Initaal size of the heap */
  unsigned int grow_size;         /* How much the heap should grow if full */
  IcHeapList*  current_heap;      /* Pointer to the current heap.          */
} IcMemContext;

/*-------------------------------------------------------------------------
  @struct The run-time context object.
*/
struct VcRTContext {
  char*           component_name;       /* @field The name of the test component owning this context. */
  int             component_id;         /* @field The ID of the test component owning this context. */
  VcContextType   context_type;         /* @field Type of context MASTER,MTC or PTC */

  /* Size of this table depends on the testsuite (number of variables in the test suite) */

  GciValue**       ts_constants;
  GciValue**       ts_parameters;
  GciValue**       ts_variables;
  GciValue**       tc_variables;
  GciValue**       timers;
  GciValue**       pcos_and_cps;   /* @field Array of all pco and cps in the test suite.Master has this array. */
  int              context_id;    /* @field Every context has a unique identifier from 1 .. 
                                     This because we have to have unique external identifiers
                                     for example timers. */
  IcMemContext     memory;         /* @field This is the temporary memory are for this component. */
/* !!! Author: x-abo. Date: 2001.Nov.20
   Patch for ccg_1008063: PreQ: ALIAS-name is not shown in logs, real name is.*/
	const char *log_alias_name;    /* pointer to the alias name for correct logging. NULL when no aliases */
/* ===/Author: x-abo. */
};
/************************************************************************
  @func Checks if two values matches. TTCN is weak types so the match will try
        to match the types first. If they are of the same base type then it
        tries to match the values.

  @parm GciValue* | constraint  | The reference object.
  @parm GciValue* | value       | The incoming value 
  @rdesc GcTRUE if they matches. NOTE if the incoming parmeters are null
         this function returns GcFALSE.
*/      
Bool VcMatch(GciValue* constraint, GciValue* value);

/*-------------------------------------------------------------------------------------------------
  @func Restriction function all base types.

  @parm  GciValue | value | not used
  
  @rdesc Always returns GcTRUE.
*/
Bool VcCheckDefault(GciValue* value, VcRTContext *context);

GciStatus VcCPInternalSend(GciValue* cp, GciValue* value, const char* sender);

/*-------------------------------------------------------------------------------------------------
  @func Resets the pco or cp to it's initial state. That is no owner and empty queues. All values
        in the inqueues will be destroyed and freed.

  @parm GciValue | *value | Value pointer to the pco or cp.

  @rdesc GciOk if the pco/cp could be cleared.
*/
GciStatus VcClearPCOorCP(GciValue* value);

/*-------------------------------------------------------------------------------------------------
  @func Resets all pcos and cps to their initial state. No onwer or queues.
  
  @rdesc GciOk if they could be cleared.
*/
GciStatus IcClearAllPCOSAndCPS(void);

/*-------------------------------------------------------------------------------------------------
  @func Clear all pcos and cps from old data. Configure the owner of the queues in the pco and
        cps given the configuration.

  @parm GciConf config | Currenct configuration.
  
  @rdesc GciOk if the pcos and cps could be initalized.
*/
GciStatus IcConfigPCOSAndCPS(GciConf config);

/*--------------------------------------------------------------------------------------------------
  @func Given a configuration this function finds the MTC component and returns the identifier of the
        MTC. Raises The gci_failed_to_get_type if the mtc component is not found.

  @parm GciConf | conf | The configuration to look in.

  @rdesc MTC id, or -1 if not found.
*/
int IcGetMTCID(GciConf conf);

/**************************************************************************************
  @func This function sets the "owner" of the CP. Owner is used in the case we have a 
        CP between two components that is in the same address space. In this case we 
        can move a value from the send queue from one end of the CP to the receive queue
        on the other end without calling the GciSend function.
  @parm GciValue    | pco_or_cp | The CP to set the name for.
  @parm const char* | owner     | The name of the owning test component.
  @rdesc GciOk on success and GciNotOk on error.
*/
GciStatus VcSetPCOOrCPOwner(GciValue* pco_or_cp, const char* owner);

/**************************************************************************************
  @func Retrieves the name of the component owning the given PCO or CP.
  @parm GciValue*     | pco_or_cp | The PCO/CP to ask.
  @parm char**        | owner_name| The name of the owning component.
  @rdesc GciOk on success and GciNotOk on error.
*/
GciStatus VcGetPCOOrCPOwnerName(GciValue* pco_or_cp, char** owner_name);

/**************************************************************************************
  @func Retrieves the name of the second component owning the given CP.
  @parm GciValue*     | cp        | The CP to ask.
  @parm char**        | owner_name| [out]The name of the owning component.
  @rdesc GciOk on success and GciNotOk on error.
*/
GciStatus VcGetCPOtherOwnerName(GciValue* cp, char** owner_name);

/*-------------------------------------------------------------------------------------------------
  @func This function is used to check if the value that is a string type contains only the tokens 
        in the incoming tokens parameter. If so this functio return GcTRUE. If it contains other
        tokens than those in the tokens parameter it returns GcFALSE.
  
  @parm GciValue       | *value  | The string type value to check.
  @parm const char     | *tokens | The string of permited characters (The permitted alphabet).
  @rdesc GcTRUE/GcFALSE
*/
Bool VcContainsOnly(GciValue* value, const char* tokens);

/********************************************************************************************************************
  @func Removes the first object of the specified PCO or CP.

  @parm const char  | *line_label   | Label of the TTCN row. This should be null if no label.
  @parm int         | line_number   | The number of the behaviour line in the ttcn table.
  @parm VcRTContext | *context      | Pointer to the runtime context.
  @parm int         | pco_or_cp_id  | Identifier to the pco or cp which to modify.
  @parm GciLogValues| entry_type    | GciLogRecE or GciLogOtherE depending on which event caused this remove.

  @rdesc MATCH if successful.
*/
GciTestResult IcRemoveObjectFromChannel(const char* line_label, int line_number, VcRTContext* context, int pco_or_cp_id,GciLogValues entry_type);

/*--------------------------------------------------------------------------------------------------
  @func Returns the currently active debug output stream.
  @rdesc A FILE* stream, or stderr if none is set.
*/
FILE* IcDebugStream(void);

/*--------------------------------------------------------------------------------------------------
  @func Sets the debug output stream.
  @parm FILE* | stream | The new output stream, e g an opened file, or stderr.
*/
void IcSetDebugStream(FILE* stream);

/*--------------------------------------------------------------------------------------------------
  @func TRUE if the given (possibly OR-ed) flag(s) are set as debug dump options.
  @parm char | dump_flags | Possibly OR-ed set of ICDEBUGQUEUES and/or ICDEBUGTIMERS.
  @rdesc GcTRUE if the flag is set.
*/
Bool IcWillDebugDump(char debug_flags);

/*--------------------------------------------------------------------------------------------------
  @func Set the debug dump flag.
  @parm char | dump_flags | Possibly OR-ed set of ICDEBUGQUEUES and/or ICDEBUGTIMERS.
*/
void IcSetDebugDump(char debug_flags);

/*--------------------------------------------------------------------------------------------------
  @func Dumps the contents of the context to the IcDebugStream according to the
        contents specified in IcDebugFlags.
  @parm VcRTContext* | context | The context to dump.
  @rdesc GciOk on success.
*/
GciStatus IcDebugDumpInternalState(VcRTContext* context);

GciVerdict IcStartTestGroup(const char *name);
Bool IcIsGroupName(const char *name);
GciVerdict IcStartTestCase(const char *name);
/*x-seanpo ---begin--- BUG=ccg_1009683 (Part 2)*/
GciStatus IcRunDefaults(GciDefaultList *defaults, VcRTContext *context, Bool *snapshot_useless); 
/*x-seanpo ---end---*/

GciStatus VcSetOMIT(GciValue* value, Bool flag);
/* !!! Author: x-abo. Date: 2001.Nov.20
   Patch for ccg_1008063: PreQ: ALIAS-name is not shown in logs, real name is.*/
void IcSetAliasName(const char *s, VcRTContext* context);
/* ===/Author: x-abo. */

#endif

