Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
e2c88cd2
Commit
e2c88cd2
authored
Mar 03, 2016
by
Uwe Schulzweida
Browse files
added function cdiZaxisInqString() and cdiZaxisDefString()
parent
1778bb43
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/cdi.h
View file @
e2c88cd2
...
...
@@ -979,6 +979,19 @@ void zaxisDefUUID(int zaxisID, const unsigned char uuid[CDI_UUID_SIZE]);
/* zaxisInqUUID: Get the UUID of a generalized Z-axis */
void
zaxisInqUUID
(
int
zaxisID
,
unsigned
char
uuid
[
CDI_UUID_SIZE
]);
/* CDI zaxis string key values */
#define CDI_ZAXIS_NAME 801 // Z-axis name
#define CDI_ZAXIS_DIMNAME 802 // Z-axis dimension name
#define CDI_ZAXIS_VDIMNAME 803 // Vertex dimension name
#define CDI_ZAXIS_LONGNAME 804 // Z-axis longname
#define CDI_ZAXIS_UNITS 805 // Z-axis units
// cdiZaxisDefString: Define a CDI Z-axis string value from a key
int
cdiZaxisDefString
(
int
zaxisID
,
int
key
,
int
size
,
const
char
*
mesg
);
// cdiZaxisInqString: Get a CDI Z-axis string value from a key
int
cdiZaxisInqString
(
int
zaxisID
,
int
key
,
int
size
,
char
*
mesg
);
/* zaxisDefName: Define the name of a Z-axis */
void
zaxisDefName
(
int
zaxisID
,
const
char
*
name_optional
);
...
...
src/mo_cdi.f90
View file @
e2c88cd2
...
...
@@ -539,6 +539,13 @@ module mo_cdi
public
::
zaxisInqNumber
public
::
zaxisDefUUID
public
::
zaxisInqUUID
integer
(
c_int
),
public
,
parameter
::
CDI_ZAXIS_NAME
=
801
integer
(
c_int
),
public
,
parameter
::
CDI_ZAXIS_DIMNAME
=
802
integer
(
c_int
),
public
,
parameter
::
CDI_ZAXIS_VDIMNAME
=
803
integer
(
c_int
),
public
,
parameter
::
CDI_ZAXIS_LONGNAME
=
804
integer
(
c_int
),
public
,
parameter
::
CDI_ZAXIS_UNITS
=
805
public
::
cdiZaxisDefString
public
::
cdiZaxisInqString
public
::
zaxisDefName
public
::
zaxisInqName
public
::
zaxisDefLongname
...
...
@@ -5431,6 +5438,73 @@ contains
end
do
end
subroutine
zaxisName
function
cdiZaxisDefString
(
zaxisID_dummy
,
key_dummy
,
size_dummy
,
mesg_dummy
)&
&
result
(
f_result
)
integer
(
c_int
)
::
f_result
integer
(
c_int
),
value
::
zaxisID_dummy
integer
(
c_int
),
value
::
key_dummy
integer
(
c_int
),
value
::
size_dummy
character
(
kind
=
c_char
,
len
=
*
),
intent
(
in
)
::
mesg_dummy
character
(
kind
=
c_char
)
::
mesg_temp
(
len
(
mesg_dummy
)
+
1
)
integer
::
mesg_i
interface
function
lib_cdiZaxisDefString
(
zaxisID_dummy
,
key_dummy
,
size_dummy
,&
&
mesg_dummy
)
bind
(
c
,
name
=
'cdiZaxisDefString'
)
result
(
c_result
)
import
c_char
,
c_int
integer
(
c_int
)
::
c_result
integer
(
c_int
),
value
::
zaxisID_dummy
integer
(
c_int
),
value
::
key_dummy
integer
(
c_int
),
value
::
size_dummy
character
(
kind
=
c_char
)
::
mesg_dummy
(
*
)
end
function
lib_cdiZaxisDefString
end
interface
do
mesg_i
=
1
,
len
(
mesg_dummy
)
mesg_temp
(
mesg_i
)
=
mesg_dummy
(
mesg_i
:
mesg_i
)
end
do
mesg_temp
(
len
(
mesg_dummy
)
+
1
)
=
c_null_char
f_result
=
lib_cdiZaxisDefString
(
zaxisID_dummy
,
key_dummy
,
size_dummy
,&
&
mesg_temp
)
end
function
cdiZaxisDefString
function
cdiZaxisInqString
(
zaxisID_dummy
,
key_dummy
,
size_dummy
,
mesg_dummy
)&
&
result
(
f_result
)
integer
(
c_int
)
::
f_result
integer
(
c_int
),
value
::
zaxisID_dummy
integer
(
c_int
),
value
::
key_dummy
integer
(
c_int
),
value
::
size_dummy
character
(
kind
=
c_char
,
len
=
*
),
intent
(
inout
)
::
mesg_dummy
character
(
kind
=
c_char
)
::
mesg_temp
(
len
(
mesg_dummy
)
+
1
)
integer
::
mesg_i
interface
function
lib_cdiZaxisInqString
(
zaxisID_dummy
,
key_dummy
,
size_dummy
,&
&
mesg_dummy
)
bind
(
c
,
name
=
'cdiZaxisInqString'
)
result
(
c_result
)
import
c_char
,
c_int
integer
(
c_int
)
::
c_result
integer
(
c_int
),
value
::
zaxisID_dummy
integer
(
c_int
),
value
::
key_dummy
integer
(
c_int
),
value
::
size_dummy
character
(
kind
=
c_char
)
::
mesg_dummy
(
*
)
end
function
lib_cdiZaxisInqString
end
interface
mesg_temp
(
len
(
mesg_dummy
)
+
1
)
=
c_null_char
do
mesg_i
=
len
(
mesg_dummy
),
1
,
-1
if
(
mesg_dummy
(
mesg_i
:
mesg_i
)
/
=
' '
)
exit
mesg_temp
(
mesg_i
)
=
c_null_char
end
do
do
mesg_i
=
mesg_i
,
1
,
-1
mesg_temp
(
mesg_i
)
=
mesg_dummy
(
mesg_i
:
mesg_i
)
end
do
f_result
=
lib_cdiZaxisInqString
(
zaxisID_dummy
,
key_dummy
,
size_dummy
,&
&
mesg_temp
)
do
mesg_i
=
1
,
len
(
mesg_dummy
)
if
(
mesg_temp
(
mesg_i
)
==
c_null_char
)
exit
mesg_dummy
(
mesg_i
:
mesg_i
)
=
mesg_temp
(
mesg_i
)
end
do
do
mesg_i
=
mesg_i
,
len
(
mesg_dummy
)
mesg_dummy
(
mesg_i
:
mesg_i
)
=
' '
end
do
end
function
cdiZaxisInqString
subroutine
zaxisDefName
(
zaxisID_dummy
,
name
)
integer
(
c_int
),
value
::
zaxisID_dummy
character
(
kind
=
c_char
,
len
=
*
),
optional
,
intent
(
in
)
::
name
...
...
src/zaxis.c
View file @
e2c88cd2
...
...
@@ -66,6 +66,8 @@ enum {
typedef
struct
{
unsigned
char
positive
;
char
dimname
[
CDI_MAX_NAME
];
char
vdimname
[
CDI_MAX_NAME
];
char
name
[
CDI_MAX_NAME
];
char
longname
[
CDI_MAX_NAME
];
char
stdname
[
CDI_MAX_NAME
];
...
...
@@ -354,6 +356,113 @@ void zaxisName(int zaxistype, char *zaxisname)
strcpy
(
zaxisname
,
zaxisNamePtr
(
zaxistype
));
}
static
inline
void
zaxisSetString
(
char
*
zaxisstrname
,
const
char
*
name
,
size_t
len
)
{
if
(
len
>
CDI_MAX_NAME
)
len
=
CDI_MAX_NAME
;
strncpy
(
zaxisstrname
,
name
,
len
);
zaxisstrname
[
len
-
1
]
=
0
;
}
static
inline
void
zaxisGetString
(
char
*
name
,
const
char
*
zaxisstrname
,
size_t
len
)
{
if
(
len
>
CDI_MAX_NAME
)
len
=
CDI_MAX_NAME
;
strncpy
(
name
,
zaxisstrname
,
len
);
name
[
len
-
1
]
=
0
;
}
static
char
*
zaxis_key_to_string
(
zaxis_t
*
zaxisptr
,
int
key
)
{
char
*
zaxisstring
=
NULL
;
switch
(
key
)
{
case
CDI_ZAXIS_DIMNAME
:
zaxisstring
=
zaxisptr
->
dimname
;
break
;
case
CDI_ZAXIS_VDIMNAME
:
zaxisstring
=
zaxisptr
->
vdimname
;
break
;
}
return
zaxisstring
;
}
/*
@Function cdiZaxisDefString
@Title Define a CDI Z-axis string value from a key
@Prototype int cdiZaxisDefString(int zaxisID, int key, int size, const char *mesg)
@Parameter
@Item zaxisID Z-axis ID, from a previous call to @fref{zaxisCreate}.
@Item key The key to be searched
@Item size The allocated length of the string on input
@Item mesg The address of a string where the data will be read
@Description
The function @func{cdiZaxisDefString} defines a CDI Z-axis string value from a key.
@Result
@func{cdiZaxisDefString} returns 0 if OK and integer value on error.
@EndFunction
*/
int
cdiZaxisDefString
(
int
zaxisID
,
int
key
,
int
size
,
const
char
*
mesg
)
{
if
(
size
==
0
||
mesg
==
NULL
||
*
mesg
==
0
)
return
-
1
;
zaxis_t
*
zaxisptr
=
zaxisID2Ptr
(
zaxisID
);
char
*
zaxisstring
=
zaxis_key_to_string
(
zaxisptr
,
key
);
if
(
zaxisstring
==
NULL
)
{
Warning
(
"CDI zaxis string key %d not supported!"
,
key
);
return
-
1
;
}
zaxisSetString
(
zaxisstring
,
mesg
,
size
);
reshSetStatus
(
zaxisID
,
&
zaxisOps
,
RESH_DESYNC_IN_USE
);
return
0
;
}
/*
@Function cdiZaxisInqString
@Title Get a CDI Z-axis string value from a key
@Prototype int cdiZaxisInqString(int zaxisID, int key, int size, char *mesg)
@Parameter
@Item zaxisID Z-axis ID, from a previous call to @fref{zaxisCreate}.
@Item key The key to be searched.
@Item size The allocated length of the string on input.
@Item mesg The address of a string where the data will be retrieved.
The caller must allocate space for the returned string.
The maximum possible length, in characters, of the string
is given by the predefined constant @func{CDI_MAX_NAME}.
@Description
The function @func{cdiZaxisInqString} return a CDI Z-axis string value from a key.
@Result
@func{cdiZaxisInqString} returns 0 if OK and integer value on error.
@EndFunction
*/
int
cdiZaxisInqString
(
int
zaxisID
,
int
key
,
int
size
,
char
*
mesg
)
{
if
(
size
==
0
||
mesg
==
NULL
)
return
-
1
;
zaxis_t
*
zaxisptr
=
zaxisID2Ptr
(
zaxisID
);
const
char
*
zaxisstring
=
zaxis_key_to_string
(
zaxisptr
,
key
);
if
(
zaxisstring
==
NULL
)
{
Warning
(
"CDI zaxis string key %d not supported!"
,
key
);
return
-
1
;
}
zaxisGetString
(
mesg
,
zaxisstring
,
size
);
return
0
;
}
/*
@Function zaxisDefName
@Title Define the name of a Z-axis
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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