repo.or.cz
/
rofl0r-hardcore-utils.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
manpp: handle groff \N[dd] escape sequence
[rofl0r-hardcore-utils.git]
/
unixordos.c
blob
923f97243f3c64242106a4f6b8427bec8396b6b9
1
#include <stdio.h>
2
3
int
is_dos_file
(
FILE
*
f
) {
4
int
c
,
was_cr
=
0
;
5
while
((
c
=
fgetc
(
f
)) !=
EOF
) {
6
if
(
c
==
0xd
)
was_cr
=
1
;
7
else if
(
c
==
0xa
&&
was_cr
) {
8
return
1
;
9
}
else
was_cr
=
0
;
10
}
11
return
0
;
12
}
13
14
int
main
(
int
argc
,
char
**
argv
) {
15
if
(
argc
<
2
) {
16
dprintf
(
2
,
"need filename
\n
"
);
17
return
1
;
18
}
19
FILE
*
f
=
fopen
(
argv
[
1
],
"r"
);
20
if
(!
f
) {
21
perror
(
"fopen"
);
22
return
2
;
23
}
24
if
(
is_dos_file
(
f
))
25
dprintf
(
1
,
"DOS
\n
"
);
26
else
27
dprintf
(
1
,
"UNIX
\n
"
);
28
fclose
(
f
);
29
return
0
;
30
}