/*****************************************************************************
 *  CDM.h:                                                                   *
 * ----------------------                                                    *
 *  This file defines the Collection and Document Manager (CDM)              *
 *  Public API.                                                              *
 *  Version: 1.0                                                             *
 *  For more details regarding CDM Version consult file "CDM_Version.h"      *
 *  CDM is the Collection and Document Manager and the core component of the *
 *  Ellogon Text Engineering Platform.                                       *
 *  CDM was designed and implemented by Georgios Petasis,                    *
 *  e-mail: petasis@iit.demokritos.gr                                        *
 *  URL:    http://www.iit.demokritos.gr/~petasis                            *
 *                                                                           *
 *  Copyright 1998-2004 by:                                                  *
 *  Georgios Petasis,                                                        *
 *  Software and Knowledge Engineering Laboratory,                           *
 *  Institute of Informatics and Telecommunications,                         *
 *  National Center for Scientific Research (N.C.S.R.) "Demokritos",         *
 *  Athens, Greece.                                                          *
 *  E-mail: petasis@iit.demokritos.gr                                        *
 *                                                                           *
 *  This file is part of the "Ellogon" Text Engineering Platform.            *
 *  For licencing information, please refer to the licence conditions of     *
 *  "Ellogon" Text Engineering Platform.                                     *
 *****************************************************************************/
#ifndef _CDM
#define _CDM

#include <tcl.h>
#include "CDM_Version.h"

/*
 * If the user wants to use the stubs facility, in order to not depend on
 * specific Tcl versions, we have to define USE_TCL_STUBS && USE_TK_STUBS.
 */
#if defined (CDM_USE_STUBS) || defined (USE_TCL_STUBS) || defined (USE_TK_STUBS)

#ifndef   CDM_USE_STUBS
#define   CDM_USE_STUBS
#endif /* CDM_USE_STUBS */

#ifndef   USE_TCL_STUBS
#define   USE_TCL_STUBS
#endif /* USE_TCL_STUBS */

#ifndef   USE_TK_STUBS
#define   USE_TK_STUBS
#endif /* USE_TK_STUBS  */

/* Include the version specific tclstub??.lib under Visual C++... */
#if defined (_MSC_VER) && defined (USE_TCL_STUBS) && defined (CDM_AUTO_INC_LIBS)
#  ifdef _DEBUG
#    pragma comment (lib, "tclstub" STRINGIFY(JOIN(TCL_MAJOR_VERSION,TCL_MINOR_VERSION)) "g.lib")
#  else /* _DEBUG */
#    pragma comment (lib, "tclstub" STRINGIFY(JOIN(TCL_MAJOR_VERSION,TCL_MINOR_VERSION)) ".lib")
#  endif
#endif  /* _MSC_VER && USE_TCL_STUBS */

/* Include the version specific tkstub??.lib under Visual C++... */
#if defined (_MSC_VER) && defined (USE_TK_STUBS) && defined (CDM_AUTO_INC_LIBS) && defined (_TK)
#  ifdef _DEBUG
#    pragma comment (lib, "tkstub" STRINGIFY(JOIN(TCL_MAJOR_VERSION,TCL_MINOR_VERSION)) "g.lib")
#  else /* _DEBUG */
#    pragma comment (lib, "tkstub" STRINGIFY(JOIN(TCL_MAJOR_VERSION,TCL_MINOR_VERSION)) ".lib")
#  endif
#endif  /* _MSC_VER && USE_TK_STUBS */

#endif /* CDM_USE_STUBS || USE_TCL_STUBS || USE_TK_STUBS */

/*
 * Try to find out if the platform the code is compiled on...
 */
#ifndef __WIN32__
#   if defined(_WIN32) || defined(WIN32)
#        define __WIN32__
#   endif
#endif /* __WIN32__ */

#ifdef __WIN32__
#define WINDOWS 
#else
#define UNIX
#endif /* __WIN32__ */

#ifdef MAC_TCL
#define MAC
#ifdef UNIX
#undef UNIX
#endif /* UNIX */
#ifdef WINDOWS
#undef WINDOWS
#endif /* WINDOWS */
#endif /* MAC_TCL */
/*
 * From this point, if the platfrom is unix, UNIX is defined.
 * For windows, WINDOWS is defined. In order to compile for the macindosh
 * platform, the user has explicitely to define MAC_TCL...
 */

/*#if defined(__STDC__) || defined(HAS_STDARG)
#  include <stdarg.h>
#else
#  include <varargs.h>
#endif*/

/*
 * Enable/Disable Debug Messages. VC++ 5.0 does not seem to support defines
 * with variable arguments (as unix gcc does), so a function gets called, even
 * if debug mode is disabled...
 */
#if defined(DEBUG) || defined(DEBUGVALIDS) || defined(DEBUG_HASHED_VALUES) || \
    defined(DEBUGIO) || defined(DEBUGGATEIO) || defined(DUPLICATE_DEBUG) || \
    defined(CDMDEBUG)
#ifdef UNIX
#  define CDM_DEBUG(a,b...) CDM_Debug(a, ##b);
#else /* UNIX */
#  define CDM_DEBUG CDM_Debug
#endif /* UNIX */
#else /* DEBUG */
#ifdef UNIX
#  define CDM_DEBUG(a,b...)
#else /* UNIX */
#  define CDM_DEBUG CDM_DebugNull
#endif /* UNIX */
#endif /* DEBUG */

/*
 * The rest of the file contains the Data Structures and CDM API 
 * Function Definitions.
 * These are the functions that can be called from extensions (plugin modules).
 */

#define CDM_CONST

/*
 * Some definetions needed internally...
 */
#define CDM_UCHAR unsigned char
#define MAX_TEMP_STRING           512
#define CDM_TCL_STD_ARGS \
    ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]
#define CDM_CALLBACK static

#define CDM_TYPE_COLLECTION       1
#define CDM_TYPE_DOCUMENT         2
#define CDM_TYPE_UNKNOWN          3

#define CDMIO_DefaultEncoding     "utf-8"
#define CDMIO_DefaultTranslation  "crlf"

/*
 * Windows specific definitions.
 * VC++ seems to not have available standart ANSI C functions,
 * like snprintf. Instead these functions are available, if an underscore
 * is placed before the name. A C++ specific problem?
 */
#ifdef WINDOWS
#define snprintf  _snprintf
#define vsnprintf _vsnprintf
#define vfprintf  _vfprintf
#define CDM_EXPORT __declspec( dllexport ) 
#include <io.h>
#else
#define CDM_EXPORT
#include <unistd.h>
#endif /* WINDOWS */

