manpp: handle groff \N[dd] escape sequence
[rofl0r-hardcore-utils.git] / unixordos.c
blob923f97243f3c64242106a4f6b8427bec8396b6b9
1 #include <stdio.h>
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;
11 return 0;
14 int main(int argc, char**argv) {
15 if(argc < 2) {
16 dprintf(2, "need filename\n");
17 return 1;
19 FILE *f = fopen(argv[1], "r");
20 if(!f) {
21 perror("fopen");
22 return 2;
24 if(is_dos_file(f))
25 dprintf(1, "DOS\n");
26 else
27 dprintf(1, "UNIX\n");
28 fclose(f);
29 return 0;