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
SWIFT
SWIFTsim
Commits
806bee60
Commit
806bee60
authored
Aug 31, 2012
by
Pedro Gonnet
Browse files
add reading gzipped dt-file.
Former-commit-id: d2bdb7236a297a4f0928dfaa73117c6eb6982b02
parent
393d4826
Changes
1
Hide whitespace changes
Inline
Side-by-side
test.c
View file @
806bee60
...
...
@@ -371,6 +371,26 @@ void read_id ( char *fname , struct part *parts , int N ) {
void
read_dt
(
char
*
fname
,
struct
part
*
parts
,
int
N
)
{
#ifdef HAVE_ZLIB
gzFile
*
fd
;
char
buff
[
1024
];
int
k
;
/* Open the given file. */
if
(
(
fd
=
gzopen
(
fname
,
"r"
)
)
==
NULL
)
error
(
"Failed to open dt file"
);
/* Read the coordinates into the part positions. */
for
(
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gzgets
(
fd
,
buff
,
1024
)
==
NULL
)
error
(
"Error reading id file."
);
if
(
sscanf
(
buff
,
"%ef"
,
&
parts
[
k
].
dt
)
!=
1
)
error
(
"Error parsing dt file."
);
}
/* Wrap it up. */
gzclose
(
fd
);
#else
FILE
*
fd
;
int
k
;
...
...
@@ -384,6 +404,10 @@ void read_dt ( char *fname , struct part *parts , int N ) {
error
(
"Error reading dt file."
);
}
/* Wrap it up. */
fclose
(
fd
);
#endif
}
...
...
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