Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
b828f4ac
Commit
b828f4ac
authored
Feb 26, 2020
by
Uwe Schulzweida
Browse files
Added function cdiInqAttType() and cdiDelAtt().
parent
3169db42
Changes
3
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
b828f4ac
2020-02-26 Uwe Schulzweida
* Added function cdiInqAttType() and cdiDelAtt()
2020-02-25 Uwe Schulzweida
* Added function cdiInqAttLen()
...
...
src/cdi.h
View file @
b828f4ac
...
...
@@ -684,6 +684,7 @@ int cdiInqNatts(int cdiID, int varID, int *nattsp);
// cdiInqAtt: Get information about an attribute
int
cdiInqAtt
(
int
cdiID
,
int
varID
,
int
attrnum
,
char
*
name
,
int
*
typep
,
int
*
lenp
);
int
cdiInqAttLen
(
int
cdiID
,
int
varID
,
const
char
*
name
);
int
cdiInqAttType
(
int
cdiID
,
int
varID
,
const
char
*
name
);
int
cdiDelAtt
(
int
cdiID
,
int
varID
,
const
char
*
name
);
int
cdiCopyAtts
(
int
cdiID1
,
int
varID1
,
int
cdiID2
,
int
varID2
);
...
...
src/cdi_att.c
View file @
b828f4ac
...
...
@@ -169,7 +169,7 @@ int cdiInqAtt(int cdiID, int varID, int attnum, char *name, int *typep, int *len
if
(
attnum
>=
0
&&
attnum
<
(
int
)
attsp
->
nelems
)
attp
=
&
(
attsp
->
value
[
attnum
]);
if
(
attp
!=
NULL
)
/* name in use */
if
(
attp
!=
NULL
&&
attp
->
name
)
/* name in use */
{
memcpy
(
name
,
attp
->
name
,
attp
->
namesz
+
1
);
*
typep
=
attp
->
exdtype
;
...
...
@@ -199,13 +199,32 @@ int cdiInqAttLen(int cdiID, int varID, const char *name)
for
(
int
attid
=
0
;
attid
<
(
int
)
attsp
->
nelems
;
attid
++
)
{
cdi_att_t
*
attp
=
&
(
attsp
->
value
[
attid
]);
if
(
strcmp
(
attp
->
name
,
name
)
==
0
)
length
=
(
int
)
attp
->
nelems
;
if
(
attp
->
name
&&
strcmp
(
attp
->
name
,
name
)
==
0
)
length
=
(
int
)
attp
->
nelems
;
}
return
length
;
}
int
cdiInqAttType
(
int
cdiID
,
int
varID
,
const
char
*
name
)
{
int
type
=
-
1
;
xassert
(
name
!=
NULL
);
cdi_atts_t
*
attsp
=
cdi_get_attsp
(
cdiID
,
varID
);
xassert
(
attsp
!=
NULL
);
for
(
int
attid
=
0
;
attid
<
(
int
)
attsp
->
nelems
;
attid
++
)
{
cdi_att_t
*
attp
=
&
(
attsp
->
value
[
attid
]);
if
(
attp
->
name
&&
strcmp
(
attp
->
name
,
name
)
==
0
)
type
=
attp
->
exdtype
;
}
return
type
;
}
int
cdiDeleteAtts
(
int
cdiID
,
int
varID
)
{
int
status
=
CDI_NOERR
;
...
...
@@ -216,7 +235,12 @@ int cdiDeleteAtts(int cdiID, int varID)
for
(
int
attid
=
0
;
attid
<
(
int
)
attsp
->
nelems
;
attid
++
)
{
cdi_att_t
*
attp
=
&
(
attsp
->
value
[
attid
]);
if
(
attp
->
name
)
Free
(
attp
->
name
);
if
(
attp
->
name
)
{
Free
(
attp
->
name
);
attp
->
name
=
NULL
;
attp
->
namesz
=
0
;
}
if
(
attp
->
xvalue
)
Free
(
attp
->
xvalue
);
}
...
...
@@ -230,11 +254,24 @@ int cdiDelAtt(int cdiID, int varID, const char *name)
{
int
status
=
CDI_NOERR
;
UNUSED
(
cdiID
);
UNUSED
(
varID
);
UNUSED
(
name
);
cdi_atts_t
*
attsp
=
cdi_get_attsp
(
cdiID
,
varID
);
xassert
(
attsp
!=
NULL
);
fprintf
(
stderr
,
"cdiDelAtt not implemented!
\n
"
);
for
(
int
attid
=
0
;
attid
<
(
int
)
attsp
->
nelems
;
attid
++
)
{
cdi_att_t
*
attp
=
&
(
attsp
->
value
[
attid
]);
if
(
attp
->
name
&&
strcmp
(
attp
->
name
,
name
)
==
0
)
{
Free
(
attp
->
name
);
attp
->
name
=
NULL
;
attp
->
namesz
=
0
;
if
(
attp
->
xvalue
)
{
Free
(
attp
->
xvalue
);
attp
->
xvalue
=
NULL
;
}
}
}
return
status
;
}
...
...
@@ -466,8 +503,7 @@ int cdiAttTypeLookup(cdi_att_t *attp)
type
=
attp
->
indtype
;
break
;
default:
xabort
(
"Unknown datatype encountered in attribute %s: %d
\n
"
,
attp
->
name
,
attp
->
indtype
);
xabort
(
"Unknown datatype encountered in attribute %s: %d
\n
"
,
attp
->
name
,
attp
->
indtype
);
}
return
type
;
}
...
...
@@ -481,7 +517,7 @@ int cdi_att_compare(cdi_atts_t *attspa, cdi_atts_t *attspb, int attnum)
if
(
attpa
->
namesz
!=
attpb
->
namesz
)
return
1
;
if
(
memcmp
(
attpa
->
name
,
attpb
->
name
,
attpa
->
namesz
))
return
1
;
if
(
attpa
->
name
&&
attpb
->
name
&&
memcmp
(
attpa
->
name
,
attpb
->
name
,
attpa
->
namesz
))
return
1
;
if
(
attpa
->
indtype
!=
attpb
->
indtype
||
attpa
->
exdtype
!=
attpb
->
exdtype
...
...
@@ -524,12 +560,11 @@ void cdiAttPack(vlist_t *vlistptr, int varID, int attnum,
void
*
buf
,
int
size
,
int
*
position
,
void
*
context
)
{
cdi_atts_t
*
attsp
;
cdi_att_t
*
attp
;
int
tempbuf
[
cdi_att_nints
];
xassert
(
attsp
=
get_attsp
(
vlistptr
,
varID
));
xassert
(
attnum
>=
0
&&
attnum
<
(
int
)
attsp
->
nelems
);
attp
=
&
(
attsp
->
value
[
attnum
]);
cdi_att_t
*
attp
=
&
(
attsp
->
value
[
attnum
]);
tempbuf
[
0
]
=
(
int
)
attp
->
namesz
;
tempbuf
[
1
]
=
attp
->
exdtype
;
tempbuf
[
2
]
=
attp
->
indtype
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment