Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
libcdi
Commits
e1f34dcc
Commit
e1f34dcc
authored
10 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
three functions that will be used in the iterator [patch 10/14 from Nathanael]
parent
b2115367
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/cdi_int.h
+4
-2
4 additions, 2 deletions
src/cdi_int.h
src/util.c
+54
-9
54 additions, 9 deletions
src/util.c
src/zaxis.c
+21
-0
21 additions, 0 deletions
src/zaxis.c
src/zaxis.h
+3
-0
3 additions, 0 deletions
src/zaxis.h
with
82 additions
and
11 deletions
src/cdi_int.h
+
4
−
2
View file @
e1f34dcc
...
...
@@ -326,13 +326,15 @@ void cdiInitialize(void);
void
uuid2str
(
const
unsigned
char
*
uuid
,
char
*
uuidstr
);
int
str2uuid
(
const
char
*
uuidstr
,
unsigned
char
*
uuid
);
static
inline
int
cdiUUIDIsNull
(
const
unsigned
char
uuid
[
CDI_UUID_SIZE
])
static
inline
int
cdiUUIDIsNull
(
const
unsigned
char
uuid
[
CDI_UUID_SIZE
])
{
static
const
unsigned
char
uuid_nil
[
CDI_UUID_SIZE
];
return
!
memcmp
(
uuid
,
uuid_nil
,
CDI_UUID_SIZE
);
}
char
*
cdiEscapeSpaces
(
const
char
*
string
);
char
*
cdiUnescapeSpaces
(
const
char
*
string
,
const
char
**
outStringEnd
);
#define CDI_UNIT_PA 1
#define CDI_UNIT_HPA 2
...
...
This diff is collapsed.
Click to expand it.
src/util.c
+
54
−
9
View file @
e1f34dcc
...
...
@@ -91,12 +91,57 @@ int str2uuid(const char *uuidstr, unsigned char *uuid)
return
iret
;
}
/*
* Local Variables:
* c-file-style: "Java"
* c-basic-offset: 2
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
//Returns a malloc'ed string that escapes all spaces and backslashes with backslashes.
char
*
cdiEscapeSpaces
(
const
char
*
string
)
{
//How much memory do we need?
size_t
escapeCount
=
0
,
length
=
0
;
for
(
const
char
*
current
=
string
;
*
current
;
current
++
)
{
if
(
strchr
(
"
\\
"
,
*
current
))
escapeCount
++
;
length
++
;
}
char
*
result
=
malloc
(
length
+
escapeCount
+
1
);
if
(
!
result
)
return
NULL
;
//Do the escaping.
for
(
size_t
in
=
0
,
out
=
0
;
in
<
length
;)
{
if
(
strchr
(
"
\\
"
,
string
[
in
]))
result
[
out
++
]
=
'\\'
;
result
[
out
++
]
=
string
[
in
++
];
}
result
[
length
+
escapeCount
]
=
0
;
//termination!
return
result
;
}
//input: a space terminated string that may contain escaped characters
//output: a new zero terminated string with the escape characters removed
//*outStringEnd points to the terminating character upon return.
char
*
cdiUnescapeSpaces
(
const
char
*
string
,
const
char
**
outStringEnd
)
{
//How much memory do we need?
size_t
escapeCount
=
0
,
length
=
0
;
for
(
const
char
*
current
=
string
;
*
current
&&
*
current
!=
' '
;
current
++
)
{
if
(
*
current
==
'\\'
)
{
current
++
,
escapeCount
++
;
if
(
!
current
)
return
NULL
;
}
length
++
;
}
char
*
result
=
malloc
(
length
+
1
);
if
(
!
result
)
return
NULL
;
//Do the unescaping.
for
(
size_t
in
=
0
,
out
=
0
;
out
<
length
;)
{
if
(
string
[
in
]
==
'\\'
)
in
++
;
result
[
out
++
]
=
string
[
in
++
];
}
result
[
length
]
=
0
;
//termination!
if
(
outStringEnd
)
*
outStringEnd
=
&
string
[
length
+
escapeCount
];
return
result
;
}
This diff is collapsed.
Click to expand it.
src/zaxis.c
+
21
−
0
View file @
e1f34dcc
...
...
@@ -105,6 +105,26 @@ static const resOps zaxisOps = {
static
int
ZAXIS_Debug
=
0
;
/* If set to 1, debugging */
void
zaxisGetTypeDescription
(
int
zaxisType
,
int
*
outPositive
,
const
char
**
outName
,
const
char
**
outLongName
,
const
char
**
outStdName
,
const
char
**
outUnit
)
{
if
(
zaxisType
<
0
||
zaxisType
>=
CDI_NumZaxistype
)
{
if
(
outPositive
)
*
outPositive
=
0
;
if
(
outName
)
*
outName
=
NULL
;
if
(
outLongName
)
*
outLongName
=
NULL
;
if
(
outStdName
)
*
outStdName
=
NULL
;
if
(
outUnit
)
*
outUnit
=
NULL
;
}
else
{
if
(
outPositive
)
*
outPositive
=
ZaxistypeEntry
[
zaxisType
].
positive
;
if
(
outName
)
*
outName
=
ZaxistypeEntry
[
zaxisType
].
name
;
if
(
outLongName
)
*
outLongName
=
ZaxistypeEntry
[
zaxisType
].
longname
;
if
(
outStdName
)
*
outStdName
=
ZaxistypeEntry
[
zaxisType
].
stdname
;
if
(
outUnit
)
*
outUnit
=
ZaxistypeEntry
[
zaxisType
].
units
;
}
}
static
void
zaxisDefaultValue
(
zaxis_t
*
zaxisptr
)
{
...
...
@@ -708,6 +728,7 @@ void zaxisDefUUID(int zaxisID, const unsigned char uuid[CDI_UUID_SIZE])
@Prototype void zaxisInqUUID(int zaxisID, char *uuid)
@Parameter
@Item zaxisID Z-axis ID, from a previous call to @fref{zaxisCreate} or @fref{vlistInqVarZaxis}.
@Item uuid A user supplied buffer of at least 16 bytes.
@Description
The function @func{zaxisInqUUID} returns the UUID to a generalized Z-axis.
...
...
This diff is collapsed.
Click to expand it.
src/zaxis.h
+
3
−
0
View file @
e1f34dcc
#ifndef _ZAXIS_H
#define _ZAXIS_H
void
zaxisGetTypeDescription
(
int
zaxisType
,
int
*
outPositive
,
const
char
**
outName
,
const
char
**
outLongName
,
const
char
**
outStdName
,
const
char
**
outUnit
);
//The returned const char* point to static storage. Don't free or modify them.
int
zaxisSize
(
void
);
void
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment