Modified media page
[mob-repo.git] / mark_dead_links.c
blob2fcb7ebceb65ab566b9edea6fef4a1d1e6e18379
1 #include <stdio.h>
3 int main(void)
5 int c, state = 0, filenameLen = 0;
6 char filename[256];
8 while ((c = getchar()) != EOF)
10 putchar(c);
12 switch (state)
14 case 0: if (c == '<') state = 1; break;
15 case 1: state = c == 'a' ? 2 : 0; break;
16 case 2: state = c == ' ' ? 3 : 0; break;
17 case 3: state = c == 'h' ? 4 : 0; break;
18 case 4: state = c == 'r' ? 5 : 0; break;
19 case 5: state = c == 'e' ? 6 : 0; break;
20 case 6: state = c == 'f' ? 7 : 0; break;
21 case 7: state = c == '=' ? 8 : 0; break;
22 case 8: state = c == '"' ? 9 : 0; break;
23 case 9:
24 if (c == '"')
26 filename[filenameLen] = 0;
28 FILE *f = fopen(filename,"r");
30 if (!f)
31 printf(" class=\"dead\"");
32 else
33 fclose(f);
35 filenameLen = 0;
36 state = 0;
38 else if (filenameLen < 128)
40 filename[filenameLen] = c;
41 filenameLen++;
44 break;
46 default: break;
51 return 0;