/****
 File : Xint_Xd_cvtr.c
 ****/

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Xm/Xm.h>
#include <stdio.h>

#include <Xint/IntDefs.h>

#include "integration.h"

#ifdef _XINT_CHART_WIDGET_H
typedef struct _TempDynamicInteger4Struct {
  int   field1;
  int   field2;
  int   field3;
  int   field4;
} XintTempDynamicInteger4, *XintTempDynamicInteger4List;
typedef struct _TempDynamicFloat4Struct {
  int   field1;
  int   field2;
  int   field3;
  int   field4;
} XintTempDynamicFloat4, *XintTempDynamicFloat4List;
#endif

/** For version 2.2 **/
#ifdef _XINT_OBJECT_EDITOR_H

#ifdef _XINT_CHART_WIDGET_H
#include        <Xint/ChartW.h>
#include        <Xint/Text.h>
#else
#include        <Xint/TextObj.h>
#endif

#include        <Xint/FreeHand.h>
#include        <Xint/Line.h>
#include        <Xint/Oval.h>
#include        <Xint/Polygon.h>
#include        <Xint/Polyline.h>
#include        <Xint/Rectangle.h>
#include        <Xint/RoundedRect.h>

typedef struct _ObjectClassStruct {
  ObjectClass   objclass;
  char          objclassname[50];
} XintObjectClassRecord, *XintObjectClassRecordList;

typedef struct _XintPixmapStruct {
  Pixmap        pmap;
  char          pmapname[20];
} XintPixmapsRcd, *XintPixmapsRcdList;

#ifdef _XINT_CHART_WIDGET_H
int     numObjClass = 9;
#else
int     numObjClass = 8;
#endif
int     numDfPmp = 106;
Boolean allocXintObjClassRecord = False;
Boolean allocXintPixmapsRcd = False;
Boolean altered = False;
XintObjectClassRecordList obj_rcd_ptr;
XintPixmapsRcdList obj_pmap_ptr;


static String defaults[6] = {"ActionEditor",
                             "ObjectEditor",
                             "ColorEditor",
                             "AttributeEditor",
                             "PixmapEditor",
                             NULL };

static String dfpixmaps[107] = {
   "Solid",             "Clear",                "25_percent_1",
   "25_percent_2",      "25_percent_3",         "25_percent_4",
   "50_percent_1",      "50_percent_2",         "75_percent",
   "Vertical",          "Vertical1",            "Vertical2",
   "Vertical3",         "Horizontal",           "Horizontal1",
   "Horizontal2",       "Horizontal3",          "Slant_Left",
   "Slant_Left1",       "Slant_Left2",          "Star_Left1",
   "Star_Left2",        "Star_Right1",          "Star_Right2",
   "Slant_Right",       "Slant_Right1",         "Slant_Right2",
   "Zigzag",            "Zigzag1",              "Zigzag2",
   "Tread",             "Tread1",               "Tread2",
   "Trellis",           "Trellis1",             "Trellis2",
   "Weave1",            "Weave2",               "Weave3",
   "Weave4",            "Weave1",               "12_5_percent_1",
   "12_5_percent_2",    "12_5_percent_3",       "12_5_percent_4",
   "12_5_percent_5",    "12_5_percent_6",       "12_5_percent_7",
   "12_5_percent_8",    "Sandstone",            "Siltstone",
   "Shale",             "Limestone",            "Dolomite",
   "Chert",             "Basement",             "Check1",
   "Check2",            "Check3",               "Wicker1",
   "Wicker2",           "Wicker3",              "Cross_Hatch",
   "Diamond1",          "Diamond2",             "Diamond3",
   "Lattice1",          "Lattice2",             "Lattice3",
   "Lattice4",          "Lattice5",             "Lattice6",
   "Lattice7",          "Herring_Bone1",        "Herring_Bone2",
   "Plaid1",            "Plaid2",               "Plaid3",
   "Plaid4",            "Imbrication1",         "Imbrication2",
   "Imbrication3",      "Imbrication4",         "Diaper",
   "Parquet1",          "Parquet2",             "Horizontal_Bar1",
   "Horizontal_Bar2",   "Horizontal_Bar3",      "Horizontal_Bar4",
   "Horizontal_Bar5",   "Horizontal_Bar6",      "Horizontal_Bar7",
   "Horizontal_Bar8",   "Horizontal_Bar9",      "Horizontal_Bar10",
   "Vertical_Bar1",     "Vertical_Bar2",        "Vertical_Bar3",
   "Vertical_Bar4",     "Vertical_Bar5",        "Vertical_Bar6",
   "Vertical_Bar7",     "Vertical_Bar8",        "Vertical_Bar9",
   "Vertical_Bar10", NULL };

