libnczarr/zattr.c
int
ncz_get_att_special(NC_FILE_INFO_T* h5, NC_VAR_INFO_T* var, const char* name,
                    nc_type* filetypep, nc_type mem_type, size_t* lenp,
                    int* attnump, void* data)
{
    int stat = NC_NOERR;
    
    /* Fail if asking for att id */
    if(attnump)
        {stat = NC_EATTMETA; goto done;}

    /* Handle the per-var case(s) first */
    if(var != NULL) {
        if(strcmp(name,NC_ATT_CODECS)==0) {	
            NClist* filters = (NClist*)var->filters;

            if(mem_type == NC_NAT) mem_type = NC_CHAR;
            if(mem_type != NC_CHAR)
                {stat = NC_ECHAR; goto done;}
            if(filetypep) *filetypep = NC_CHAR;
	    if(lenp) *lenp = 0;
	    if(filters == NULL) goto done;	  
 	    if((stat = NCZ_codec_attr(var,lenp,data))) goto done;
	}
	goto done;
    }

    /* The global reserved attributes */
    if(strcmp(name,NCPROPS)==0) {
        int len;
        if(h5->provenance.ncproperties == NULL)
            {stat = NC_ENOTATT; goto done;}
        if(mem_type == NC_NAT) mem_type = NC_CHAR;
        if(mem_type != NC_CHAR)
            {stat = NC_ECHAR; goto done;}
        if(filetypep) *filetypep = NC_CHAR;
	len = strlen(h5->provenance.ncproperties);
        if(lenp) *lenp = len;
        if(data) strncpy((char*)data,h5->provenance.ncproperties,len+1);
    } else if(strcmp(name,ISNETCDF4ATT)==0
              || strcmp(name,SUPERBLOCKATT)==0) {
        unsigned long long iv = 0;
        if(filetypep) *filetypep = NC_INT;
        if(lenp) *lenp = 1;
        if(strcmp(name,SUPERBLOCKATT)==0)
            iv = (unsigned long long)h5->provenance.superblockversion;
        else /* strcmp(name,ISNETCDF4ATT)==0 */
            iv = NCZ_isnetcdf4(h5);
        if(mem_type == NC_NAT) mem_type = NC_INT;
        if(data)
            switch (mem_type) {
            case NC_BYTE: *((char*)data) = (char)iv; break;
            case NC_SHORT: *((short*)data) = (short)iv; break;
            case NC_INT: *((int*)data) = (int)iv; break;
            case NC_UBYTE: *((unsigned char*)data) = (unsigned char)iv; break;
            case NC_USHORT: *((unsigned short*)data) = (unsigned short)iv; break;
            case NC_UINT: *((unsigned int*)data) = (unsigned int)iv; break;
            case NC_INT64: *((long long*)data) = (long long)iv; break;
            case NC_UINT64: *((unsigned long long*)data) = (unsigned long long)iv; break;
            default:
                {stat = NC_ERANGE; goto done;}
            }
    }
done:
    return stat;

}
/**
 * @internal Get one of three special attributes, NCPROPS,
 * ISNETCDF4ATT, and SUPERBLOCKATT. These atts are not all really in
 * the file, they are constructed on the fly.
 *
 * @param h5 Pointer to ZARR file info struct.
 * @param var Pointer to var info struct; NULL signals global.
 * @param name Name of attribute.
 * @param filetypep Pointer that gets type of the attribute data in
 * file.
 * @param mem_type Type of attribute data in memory.
 * @param lenp Pointer that gets length of attribute array.
 * @param attnump Pointer that gets the attribute number.
 * @param data Attribute data.
 *
 * @return ::NC_NOERR No error.
 * @return ::NC_EBADID Bad ncid.
 * @return ::NC_ERANGE Data conversion out of range.
 * @author Dennis Heimbigner
 */
@internal Get one of three special attributes, NCPROPS,
ISNETCDF4ATT, and SUPERBLOCKATT. These atts are not all really in
the file, they are constructed on the fly.

@param h5 Pointer to ZARR file info struct.
@param var Pointer to var info struct; NULL signals global.
@param name Name of attribute.
@param filetypep Pointer that gets type of the attribute data in
file.
@param mem_type Type of attribute data in memory.
@param lenp Pointer that gets length of attribute array.
@param attnump Pointer that gets the attribute number.
@param data Attribute data.

