int ias_odl_add_or_replace_field
(
    OBJDESC *curr_object,       /* I/O: Object tree to populate */
    const char *p_LabelName,    /* I: Field to add */
    IAS_ODL_TYPE ValueType,     /* I: What type the field is */
    const int p_MemorySize,     /* I: Total memory size of attribues values */
    void *p_MemoryAddr,         /* I: Pointer to the attribute information */
    const int nelements,        /* I: Number of attribute values */
    const int action_flag       /* I: Flag indicated the attribute name will 
                                      be replaced */
)
{
    int i;                       /* Looping variable */
    int sz;                      /* Memory size base on data type */
    int count = 0;               /* Count of attribute values */
    int total_indentation;       /* Total number of indent characters */
    int curr_length;             /* Current length of keyword string */
    int tmp_len;                 /* Length of the temporary string */
    char tmp_string[TB_MAXLINE]; /* Temporary string for converting values */
    char *value_to_paste = NULL; /* Pointer to ODL keyword values */
    char newline_blanks[MAX_LEN] = "\n"; /* String for newline and indenting */
    const char *p_ClassName = NULL; /* Group/Object name */
    KEYWORD *new_keyword = NULL; /* Pointer to new ODL keyword */
    KEYWORD *curr_keyword = NULL;/* Pointer to current ODL keyword */
    KEYWORD *ptr_keyword = NULL; /* Pointer to cut ODL keyword */
    char *cptr = NULL;           /* Pointer to the current value */
    OBJDESC *p_lp = NULL;        /* Pointer to ODL object */

    /* Check to make sure a valid Label Name was specified */
    if ((p_LabelName == NULL) || (strlen(p_LabelName) == 0))
    {
        IAS_LOG_ERROR("Invalid attribute name");
        return ERROR;
    }

    /* Check to make sure there are values to convert */
    if ((p_MemorySize <= 0) || (nelements <= 0))
    {
        IAS_LOG_ERROR("Undefined attribute size");
        return ERROR;
    }

    /* Calculate the indentation size */
    total_indentation = curr_object->level * INDENT_SIZE;
    
    /* ensure indentation does not overrun newline buffer size */
    if (total_indentation > 78)
        total_indentation = 78;

    /* Calculate the length of the output string.  This includes the
       indentation, label name, and equal sign surrounded by spaces " = " */
    curr_length = total_indentation + strlen(p_LabelName) + 3;

    /* Add blanks for the indentation */
    for(i = 0; i < total_indentation ; i++)
        strcat(newline_blanks," ");

    /* Determine the size of the data input */
    sz = p_MemorySize / nelements;
    cptr = (char *)p_MemoryAddr;

    if (nelements > 1)
    {
        /* Start the array of strings with a left parenthesis */
        CopyString(value_to_paste, "(");
        curr_length++;
    }

    while (count < nelements)
    {
        /* Convert the value at the current position to a
           formatted string */
        switch (ValueType)
        {
            case IAS_ODL_String:
                sprintf(tmp_string, "\"%s\"", (char *)cptr);
                break;
            case IAS_ODL_ArrayOfString:
                sprintf(tmp_string, "\"%s\"", (char *)cptr);
                cptr += sz;
                break;
            case IAS_ODL_Int:
                sprintf(tmp_string, "%d", *(int *)cptr);
                cptr += sizeof(int);
                break;
            case IAS_ODL_Long:
                sprintf(tmp_string, "%ld", *(long *)cptr);
                cptr += sizeof(long);
                break;
            case IAS_ODL_Float:
                sprintf(tmp_string, "%G", *(float *)cptr);
                cptr += sizeof(float);
                break;
            case IAS_ODL_Double:
                sprintf(tmp_string, "%-4.14G", *(double *)cptr);
                cptr += sizeof(double);
                break;
            case IAS_ODL_Sci_Not:
                sprintf(tmp_string, "%-4.11G", *(double *)cptr);
                cptr += sizeof(double);
                break;
        }

        /* Remove any extra spaces exceptt in array of strings type */
          if ( ValueType != IAS_ODL_String )
             ias_odl_remove_character(tmp_string,' ');

        /* Determine if the line needs to be wrapped.
           The 2 accounts for the comma and space or
           the ending paranthesis.
        */
        tmp_len = strlen(tmp_string);
        if ((curr_length + tmp_len + 2) > MAX_LEN)
        {
            /* Add a new line and indentation */
            AppendString(value_to_paste, newline_blanks);

            /* Reset the current string length */
            curr_length = tmp_len + strlen(newline_blanks);
        }

        /* Append the formatted string to the value to paste */
        AppendString(value_to_paste, tmp_string);
        curr_length += tmp_len;

        /* Increment the element counter */
        count++;

        if (count < nelements)
        {
            /* Append a comma and space to separate values */
            AppendString(value_to_paste, ", ");
            curr_length += 2;
        }
    }

    if (nelements > 1)
    {
        /* End the array of strings with a left parenthesis */
        AppendString(value_to_paste, ")");
        curr_length++;
    }
    
    if (action_flag == TRUE)
    { 
        /* find ODL object */
        if ((p_lp = OdlFindObjDesc(curr_object, p_ClassName, 
                    p_LabelName, NULL, 1, 
                    ODL_RECURSIVE_DOWN)) == NULL)
        {
            if ((long)strlen(ODLErrorMessage) <= 1 )
            {
                IAS_LOG_ERROR("%s", ODLErrorMessage);
                IAS_LOG_ERROR("Object %s not found with %s keyword", 
                    (p_ClassName) ? (p_ClassName) : "null", p_LabelName);
            }
            free(value_to_paste);
            return ERROR;
        }

        /* search for keyword */
        if ((curr_keyword = OdlFindKwd(p_lp, p_LabelName, NULL, 1,
            ODL_RECURSIVE_DOWN)) == NULL)
        {
            if ((long)strlen(ODLErrorMessage) <= 1 )
            {
                IAS_LOG_ERROR("%s", ODLErrorMessage);
                IAS_LOG_ERROR("Keyword %s not found", p_LabelName);
            }
            free(value_to_paste);
            return ERROR;
        }

        /* cut old keyword */
        ptr_keyword = OdlCutKwd(curr_keyword);
    } /* end of replace field */

    /* Paste the new label, with values, into the ODL Object Tree */
    new_keyword = OdlNewKwd((char *)p_LabelName, (char *)value_to_paste,
                            NULL, NULL, NULL, 0);

    /* Free the space allocated to the value_to_paste pointer */
    free(value_to_paste);

    curr_keyword = OdlPasteKwd(new_keyword, curr_object);
    if (!curr_keyword)
    {
        IAS_LOG_ERROR("Add attribute to tree failed");
        return ERROR ;
    }
    /* free old keyword */
    OdlFreeKwd(ptr_keyword);

    return SUCCESS;
}
Beispiel #2
0
main() {

OA_OBJECT oa_object, table_A, table_B, file_object, tmp_object;
ODLTREE root_node, odltreenode, table_node, column_node, column_nodes[10];
char *label_filename, *errfilespec;
float *column_values1, *column_values2;
int i, *table_values;
char c, *ptr, *data_type;
long row_bytes;

/* Read in the label from SGC_0031.LBL.  This contains two binary TABLES
   with VAX data types - orbit/pointing info for PV/OUVS orbit #31.  */

label_filename = "SGC_0031.LBL";
sprintf( error_string, "Reading %s...", label_filename);
OaReportError( error_string);
if ((root_node = OaParseLabelFile( label_filename, NULL, 0, 0)) == NULL) {
  OaReportError( "Error from OaParseLabelFile");
  return(0);
}

/* Find the SGC_TABLE node.  */

if ((table_node = OdlFindObjDesc( root_node, "SGC_TABLE", NULL, NULL, 0,
                                  ODL_RECURSIVE_DOWN)) == NULL) {
  OaReportError( "Couldn't find SGC_TABLE node!");
  return(0);
}

/* Get the VENUS_SC_VECTOR column of the TABLE into memory two different ways.
   #1: Read in the entire table, then extract the VENUS_SC_VECTOR column. */

if ((table_A = OaReadObject( table_node)) == NULL) {
  OaReportError( "OaReadObject failed!");
  return(1);
}

/* Find the VENUS_SC_VECTOR column node (in the ODL tree of the in-memory
   table).  */

if ((column_node = OdlFindObjDesc( table_A->odltree, "COLUMN",
                                  "NAME", "VENUS_SC_VECTOR", 0,
                                   ODL_RECURSIVE_DOWN)) == NULL) {
  OaReportError( "Couldn't find VENUS_SC_VECTOR column!");
  return(1);
}

column_nodes[0] = column_node;

OaReportError( "OaGetSubTable extracting VENUS_SC_VECTOR column...");

if ((table_B = OaGetSubTable( table_A, (long) 1, (long) 256,
                                    column_nodes, 1)) == NULL) {
  OaReportError( "OaGetSubTable failed!");
  return(1);
}

/* Free table_A.  */

OaDeleteObject( table_A);

/* Method #2: read in only the VENUS_SC_VECTOR with OaReadSubTable.  */

if ((column_node = OdlFindObjDesc( root_node, "COLUMN",
                                  "NAME", "VENUS_SC_VECTOR", 0,
                                   ODL_RECURSIVE_DOWN)) == NULL) {
  OaReportError( "Couldn't find VENUS_SC_VECTOR column!");
  return(1);
}

column_nodes[0] = column_node;

OaReportError( "OaReadSubTable reading in VENUS_SC_VECTOR...");

if ((table_A = OaReadSubTable( table_node, (long) 1, (long) 256,
                                     column_nodes, 1)) == NULL) {
  OaReportError( "OaReadSubTable failed!");
  return(1);
}

/* Print out a few values to see if it worked.  */

column_values1 = (float *) table_A->data_ptr;
column_values2 = (float *) table_B->data_ptr;
OaReportError( "First 3 values should be:  5940.21    -729.04   10895.34");
sprintf( error_string, "First 3 values are:     %10.2f %10.2f %10.2f",
         column_values1[0], column_values1[1], column_values1[2]);
OaReportError( error_string);


/* Compare every element in the two tables. */

for (i=0; i<(3*256); i++) {
  if (column_values1[i] != column_values2[i]) {
    sprintf( error_string, "columns don't match: i = %d\n", i);
    OaReportError( error_string);
    return(1);
  }
}
OaReportError( "column data matches.");

OaDeleteObject( table_B);

/* Convert the object data to ASCII.  */

Oa_profile.dst_format_for_binary_src = OA_ASCII_INTERCHANGE_FORMAT;
printf( "Converting column data to ASCII...\n");
if ((table_B = OaConvertObject( table_A)) == NULL) {
  OaReportError( "OaConvertObject failed!");
  return(1);
}

/* Print out first 40 chars of the ASCII data.  */

ptr = (char *) table_B->data_ptr;
c = ptr[40];
ptr[40] = '\0';
sprintf( error_string, "First 40 chars of ASCII tables are: %s", ptr);
OaReportError( error_string);
ptr[40] = c;

/* Append CR/LF to each row of the ASCII table.  */

if (OaAddLineTerminatorstoTable( table_B) == NULL) {
  printf( "OaAddLineTerminatorstoTable failed!\n");
  return(1);
}

/* Open output file. */

if ((file_object = OaOpenOutputFile( "TMP_TABLE.DAT", OA_STREAM,
                                      0)) == NULL) {
  OaReportError( "OaOpenOutputFile failed!");
  return(1);
}

/* Write the ASCII table to the output file.  */

if (OaWriteObject( file_object, table_B) != 0) {
  OaReportError( "OaWriteObject failed!");
  return(1);
}

/* Close the output file and write the label.  */

if (OaCloseOutputFile( file_object, "TMP_TABLE.LBL") != 0) {
  OaReportError( "OaCloseOutputFile failed!");
  return(1);
}
OaReportError( 
        "Type out TMP_TABLE.DAT and TMP_TABLE.LBL and verify contents.");

/* Import two columns and slice and dice them.  */

table_values = (int *) OaMalloc( sizeof(int)*3);
table_values[0] = 11;
table_values[1] = 21;
table_values[2] = 31;

#if (defined(ALPHA_VMS) || defined(ALPHA_OSF) || defined(VAX) || defined(IBM_PC) || defined(ULTRIX))
data_type = "LSB_INTEGER";
#else
data_type = "MSB_INTEGER";
#endif


OaReportError( "Calling OaImportColumn...");
table_A = OaImportColumn( (char *) table_values, (long) 3, (long) 1,
                          (long) sizeof( int), data_type, 
                          OA_BINARY_INTERCHANGE_FORMAT, "FIRST_COLUMN");
if (table_A == NULL) {
  OaReportError( "OaImportColumn failed!");
  return(1);
}

table_values = (int *) OaMalloc( sizeof(int)*3);
table_values[0] = 12;
table_values[1] = 22;
table_values[2] = 32;
OaReportError( "Calling OaImportColumn...");
table_B = OaImportColumn( (char *) table_values, (long) 3, (long) 1,
                          (long) sizeof( int), data_type, 
                          OA_BINARY_INTERCHANGE_FORMAT, "SECOND_COLUMN");
if (table_B == NULL) {
  OaReportError( "OaImportColumn failed!");
  return(1);
}

/* Join the two TABLES, appending COLUMNS, and print out the new table's
   data.  */

OaReportError( "Calling OaJoinTables...");
if (OaJoinTables( table_A, table_B, OA_ADD_COLUMNS) == NULL) {
  OaReportError( "OaJoinTables failed!");
  return(1);
}

OaDeleteObject( table_B);

OaReportError( "TABLE should be row-major, with three rows and two columns:");
table_values = (int *) table_A->data_ptr;
sprintf( error_string, 
        "%d %d\n%d %d\n%d %d\n\n", table_values[0], table_values[1],
        table_values[2], table_values[3], table_values[4], table_values[5]);
OaReportError( error_string);

/* Transpose the TABLE to COLUMN_MAJOR and print out its data.  */

OaReportError( "Calling OaTransposeTable...");

if (OaTransposeTable( table_A) == NULL) {
  OaReportError( "OaTransposeTable failed!");
  return(1);
}

OaReportError( "TABLE should now be column-major:");
table_values = (int *) table_A->data_ptr;
sprintf( error_string,
        "%d %d %d\n%d %d %d\n\n", table_values[0], table_values[1],
        table_values[2], table_values[3], table_values[4], table_values[5]);
OaReportError( error_string);

/* Transpose the TABLE back to ROW_MAJOR and print out its data.  */

OaReportError( "Calling OaTransposeTable again...");

if (OaTransposeTable( table_A) == NULL) {
  OaReportError( "OaTransposeTable failed!");
  return(1);
}

OaReportError( "TABLE should be row-major, with three rows and two columns:");
table_values = (int *) table_A->data_ptr;
sprintf( error_string, 
         "%d %d\n%d %d\n%d %d\n\n", table_values[0], table_values[1],
        table_values[2], table_values[3], table_values[4], table_values[5]);
OaReportError( error_string);

/* Delete the middle row and print out the data.  */

OaReportError( "Calling OaDeleteRow to delete second row...");
if (OaDeleteRow( table_A, (long) 2) == NULL) {
  OaReportError( "OaDeleteRow failed!");
  return(1);
}

OaReportError( "TABLE should have first and third rows and two columns:");
table_values = (int *) table_A->data_ptr;
sprintf( error_string, "%d %d\n%d %d\n\n", table_values[0], table_values[1],
         table_values[2], table_values[3]);
OaReportError( error_string);

/* Delete the first column.  */

if ((column_node = OdlFindObjDesc( table_A->odltree, "COLUMN",
                                  "NAME", "FIRST_COLUMN", 0,
                                   ODL_RECURSIVE_DOWN)) == NULL) {
  OaReportError( "Couldn't find FIRST_COLUMN column!");
  return(1);
}

OaReportError( "Calling OaDeleteColumn to delete first column...");
if (OaDeleteColumn( table_A, column_node) == NULL) {
  OaReportError( "OaDeleteColumn failed!");
  return(1);
}

OaReportError( "TABLE should have first and third rows and second column:");
table_values = (int *) table_A->data_ptr;
sprintf( error_string, "%d\n%d\n\n", table_values[0], table_values[1]);
OaReportError( error_string);

OaReportError( "All tests worked!");
return(0);
}
int ias_odl_get_field
( 
    void *p_MemoryAddr,             /* I/O: List of attributes to retrieve */
    int MemorySize,                 /* I: mem size of attributes */ 
    IAS_ODL_TYPE ValueType,         /* I: ODL data type */
    IAS_OBJ_DESC *p_ODLTree,        /* I: ODL tree */
    const char *p_ClassName,        /* I: Group/Object name */
    const char *p_LabelName,        /* I: Field to get */
    int *p_Count                    /* I: number of values in attribute */
)
{
    OBJDESC *p_lp;              /* Object Descriptor */
    KEYWORD *p_kw;              /* Keyword Name */
    char *p_kwv;                /* Keyword Value */
    char *p_keyword;            /* Copy of the Keyword Value */
    int i;                      /* loop counter */
    char *p_word;               /* word to convert */
    int ret_code = 0;           /* function return value */

    *p_Count = 0;

    if ( (p_LabelName == NULL) || (strlen(p_LabelName) == 0) )
    {
        IAS_LOG_ERROR("Attribute name missing");
        return ERROR;
    }

    if ((p_lp = OdlFindObjDesc(p_ODLTree, p_ClassName, p_LabelName, NULL, 1, 
        ODL_RECURSIVE_DOWN)) == NULL)
    {
        /* it's possible that we have NULL for a group(p_ClassName), that's OK;
           no need to log an error, just return */
        return IAS_ODL_NOT_FOUND;
    }

    if ((p_kw = OdlFindKwd(p_lp, p_LabelName, NULL, 1 ,ODL_RECURSIVE_DOWN)) 
        == NULL)
    {
        if ((long)strlen(ODLErrorMessage) <= 1 )
        {
            IAS_LOG_ERROR("%s", ODLErrorMessage);
            IAS_LOG_ERROR("Keyword '%s' not found", p_LabelName);
        }
        return IAS_ODL_NOT_FOUND;
    }

    if ((p_kwv = OdlGetKwdValue(p_kw)) == NULL)
    {
        if ((long)strlen(ODLErrorMessage) <= 1 )
        {
            IAS_LOG_ERROR("%s", ODLErrorMessage);
            IAS_LOG_ERROR("Keyword %s not found", p_LabelName);
        }
        return IAS_ODL_NOT_FOUND;
    }
    if ((p_keyword= malloc(strlen(p_kwv)+1)) == NULL)
    {
        IAS_LOG_ERROR("Malloc error");
        return ERROR;
    }
    (void)strcpy(p_keyword,p_kwv);

    /* When working with a set or a sequence, all of the newline characters
       should be removed from the incoming string.  The ODL library is placing
       newlines into these strings around character 2025 even though they don't
       exist in the ODL file. */
    if ((OdlGetKwdValueType(p_kw) == ODL_SET) ||
        (OdlGetKwdValueType(p_kw) == ODL_SEQUENCE))
    {
        char * p_newline;

        while ((p_newline = strchr(p_keyword, '\n')) != NULL)
        {
            while (*p_newline != '\0')
            {
                *p_newline = *(p_newline + 1);
                p_newline++;
            }
        }
    }

    if (OdlGetKwdValueType(p_kw) == ODL_SET)
    {
        p_word = strtok(p_keyword,"(,) \"\n");
        while(p_word != NULL)
        {
            if (strlen(p_word))
            {
                switch (ValueType)
                {
                case IAS_ODL_Long :
                    MemorySize -= sizeof(long);
                    if (MemorySize < 0 )
                    {
                        IAS_LOG_ERROR("Input ODL value overflows allocated "
                            "space ");
                        free(p_keyword);
                        return IAS_ODL_NOT_ENOUGH_MEMORY_SUPPLIED;
                    }
                    if ( ( ret_code = convert_string(p_MemoryAddr,
                        ValueType,p_word) ) != SUCCESS )
                    {
                        IAS_LOG_ERROR("Converting %s keyword's value "
                            "%s",p_LabelName, p_word);
                        free(p_keyword);
                        return ret_code;
                    }
                    p_MemoryAddr = (long *)p_MemoryAddr + 1;
                    break;

                case IAS_ODL_Int :
                    MemorySize -= sizeof(int);
                    if (MemorySize < 0 )
                    {
                        IAS_LOG_ERROR("Input ODL value overflows allocated "
                            "space ");
                        free(p_keyword);
                        return IAS_ODL_NOT_ENOUGH_MEMORY_SUPPLIED;
                    }
                    if ( ( ret_code = convert_string(p_MemoryAddr,
                        ValueType,p_word) ) != SUCCESS )
                    {
                        IAS_LOG_ERROR("Converting %s keyword's value "
                            "%s",p_LabelName, p_word);
                        free(p_keyword);
                        return ret_code;
                    }
                    p_MemoryAddr = (int *)p_MemoryAddr + 1;
                    break;

                case IAS_ODL_Float :
                    MemorySize -= sizeof(float);
                    if (MemorySize < 0 )
                    {
                        IAS_LOG_ERROR("Input ODL value overflows allocated "
                            "space ");
                        free(p_keyword);
                        return IAS_ODL_NOT_ENOUGH_MEMORY_SUPPLIED;
                    }
                    if ( ( ret_code = convert_string(p_MemoryAddr,
                        ValueType,p_word) ) != SUCCESS )
                    {
                        IAS_LOG_ERROR("Converting %s keyword's value "
                            "%s",p_LabelName, p_word);
                        free(p_keyword);
                        return ret_code;
                    }
                    p_MemoryAddr = (float *)p_MemoryAddr + 1;
                    break;

                case IAS_ODL_Double :
                case IAS_ODL_Sci_Not :
                    MemorySize -= sizeof(double);
                    if (MemorySize < 0 )
                    {
                        IAS_LOG_ERROR("Input ODL value overflows allocated "
                            "space ");
                        free(p_keyword);
                        return IAS_ODL_NOT_ENOUGH_MEMORY_SUPPLIED;
                    }
                    if ( ( ret_code = convert_string(p_MemoryAddr,
                        ValueType,p_word) ) != SUCCESS )
                    {
                        IAS_LOG_ERROR("Converting %s keyword's value "
                            "%s",p_LabelName, p_word);
                        free(p_keyword);
                        return ret_code;
                    }
                    p_MemoryAddr = (double *)p_MemoryAddr + 1;
                    break;

                case IAS_ODL_ArrayOfString :
                    MemorySize -= sizeof(char *);
                    if (MemorySize < 0 )
                    {
                        IAS_LOG_ERROR("Input ODL value overflows allocated "
                            "space ");
                        free(p_keyword);
                        return  IAS_ODL_NOT_ENOUGH_MEMORY_SUPPLIED;
                    }
                    if ( ( ret_code = convert_string(p_MemoryAddr,
                        ValueType,p_word) ) != SUCCESS )
                    {
                        for( i=0;i<*p_Count;i++)
                            free((char *)p_MemoryAddr + i);
                        IAS_LOG_ERROR("Converting %s keyword's value "
                            "%s",p_LabelName, p_word);
                        free(p_keyword);
                        return ret_code;
                    }
                    p_MemoryAddr = (char *)p_MemoryAddr + sizeof(char *);
                    break;

                default:
                    (void)strncpy( p_MemoryAddr, p_word, MemorySize);
                    IAS_LOG_ERROR("Type IAS_ODL_String is not valid for arrays "
                        "of strings");
                    free(p_keyword);
                    return ERROR;
                }
                *p_Count += 1;
                p_word = strtok(NULL,",() \"\n");
            }
        }
    }
    else if (OdlGetKwdValueType(p_kw) == ODL_SEQUENCE)
    {
        p_word = strtok(p_keyword,"{,} \"\n");
        while(p_word != NULL)
        {
            if (strlen(p_word))
            {
                switch (ValueType)
                {
                case IAS_ODL_ArrayOfString :
                    MemorySize -= sizeof(char *);
                    if (MemorySize < 0 )
                    {
                        IAS_LOG_ERROR("Input ODL value overflows allocated "
                            "space ");
                        free(p_keyword);
                        return  IAS_ODL_NOT_ENOUGH_MEMORY_SUPPLIED;
                    }
                    if ( ( ret_code = convert_string(p_MemoryAddr,
                        ValueType,p_word) ) != SUCCESS )
                    {
                        for( i=0;i<*p_Count;i++)
                            free((char *)p_MemoryAddr + i);
                        IAS_LOG_ERROR("Converting %s keyword's value "
                            "%s", p_LabelName, p_word);
                        free(p_keyword);
                        return ret_code;
                    }
                    p_MemoryAddr = (char *)p_MemoryAddr + sizeof(char *);
                    break;

                default:
                    (void)strncpy( p_MemoryAddr, p_word, MemorySize);
                    IAS_LOG_ERROR("An ODL sequence is of type "
                        "IAS_ODL_ArrayOfString only");
                    free(p_keyword);
                    return ERROR;
                }
                *p_Count += 1;
                p_word = strtok(NULL,",{} \"\n");
            }
        }
    }
    else
    {
        if (ValueType == IAS_ODL_String)
        {
            char * p_start = p_kwv;
            int    len     = strlen(p_kwv);

            /* If we are working with a double quoted string, we'll need to
               remove the double quotes in the string that is passed back.
               Adjust the length of the string and the starting point for
               copying, if necessary. */
            if (p_kwv[0] == '\"')
            {
                len -= 2;
                p_start++;
            }

            if (MemorySize < (len + 1))
            {
                IAS_LOG_ERROR("Input ODL value overflows allocated space");
                (void)strncpy(p_MemoryAddr, p_start, MemorySize);
                ((char *)p_MemoryAddr)[MemorySize-1] = '\0';
                free(p_keyword);
                return IAS_ODL_NOT_ENOUGH_MEMORY_SUPPLIED;
            }

            (void)strncpy(p_MemoryAddr, p_start, len);
            ((char *)p_MemoryAddr)[len] = '\0';
        }
        else
        {
            switch(ValueType)
            {
            case IAS_ODL_Long:
                MemorySize -= sizeof(long);
                break;

            case IAS_ODL_Int:
                MemorySize -= sizeof(int);
                break;

            case IAS_ODL_Float:
                MemorySize -= sizeof(float);
                break;

            case IAS_ODL_Double:
            case IAS_ODL_Sci_Not:
                MemorySize -= sizeof(double);
                break;

            default:
                IAS_LOG_ERROR("Invalid Type specified");
                free(p_keyword);
                return ERROR;
            }

            if (MemorySize < 0 )
            {
                IAS_LOG_ERROR("Input ODL value overflows allocated space ");
                free(p_keyword);
                return ERROR;
            }

            if ( ( ret_code = convert_string(p_MemoryAddr,ValueType,
                p_kwv) ) != SUCCESS )
            {
                IAS_LOG_ERROR("Converting %s keyword's value %s",
                    p_LabelName,p_kwv);
                free(p_keyword);
                return ret_code;
            }
        }
        *p_Count += 1;
    }
    free(p_keyword);
    return SUCCESS;
}