/* 
 * Document File Formats supported by the CDM.
 */
#define CDM_FORMAT_NATIVE         1
#define CDM_FORMAT_GATE_1x        2
#define CDM_FORMAT_GATE_2x        3
#define CDM_FORMAT_SGML           4
#define CDM_FORMAT_NATIVE2        5
#define CDM_FORMAT_REGISTERED    40

/*
 * CDM defined types.
 */
typedef struct Tcl_Obj* CDM_Annotation;
typedef struct Tcl_Obj* CDM_AnnotationSet;
typedef struct Tcl_Obj* CDM_Attribute;
typedef struct Tcl_Obj* CDM_AttributeSet;
typedef struct Tcl_Obj* CDM_AttributeName;
typedef struct Tcl_Obj* CDM_AttributeValue;
typedef struct Tcl_Obj* CDM_ByteSequence;
typedef struct Tcl_Obj* CDM_ByteSequenceSet;
typedef struct Tcl_Obj* CDM_RawData;
typedef struct Tcl_Obj* CDM_RawDataSet;
typedef struct Tcl_Obj* CDM_Span;
typedef struct Tcl_Obj* CDM_SpanSet;
typedef struct Tcl_Obj* CDM_Set;
typedef struct Tcl_Obj* CDM_Object;

/*
 * Enable the use of Tcl objects as keys, whenever possible...
 */
#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 4
#define CDM_OBJ_HASH_KEYS 1
#endif

#include "CDM_Utils.h"

#ifdef DONT_HASH_DOC_ANNOTATIONS
/*
 * By default, CDM will place Annotations into hash tables that have as key
 * the Annotation id. If the user does not want this, can enable to store
 * Annotation into linked lists, instead of hash tables.
 * The advantage is slightly (less than 1%) less memory required...
 */

/*
 * Annotation Linked List Class
 */
typedef struct NodeStr {
  CDM_Annotation  Ann;
  long            Id;
  struct NodeStr *next;
  struct NodeStr *prev;
} CDM_AnnotationListNode;

class CDM_AnnotationList {
  protected:
    CDM_AnnotationListNode *Head;
    CDM_AnnotationListNode *Last;
    CDM_AnnotationListNode *FindPosition(long Id);
  public:
                            CDM_AnnotationList(void);
                           ~CDM_AnnotationList(void);
    CDM_Annotation          Ann(long Id);
    int                     Set(CDM_Annotation Ann, long Id);
    CDM_AnnotationListNode *Get(long Id);
    int                     Delete(long Id);
}; /* Annotation Linked List Class */
#endif /* DONT_HASH_DOC_ANNOTATIONS */


/*
 * Document Structure.
 */
typedef struct CDM_DocumentStr {
  /* Type of Object. Valid types are:
   * CDM_TYPE_COLLECTION, CDM_TYPE_DOCUMENT */
  CDM_UCHAR           Type;
  CDM_UCHAR           FileFormat;       /* Native, XML, Gate, Registered etc. */
  CDM_UCHAR           RefCount;         /* Reference Count */
  CDM_UCHAR           Modified;         /* Is the current obj modified? */
  char               *Encoding;         /* Encoding of Object */
  Tcl_Command         Tcl_Cmd;          /* Tcl Command that refers to Object */
  Tcl_Interp         *Interp;           /* Tcl Interpeter pointer */

  void               *ParentPtr;        /* Pointer to Parent Collection */
  CDM_ListNode       *DocumentPtr;      /* Pointer to info like Id & XId */
  CDM_ByteSequence    RawData;          /* Document's Text */
  long                AnnotationMaxID;  /* Max ID of all Annotations */
  long                CurrentAnnID;     /* Current Annotation Id */

  /* Keeping Data... */
  Tcl_HashTable       Attributes_HashTable;
#ifdef DONT_HASH_DOC_ANNOTATIONS
  CDM_AnnotationList *Annotations_List;
#else  /* DONT_HASH_DOC_ANNOTATIONS */
  Tcl_HashTable       Annotations_HashTable;
#endif /* DONT_HASH_DOC_ANNOTATIONS */
} CDM_DocumentStr;
/*
 * Define the CDM Document type...
 */
typedef               CDM_DocumentStr* CDM_Document;
/* 
 * Always use this function to allocate a CDM_Document...
 */
CDM_Document          CDM_NewDocumentObj(void);


/*
 * CDM Collection Structure.
 */
typedef struct CDM_CollectionStr {
  /* Type of Object. Valid types are:
   * CDM_TYPE_COLLECTION, CDM_TYPE_DOCUMENT */
  CDM_UCHAR     Type;
  CDM_UCHAR     FileFormat;            /* Native, XML, Gate, Registered etc.  */
  CDM_UCHAR     RefCount;              /* Reference Count */
  CDM_UCHAR     Modified;              /* Is the current obj modified?        */
  CDM_UCHAR     ModifiedDocuments;     /* Is one of the Documents modified?   */
  char         *Encoding;              /* Encoding of Object                  */
  Tcl_Command   Tcl_Cmd;               /* Tcl Command that refers to Object   */
  Tcl_Interp   *Interp;                /* Tcl Interpeter pointer              */

  char         *Name;                  /* Collection: Full Path of Collection */
  char         *Owner;                 /* Collection's Owner                  */
  /* 
   * The following structure holds information about the Documents of the
   * Collection, like Document IDs, XIDs, if a Document is opened and the
   * Document memory pointer...
   */
  CDM_ListNode *Documents;
  CDM_ListNode *CurrentDocumentIndex;  /* Current Document List index         */
  Tcl_Obj      *RemoveDiskDocuments;   /* List with Documents to be removed from                                          disk... */

  /* Keeping Data... */
  Tcl_HashTable Attributes_HashTable;  /* Table that holds Attributes         */

  /* In this object we can optionally keep what the user may want to associate
   * with this particular Collection... */
  Tcl_Obj      *AssociatedInfo;
  /*
   * In this object we can hold Comments...
   */
  Tcl_Obj      *CommentObj;
} CDM_CollectionStr;
/*
 * Define the CDM Collection type...
 */
typedef              CDM_CollectionStr* CDM_Collection;
/* 
 * Always use this function to allocate a CDM_Collection... 
 */
CDM_Collection       CDM_NewCollectionObj(void);

