/* Auteur: Tchetch-2 */
/* Plateforme: Linux/Win32 */
/* Compilateur/version: gcc/4.0.3 */
/* Dernière modif: 8 aout 08:20 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Fonction getc_unlocked et putc_unlocked sont POSIX.1 */
#ifndef WIN32
#undef getc
#define getc getc_unlocked
#undef putc
#define putc putc_unlocked
#endif
#define IN_TAG 1
#define SPACE 2
#define IN_A 4
#define IN_IMG 8
#define BUFFER_SIZE 1024
char buffer[BUFFER_SIZE];
int a_img[BUFFER_SIZE];
inline char parse_stdin()
{
int c=0;
static int state=0;
int i=0, j=0;
buffer[0]='\0';
a_img[0]=-1;
while(i<BUFFER_SIZE)
{
c=getc(stdin);
if(c==EOF)
{
break;
}
if(c=='<' && !(state & IN_TAG))
{
state+=IN_TAG;
a_img[j]=i;
++j;
}
if(state & IN_TAG)
{
if(c>64&&c<91)
{
c=c+32;
}
if(c=='\n' || c=='\r')
{
if(buffer[i-1]!='=')
{
c=' ';
} else {
continue;
}
}
if(c==' ')
{
if(!(state & SPACE))
{
c='\0';
} else {
continue;
}
}
buffer[i]=(char)c;
if(state & SPACE)
{
a_img[j]=i;
++j;
state-=SPACE;
}
if(c=='\0')
{
state+=SPACE;
}
++i;
}
if(c=='>' && (state & IN_TAG))
{
state-=IN_TAG;
break;
}
}
buffer[i]='\0';
a_img[j]=-1;
return c;
}
inline void get_a_img()
{
int i=0, j=0;
int x=0;
int static state=0;
char href[]="href";
char src[]="src";
int found=0;
char tmp;
while((x=a_img[i])!=-1)
{
if(buffer[x]=='<')
{
state=0;
}
if(strcmp(&buffer[x], "<a")==0)
{
state+=IN_A;
++i;
continue;
} else if(strcmp(&buffer[x], "<img")==0)
{
state+=IN_IMG;
++i;
continue;
}
if(state & IN_A)
{
if(buffer[x]=='h')
{
j=1;
found=1;
while((href[j]!='\0'))
{
if(buffer[x+j]!=href[j])
{
found=0;
break;
}
++j;
}
if(x+j+1>=BUFFER_SIZE-1)
{
break;
}
if(found && (buffer[x+j]<97 ||
buffer[x+j]>122))
{
++j;
found=0;
while((tmp=buffer[x+j])!='\0')
{
if((tmp==' ' ||
tmp=='>' ||
tmp=='\'' ||
tmp=='"') &&
found)
{
break;
}
if((tmp>96&&tmp <123||
tmp==47||
tmp==46) &&
!found)
{
found=1;
}
if(found)
{
putc(tmp, stdout);
}
++j;
}
putc('\n', stdout);
}
} else {
++i;
continue;
}
}
if(state & IN_IMG)
{
if(buffer[x]=='s')
{
j=1;
found=1;
while((src[j]!='\0'))
{
if(buffer[x+j]!=src[j])
{
found=0;
break;
}
++j;
}
if(x+j+1>=BUFFER_SIZE-1)
{
break;
}
if(found && (buffer[x+j]<97 ||
buffer[x+j]>122))
{
++j;
found=0;
while((tmp=buffer[x+j])!='\0')
{
if((tmp==' ' ||
tmp=='>' ||
tmp=='\'' ||
tmp=='"') &&
found)
{
break;
}
if((tmp>96&&tmp<123 ||
tmp==47||
tmp==46) &&
!found)
{
found=1;
}
if(found)
{
putc(tmp, stdout);
}
++j;
}
putc('\n', stdout);
}
} else {
++i;
continue;
}
}
++i;
}
}
int main(int argc, char **argv)
{
char c='a';
while(1)
{
c=parse_stdin();
get_a_img();
if(c==EOF)
{
break;
}
}
return 0;
}