#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char c;
int ip1, ip2, ip3, ip4 ;
char data[256];
char operation[256];
char page[256];
char nomefile[]="t2anonimizzato.log"; FILE * Fp1;
Fp1 = fopen(nomefile, "r");
if (Fp1==NULL){
printf("File %s not found\n", nomefile);
exit(-1);
}
while ( fscanf(Fp1, "%d.", &ip1 ) > 0 )
{
fscanf(Fp1, "%d.%d.%d", &ip2, &ip3, &ip4 );
fscanf(Fp1, " - - [%s +0200] %s", data , operation);
fscanf(Fp1, " %s HTTP/1.1", page);
printf( "%d.%d.%d.%d \n", ip1, ip2, ip3, ip4 ); printf( " page: %s \n", page );
while ( fscanf(Fp1, "%c", &c ) > 0 )
{
if (c == '\n' ) break;
}
printf( " \n\n\n" );
}
fflush(stdin);
getchar();
fflush(Fp1); fclose (Fp1);
return 0;
}