/*
 * This Class is used in order to create the unique Ids that are assigned to 
 * Collection & Document objects...
 */
class CDM_UniqIDs {
  protected:
    int           CollectionMaxID;
    int           DocumentMaxID;
    int           MaxID;
  public:
                  CDM_UniqIDs();
    void          Init();
    int           CollectionUniqID(void);
    int           DocumentUniqID(void);
    int           UniqID(void);
    void          CancelCollectionUniqID(int ID);
    void          CancelDocumentUniqID(int ID);
    void          CancelUniqID(int ID);
};

/* 
 * New Tcl Object Type: A pointer List!
 */
Tcl_Obj          *CDM_NewPointerObj(void *ptr);
void             *CDM_GetPointerFromObj(Tcl_Obj *Obj);

/* Function Prototypes */

/******************************************************************************
 ******************************************************************************
 ****    +-------------------------------------------------------+         ****
 ****    |     C O L L E C T I O N            S E C T I O N      |         ****
 ****    +-------------------------------------------------------+         ****
 ******************************************************************************
 *****************************************************************************/
extern "C" int     CDM_CollectionCallback(CDM_TCL_STD_ARGS);
CDM_EXPORT
int                CDM_AnnotateCollection(CDM_Collection Collection);
CDM_EXPORT
int                CDM_Close(CDM_Collection Collection);
CDM_EXPORT
CDM_Collection     CDM_CreateCollection(
                       char *Name, CDM_AttributeSet Attributes, char *Encoding);
CDM_EXPORT
CDM_Collection     CDM_CreateCollection(char *Name,CDM_AttributeSet Attributes);
CDM_EXPORT
CDM_Document       CDM_CreateDocument(
                       CDM_Collection Collection, char *ExternalId,
                       CDM_ByteSequence RawData, CDM_AnnotationSet Annotations,
                       CDM_AttributeSet Attributes, char *Encoding);
CDM_EXPORT
CDM_Document       CDM_CreateDocument(
                       CDM_Collection Collection, char *ExternalId,
                       CDM_ByteSequence RawData, CDM_AnnotationSet Annotations,
                       CDM_AttributeSet Attributes);
CDM_EXPORT
int                CDM_Destroy(char *Name);
CDM_EXPORT
CDM_Document       CDM_FirstDocument(CDM_Collection Collection);
CDM_EXPORT
Tcl_Obj           *CDM_GetAssociatedInfo(CDM_Collection Collection);
CDM_EXPORT
CDM_Attribute      CDM_GetAttribute(CDM_Collection Collection, char *Name);
CDM_EXPORT
CDM_AttributeSet   CDM_GetAttributes(CDM_Collection Collection);
CDM_EXPORT
CDM_Document       CDM_GetByExternalId(CDM_Collection Collection, char *XID);
CDM_EXPORT
Tcl_Obj           *CDM_GetComment(CDM_Collection Collection);
CDM_EXPORT
CDM_Document       CDM_GetDocument(CDM_Collection Collection, char *Id);
CDM_EXPORT
char              *CDM_GetEncoding(CDM_Collection Collection);
CDM_EXPORT
char              *CDM_GetName(CDM_Collection Collection);
CDM_EXPORT
char              *CDM_GetOwner(CDM_Collection Collection);
CDM_EXPORT
int                CDM_Length(CDM_Collection Collection);
CDM_EXPORT
CDM_Document       CDM_NextDocument(CDM_Collection Collection);
CDM_EXPORT
CDM_Collection     CDM_OpenCollection(CDM_CONST char *Path);
CDM_EXPORT
int                CDM_PutAttribute(CDM_Collection Collection,
                                    CDM_Attribute Attr);
CDM_EXPORT
int                CDM_RemoveAttribute(CDM_Collection Collection, char *Name);
CDM_EXPORT
int                CDM_RemoveDocument(CDM_Collection Collection, char *Id);
CDM_EXPORT
int                CDM_SetAssociatedInfo(CDM_Collection Collection,
                                    Tcl_Obj *Info);
CDM_EXPORT
int                CDM_SetComment(CDM_Collection Collection, Tcl_Obj *Info);
CDM_EXPORT
char              *CDM_SetEncoding(CDM_Collection Collection, char *Encoding);
CDM_EXPORT
char              *CDM_SetOwner(CDM_Collection Collection, char *Owner);
CDM_EXPORT
char              *CDM_SetName(CDM_Collection Collection, char *Name);
CDM_EXPORT
CDM_ByteSequence   CDM_Status(CDM_Collection Collection);
CDM_EXPORT
int                CDM_Sync(CDM_Collection Collection);

/******************************************************************************
 ******************************************************************************
 ****    +-------------------------------------------------------+         ****
 ****    |     D O C U M E N T                S E C T I O N      |         ****
 ****    +-------------------------------------------------------+         ****
 ******************************************************************************
 *****************************************************************************/
extern "C" int     CDM_DocumentCallback(CDM_TCL_STD_ARGS);
CDM_EXPORT
long               CDM_AddAnnotation(CDM_Document Document, CDM_Annotation Ann);
CDM_EXPORT
CDM_AnnotationSet  CDM_AnnotationsAt(CDM_Document Document, long Position);
CDM_EXPORT
CDM_AnnotationSet  CDM_AnnotationsContaining(CDM_Document Document,
                                            long Position);
CDM_EXPORT
CDM_AnnotationSet  CDM_AnnotationsContaining(CDM_Document Document,
                                            long Position1, long Position2);
CDM_EXPORT
CDM_AnnotationSet  CDM_AnnotationsInRange(CDM_Document Document,
                                            long Start, long End);
CDM_EXPORT
CDM_AnnotationSet  CDM_AnnotationsMatchingRange(CDM_Document Document,
                                            long Start, long End);
CDM_EXPORT
CDM_ByteSequence   CDM_ByteSequenceInsertString(CDM_Document Document, long pos,
                                            char *string);
CDM_EXPORT
CDM_ByteSequence   CDM_ByteSequenceReplaceCharacters(CDM_Document Document,
                                            long pos, int chars, char *string);
CDM_EXPORT
CDM_ByteSequence   CDM_ByteSequenceReplace(CDM_Document Document,
                                            long first, long last,
                                            char *newstring);