#endif


#ifdef _XINT_EDIT_TABLE_H
/*
** XmRRowAnnotationData is defined for version 2.2
*/
#ifdef XmRRowAnnotationData
extern Boolean xintEditTableCvtRowAnnotationData;
#endif
extern Boolean xintEditTableCvtColumnAnnotationData;
extern Boolean xintEditTableCvtColumnDataFormatData;
extern Boolean xintEditTableCvtFontTable;
extern Boolean xintEditTableCvtColumnFontIndexData;
extern Boolean xintEditTableCvtCellWidthData;
extern Boolean xintEditTableCvtCellHeightData;
extern Boolean xintEditTableCvtColumnEditModeData;
extern Boolean xintEditTableCvtColumnAlignmentData;
extern Boolean xintEditTableCvtColumnDataTypeData;
#endif


static char NextChar(str, index)
String str;
int   index;
{
   return(str[index]);
}

static String
ParseToken(str)
String str;
{
int		index1,	index2, length;
String          tempstr = NULL;
char		ch;

   length = strlen(str);
   tempstr = (String)XtMalloc(sizeof(char)*(length+1));

   index1 = 0;
   index2 = 0;
   while (length > index1) {
      ch = NextChar(str, index2);
      if (ch == '\\') {
   	   index2++;
	   ch = NextChar(str,index2);
	   if (ch == 'n') {
	      tempstr[index1] = '\n';
	   } else {
	      tempstr[index1] = str[--index2];
	      index1++;
	      index2++;
	      tempstr[index1] = str[index2];
	   }
      } else {
	   tempstr[index1] = ch;
      }
      index1++;
      index2++;
   }
   tempstr[length] = '\0';
   return(tempstr);
}


