#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef enum
{
IN_TAG,
IN_QUOTE,
NORMAL
} parseState;
int main(int argc, char **argv)
{
FILE *inputFile = NULL;
FILE *outputFile = NULL;
int c = 0;
parseState ps = NORMAL;
if (argc < 3)
{
fprintf(stderr, "args");
exit(EXIT_FAILURE);
}
inputFile = fopen(argv[1], "r");
outputFile = fopen(argv[2], "w");
while (!feof(inputFile))
{
c = fgetc(inputFile);
switch (ps)
{
case IN_TAG:
if (c == '\'' || c == '"')
ps = IN_QUOTE;
if (c == '>' && ps != IN_QUOTE)
{
ps = NORMAL;
continue;
}
break;
case IN_QUOTE:
if (c == '\'' || c == '"')
ps = IN_TAG;
case NORMAL:
if (c == '<')
ps = IN_TAG;
break;
}
if (ps == NORMAL)
fputc(c, stdout);
}
fclose(outputFile);
fclose(inputFile);
return 0;
}