typedef struct {
  const char *CellAnnotation;
  const char *CellAttribute;
  const char *CellFail;
  int         Contained;
  int         AnnotationText;
  int         Expand;
  mutable CDM_Object tmpObj;
  mutable CDM_Object CellFailObj;
} CDM_CreateVectorsCellSpec;
CDM_EXPORT
CDM_ByteSequenceSet CDM_CreateVectors(CDM_Document Document,
                              const char *VectorAnnotation,
                              const char *VectorAnnConstraints,
                              const char *VectorFormat,
                              const char *ClassAnnotation,
                              const char *ClassAttribute,
                              const char *ClassAttributeAbsenceValue,
                              const char *ClassFail,
                                    int   ClassCanContain,
                                    int   ClassPrefixStartMode,
                                    int   ClassPrefixEndMode,
                              const char *ClassPrefixStart,
                              const char *ClassPrefixEnd,
                                    int   CellNumber,
                              const CDM_CreateVectorsCellSpec CellSpec[],
                              const char *StatusWindow = NULL);
CDM_EXPORT
int                CDM_Close(CDM_Document Document);
CDM_EXPORT
int                CDM_DeleteAnnotations(CDM_Document Document, char *Type);
CDM_EXPORT
int                CDM_DeleteAnnotations(CDM_Document Document, char *Type,
                                            char *Constraints);
CDM_EXPORT
int                CDM_DeleteAnnotations(CDM_Document Document, char *Type,
                                            Tcl_Obj *Constraints);
CDM_EXPORT
int                CDM_DisplaceAnnotations(CDM_Document Document, long offset,
                                            long displacement);
CDM_EXPORT
long               CDM_FindMaxUsedAnnotationId(CDM_Document Document);
CDM_EXPORT
CDM_Annotation     CDM_FirstAnnotationContaining(CDM_Document Document,
                                            const long Position);
CDM_EXPORT
CDM_Annotation     CDM_FirstAnnotationContaining(CDM_Document Document,
                                                 const long Position1,
                                                 const long Position2);
CDM_EXPORT
CDM_ByteSequenceSet
                   CDM_GetAnnotatedTextRanges(CDM_Document Document,
                                            CDM_Annotation Annotation);
CDM_EXPORT
CDM_Annotation     CDM_GetAnnotation(CDM_Document Document, long Id);
CDM_EXPORT
CDM_Annotation     CDM_GetAnnotation(CDM_Document Document, Tcl_Obj *Id);
CDM_EXPORT
CDM_AnnotationSet  CDM_GetAnnotations(CDM_Document Document);
CDM_EXPORT
Tcl_Obj           *CDM_GetAnnotationAttributeNames(CDM_Document Document,
                                            Tcl_Obj *Type);
CDM_EXPORT
Tcl_Obj           *CDM_GetAnnotationAttributeValues(CDM_Document Document,
                                            Tcl_Obj *Type, Tcl_Obj *Name);
CDM_EXPORT
Tcl_Obj           *CDM_GetAnnotationTypes(CDM_Document Document);
CDM_EXPORT
CDM_Attribute      CDM_GetAttribute(CDM_Document Document, char *Name);
CDM_EXPORT
CDM_AttributeSet   CDM_GetAttributes(CDM_Document Document);
CDM_EXPORT
CDM_ByteSequence   CDM_GetByteSequence(CDM_Document Document);
CDM_EXPORT
char              *CDM_GetByteSequence(CDM_Document Document, char *Encoding);
CDM_EXPORT
char              *CDM_GetByteSequence(CDM_Document Document,
                                            const Tcl_Encoding Encoding);
CDM_EXPORT
char              *CDM_GetEncoding(CDM_Document Document);
CDM_EXPORT
char              *CDM_GetExternalId(CDM_Document Document);
CDM_EXPORT
CDM_ByteSequenceSet
                   CDM_GetFirstAnnotatedTextRange(CDM_Document Document,
                                            CDM_Annotation Annotation);
CDM_EXPORT
CDM_Annotation     CDM_GetFirstAnnotation(CDM_Document Document, char *Type);
CDM_EXPORT
char              *CDM_GetId(CDM_Document Document);
CDM_EXPORT
CDM_Annotation     CDM_GetNextAnnotation(CDM_Document Document);
CDM_EXPORT
CDM_Collection     CDM_GetParent(CDM_Document Document);
CDM_EXPORT
CDM_RawData        CDM_GetRawData(CDM_Document Document);
CDM_EXPORT
char              *CDM_GetRawData(CDM_Document Document, char *Encoding);
CDM_EXPORT
char              *CDM_GetRawData(CDM_Document Document,
                                            const Tcl_Encoding Encoding);
CDM_EXPORT
CDM_AnnotationSet  CDM_NextAnnotations(CDM_Document Document, long Position);
CDM_EXPORT
int                CDM_PutAttribute(CDM_Document Document, CDM_Attribute Attr);
CDM_EXPORT
CDM_RawData        CDM_RawDataInsertString(CDM_Document Document, long pos,
                                            char *string);
CDM_EXPORT
CDM_RawData        CDM_RawDataReplaceCharacters(CDM_Document Document,
                                            long pos, int chars, char *string);
CDM_EXPORT
CDM_ByteSequence   CDM_RawDataReplace(CDM_Document Document,
                                            long first, long last,
                                            char *newstring);
CDM_EXPORT
int                CDM_RemoveAnnotation(CDM_Document Document, long Id);
CDM_EXPORT
int                CDM_RemoveAttribute(CDM_Document Document, char *Name);
CDM_EXPORT
CDM_AnnotationSet  CDM_SelectAnnotations(CDM_Document Document, char *Type);
CDM_EXPORT
CDM_AnnotationSet  CDM_SelectAnnotations(CDM_Document Document, char *Type,
                                            char *Constraints);
CDM_EXPORT
CDM_AnnotationSet  CDM_SelectAnnotationsSorted(CDM_Document Document,
                                            char *Type);
CDM_EXPORT
CDM_AnnotationSet  CDM_SelectAnnotationsSorted(CDM_Document Document,
                                            char *Type, char *Constraints);
CDM_EXPORT
int                CDM_SetByteSequence(CDM_Document Document,
                                            CDM_ByteSequence Text);
CDM_EXPORT
char              *CDM_SetEncoding(CDM_Document Document, char *Encoding);
CDM_EXPORT
char              *CDM_SetExternalId(CDM_Document Document, char *ExternalId);
CDM_EXPORT
int                CDM_SetRawData(CDM_Document Document, CDM_RawData Text);
CDM_EXPORT
CDM_ByteSequence   CDM_Status(CDM_Document Document);
CDM_EXPORT
int                CDM_Sync(CDM_Document Document);
CDM_EXPORT
int                CDM_Free(CDM_Document Document);