#ifdef _XINT_EDIT_TABLE_H
Boolean
StrToTranslationTable(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String  str = (String)fromVal->addr;
static	XtTranslations transTable;
String  tempstr = NULL;


  tempstr = ParseToken(str);
  if (tempstr == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&transTable;
  toVal->size = sizeof(XtTranslations);

  transTable = XtParseTranslationTable(tempstr);

  return(True);
}
#endif



#if defined (_XINT_EDIT_TABLE_H) || defined (_XINT_EDIT_OBJECT_H)
Boolean
StrToCursorType(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static int      cursorType;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int             n = 1;


  temp = XtNewString(str);
  sprintf(delimiter, "\t ,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&cursorType;
  toVal->size = sizeof(int);

  if (isdigit(token[0])) {
     cursorType = atoi(token);
  } else {
       toVal->addr = NULL;
       toVal->size = 0;
       XtStringConversionWarning ((String) fromVal->addr, "CursorType");
  }

  return(True);
}
#endif



Boolean
StrToIntArray(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static int      * intarray;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int             n = 1;


  temp = XtNewString(str);
  sprintf(delimiter, "\t ,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&intarray;
  toVal->size = sizeof(XtPointer);

  intarray = (int *)XtMalloc(sizeof(int));
  if (isdigit(token[0])) {
     intarray[0] = atoi(token);
  } else if (token[0] == '-') {
     intarray[0] = -1;
  } else {
       toVal->addr = NULL;
       toVal->size = 0;
       XtStringConversionWarning ((String) fromVal->addr, "IntegerArray");
  }

  while (token = strtok(NULL, delimiter)) {
     intarray = (int *) XtRealloc((char *)intarray,
                           (++n) * sizeof(int));
     if (isdigit(token[0])) {
        intarray[n - 1] = atoi(token);
     } else if (token[0] == '-') {
               intarray[n - 1] = -1;
            } else {
                toVal->addr = NULL;
                toVal->size = 0;
                XtStringConversionWarning ((String) fromVal->addr, "IntegerArray");
            }
  }

  intarray = (int *) XtRealloc((char *)intarray, (++n) * sizeof(int));
  intarray[n - 1] = (int)NULL;
  XtFree((char *)temp);

  return(True);
}



#ifdef _XINT_EDIT_TABLE_H
Boolean
StrToETBColumnFontIndexData(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String		str = (String)fromVal->addr;

static int	* intarray;
String		temp = NULL;
String		token = NULL;
char		delimiter[16];
int		n = 1;


  temp = XtNewString(str);
  sprintf(delimiter, "\t ,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&intarray;
  toVal->size = sizeof(XtPointer);

  intarray = (int *)XtMalloc(sizeof(int));
  if (isdigit(token[0])) {
     intarray[0] = atoi(token);
  } else if (token[0] == '-') {
     intarray[0] = -1;
  } else {
       toVal->addr = NULL;
       toVal->size = 0;
       XtStringConversionWarning ((String) fromVal->addr, "ColumnFontIndexData");
  }

  while (token = strtok(NULL, delimiter)) {
     intarray = (int *) XtRealloc((char *)intarray,
                           (++n) * sizeof(int));
     if (isdigit(token[0])) {
        intarray[n - 1] = atoi(token);
     } else if (token[0] == '-') {
               intarray[n - 1] = -1;
            } else {
       		toVal->addr = NULL;
       		toVal->size = 0;
       		XtStringConversionWarning ((String) fromVal->addr, "ColumnFontIndexData");
            }
  }

  intarray = (int *) XtRealloc((char *)intarray, (++n) * sizeof(int));
  intarray[n - 1] = 500;
  XtFree((char *)temp);

  xintEditTableCvtColumnFontIndexData = True;

  return(True);
}




Boolean
StrToETBCellWidthData(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static int      * intarray;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int             n = 1;


  temp = XtNewString(str);
  sprintf(delimiter, "\t ,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&intarray;
  toVal->size = sizeof(XtPointer);

  intarray = (int *)XtMalloc(sizeof(int));
  if (isdigit(token[0])) {
     intarray[0] = atoi(token);
  } else if (token[0] == '-') {
     intarray[0] = -1;
  } else {
       toVal->addr = NULL;
       toVal->size = 0;
       XtStringConversionWarning ((String) fromVal->addr, "CellWidthData");
  }

  while (token = strtok(NULL, delimiter)) {
     intarray = (int *) XtRealloc((char *)intarray,
                           (++n) * sizeof(int));
     if (isdigit(token[0])) {
        intarray[n - 1] = atoi(token);
     } else if (token[0] == '-') {
               intarray[n - 1] = -1;
            } else {
                toVal->addr = NULL;
                toVal->size = 0;
                XtStringConversionWarning ((String) fromVal->addr, "CellWidthData");
            }
  }

  intarray = (int *) XtRealloc((char *)intarray, (++n) * sizeof(int));
  intarray[n - 1] = 500;
  XtFree((char *)temp);

  xintEditTableCvtCellWidthData = True;

  return(True);
}





Boolean
StrToETBCellHeightData(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static int      * intarray;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int             n = 1;


  temp = XtNewString(str);
  sprintf(delimiter, "\t ,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&intarray;
  toVal->size = sizeof(XtPointer);

  intarray = (int *)XtMalloc(sizeof(int));
  if (isdigit(token[0])) {
     intarray[0] = atoi(token);
  } else if (token[0] == '-') {
     intarray[0] = -1;
  } else {
       toVal->addr = NULL;
       toVal->size = 0;
       XtStringConversionWarning ((String) fromVal->addr, "CellHeightData");
  }

  while (token = strtok(NULL, delimiter)) {
     intarray = (int *) XtRealloc((char *)intarray,
                           (++n) * sizeof(int));
     if (isdigit(token[0])) {
        intarray[n - 1] = atoi(token);
     } else if (token[0] == '-') {
               intarray[n - 1] = -1;
            } else {
                toVal->addr = NULL;
                toVal->size = 0;
                XtStringConversionWarning ((String) fromVal->addr, "CellHeightData");
            }
  }

  intarray = (int *) XtRealloc((char *)intarray, (++n) * sizeof(int));
  intarray[n - 1] = 500;
  XtFree((char *)temp);

  xintEditTableCvtCellHeightData = True;

  return(True);
}





Boolean
StrToETBColumnEditModeData(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static int      * intarray;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int             n = 1;


  temp = XtNewString(str);
  sprintf(delimiter, "\t ,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&intarray;
  toVal->size = sizeof(XtPointer);

  intarray = (int *)XtMalloc(sizeof(int));
  if (isdigit(token[0])) {
     intarray[0] = atoi(token);
  } else if (token[0] == '-') {
     intarray[0] = -1;
  } else {
       toVal->addr = NULL;
       toVal->size = 0;
       XtStringConversionWarning ((String) fromVal->addr, "ColumnEditModeData");
  }

  while (token = strtok(NULL, delimiter)) {
     intarray = (int *) XtRealloc((char *)intarray,
                           (++n) * sizeof(int));
     if (isdigit(token[0])) {
        intarray[n - 1] = atoi(token);
     } else if (token[0] == '-') {
               intarray[n - 1] = -1;
            } else {
                toVal->addr = NULL;
                toVal->size = 0;
                XtStringConversionWarning ((String) fromVal->addr, "ColumnEditModeData");
            }
  }

  intarray = (int *) XtRealloc((char *)intarray, (++n) * sizeof(int));
  intarray[n - 1] = 500;
  XtFree((char *)temp);

  xintEditTableCvtColumnEditModeData = True;

  return(True);
}





Boolean
StrToETBColumnAlignmentData(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static int      * intarray;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int             n = 1;


  temp = XtNewString(str);
  sprintf(delimiter, "\t ,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&intarray;
  toVal->size = sizeof(XtPointer);

  intarray = (int *)XtMalloc(sizeof(int));
  if (isdigit(token[0])) {
     intarray[0] = atoi(token);
  } else if (token[0] == '-') {
     intarray[0] = -1;
  } else {
       toVal->addr = NULL;
       toVal->size = 0;
       XtStringConversionWarning ((String) fromVal->addr, "ColumnAlignmentData");
  }

  while (token = strtok(NULL, delimiter)) {
     intarray = (int *) XtRealloc((char *)intarray,
                           (++n) * sizeof(int));
     if (isdigit(token[0])) {
        intarray[n - 1] = atoi(token);
     } else if (token[0] == '-') {
               intarray[n - 1] = -1;
            } else {
                toVal->addr = NULL;
                toVal->size = 0;
                XtStringConversionWarning ((String) fromVal->addr, "ColumnAlignmentData");
            }
  }

  intarray = (int *) XtRealloc((char *)intarray, (++n) * sizeof(int));
  intarray[n - 1] = 500;
  XtFree((char *)temp);

  xintEditTableCvtColumnAlignmentData = True;

  return(True);
}






Boolean
StrToETBColumnDataTypeData(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static int      * intarray;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int             n = 1;


  temp = XtNewString(str);
  sprintf(delimiter, "\t ,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&intarray;
  toVal->size = sizeof(XtPointer);

  intarray = (int *)XtMalloc(sizeof(int));
  if (isdigit(token[0])) {
     intarray[0] = atoi(token);
  } else if (token[0] == '-') {
     intarray[0] = -1;
  } else {
       toVal->addr = NULL;
       toVal->size = 0;
       XtStringConversionWarning ((String) fromVal->addr, "ColumnDataTypeData");
  }

  while (token = strtok(NULL, delimiter)) {
     intarray = (int *) XtRealloc((char *)intarray,
                           (++n) * sizeof(int));
     if (isdigit(token[0])) {
        intarray[n - 1] = atoi(token);
     } else if (token[0] == '-') {
               intarray[n - 1] = -1;
            } else {
                toVal->addr = NULL;
                toVal->size = 0;
                XtStringConversionWarning ((String) fromVal->addr, "ColumnDataTypeData");
            }
  }

  intarray = (int *) XtRealloc((char *)intarray, (++n) * sizeof(int));
  intarray[n - 1] = 500;
  XtFree((char *)temp);

  xintEditTableCvtColumnDataTypeData = True;

  return(True);
}
#endif






Boolean
StrToStrArray(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static String   *strarray;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int             n = 1;


  temp = XtNewString(str);
  sprintf(delimiter, "\t,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer) &strarray;
  toVal->size = sizeof(XtPointer);

  strarray = (String *)XtMalloc(sizeof(String));

  strarray[0] = ParseToken(token);

  while (token = strtok(NULL, delimiter)) {
     strarray = (String *) XtRealloc((char *)strarray,
                           (++n) * sizeof(String));
     strarray[n-1] = ParseToken(token);
  }

  strarray = (String *) XtRealloc((char *)strarray,
                           (++n) * sizeof(String));
  strarray[n - 1] = NULL;
  XtFree((char *)temp);

  return(True);
}



#ifdef _XINT_EDIT_TABLE_H

/*
** XmRRowAnnotationData is defined for version 2.2
*/
#ifdef XmRRowAnnotationData
Boolean
StrToETBRowAnnotationData(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static String	*strarray;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int             n = 1;


  temp = XtNewString(str);
  sprintf(delimiter, "\t,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer) &strarray;
  toVal->size = sizeof(XtPointer);

  strarray = (String *)XtMalloc(sizeof(String));

  strarray[0] = ParseToken(token);

  while (token = strtok(NULL, delimiter)) {
     strarray = (String *) XtRealloc((char *)strarray,
                           (++n) * sizeof(String));
     strarray[n-1] = ParseToken(token);
  }

  strarray = (String *) XtRealloc((char *)strarray,
                           (++n) * sizeof(String));
  strarray[n - 1] = (String)500;
  XtFree((char *)temp);

  xintEditTableCvtRowAnnotationData = True;

  return(True);
}
#endif


Boolean
StrToETBColumnAnnotationData(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static String	*strarray;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int             n = 1;


  temp = XtNewString(str);
  sprintf(delimiter, "\t,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer) &strarray;
  toVal->size = sizeof(XtPointer);

  strarray = (String *)XtMalloc(sizeof(String));

  strarray[0] = ParseToken(token);

  while (token = strtok(NULL, delimiter)) {
     strarray = (String *) XtRealloc((char *)strarray,
                           (++n) * sizeof(String));
     strarray[n-1] = ParseToken(token);
  }

  strarray = (String *) XtRealloc((char *)strarray,
                           (++n) * sizeof(String));
  strarray[n - 1] = (String)500;
  XtFree((char *)temp);

  xintEditTableCvtColumnAnnotationData = True;

  return(True);
}





Boolean
StrToETBColumnDataFormatData(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static String   *strarray;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int             n = 1;


  temp = XtNewString(str);
  sprintf(delimiter, "\t,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer) &strarray;
  toVal->size = sizeof(XtPointer);

  strarray = (String *)XtMalloc(sizeof(String));

  strarray[0] = ParseToken(token);

  while (token = strtok(NULL, delimiter)) {
     strarray = (String *) XtRealloc((char *)strarray,
                           (++n) * sizeof(String));
     strarray[n-1] = ParseToken(token);
  }

  strarray = (String *) XtRealloc((char *)strarray,
                           (++n) * sizeof(String));
  strarray[n - 1] = (String)500;
  XtFree((char *)temp);

  xintEditTableCvtColumnDataFormatData = True;

  return(True);
}






Boolean
StrToETBFontTable(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static String   *strarray;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int             n = 1;


  temp = XtNewString(str);
  sprintf(delimiter, "\t, ");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer) &strarray;
  toVal->size = sizeof(XtPointer);

  strarray = (String *)XtMalloc(sizeof(String));

  strarray[0] = ParseToken(token);

  while (token = strtok(NULL, delimiter)) {
     strarray = (String *) XtRealloc((char *)strarray,
                           (++n) * sizeof(String));
     strarray[n-1] = ParseToken(token);
  }

  strarray = (String *) XtRealloc((char *)strarray,
                           (++n) * sizeof(String));
  strarray[n - 1] = (String)500;
  XtFree((char *)temp);

  xintEditTableCvtFontTable = True;

  return(True);
}
#endif




Boolean
StrToWidgetList(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{

fprintf(stdout,"in StrToWidgetList\n");
fflush(stdout);
}


Boolean
StrToPointer(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;
int		count;

fprintf(stdout,"in StrToPointer\n");
fflush(stdout);
}



Boolean
StrToReferenceChar(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
  String 		str = (String) (fromVal->addr);

  static int	reference;

  toVal->size = sizeof(int);
  toVal->addr = (XtPointer) &reference;

  reference = (int) str[0];

  if (reference < (int) ' ' || reference > (int) '~') {
    toVal->size = 0;
    toVal->addr = NULL;
    return(False);
  }

  return(True);
}



Boolean
StrToWindow(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

fprintf(stdout,"in StrToWindow\n");
fflush(stdout);
}


Boolean
StrToFloatArray(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static float	*fltarray;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int             n = 1;
int		count;
float		value;


  temp = XtNewString((String) str);
  sprintf(delimiter, "\t ,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&fltarray;
  toVal->size = sizeof(XtPointer);
  fltarray = (float *)XtMalloc(sizeof(float));
  count = sscanf(token, "%f.3", &value);
  if (count != 1) return(False);
  fltarray[0] = value;

  while (token = strtok(NULL, delimiter)) {
     fltarray = (float *) XtRealloc((char *)fltarray, (++n) * sizeof(float));
     count = sscanf(token, "%f.3", &value);
     if (count != 1) return(False);
     fltarray[n - 1] = value;
  }

  fltarray = (float *) XtRealloc((char *)fltarray, (++n) * sizeof(float));
  fltarray[n - 1] = XintUNDEFINED_FLOAT;
  XtFree((char *)temp);

  return(True);
}



Boolean
StrToFloatPtr(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static float    **value_ptr_ptr;
static float	*value_ptr;
float		value;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];
int		count;


  temp = XtNewString(str);
  sprintf(delimiter, "\t ,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  value_ptr_ptr = (float **) XtMalloc(sizeof(float *));
  value_ptr = (float *)XtMalloc(sizeof(float));
  value_ptr_ptr = (float **)&value_ptr;
  toVal->addr = (XtPointer)value_ptr_ptr;
  toVal->size = sizeof(XtPointer);
  count = sscanf(token, "%f.3", &value);
  if (count != 1) return(False);
  *value_ptr = value;
  XtFree((char *)temp);
}


Boolean
StrToTraceColorArray(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
fprintf(stdout,"in StrToTraceColorArray\n");
fflush(stdout);
}


#ifdef _XINT_OBJECT_EDITOR_H

Boolean
ObjEdtStrToStrArray(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
  String          str = (String)fromVal->addr;

  static  String *strarray;
  String temp = NULL;
  String token = NULL;
  char   delimiter[16];

  int  n = 1;

  temp = XtNewString((String) str);
  sprintf(delimiter, "\t ,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&strarray;
  toVal->size = sizeof(XtPointer);
  strarray = (String *) XtMalloc(sizeof(String));
  strarray[0] = XtNewString(token);
  while (token = strtok(NULL, delimiter)) {
      strarray = (String *) XtRealloc
		 ((char *)strarray, (++n) * sizeof(String));
      strarray[n - 1] = XtNewString(token);
  }
  strarray = (String *) XtRealloc((char *)strarray, (++n) * sizeof(String));
  strarray[n - 1] = NULL;

  free(temp);
  return(True);
}


Boolean
ObjEdtStrToEditList(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
  String          str = (String)fromVal->addr;

  static String *strarray;
  String temp = NULL;
  String token = NULL;
  char   delimiter[16];

  static String defaults[6] = { "ActionEditor",
                                "ObjectEditor",
                                "ColorEditor",
                                "AttributeEditor",
                                "PixmapEditor",
                                NULL };
  int  numDefault = 5;
  int  i,  j;
  int  n = 1;
  int  k;


  temp = XtNewString(str);
  sprintf(delimiter, "\t, ");
  token = strtok(temp, delimiter);


  toVal->addr = (XtPointer)&strarray;
  toVal->size = sizeof(XtPointer);
  /** XmNeditList cannot be null, therefore, default
  *  to "ActionEditor . . . PixmapEditor". **/
  if (token == NULL) {
     strarray = (String *) XtMalloc(sizeof(String));
     strarray[0] = XtNewString(defaults[0]);
     while (n < numDefault) {
       strarray = (String *) XtRealloc ((char *)strarray, (++n) * sizeof(String));
       strarray[n - 1] = XtNewString(defaults[n-1]);
     }
     strarray = (String *) XtRealloc((char *)strarray, (++n) * sizeof(String));
     strarray[n - 1] = NULL;
     return(True);
  }

  strarray = (String *) XtMalloc(sizeof(String));
  strarray[0] = XtNewString(token);

  while (token = strtok(NULL, delimiter)) {
     strarray = (String *) XtRealloc((char *)strarray, (++n) * sizeof(String));
     strarray[n - 1] = XtNewString(token);
  }
  strarray = (String *) XtRealloc((char *)strarray, (++n) * sizeof(String));
  strarray[n - 1] = NULL;

  free(temp);
  return(True);
}


void
initXintObjClassRecord()
{
  int   i = 0;

  obj_rcd_ptr = (XintObjectClassRecordList)XtMalloc
                ((numObjClass+1) * sizeof(XintObjectClassRecord));

#ifdef _XINT_CHART_WIDGET_H
  obj_rcd_ptr[i].objclass = xintChartObjectClass;
  strcpy(obj_rcd_ptr[i].objclassname, "xintChartObjectClass");
  i++;
#endif

  obj_rcd_ptr[i].objclass = xintFreeHandObjectClass;
  strcpy(obj_rcd_ptr[i].objclassname, "xintFreeHandObjectClass");
  i++;

  obj_rcd_ptr[i].objclass = xintLineObjectClass;
  strcpy(obj_rcd_ptr[i].objclassname, "xintLineObjectClass");
  i++;

  obj_rcd_ptr[i].objclass = xintOvalObjectClass;
  strcpy(obj_rcd_ptr[i].objclassname, "xintOvalObjectClass");
  i++;

  obj_rcd_ptr[i].objclass = xintPolygonObjectClass;
  strcpy(obj_rcd_ptr[i].objclassname, "xintPolygonObjectClass");
  i++;

  obj_rcd_ptr[i].objclass = xintPolylineObjectClass;
  strcpy(obj_rcd_ptr[i].objclassname, "xintPolylineObjectClass");
  i++;

  obj_rcd_ptr[i].objclass = xintRectangleObjectClass;
  strcpy(obj_rcd_ptr[i].objclassname, "xintRectangleObjectClass");
  i++;

  obj_rcd_ptr[i].objclass = xintRoundedRectObjectClass;
  strcpy(obj_rcd_ptr[i].objclassname, "xintRoundedRectObjectClass");
  i++;

#ifdef _XINT_CHART_WIDGET_H
  obj_rcd_ptr[i].objclass = xintTextObjectClass;
  strcpy(obj_rcd_ptr[i].objclassname, "xintTextObjectClass");
  i++;
#else
  obj_rcd_ptr[i].objclass = xintTextObjObjectClass;
  strcpy(obj_rcd_ptr[i].objclassname, "xintTextObjObjectClass");
  i++;
#endif

  obj_rcd_ptr[i].objclass = (ObjectClass)NULL;
  i++;
}



ObjectClass *
XintGetObjectClass(name)
String name;
{
  int n, i;
  int found;

  found = 0;
  for (i=0; i<numObjClass; i++) {
    n = strcmp(name,obj_rcd_ptr[i].objclassname);
    if (n == 0) {
       found = 1;
       break;
    }
  }
  if (found) {
       return(&(obj_rcd_ptr[i].objclass));
  } else {
       return NULL;
  }
}



Boolean
ObjEdtStrToObjectClassList(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
String          str = (String)fromVal->addr;

static ObjectClass * objclasslist = NULL;
ObjectClass * tempobjptr = NULL;
String          temp = NULL;
String          token = NULL;
char            delimiter[16];

int             n = 1;
int             lastObj = 0;

fprintf(stdout,"in ObjEdtStrToObjectClassList\n");
fflush(stdout);

  if (allocXintObjClassRecord == False) {
     initXintObjClassRecord();
     allocXintObjClassRecord = True;
  }

  temp = XtNewString((String) str);
  sprintf(delimiter, "\t ,");
  token = strtok(temp, delimiter);

  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&objclasslist;
  toVal->size = sizeof(XtPointer);
  objclasslist = (ObjectClass *)XtMalloc(sizeof(ObjectClass));
  tempobjptr =  XintGetObjectClass(token);
  objclasslist[0] = *tempobjptr;

  while (token = strtok(NULL, delimiter)) {
     tempobjptr =  XintGetObjectClass(token);
     objclasslist = (ObjectClass *)XtRealloc ((char *)objclasslist, (++n) * sizeof(ObjectClass));
     objclasslist[n - 1] = *tempobjptr;
  }

  objclasslist = (ObjectClass *) XtRealloc((char *)objclasslist, (++n) * sizeof(ObjectClass));
  objclasslist[n - 1] = (ObjectClass)NULL;

  XtFree((char *)temp);

fprintf(stdout,"out ObjEdtStrToObjectClassList\n");
fflush(stdout);

  return(True);
}



void
initXintPixmapsRcd(oe)
Widget oe;
{
  int i;

  obj_pmap_ptr = (XintPixmapsRcdList)XtMalloc
                ((numDfPmp+1) * sizeof(XintPixmapsRcd));
  for (i=0; i<(numDfPmp); i++) {
     obj_pmap_ptr[i].pmap = XintObjectEditorGetDefinedPixmap(oe,dfpixmaps[i]);
     strcpy(obj_pmap_ptr[i].pmapname, dfpixmaps[i]);
  }
  obj_pmap_ptr[i].pmap = XmUNSPECIFIED_PIXMAP;
}


Pixmap *
XintGetPixmaps(name)
String name;
{
  int n, i;
  int found;

  found = 0;
  for (i=0; i<numDfPmp; i++) {
    n = strcmp(name,obj_pmap_ptr[i].pmapname);
    if (n == 0) {
       found = 1;
       break;
    }
  }
  if (found) {
       return(&(obj_pmap_ptr[i].pmap));
  } else {
       return NULL;
  }
}


Boolean
ObjEdtStrToPixmapList(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
  String          str = (String)fromVal->addr;

  String temp = NULL;
  String token = NULL;
  char   delimiter[16];

  int   i, j, lastPmap;
  int   n = 1;
  Widget dummy = (Widget) NULL;
  Widget oe;
  static Pixmap *pmapptr = NULL;
  Pixmap *temppmapptr = NULL;

fprintf(stdout,"in ObjEdtStrToPixmapList\n");
fprintf(stdout,"num_args is : %d\n",*num_args);
fflush(stdout);

  if (allocXintPixmapsRcd == False) {
     initXintPixmapsRcd(dummy);
     allocXintPixmapsRcd = True;
  }

  temp = XtNewString(str);
  sprintf(delimiter, "\t, ");
  token = strtok(temp, delimiter);
  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&pmapptr;
  toVal->size = sizeof(XtPointer);
  pmapptr = (Pixmap *) XtMalloc(sizeof(Pixmap));
  pmapptr[0] = *(XintGetPixmaps(token));

  while (token = strtok(NULL, delimiter)) {
         pmapptr = (Pixmap *)XtRealloc
                           ((char *)pmapptr, (++n) * sizeof(Pixmap));
         pmapptr[n - 1] = *(XintGetPixmaps(token));
  }
  pmapptr = (Pixmap *) XtRealloc((char *) pmapptr,
                        (++n) * sizeof(Pixmap));
  pmapptr[n - 1] = XmUNSPECIFIED_PIXMAP;

  free(temp);
fprintf(stdout,"out ObjEdtStrToPixmapList\n");
fflush(stdout);
  return(True);
}


#endif


#ifdef _XINT_CHART_WIDGET_H
Boolean
StrToDynamicInteger4(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
  String          str = (String)fromVal->addr;

  String temp = NULL;
  String token = NULL;
  char   delimiter[16];
  XintTempDynamicInteger4List int4ptr;

  int   i, j;
  int   n = 1;
  int   inF2, inF3, inF4;

  temp = XtNewString(str);
  sprintf(delimiter, "\t, ");
  token = strtok(temp, delimiter);
  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&int4ptr;
  toVal->size = sizeof(XtPointer);
  int4ptr = (XintTempDynamicInteger4List) XtMalloc
			(sizeof(XintTempDynamicInteger4));
  if (isdigit(token[0])) {
     int4ptr->field1 = atoi(token);
  } else {
     int4ptr->field1 = 0;
  }

  inF2 = 0;  inF3 = 0;  inF4 = 0;
  while (token = strtok(NULL, delimiter)) {
     if (isdigit(token[0])) {
        if (!inF2) {
           int4ptr->field2 = atoi(token);
	   inF2 = 1;
        } else if (!inF3) {
           int4ptr->field3 = atoi(token);
	   inF3 = 1;
        } else if (!inF4) {
           int4ptr->field4 = atoi(token);
	   inF4 = 1;
        }
     } else {
        if (!inF2) {
           int4ptr->field2 = 0;
	   inF2 = 1;
        } else if (!inF3) {
           int4ptr->field3 = 0;
	   inF3 = 1;
        } else if (!inF4) {
           int4ptr->field4 = 0;
	   inF4 = 1;
        }
     }
  }

  free(temp);
  return(True);
}



Boolean
StrToDynamicFloat4(dpy, args, num_args, fromVal, toVal, closure_ret)
Display         *dpy;
XrmValuePtr     args;
Cardinal        *num_args;
XrmValuePtr     fromVal;
XrmValuePtr     toVal;
XtPointer       *closure_ret;
{
  String          str = (String)fromVal->addr;

  String temp = NULL;
  String token = NULL;
  char   delimiter[16];
  XintTempDynamicFloat4List flt4ptr;

  float value;
  int   i, j, count;
  int   n = 1;
  int   inF2, inF3, inF4;

  temp = XtNewString(str);
  sprintf(delimiter, "\t, ");
  token = strtok(temp, delimiter);
  if (token == NULL) {
     toVal->addr = NULL;
     toVal->size = sizeof(XtPointer);
     return(True);
  }

  toVal->addr = (XtPointer)&flt4ptr;
  toVal->size = sizeof(XtPointer);
  flt4ptr = (XintTempDynamicFloat4List) XtMalloc
			(sizeof(XintTempDynamicFloat4));

  count = sscanf(token, "%f.3", &value);
  if (count != 1) return(False);
  flt4ptr->field1 = value;

  inF2=0;inF3=0;inF4=0;
  while (token = strtok(NULL, delimiter)) {
     if (!inF2) {
        count = sscanf(token, "%f.3", &value);
        if (count != 1) return(False);
        flt4ptr->field2 = value;
        inF2=1;
     } else if (!inF3) {
        count = sscanf(token, "%f.3", &value);
        if (count != 1) return(False);
        flt4ptr->field2 = value;
        inF3=1;
     } else if (!inF4) {
        count = sscanf(token, "%f.3", &value);
        if (count != 1) return(False);
        flt4ptr->field2 = value;
        inF4=1;
     }
  } /** end while (token = strtok(NULL, delimiter) **/
   
  free(temp);
  return(True);
}

#endif
