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
24c273a1
Commit
24c273a1
authored
9 years ago
by
Thomas Jahns
Browse files
Options
Downloads
Patches
Plain Diff
Extract repeated code to function.
parent
d4eea229
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/stream_gribapi.c
+41
-36
41 additions, 36 deletions
src/stream_gribapi.c
with
41 additions
and
36 deletions
src/stream_gribapi.c
+
41
−
36
View file @
24c273a1
...
...
@@ -1831,6 +1831,38 @@ void gribapiDefTime(int editionNumber, int productDefinitionTemplate, int typeOf
}
}
struct
gribApiMsg
{
size_t
msgLen
;
const
char
*
msg
;
};
static
struct
gribApiMsg
getGribApiCompTypeMsg
(
grib_handle
*
gh
,
int
comptype
,
int
gridsize
)
{
const
char
*
mesg
;
size_t
len
;
if
(
comptype
==
COMPRESS_JPEG
&&
gridsize
>
1
)
{
static
const
char
mesg_grid_jpeg
[]
=
"grid_jpeg"
;
len
=
sizeof
(
mesg_grid_jpeg
)
-
1
;
mesg
=
mesg_grid_jpeg
;
}
else
if
(
comptype
==
COMPRESS_SZIP
&&
gridsize
>
1
)
{
static
const
char
mesg_grid_ccsds
[]
=
"grid_ccsds"
;
len
=
sizeof
(
mesg_grid_ccsds
)
-
1
;
mesg
=
mesg_grid_ccsds
;
}
else
{
static
const
char
mesg_simple
[]
=
"grid_simple"
;
len
=
sizeof
(
mesg_simple
)
-
1
;
mesg
=
mesg_simple
;
}
return
(
struct
gribApiMsg
){
.
msgLen
=
len
,
.
msg
=
mesg
};
}
static
void
gribapiDefGrid
(
int
editionNumber
,
grib_handle
*
gh
,
int
gridID
,
int
comptype
,
int
lieee
,
int
datatype
,
int
nmiss
,
int
gcinit
)
{
...
...
@@ -1887,24 +1919,11 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
if
(
comptype
)
{
if
(
comptype
==
COMPRESS_JPEG
&&
gridsize
>
1
)
{
static
const
char
mesg
[]
=
"grid_jpeg"
;
size_t
len
=
sizeof
(
mesg
)
-
1
;
GRIB_CHECK
(
my_grib_set_string
(
gh
,
"packingType"
,
mesg
,
&
len
),
0
);
}
else
if
(
comptype
==
COMPRESS_SZIP
&&
gridsize
>
1
)
{
static
const
char
mesg
[]
=
"grid_ccsds"
;
size_t
len
=
sizeof
(
mesg
)
-
1
;
GRIB_CHECK
(
my_grib_set_string
(
gh
,
"packingType"
,
mesg
,
&
len
),
0
);
}
else
{
static
const
char
mesg
[]
=
"grid_simple"
;
size_t
len
=
sizeof
(
mesg
)
-
1
;
GRIB_CHECK
(
my_grib_set_string
(
gh
,
"packingType"
,
mesg
,
&
len
),
0
);
}
struct
gribApiMsg
gaMsg
=
getGribApiCompTypeMsg
(
gh
,
comptype
,
gridsize
);
size_t
len
=
gaMsg
.
msgLen
;
const
char
*
mesg
=
gaMsg
.
msg
;
GRIB_CHECK
(
my_grib_set_string
(
gh
,
"packingType"
,
mesg
,
&
len
),
0
);
}
}
...
...
@@ -2074,24 +2093,10 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
}
else
{
if
(
comptype
==
COMPRESS_JPEG
&&
gridsize
>
1
)
{
static
const
char
mesg_grid_jpeg
[]
=
"grid_jpeg"
;
len
=
sizeof
(
mesg_grid_jpeg
)
-
1
;
mesg
=
mesg_grid_jpeg
;
}
else
if
(
comptype
==
COMPRESS_SZIP
&&
gridsize
>
1
)
{
static
const
char
mesg_grid_ccsds
[]
=
"grid_ccsds"
;
len
=
sizeof
(
mesg_grid_ccsds
)
-
1
;
mesg
=
mesg_grid_ccsds
;
}
else
{
static
const
char
mesg_simple
[]
=
"grid_simple"
;
len
=
sizeof
(
mesg_simple
)
-
1
;
mesg
=
mesg_simple
;
}
struct
gribApiMsg
gaMsg
=
getGribApiCompTypeMsg
(
gh
,
comptype
,
gridsize
);
len
=
gaMsg
.
msgLen
;
mesg
=
gaMsg
.
msg
;
}
GRIB_CHECK
(
my_grib_set_string
(
gh
,
"packingType"
,
mesg
,
&
len
),
0
);
if
(
lieee
)
...
...
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