/******************************************************************************
 ******************************************************************************
 ****    +-------------------------------------------------------+         ****
 ****    |     A T T R I B U T E              S E C T I O N      |         ****
 ****    +-------------------------------------------------------+         ****
 ******************************************************************************
 *****************************************************************************/
#define CDM_STRING            1
#define CDM_STRING_SET        2
#define CDM_IMAGE            10
#define CDM_BASE64_IMAGE     11
CDM_EXPORT
CDM_AttributeSet   CDM_AddAttribute(CDM_AttributeSet Set, CDM_Attribute Attr);
CDM_EXPORT
CDM_Attribute      CDM_CreateAttribute(char *Name, CDM_AttributeValue Value);
CDM_EXPORT
CDM_AttributeValue CDM_CreateAttributeValue(int Type, char *Value);
CDM_EXPORT
CDM_AttributeValue CDM_CreateAttributeValue(int Type, Tcl_Obj *Value);
CDM_EXPORT
char              *CDM_GetName(CDM_Attribute Attribute);
CDM_EXPORT
CDM_AttributeName  CDM_GetNameObj(CDM_Attribute Attribute);
CDM_EXPORT
CDM_AttributeValue CDM_GetValue(CDM_Attribute Attribute);
CDM_EXPORT
int                CDM_GetValueType(CDM_Attribute Attribute);
CDM_EXPORT
char              *CDM_GetValueString(CDM_Attribute Attribute);
CDM_EXPORT
CDM_AttributeValue CDM_GetValueValue(CDM_Attribute Attribute);
CDM_EXPORT
CDM_Attribute      CDM_ReconstructAttribute(CDM_Attribute Attribute);
CDM_EXPORT
CDM_Attribute      CDM_ReconstructAttribute(CDM_Attribute Attribute, int *type);

/******************************************************************************
 ******************************************************************************
 ****    +-------------------------------------------------------+         ****
 ****    |     A T T R I B U T E    S E T     S E C T I O N      |         ****
 ****    +-------------------------------------------------------+         ****
 ******************************************************************************
 *****************************************************************************/
CDM_EXPORT
CDM_AttributeSet   CDM_CreateAttributeSet(void);
CDM_EXPORT
CDM_AttributeSet   CDM_CreateAttributeSet(char *Name, CDM_AttributeValue Value);
CDM_EXPORT
int                CDM_AttributeSetGetElements(CDM_AttributeSet AttributeSet,
                                               int *objcPtr,
                                               CDM_Attribute **objvPtr);

/******************************************************************************
 ******************************************************************************
 ****    +-------------------------------------------------------+         ****
 ****    |     A N N O T A T I O N            S E C T I O N      |         ****
 ****    +-------------------------------------------------------+         ****
 ******************************************************************************
 *****************************************************************************/
CDM_EXPORT
int                CDM_AnnotationContainsAttributeMatchingValue(
                                              CDM_Annotation Ann,
                                              char *AttributeName,
                                              char *ValuePattern);
CDM_EXPORT
int                CDM_AnnotationContainsAttributeMatchingValues(
                                              CDM_Annotation Ann,
                                              char *AttributeName,
                                              Tcl_Obj *ValuePatternsObj);
CDM_EXPORT
int                CDM_AnnotationContainsPosition(const CDM_Annotation Ann,
                                              const long Position);
CDM_EXPORT
int                CDM_AnnotationMatchesRange(const CDM_Annotation Ann,
                                              const long start, const long end);
CDM_EXPORT
int                CDM_CompareAnnotations(CDM_Annotation Ann1,
                                              CDM_Annotation Ann2);
CDM_EXPORT
CDM_Annotation     CDM_CreateAnnotation(char *Type, CDM_SpanSet Spans,
                                              CDM_AttributeSet Attributes);
CDM_EXPORT
CDM_Annotation     CDM_CreateAnnotation(const char *Type, long start, long end,
                                              CDM_AttributeSet Attributes);
CDM_EXPORT
CDM_Annotation     CDM_DisplaceAnnotation(CDM_Annotation Ann, long offset,
                                            long displacement);
CDM_EXPORT
CDM_ByteSequenceSet
                   CDM_GetAnnotatedTextRanges(CDM_ByteSequence Text,
                                              CDM_Annotation Annotation);
CDM_EXPORT
CDM_Attribute      CDM_GetAttribute(CDM_Annotation Annotation, char *Name);
CDM_EXPORT
CDM_AttributeSet   CDM_GetAttributes(CDM_Annotation Annotation);
CDM_EXPORT
CDM_ByteSequenceSet
                   CDM_GetFirstAnnotatedTextRange(CDM_ByteSequence Text,
                                              CDM_Annotation Annotation);
CDM_EXPORT
CDM_Span           CDM_GetFirstSpan(CDM_Annotation Ann);
CDM_EXPORT
int                CDM_GetFirstSpanOffsets(CDM_Annotation Annotation,
                                              long *start, long *end);
CDM_EXPORT
CDM_SpanSet        CDM_GetSpans(CDM_Annotation Ann);
CDM_EXPORT
char              *CDM_GetType(CDM_Annotation Ann);
CDM_EXPORT
CDM_ByteSequence   CDM_GetTypeObj(CDM_Annotation Ann);
CDM_EXPORT
long               CDM_GetId(CDM_Annotation Ann);
CDM_EXPORT
CDM_Annotation     CDM_PutAttribute(CDM_Annotation Ann, CDM_Attribute Attr);
CDM_EXPORT
CDM_Annotation     CDM_RemoveAttribute(CDM_Annotation Ann, char *Name);
CDM_EXPORT
CDM_Annotation     CDM_ReconstructAnnotation(CDM_Annotation Annotation);
CDM_EXPORT
CDM_Annotation     CDM_AddAnnotationSpan(CDM_Annotation Annotation,
                                  CDM_Span span);
CDM_EXPORT
CDM_Annotation     CDM_RemoveSpan(CDM_Annotation Annotation,
                                  long start, long end);

/******************************************************************************
 ******************************************************************************
 ****    +-------------------------------------------------------+         ****
 ****    |     A N N O T A T I O N    S E T   S E C T I O N      |         ****
 ****    +-------------------------------------------------------+         ****
 ******************************************************************************
 *****************************************************************************/