@return ::NC_NOERR No error.
@return ::NC_EBADID Bad ncid.
@return ::NC_ERANGE Data conversion out of range.
@author Dennis Heimbigner
@internal Get one of three special attributes NCPROPS ISNETCDF4ATT and SUPERBLOCKATT . These atts are not all really in the file they are constructed on the fly . @param h5 Pointer to ZARR file info struct . @param var Pointer to var info struct ; NULL signals global . @param name Name of attribute . @param filetypep Pointer that gets type of the attribute data in file . @param mem_type Type of attribute data in memory . @param lenp Pointer that gets length of attribute array . @param attnump Pointer that gets the attribute number . @param data Attribute data . @return :: NC_NOERR No error . @return :: NC_EBADID Bad ncid . @return :: NC_ERANGE Data conversion out of range . @author Dennis Heimbigner
int
ncz_get_att_special(NC_FILE_INFO_T* h5, NC_VAR_INFO_T* var, const char* name,
                    nc_type* filetypep, nc_type mem_type, size_t* lenp,
                    int* attnump, void* data)
{
    int stat = NC_NOERR;
    if(attnump)
        {stat = NC_EATTMETA; goto done;}
    if(var != NULL) {
        if(strcmp(name,NC_ATT_CODECS)==0) {	
            NClist* filters = (NClist*)var->filters;
            if(mem_type == NC_NAT) mem_type = NC_CHAR;
            if(mem_type != NC_CHAR)
                {stat = NC_ECHAR; goto done;}
            if(filetypep) *filetypep = NC_CHAR;
	    if(lenp) *lenp = 0;
	    if(filters == NULL) goto done;	  
 	    if((stat = NCZ_codec_attr(var,lenp,data))) goto done;
	}
	goto done;
    }
    if(strcmp(name,NCPROPS)==0) {
        int len;
        if(h5->provenance.ncproperties == NULL)
            {stat = NC_ENOTATT; goto done;}
        if(mem_type == NC_NAT) mem_type = NC_CHAR;
        if(mem_type != NC_CHAR)
            {stat = NC_ECHAR; goto done;}
        if(filetypep) *filetypep = NC_CHAR;
	len = strlen(h5->provenance.ncproperties);
        if(lenp) *lenp = len;
        if(data) strncpy((char*)data,h5->provenance.ncproperties,len+1);
    } else if(strcmp(name,ISNETCDF4ATT)==0
              || strcmp(name,SUPERBLOCKATT)==0) {
        unsigned long long iv = 0;
        if(filetypep) *filetypep = NC_INT;
        if(lenp) *lenp = 1;
        if(strcmp(name,SUPERBLOCKATT)==0)
            iv = (unsigned long long)h5->provenance.superblockversion;
        else 
            iv = NCZ_isnetcdf4(h5);
        if(mem_type == NC_NAT) mem_type = NC_INT;
        if(data)
            switch (mem_type) {
            case NC_BYTE: *((char*)data) = (char)iv; break;
            case NC_SHORT: *((short*)data) = (short)iv; break;
            case NC_INT: *((int*)data) = (int)iv; break;
            case NC_UBYTE: *((unsigned char*)data) = (unsigned char)iv; break;
            case NC_USHORT: *((unsigned short*)data) = (unsigned short)iv; break;
            case NC_UINT: *((unsigned int*)data) = (unsigned int)iv; break;
            case NC_INT64: *((long long*)data) = (long long)iv; break;
            case NC_UINT64: *((unsigned long long*)data) = (unsigned long long)iv; break;
            default:
                {stat = NC_ERANGE; goto done;}
            }
    }
done:
    return stat;
}
int ncz_get_att_special ( NC_FILE_INFO_T * h5 , NC_VAR_INFO_T * var , const char * name , nc_type * filetypep , nc_type mem_type , size_t * lenp , int * attnump , void * data ) { int stat = NC_NOERR ; if ( attnump ) { stat = NC_EATTMETA ; goto done ; } if ( var != NULL ) { if ( strcmp ( name , NC_ATT_CODECS ) == 0 ) { NClist * filters = ( NClist * ) var -> filters ; if ( mem_type == NC_NAT ) mem_type = NC_CHAR ; if ( mem_type != NC_CHAR ) { stat = NC_ECHAR ; goto done ; } if ( filetypep ) * filetypep = NC_CHAR ; if ( lenp ) * lenp = 0 ; if ( filters == NULL ) goto done ; if ( ( stat = NCZ_codec_attr ( var , lenp , data ) ) ) goto done ; } goto done ; } if ( strcmp ( name , NCPROPS ) == 0 ) { int len ; if ( h5 -> provenance . ncproperties == NULL ) { stat = NC_ENOTATT ; goto done ; } if ( mem_type == NC_NAT ) mem_type = NC_CHAR ; if ( mem_type != NC_CHAR ) { stat = NC_ECHAR ; goto done ; } if ( filetypep ) * filetypep = NC_CHAR ; len = strlen ( h5 -> provenance . ncproperties ) ; if ( lenp ) * lenp = len ; if ( data ) strncpy ( ( char * ) data , h5 -> provenance . ncproperties , len + 1 ) ; } else if ( strcmp ( name , ISNETCDF4ATT ) == 0 || strcmp ( name , SUPERBLOCKATT ) == 0 ) { unsigned long long iv = 0 ; if ( filetypep ) * filetypep = NC_INT ; if ( lenp ) * lenp = 1 ; if ( strcmp ( name , SUPERBLOCKATT ) == 0 ) iv = ( unsigned long long ) h5 -> provenance . superblockversion ; else iv = NCZ_isnetcdf4 ( h5 ) ; if ( mem_type == NC_NAT ) mem_type = NC_INT ; if ( data ) switch ( mem_type ) { case NC_BYTE : * ( ( char * ) data ) = ( char ) iv ; break ; case NC_SHORT : * ( ( short * ) data ) = ( short ) iv ; break ; case NC_INT : * ( ( int * ) data ) = ( int ) iv ; break ; case NC_UBYTE : * ( ( unsigned char * ) data ) = ( unsigned char ) iv ; break ; case NC_USHORT : * ( ( unsigned short * ) data ) = ( unsigned short ) iv ; break ; case NC_UINT : * ( ( unsigned int * ) data ) = ( unsigned int ) iv ; break ; case NC_INT64 : * ( ( long long * ) data ) = ( long long ) iv ; break ; case NC_UINT64 : * ( ( unsigned long long * ) data ) = ( unsigned long long ) iv ; break ; default : { stat = NC_ERANGE ; goto done ; } } } done : return stat ; }
@internal Get one of three special attributes, NCPROPS,
 ISNETCDF4ATT, and SUPERBLOCKATT.
@internal Get one of three special attributes NCPROPS ISNETCDF4ATT and SUPERBLOCKATT .
/* Fail if asking for att id */ /* Handle the per-var case(s) first */ /* The global reserved attributes */ /* strcmp(name,ISNETCDF4ATT)==0 */