diff --git a/das2/http.c b/das2/http.c index 9a555c7..00bb8aa 100644 --- a/das2/http.c +++ b/das2/http.c @@ -88,6 +88,9 @@ char html5[256] = { #define HTTP_NotFound 404 #define HTTP_Error 500 +#define _QDEF(x) #x +#define QDEF(x) _QDEF(x) + /* ************************************************************************* */ /* The global SSL context and mutexes for manipulating it. We use lazy * initialization of SSL so that programs that don't need it don't have to @@ -1047,8 +1050,8 @@ bool das_http_getBody( DasHttpResp_clear(pRes); /* Sets nSockFd to -1 */ - if(strlen(sUrl) > 511){ - pRes->sError = das_string("URL is greater than 511 bytes"); + if(strlen(sUrl) > DASURL_SZ_QUERY){ + pRes->sError = das_string("URL is greater than " QDEF(DASURL_SZ_QUERY) " bytes"); return false; } diff --git a/das2/http.h b/das2/http.h index a031c7d..c983962 100644 --- a/das2/http.h +++ b/das2/http.h @@ -36,7 +36,7 @@ extern "C" { #define DASURL_SZ_SCHEME 31 #define DASURL_SZ_HOST 63 #define DASURL_SZ_PATH 127 -#define DASURL_SZ_QUERY 511 +#define DASURL_SZ_QUERY 1023 #define DASURL_SZ_DATASET 63 #define DASURL_SZ_PORT 7 diff --git a/das2/property.c b/das2/property.c index 1950961..46e7448 100644 --- a/das2/property.c +++ b/das2/property.c @@ -462,6 +462,8 @@ int DasProp_convertReal(const DasProp* pProp, double* pBuf, size_t uBufLen) return -1 * das_error(DASERR_PROP, "Error converting '%s' to a double", DasProp_value(pProp) ); + if(DasProp_items(pProp) > 1) + return -1 * das_error(DASERR_NOTIMP, "Add array property handling before v3.0 release"); return 1; } @@ -477,7 +479,17 @@ int DasProp_convertBool(const DasProp* pProp, uint8_t* pBuf, size_t uBufLen) /** Convert datatime properties TT2K long integers */ int DasProp_convertTt2k(const DasProp* pProp, int64_t* pBuf, size_t uBufLen) { - return -1 * das_error(DASERR_NOTIMP, "Tt2k property conversion not yet implemented"); + const char* sValue = DasProp_value(pProp); + das_time dt; + if(!dt_parsetime(sValue, &dt)) + return -1 * das_error(DASERR_TIME, "Could not convert %s to a datetime", sValue); + + *pBuf = dt_to_tt2k(&dt); + + if(DasProp_items(pProp) > 1) + return -1 * das_error(DASERR_NOTIMP, "Add array property handling before v3.0 release"); + + return 1; } /** Convert datatime properties to a double based value of units */ diff --git a/utilities/das3_cdf.c b/utilities/das3_cdf.c index 6ca8351..80cdcf6 100644 --- a/utilities/das3_cdf.c +++ b/utilities/das3_cdf.c @@ -136,19 +136,19 @@ void prnHelp() " During the metadata mapping, common das3 property names are converted\n" " to equivalent ISTP metadata names. The property conversions are:\n" "\n" -" description -> CATDESC\n" -" format -> FORMAT\n" -" info -> VAR_NOTES\n" " label -> LABLAXIS (with units stripped)\n" +" title,description -> FIELDNAM\n" +" summary -> CATDESC\n" +" notes -> VAR_NOTES\n" +" format -> FORMAT\n" " nominalMin,nominalMax -> LIMITS_NOMINAL_MIN,LIMITS_NOMINAL_MAX\n" " scaleMin,scaleMax -> SCALEMIN,SCALEMAX\n" " scaleType -> SCALETYP\n" -" summary -> VAR_NOTES\n" -" title -> FIELDNAM\n" " validMin,validMax -> VALIDMIN,VALIDMAX\n" " warnMin,warnMax -> LIMITS_WARN_MIN,LIMITS_WARN_MAX\n" +" compLabel -> LABL_PTR_1\n" "\n" -" Note that if a property is named 'CDF_NAME' it is not written to the CDF\n" +" Note that if a property is named 'cdfName' it is not written to the CDF\n" " but instead changes the name of a CDF variable.\n" "\n" " Other CDF attributes are also set based on the data structure type. Some\n" @@ -157,6 +157,7 @@ void prnHelp() " DasVar.units -> UNITS\n" " DasAry.fill -> FILLVAL\n" " (algorithm) -> DEPEND_N\n" +" DasFrame.dir -> LABL_PTR_1 (if compLabel missing)\n" "\n" " Note that if the input is a legacy das2 stream, it is upgraded internally\n" " to a das3 stream priror to writing the CDF file.\n" @@ -466,23 +467,31 @@ const char* DasProp_cdfVarName(const DasProp* pProp) { /* Translate some of the common das property names to CDF names */ const char* sName = DasProp_name(pProp); - if(strcmp(sName, "description") == 0) return "CATDESC"; + + if(strcmp(sName, "label" ) == 0) return "LABLAXIS"; + if(strcmp(sName, "description") == 0) return "FIELDNAM"; /* Common das2 property */ + if(strcmp(sName, "title" ) == 0) return "FIELDNAM"; + if(strcmp(sName, "summary" ) == 0) return "CATDESC"; + if(strcmp(sName, "info" ) == 0) return "VAR_NOTES"; + if(strcmp(sName, "notes" ) == 0) return "VAR_NOTES"; + if(strcmp(sName, "fill" ) == 0) return "FILLVAL"; if(strcmp(sName, "format" ) == 0) return "FORMAT"; if(strcmp(sName, "info" ) == 0) return "VAR_NOTES"; - if(strcmp(sName, "label" ) == 0) return "LABLAXIS"; + if(strcmp(sName, "nominalMin" ) == 0) return "LIMITS_NOMINAL_MIN"; if(strcmp(sName, "nominalMax" ) == 0) return "LIMITS_NOMINAL_MAX"; if(strcmp(sName, "scaleMin" ) == 0) return "SCALEMIN"; if(strcmp(sName, "scaleMax" ) == 0) return "SCALEMAX"; if(strcmp(sName, "scaleType" ) == 0) return "SCALETYP"; - if(strcmp(sName, "summary" ) == 0) return "VAR_NOTES"; - if(strcmp(sName, "title" ) == 0) return "FIELDNAM"; + if(strcmp(sName, "validMin" ) == 0) return "VALIDMIN"; if(strcmp(sName, "validMax" ) == 0) return "VALIDMAX"; if(strcmp(sName, "warnMin" ) == 0) return "LIMITS_WARN_MIN"; if(strcmp(sName, "warnMax" ) == 0) return "LIMITS_WARN_M"; + if(strcmp(sName, "compLabel") == 0) return NULL; /* Eat some properties */ + return sName; } @@ -630,20 +639,21 @@ long DasProp_cdfEntLen(const DasProp* pProp, long iEntry) return 0; } +/* Function is NOT MULTI-THREAD SAFE (not that we care here) */ void* DasProp_cdfValues(const DasProp* pProp){ + size_t uBufLen = 0; + const char* sValue = NULL; + + ubyte uType = (DasProp_type(pProp) & DASPROP_TYPE_MASK); + + switch(uType){ + /* For strings this is easy, others have to be parsed */ - if(DasProp_type(pProp) & DASPROP_STRING){ - const char* sValue = DasProp_value(pProp); + case DASPROP_STRING: + sValue = DasProp_value(pProp); if((sValue == NULL)||(sValue[0] == '\0')) sValue = " "; return (void*) sValue; - } - - size_t uBufLen = 0; - - ubyte uType = DasProp_type(pProp); - - switch(uType & DASPROP_TYPE_MASK){ /* Properties don't have fill, so an unsigned byte works */ case DASPROP_BOOL: @@ -789,6 +799,11 @@ DasErrCode writeVarProp(struct context* pCtx, long iVarNum, const DasProp* pProp CDFstatus iStatus; /* Used by CDF_MAD macro */ const char* sName = DasProp_cdfVarName(pProp); + + /* If return null, the cdfVarName ate the property */ + if(sName == NULL) + return DAS_OKAY; + long iAttr = CDFattrId(pCtx->nCdfId, sName); long nScope = 0L; /* from cdf.h, this is NO_SCOPE */ if(iAttr >= 0){