CDM_EXPORT
int                CDM_AnnotationSetGetElements(CDM_AnnotationSet AnnotationSet,
                                               int *objcPtr,
                                               CDM_Annotation **objvPtr);
CDM_EXPORT
CDM_AnnotationSet  CDM_CreateAnnotationSet(void);
CDM_EXPORT
CDM_AnnotationSet  CDM_AddAnnotation(CDM_AnnotationSet Set, CDM_Annotation Ann);
CDM_EXPORT
CDM_AnnotationSet  CDM_AnnotationsAt(CDM_AnnotationSet Set, long Position);
CDM_EXPORT
CDM_AnnotationSet  CDM_AnnotationsContaining(CDM_AnnotationSet Set,
                                            long Position);
CDM_EXPORT
CDM_AnnotationSet  CDM_AnnotationsContaining(CDM_AnnotationSet Set,
                                            long Position1, long Position2);
CDM_EXPORT
CDM_AnnotationSet  CDM_AnnotationsInRange(CDM_AnnotationSet Set,
                                            long Start, long End);
CDM_EXPORT
CDM_AnnotationSet  CDM_AnnotationsMatchingRange(CDM_AnnotationSet Set,
                                            long Start, long End);
CDM_EXPORT
CDM_AnnotationSet  CDM_DisplaceAnnotations(CDM_AnnotationSet Set, long offset,
                                            long displacement);
CDM_EXPORT
CDM_Annotation     CDM_FirstAnnotationContaining(CDM_AnnotationSet Set,
                                                 const long Position);
CDM_EXPORT
CDM_Annotation     CDM_FirstAnnotationContaining(CDM_AnnotationSet Set,
                                                 const long Position1,
                                                 const long Position2);
CDM_EXPORT
CDM_Annotation     CDM_GetAnnotation(CDM_AnnotationSet Set, long Id);
CDM_EXPORT
int                CDM_Length(CDM_AnnotationSet Set);
CDM_EXPORT
CDM_AnnotationSet  CDM_NextAnnotations(CDM_AnnotationSet Set, long Position);
CDM_EXPORT
Tcl_Obj           *CDM_Nth(Tcl_Obj *Set, long n);
CDM_EXPORT
CDM_AnnotationSet  CDM_MergeAnnotations(
                   CDM_AnnotationSet Set1, CDM_AnnotationSet Set2);
CDM_EXPORT
CDM_AnnotationSet  CDM_RemoveAnnotation(CDM_AnnotationSet Set, long Id);
CDM_EXPORT
CDM_AnnotationSet  CDM_SelectAnnotations(CDM_AnnotationSet Set, char *Type);
CDM_EXPORT
CDM_AnnotationSet  CDM_SelectAnnotations(CDM_AnnotationSet Set, char *Type,
                                               char *Constraints);
CDM_EXPORT
CDM_AnnotationSet  CDM_SelectAnnotationsSorted(CDM_AnnotationSet Set,
                                               char *Type);
CDM_EXPORT
CDM_AnnotationSet  CDM_SelectAnnotationsSorted(CDM_AnnotationSet Set,
                                               char *Type, char *Constraints);
CDM_EXPORT
CDM_AnnotationSet  CDM_SortAnnotationSet(CDM_AnnotationSet Set);

/******************************************************************************
 ******************************************************************************
 ****    +-------------------------------------------------------+         ****
 ****    |     S P A N                        S E C T I O N      |         ****
 ****    +-------------------------------------------------------+         ****
 ******************************************************************************
 *****************************************************************************/
CDM_EXPORT
CDM_SpanSet        CDM_AddSpan(CDM_SpanSet SpanSet, CDM_Span Span);
CDM_EXPORT
CDM_SpanSet        CDM_CreateSpanSet(void);
CDM_EXPORT
CDM_SpanSet        CDM_CreateSpanSet(long start, long end);
CDM_EXPORT
CDM_Span           CDM_CreateSpan(long start, long end);
CDM_EXPORT
long               CDM_GetStart(CDM_Span Span);
CDM_EXPORT
long               CDM_GetEnd(CDM_Span Span);
CDM_EXPORT
int                CDM_GetSpanOffsets(CDM_Span Span, long *start, long *end);
CDM_EXPORT
int                CDM_SpanSetGetElements(CDM_SpanSet SpanSet, int *objcPtr,
                                          CDM_Span **objvPtr);

/******************************************************************************
 ******************************************************************************
 ****    +-------------------------------------------------------+         ****
 ****    |     V A L I D A T I O N          R O U T I N E S      |         ****
 ****    +-------------------------------------------------------+         ****
 ******************************************************************************
 *****************************************************************************/
CDM_EXPORT
int                CDM_ValidAnnotation(CDM_Annotation Ann);
CDM_EXPORT
int                CDM_ValidAttribute(CDM_Attribute Attribute);

/******************************************************************************
 ******************************************************************************
 ****    +-------------------------------------------------------+         ****
 ****    |     G U I     R E L A T E D      R O U T I N E S      |         ****
 ****    +-------------------------------------------------------+         ****
 ******************************************************************************
 *****************************************************************************/
CDM_EXPORT
Tcl_Obj           *CDM_GetCollectionFileXIDs(char *FileName, int Format);
CDM_EXPORT
Tcl_Obj           *CDM_GetCollectionFileIDs(char *FileName, int Format);
CDM_EXPORT
Tcl_Obj           *CDM_GetDocumentAttributes(char *FileName, int Format);

/******************************************************************************
 ******************************************************************************
 ****    +-------------------------------------------------------+         ****
 ****    |     U T I L I T I E S            R O U T I N E S      |         ****
 ****    +-------------------------------------------------------+         ****
 ******************************************************************************
 *****************************************************************************/

/* CDM Utilities */
CDM_EXPORT
int                CDM_CompareAnnotationSets(CDM_AnnotationSet KeySet,
                                             CDM_AnnotationSet ResSet,
                                             Tcl_Obj *AttributesList,
                                             Tcl_Obj *ValuesList,
                                             double   spanOverlapPercent,
                                             int checkValues, int LogInfo);
CDM_EXPORT
int                CDM_Eval TCL_VARARGS_DEF(Tcl_Interp *, arg1);
CDM_EXPORT
int                CDM_Exec TCL_VARARGS_DEF(Tcl_Interp *, arg1);
#define CDM_EXTRACT_TEXT_LEAVE_UNSPANNED_TEXT   0
#define CDM_EXTRACT_TEXT_REMOVE_UNSPANNED_TEXT  1
CDM_EXPORT
CDM_ByteSequence   CDM_ExtractTextBasedOnAnnotations(CDM_ByteSequence Text,
                                              CDM_AnnotationSet Set);
