IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9798 for trunk/psLib


Ignore:
Timestamp:
Oct 30, 2006, 2:08:19 PM (20 years ago)
Author:
drobbin
Message:

Merged differences from recent check-in. Edited long-lines. Updated Time outputting format to match the input scheme. (This way an output psTime can then be correctly read in by psMetadataConfigParse). Also removed a couple unreachable spots in the internal parse fxns.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psMetadataConfig.c

    r9763 r9798  
    1010*  @author Eric Van Alst, MHPCC
    1111*
    12 *  @version $Revision: 1.101 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-10-27 02:26:42 $
     12*  @version $Revision: 1.102 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2006-10-31 00:08:19 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    152152            ptrB++;
    153153        }
    154     } else {
    155         while (isspace(*ptrB)) {
    156             ptrB++;
    157         }
    158     }
     154    }
     155    /*    else {
     156            while (isspace(*ptrB)) {
     157                ptrB++;
     158            }
     159        }
     160    */
    159161
    160162    // Skip over trailing whitespace, null terminators, and # characters
     
    229231        // Move to end of token
    230232        (*inString) += sLen;
    231     } else if(**inString!='\0' && sLen==0) {
    232         *status = 1;
    233     }
    234 
     233    }
     234    /*    else if(**inString!='\0' && sLen==0) {
     235            *status = 1;
     236        }
     237    */
    235238    return cleanToken;
    236239}
     
    247250    if(*end != '\0') {
    248251        *status = 1;
    249     } else if(inString==end) {
    250         *status = 1;
    251     }
    252 
     252    }
     253    /*    else if(inString==end) {
     254            *status = 1;
     255        }
     256    */
    253257    return value;
    254258}
     
    265269    if(*end != '\0') {
    266270        *status = 1;
    267     } else if(inString==end) {
    268         *status = 1;
    269     }
    270 
     271    }
     272    /*    else if(inString==end) {
     273            *status = 1;
     274        }
     275    */
    271276    return value;
    272277}
     
    283288    if(*end != '\0') {
    284289        *status = 1;
    285     } else if(inString==end) {
    286         *status = 1;
    287     }
    288 
     290    }
     291    /*    else if(inString==end) {
     292            *status = 1;
     293        }
     294    */
    289295    return value;
    290296}
     
    295301{
    296302    // if inString is NULL return flalse, status = 0
    297     if (!inString) {
    298         if (status) {
    299             *status = 0;
    300         }
    301         return false;
    302     }
    303 
     303    /*    if (!inString) {
     304            if (status) {
     305                *status = 0;
     306            }
     307            return false;
     308        }
     309    */
    304310    if (!strncasecmp(inString, "T", 2) ||
    305311            !strncmp(inString, "1", 2) ||
    306312            !strncasecmp(inString, "true", 5)) {
    307         if (status) {
     313        if (status != NULL) {
    308314            *status = 0;
    309315        }
     
    313319            !strncmp(inString, "0", 2) ||
    314320            !strncasecmp(inString, "false", 6)) {
    315         if (status) {
     321        if (status != NULL) {
    316322            *status = 0;
    317323        }
     
    319325    }
    320326
    321     if (status) {
     327    if (status != NULL) {
    322328        *status = 1;
    323329    }
     
    331337{
    332338    PS_ASSERT_PTR_NON_NULL(status, NULL);
    333     if (!inString) {
    334         *status = 0;
    335         return NULL;
    336     }
    337 
     339    /*    if (!inString) {
     340            *status = 0;
     341            return NULL;
     342        }
     343    */
    338344    // handle "NULL" as the time value
    339345    if (strncmp(inString, "NULL", 5) == 0) {
     
    373379    while(*inString!='\0') {
    374380        strtod(inString, &end);
    375         if(inString==end) {
    376             *status = 1;
    377             return NULL;
    378         }
    379         while(*end==' ' || *end==',') { // Commas or spaces may be used as delimiters for vector values
     381        /*        if(inString==end) {
     382                    *status = 1;
     383                    return NULL;
     384                }
     385        */
     386        // Commas or spaces may be used as delimiters for vector values
     387        while(*end==' ' || *end==',') {
    380388            end++;
    381389        }
     
    392400        while(*inString!='\0') {
    393401            value = strtod(inString, &end);
    394             if(inString==end) {
    395                 *status = 1;
    396                 return vec;
    397             }
     402            /*            if(inString==end) {
     403                            *status = 1;
     404                            return vec;
     405                        }
     406                        */
    398407            switch(elemType) {
    399408            case PS_TYPE_U8:
     
    425434                break;
    426435            case PS_TYPE_F64:
     436            default:
    427437                vec->data.F64[i++] = (psF64)value;
    428438                break;
    429             default:
    430                 *status = 1;
    431                 psError(PS_ERR_BAD_PARAMETER_VALUE,true,
    432                         _("Specified type, %d, is not supported."),
    433                         elemType);
     439                /*                *status = 1;
     440                                psError(PS_ERR_BAD_PARAMETER_VALUE,true,
     441                                        _("Specified type, %d, is not supported."),
     442                                        elemType);
     443                                */
    434444            }
    435445            vec->n++;
     
    585595        // Create metadata item to represent token read
    586596        tempItem = psMetadataItemAllocStr(token,"","");
    587         if(tempItem == NULL) {
    588             psFree(metadataTemplate);
    589             psFree(token);
    590             metadataTemplate = NULL;
    591             break;
    592         }
    593 
    594         // Add item to template
    595         if(!psMetadataAddItem(metadataTemplate, tempItem, PS_LIST_TAIL, PS_META_DEFAULT)) {
    596             psFree(metadataTemplate);
    597             psFree(tempItem);
    598             psFree(token);
    599             metadataTemplate = NULL;
    600             break;
    601         }
     597        psMetadataAddItem(metadataTemplate, tempItem, PS_LIST_TAIL, PS_META_DEFAULT);
     598        /*        if(tempItem == NULL) {
     599                    psFree(metadataTemplate);
     600                    psFree(token);
     601                    metadataTemplate = NULL;
     602                    break;
     603                }
     604         
     605                // Add item to template
     606                if(!psMetadataAddItem(metadataTemplate, tempItem, PS_LIST_TAIL, PS_META_DEFAULT)) {
     607                    psFree(metadataTemplate);
     608                    psFree(tempItem);
     609                    psFree(token);
     610                    metadataTemplate = NULL;
     611                    break;
     612                }
     613        */
    602614        psFree(tempItem);
    603615        psFree(token);
     
    712724    // Check for no type
    713725    if(strType==NULL) {
    714         psError(PS_ERR_IO, true, _("Failed to read a metadata %s on line %u."), "type",lineCount);
     726        psError(PS_ERR_IO, true,
     727                _("Failed to read a metadata %s on line %u."), "type",lineCount);
    715728        returnValue = false;
    716729    } else {
     
    743756                vectorType = PS_TYPE_F64;
    744757            } else {
    745                 psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), "", keyName,
    746                         strType, lineCount);
     758                psError(PS_ERR_IO, true,
     759                        _("Failed to parse the value '%s' of metadata item %s, type %s, "
     760                          "on line %u."), "", keyName,  strType, lineCount);
    747761                psFree(strType);
    748762                return false;
     
    758772        } else if(!strncmp(strType, "S32", 3)) {
    759773            mdType = PS_DATA_S32;
     774        } else if(!strncmp(strType, "S64", 3)) {
     775            mdType = PS_DATA_S64;
    760776        } else if(!strncmp(strType, "U8", 2)) {
    761777            mdType = PS_DATA_U8;
     
    764780        } else if(!strncmp(strType, "U32", 3)) {
    765781            mdType = PS_DATA_U32;
     782        } else if(!strncmp(strType, "U64", 3)) {
     783            mdType = PS_DATA_U64;
    766784        } else if(!strncmp(strType, "F32", 3)) {
    767785            mdType = PS_DATA_F32;
     
    785803                        // Add metadata item
    786804                        md = ((p_psParseLevelInfo*)(levelArray->data[*level]))->metadata;
    787                         addStatus = psMetadataAdd(md,PS_LIST_TAIL,keyName,PS_DATA_METADATA | flags,"",tempMeta);
     805                        addStatus = psMetadataAdd(md,PS_LIST_TAIL,keyName,
     806                                                  PS_DATA_METADATA | flags,"",tempMeta);
    788807                        // Check for add failure
    789808                        if (! addStatus) {
    790                             psError(PS_ERR_IO, true, _("Duplicate Metadata item, %s, found on line %u.  Overwrite not allowed."),
     809                            psError(PS_ERR_IO, true,
     810                                    _("Duplicate Metadata item, %s, found on line %u.  "
     811                                      "Overwrite not allowed."),
    791812                                    keyName, lineCount);
    792813                            psFree(strType);
     
    797818                    } else {
    798819                        // Metadata type read error
    799                         psError(PS_ERR_IO,true,_("Failed to read a metadata %s on line %u."),
     820                        psError(PS_ERR_IO,true,
     821                                _("Failed to read a metadata %s on line %u."),
    800822                                keyName, lineCount);
    801823                        psFree(strType);
     
    807829            }
    808830            if(!typeFound) {
    809                 psError(PS_ERR_IO, true, _("Metadata type '%s', found on line %u, is invalid."),
     831                psError(PS_ERR_IO, true,
     832                        _("Metadata type '%s', found on line %u, is invalid."),
    810833                        strType, lineCount);
    811834                psFree(strType);
     
    824847        strValue = getToken(&linePtr, "#", &status,true);
    825848        if(status) {
    826             psError(PS_ERR_IO, true, _("Failed to read a metadata %s on line %u."), "value", lineCount);
     849            psError(PS_ERR_IO, true,
     850                    _("Failed to read a metadata %s on line %u."), "value", lineCount);
    827851            psFree(strType);
    828852            psFree(strValue);
     
    830854        }
    831855        if(strValue==NULL) {
    832             psError(PS_ERR_IO, true, _("Failed to read a metadata %s on line %u."), "value", lineCount);
     856            psError(PS_ERR_IO, true,
     857                    _("Failed to read a metadata %s on line %u."), "value", lineCount);
    833858            psFree(strType);
    834859            psFree(strValue);
     
    839864        strComment = getToken(&linePtr,"~", &status,true);
    840865        if(status) {
    841             psError(PS_ERR_IO, true, _("Failed to read a metadata %s on line %u."), "comment", lineCount);
     866            psError(PS_ERR_IO, true,
     867                    _("Failed to read a metadata %s on line %u."), "comment", lineCount);
    842868            psFree(strType);
    843869            psFree(strValue);
     
    863889                                      strComment, tempBool);
    864890        } else {
    865             psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName,
    866                     strType, lineCount);
     891            psError(PS_ERR_IO, true,
     892                    _("Failed to parse the value '%s' of metadata item %s, type %s, "
     893                      "on line %u."), strValue, keyName, strType, lineCount);
    867894            returnValue = false;
    868895        }
     
    877904        } else {
    878905            psError(PS_ERR_IO, true,
    879                     _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName, strType, lineCount);
     906                    _("Failed to parse the value '%s' of metadata item %s, type %s, "
     907                      "on line %u."), strValue, keyName, strType, lineCount);
    880908            returnValue = false;
    881909        }
     
    884912        tempInt = (psS8) parseSignedInt(strValue, &status);
    885913        if(!status) {
    886             addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempInt);
     914            addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags,
     915                                      strComment, tempInt);
    887916        } else {
    888             psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName,
    889                     strType, lineCount);
     917            psError(PS_ERR_IO, true,
     918                    _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."),
     919                    strValue, keyName, strType, lineCount);
    890920            returnValue = false;
    891921        }
     
    894924        tempInt = (psS16) parseSignedInt(strValue, &status);
    895925        if(!status) {
    896             addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempInt);
     926            addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags,
     927                                      strComment, tempInt);
    897928        } else {
    898             psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName,
    899                     strType, lineCount);
     929            psError(PS_ERR_IO, true,
     930                    _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."),
     931                    strValue, keyName, strType, lineCount);
    900932            returnValue = false;
    901933        }
     
    904936        tempInt = (psS32) parseSignedInt(strValue, &status);
    905937        if(!status) {
    906             addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempInt);
     938            addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags,
     939                                      strComment, tempInt);
    907940        } else {
    908             psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName,
    909                     strType, lineCount);
     941            psError(PS_ERR_IO, true,
     942                    _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."),
     943                    strValue, keyName, strType, lineCount);
    910944            returnValue = false;
    911945        }
     
    914948        tempUint = (psU8)parseUnsignedInt(strValue, &status);
    915949        if(!status) {
    916             addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempUint);
     950            addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags,
     951                                      strComment, tempUint);
    917952        } else {
    918             psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName,
    919                     strType, lineCount);
     953            psError(PS_ERR_IO, true,
     954                    _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."),
     955                    strValue, keyName, strType, lineCount);
    920956            returnValue = false;
    921957        }
     
    924960        tempUint = (psU16)parseUnsignedInt(strValue, &status);
    925961        if(!status) {
    926             addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempUint);
     962            addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags,
     963                                      strComment, tempUint);
    927964        } else {
    928             psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName,
    929                     strType, lineCount);
     965            psError(PS_ERR_IO, true,
     966                    _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."),
     967                    strValue, keyName, strType, lineCount);
    930968            returnValue = false;
    931969        }
     
    934972        tempUint = (psU32)parseUnsignedInt(strValue, &status);
    935973        if(!status) {
    936             addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags, strComment, tempUint);
     974            addStatus = psMetadataAdd(md, PS_LIST_TAIL, keyName, mdType | flags,
     975                                      strComment, tempUint);
    937976        } else {
    938             psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName,
    939                     strType, lineCount);
     977            psError(PS_ERR_IO, true,
     978                    _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."),
     979                    strValue, keyName, strType, lineCount);
    940980            returnValue = false;
    941981        }
     
    958998                                      strComment, mTime);
    959999        } else {
    960             psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName,
    961                     strType, lineCount);
     1000            psError(PS_ERR_IO, true,
     1001                    _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."),
     1002                    strValue, keyName, strType, lineCount);
    9621003            returnValue = false;
    9631004        }
     
    9711012                                      strComment, tempVec);
    9721013        } else {
    973             psError(PS_ERR_IO, true, _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."), strValue, keyName,
    974                     strType, lineCount);
     1014            psError(PS_ERR_IO, true,
     1015                    _("Failed to parse the value '%s' of metadata item %s, type %s, on line %u."),
     1016                    strValue, keyName, strType, lineCount);
    9751017            returnValue = false;
    9761018        }
     
    10091051        break;
    10101052    default:
    1011         psError(PS_ERR_IO,true,_("Metadata of unknown type found on line %u."),
    1012                 lineCount);
     1053        psError(PS_ERR_IO, true,
     1054                _("Metadata of unknown type found on line %u."), lineCount);
    10131055        break;
    10141056    }
     
    10561098        if(repeatedChars(linePtr, '@') > 1) {
    10571099            psError(PS_ERR_IO, true,
    1058                     _("More than one '%c' character not allowed.  Found on line %u."), '@', lineCount);
     1100                    _("More than one '%c' character not allowed.  Found on line %u."),
     1101                    '@', lineCount);
    10591102            return false;
    10601103        }
     
    10741117            strType = getToken(&linePtr," ",&status,true);
    10751118            if(strType == NULL) {
    1076                 psError(PS_ERR_IO,true,_("Failed to read a metadata %s on line %u."),"type",lineCount);
     1119                psError(PS_ERR_IO,true,
     1120                        _("Failed to read a metadata %s on line %u."), "type", lineCount);
    10771121                psFree(keyName);
    10781122                return false;
     
    10871131                    // Compare type name with the list of current types
    10881132                    if(strcmp(strType,(char*)typeArray->data[k]) == 0) {
    1089                         psError(PS_ERR_IO,true,_("Specified type, %s, on line %u is already defined."),
     1133                        psError(PS_ERR_IO,true,
     1134                                _("Specified type, %s, on line %u is already defined."),
    10901135                                strType,lineCount);
    10911136                        psFree(tempTemplate);
     
    11021147                psFree(tempTemplate);
    11031148            } else {
    1104                 psError(PS_ERR_IO,true,_("Metadata type '%s', found on line %u, is invalid."),
     1149                psError(PS_ERR_IO,true,
     1150                        _("Metadata type '%s', found on line %u, is invalid."),
    11051151                        strType,lineCount);
    11061152                psFree(keyName);
     
    14501496            }
    14511497            psString timeStr = psTimeToISO(time);
    1452             psStringAppend(&content, "%-15s", timeStr);
     1498            psString timeOutput;
     1499            timeOutput = psStringNCopy(timeStr, 19);
     1500            psStringAppend(&content, "%s", timeOutput);
     1501            psStringAppend(&content, "Z");
    14531502            psFree(timeStr);
     1503            psFree(timeOutput);
    14541504        } else {
    14551505            // psTime is a NULL pointer
     
    15241574            psStringAppend(&content, "F64 ");
    15251575            for (int i = 0; i < vector->n; i++) {
    1526                 psStringAppend(&content, "%.15g", vector->data.F64[i]);
     1576                psStringAppend(&content, "%.15g ", vector->data.F64[i]);
    15271577            }
    15281578            break;
Note: See TracChangeset for help on using the changeset viewer.