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
2321de43
Commit
2321de43
authored
Feb 22, 2018
by
Uwe Schulzweida
Browse files
Added function cdiDefKeyString().
parent
8ae3f448
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cdi_key.c
View file @
2321de43
...
...
@@ -9,7 +9,7 @@
#include "zaxis.h"
#include "resource_unpack.h"
enum
{
KEY_INT
,
KEY_FLOAT
,
KEY_BYTES
};
enum
{
KEY_INT
,
KEY_FLOAT
,
KEY_BYTES
,
KEY_STRING
};
static
cdi_keys_t
*
get_keysp
(
vlist_t
*
vlistptr
,
int
varID
)
...
...
@@ -134,6 +134,25 @@ int cdiDelKeys(int cdiID, int varID)
return
status
;
}
// cdiInqKeyLen: Get the length of the string representation of the key
int
cdiInqKeyLen
(
int
cdiID
,
int
varID
,
int
key
,
int
*
length
)
{
int
status
=
-
1
;
cdi_keys_t
*
keysp
=
cdi_get_keysp
(
cdiID
,
varID
);
xassert
(
keysp
!=
NULL
);
cdi_key_t
*
keyp
=
find_key
(
keysp
,
key
);
if
(
keyp
!=
NULL
)
{
*
length
=
keyp
->
length
;
if
(
*
length
==
0
)
*
length
=
1
;
status
=
CDI_NOERR
;
}
return
status
;
}
int
cdiCopyKeys
(
int
cdiID1
,
int
varID1
,
int
cdiID2
,
int
varID2
)
{
...
...
@@ -223,31 +242,36 @@ int cdiDefKeyBytes(int cdiID, int varID, int key, unsigned char *bytes, int leng
return
status
;
}
// cdiInqKey
Len
: Get
the length of the string representation of the key
int
cdiInqKey
Len
(
int
cdiID
,
int
varID
,
int
key
,
int
*
length
)
// cdiInqKey
Bytes
: Get
a bytes array from a key of a CDI variable
int
cdiInqKey
Bytes
(
int
cdiID
,
int
varID
,
int
key
,
unsigned
char
*
bytes
,
int
*
length
)
{
int
status
=
-
1
;
return
status
;
}
// cdiDefKeyString: Define a string value from a key of a CDI variable
int
cdiDefKeyString
(
int
cdiID
,
int
varID
,
int
key
,
unsigned
char
*
bytes
,
int
length
)
{
int
status
=
CDI_NOERR
;
cdi_keys_t
*
keysp
=
cdi_get_keysp
(
cdiID
,
varID
);
xassert
(
keysp
!=
NULL
);
cdi_key_t
*
keyp
=
find_key
(
keysp
,
key
);
if
(
keyp
==
NULL
)
keyp
=
new_key
(
keysp
,
key
);
if
(
keyp
!=
NULL
)
{
*
length
=
keyp
->
length
;
status
=
CDI_NOERR
;
if
(
keyp
->
length
!=
0
&&
keyp
->
length
!=
length
)
free
(
keyp
->
v
.
s
);
keyp
->
length
=
length
;
keyp
->
v
.
s
=
(
unsigned
char
*
)
malloc
(
length
+
1
);
memcpy
(
keyp
->
v
.
s
,
bytes
,
length
+
1
);
keyp
->
type
=
KEY_STRING
;
}
return
status
;
}
// cdiInqKeyBytes: Get a bytes array from a key of a CDI variable
int
cdiInqKeyBytes
(
int
cdiID
,
int
varID
,
int
key
,
unsigned
char
*
bytes
,
int
*
length
)
{
int
status
=
-
1
;
return
status
;
}
/*
* Local Variables:
* c-file-style: "Java"
...
...
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