CDM_EXPORT
CDM_ByteSequence   CDM_ExtractTextBasedOnAnnotations(CDM_ByteSequence Text,
                                              CDM_AnnotationSet Set, int mode);
CDM_EXPORT
int                CDM_ActiveInterpreterResultEmpty(void);
CDM_EXPORT
Tcl_Interp        *CDM_GetActiveInterpreter(void);
CDM_EXPORT
int                CDM_SetActiveInterpreter(Tcl_Interp *Interpreter);
CDM_EXPORT
int                CDM_SetProcessStatus(CDM_Document Doc, int status);
CDM_EXPORT
int                CDM_ValidCollectionPointer(CDM_Collection Pointer);
CDM_EXPORT
int                CDM_ValidDocumentPointer(CDM_Document Pointer);
CDM_EXPORT
CDM_Collection     CDM_GetCollectionPointer(Tcl_Obj *Obj);
CDM_EXPORT
CDM_Document       CDM_GetDocumentPointer(Tcl_Obj *Obj);
CDM_EXPORT
Tcl_Obj           *CDM_NewLongObj(long Value);
CDM_EXPORT
Tcl_Obj           *CDM_NewStringObj(char *Value);
CDM_EXPORT
Tcl_Obj           *CDM_NewStringObj(const char *Value);
CDM_EXPORT
Tcl_Obj           *CDM_NewStringObj(const char *Value, int len);

/* Tcl's "lsearch" replacement... */
#define CDM_LSEARCH_EXACT  1
#define CDM_LSEARCH_GLOB   2
#define CDM_LSEARCH_REGEXP 3
CDM_EXPORT
Tcl_Obj           *CDM_Lsearch(Tcl_Obj *List, Tcl_Obj *patObj, int mode);
CDM_EXPORT
Tcl_Obj           *CDM_Lsearch(Tcl_Obj *List, Tcl_Obj *patObj,
                               int *position, int mode);
CDM_EXPORT
int                CDM_LappendUnique(Tcl_Obj *List, Tcl_Obj *Obj);
CDM_EXPORT
Tcl_Obj           *CDM_SplitString(char *string);
CDM_EXPORT
Tcl_Obj           *CDM_SplitString(char *string, int allowEmptyElements);
CDM_EXPORT
Tcl_Obj           *CDM_SplitString(char *string, char *splitChars);
CDM_EXPORT
Tcl_Obj           *CDM_SplitString(char *string, char *splitChars,
                               int allowEmptyElements);
/* File Utilities */
CDM_EXPORT
int                CDM_DeleteFile(char *path);
CDM_EXPORT
char              *CDM_FileNameDirname(char *FileName);
CDM_EXPORT
char              *CDM_FileNameTail(char *FileName);
CDM_EXPORT
char              *CDM_GetNativeFileName(char *FileName);
CDM_EXPORT
char              *CDM_GetIP(void);
CDM_EXPORT
int                CDM_GetPid(void);
CDM_EXPORT
char              *CDM_GetTempDir(void);
CDM_EXPORT
void              *CDM_GetCurrentThread(void);
CDM_EXPORT
CDM_ByteSequence   CDM_JoinSetElements(CDM_Set Set,const char *joinString=NULL);
CDM_EXPORT
char              *CDM_JoinPaths TCL_VARARGS_DEF(char *, arg1);
CDM_EXPORT
int                CDM_Mkdir(char *Directory);
CDM_EXPORT
int                CDM_FileExists(const char *path);
CDM_EXPORT
int                CDM_FileExists(Tcl_Obj *path);
CDM_EXPORT
int                CDM_SetGetElements(CDM_Set Set, int *objcPtr,
                                      CDM_Object **objvPtr);

/* Memory Allocation */
CDM_EXPORT
char              *CDM_Malloc(size_t size);

/* Duplicating UTF-8 Strings */
CDM_EXPORT
char              *CDM_Strdup(char *string);
CDM_EXPORT
char              *CDM_Strdup(const char *string);
CDM_EXPORT
char              *CDM_Strdup(Tcl_Obj *stringObj);

/* Get a part from a text object */
CDM_EXPORT
CDM_ByteSequence   CDM_GetRange(CDM_ByteSequence textObj, long start, long end);


/* Getting Number of UTF-8 Characters */
CDM_EXPORT
long               CDM_Strlen(CDM_CONST char *string);

CDM_EXPORT
int                CDM_Strcmp(CDM_CONST char *str1, CDM_CONST char *str2);
CDM_EXPORT
int                CDM_Strcmp(Tcl_Obj *str1, Tcl_Obj *str2);

CDM_EXPORT
int                CDM_Strncmp(CDM_CONST char *str1, CDM_CONST char *str2,
                               long len);

CDM_EXPORT
int                CDM_Isdigit(CDM_CONST char c);

/* Convert a string between a known encoding to UTF-8 */
CDM_EXPORT
char *             CDM_ExternalToUtf(char *encoding, char *str);
CDM_EXPORT
char *             CDM_ExternalToUtf(const Tcl_Encoding encoding,
                                     const char *str);
CDM_EXPORT
char *             CDM_UtfToExternal(char *encoding, char *str);
CDM_EXPORT
char *             CDM_UtfToExternal(const Tcl_Encoding encoding,
                                     const char *str);

/* Free string returned by CDM_Strdup */
CDM_EXPORT
int                CDM_Free(char *string);

/* Free a CDM (Tcl) object... */
CDM_EXPORT
int                CDM_Free(Tcl_Obj *obj);

/* Linking Strings between C++ and Tcl */
CDM_EXPORT
int                CDM_LinkVar(Tcl_Interp *Interp, char *tcl_var, char **c_var);
CDM_EXPORT
void               CDM_UnlinkVar(Tcl_Interp *Interp, char *tcl_var_name);

/* Error Reporting */
CDM_EXPORT
void               CDM_NotReady(void);
CDM_EXPORT
int                CDM_ReportError TCL_VARARGS_DEF(char*, arg1);
CDM_EXPORT
int                CDM_ReportError TCL_VARARGS_DEF(const char*, arg1);
CDM_EXPORT
int                CDM_AppendError TCL_VARARGS_DEF(char*, arg1);
CDM_EXPORT
int                CDM_AppendError TCL_VARARGS_DEF(const char*, arg1);
CDM_EXPORT
void               CDM_Panic(char *error);
#define CDM_Error  CDM_ReportError

