repo.or.cz
/
congif.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Merge pull request #13 from rdebath/patch-fixes
[congif.git]
/
dump.c
blob
1f62b1420e79c85e28319c4befa7b8a952fd9b1a
1
#include <stdint.h>
2
#include <unistd.h>
3
#include <sys/types.h>
4
#include <sys/stat.h>
5
#include <fcntl.h>
6
7
#include
"term.h"
8
9
void
10
dump_txt
(
Term
*
term
,
const char
*
fname
)
11
{
12
int
i
,
j
,
fd
;
13
uint16_t
code
;
14
char
ch
;
15
16
fd
=
creat
(
fname
,
0666
);
17
if
(
fd
== -
1
)
18
return
;
19
for
(
i
=
0
;
i
<
term
->
rows
;
i
++) {
20
for
(
j
=
0
;
j
<
term
->
cols
;
j
++) {
21
code
=
term
->
addr
[
i
][
j
].
code
;
22
if
(
code
>=
0x20
&&
code
<
0x7F
)
23
ch
= (
char
)
code
;
24
else
25
ch
=
0x20
;
26
write
(
fd
, &
ch
,
1
);
27
}
28
write
(
fd
,
"
\n
"
,
1
);
29
}
30
close
(
fd
);
31
}