/******************************************************************************
 ******************************************************************************
 ****    +-------------------------------------------------------+         ****
 ****    |     C D M    L I C E N S E   V A L I D A T I O N      |         ****
 ****    +-------------------------------------------------------+         ****
 ******************************************************************************
 *****************************************************************************/
CDM_EXPORT
int                CDM_DeclareLicensingInformation(char *ComponentName,
                       char *CustomerID, char *ProductID, char *HostID,
                       char *HostIP, char *UserKey);
CDM_EXPORT
int                CDM_DeclareLicensingInformation(Tcl_Obj *ComponentName,
                       Tcl_Obj *CustomerID, Tcl_Obj *ProductID,
                       Tcl_Obj *HostID, Tcl_Obj *HostIP, Tcl_Obj *UserKey);

/******************************************************************************
 ******************************************************************************
 ****    +-------------------------------------------------------+         ****
 ****    |     C D M    C O L L E C T I O N   P L U G I N S      |         ****
 ****    +-------------------------------------------------------+         ****
 ******************************************************************************
 *****************************************************************************/
#define CDM_MAXIMUM_COLLECTION_PLUGINS_NUMBER 20
typedef int (CDM_SaveCollectionProc) (CDM_Collection Collection);
typedef int (CDM_LoadCollectionProc) (CDM_Collection Collection);
typedef int (CDM_SaveDocumentProc)   (CDM_Document Document, Tcl_Channel File);
typedef int (CDM_LoadDocumentProc)   (CDM_Document Document, Tcl_Channel File,
                                      char **Id, char **ExternalId);
typedef Tcl_Obj *        (CDM_CollectionXIdsProc)     (char *dir);
typedef Tcl_Obj *        (CDM_CollectionIdsProc)      (char *dir);
typedef CDM_AttributeSet (CDM_DocumentAttributesProc) (Tcl_Channel File);

typedef struct {
  char *CollectionType;
  CDM_LoadCollectionProc     *loadCollectionPtr;
  CDM_SaveCollectionProc     *saveCollectionPtr;
  CDM_LoadDocumentProc       *loadDocumentPtr;
  CDM_SaveDocumentProc       *saveDocumentPtr;
  CDM_CollectionXIdsProc     *CollectionXIdsPtr;
  CDM_CollectionIdsProc      *CollectionIdsPtr;
  CDM_DocumentAttributesProc *DocumentAttrsPtr;
} CDM_RegisteredCollectionTypes;

CDM_EXPORT
int                CDM_RegisterCollectionType(char *type,
                        CDM_LoadCollectionProc     *loadCollectionPtr,
                        CDM_SaveCollectionProc     *saveCollectionPtr,
                        CDM_LoadDocumentProc       *loadDocumentPtr,
                        CDM_SaveDocumentProc       *saveDocumentPtr,
                        CDM_CollectionXIdsProc     *CollectionXIdsPtr,
                        CDM_CollectionIdsProc      *CollectionIdsPtr,
                        CDM_DocumentAttributesProc *DocumentAttrsProc);

/******************************************************************************
 ******************************************************************************
 ****    +-------------------------------------------------------+         ****
 ****    |     C D M     V E R S I O N      R O U T I N E S      |         ****
 ****    +-------------------------------------------------------+         ****
 ******************************************************************************
 *****************************************************************************/
CDM_EXPORT
int                CDM_MajorVersion(void);
CDM_EXPORT
int                CDM_MinorVersion(void);
CDM_EXPORT
const char        *CDM_Version(void);
CDM_EXPORT
const char        *CDM_PatchLevel(void);
CDM_EXPORT
const char        *CDM_ReleaseDate(void);
CDM_EXPORT
const char        *CDM_ExtendedReleaseDate(void);

/* Debugging Facilities... */
CDM_EXPORT
void               CDM_Debug(const char* fmt, ... );
CDM_EXPORT
void               CDM_DebugNull(const char* fmt, ... );
CDM_EXPORT
void               CDM_Log(const char* fmt, ... );

/* Pointer Object */
int                CDM_DeletePointerFromList(Tcl_Obj *List, void *ptr);

/* Initialisation/Finalisation of CDM in non-Tcl aware applications */
extern "C" CDM_EXPORT
int                CDM_Initialise(const char*);
extern "C" CDM_EXPORT
void               CDM_Finalise(void);
#define CDM_GET_LIBRARY_FUNCTION_POINTERS {\
   if (CDM_GetActiveInterpreter() == NULL) {\
     CDM_SetActiveInterpreter(Tcl_CreateInterp());\
     Tcl_InitStubs(CDM_GetActiveInterpreter(), "8.4", 0);\
     Tcl_DeleteInterp(CDM_GetActiveInterpreter());\
   } else {\
     Tcl_InitStubs(CDM_GetActiveInterpreter(), "8.4", 0);\
   }}


CDM_EXPORT
Tcl_Obj *          CDMTCL_GetObjResult(Tcl_Interp *);
CDM_EXPORT
CONST char *       CDMTCL_GetString(Tcl_Obj *);
CDM_EXPORT
CONST char *       CDMTCL_GetStringFromObj(Tcl_Obj *, int *);
CDM_EXPORT
Tcl_Obj *          CDMTCL_NewStringObj(CONST char *, int);
CDM_EXPORT
Tcl_Obj *          CDMTCL_NewListObj(int objc, Tcl_Obj *CONST objv[]);
CDM_EXPORT
int                CDMTCL_ListObjAppendElement(Tcl_Interp *,
                                               Tcl_Obj *, Tcl_Obj *);
CDM_EXPORT
void               CDMTCL_IncrRefCount(Tcl_Obj *);
CDM_EXPORT
void               CDMTCL_DecrRefCount(Tcl_Obj *);
CDM_EXPORT
CONST char *       CDMTCL_GetCommandName(Tcl_Interp *, Tcl_Command);
CDM_EXPORT
int                CDMTCL_Eval(Tcl_Interp *, CONST char *);
CDM_EXPORT
int                CDMTCL_ListObjGetElements(Tcl_Obj *obj, int *objcPtr,
                                                           Tcl_Obj ***objvPtr);
#endif /* _CDM */

#include "CDM_Macros.h"

/*
 * CDM.h - EOF -
 */