/* converts timestamps in logfiles to a more human-readable format */ /* usage : cnvlog */ #include #include #include /* gettimeofday */ #include void main(int argc, char **argv) { struct tm *tmp; FILE *fp; int column; long time; char event[20]; struct timeval tv; if (argc!=2) { printf("usage : %s filename\n",argv[0]); exit(-1); } fp = fopen(argv[1],"r"); if (fp==NULL) { printf("can't open file\n"); exit(-1); } tv.tv_usec=0; while(fscanf(fp,"%d%s%ld\n",&column,event,&time) != EOF) { tv.tv_sec=time; tmp=localtime(&tv.tv_sec); printf("%d %s %s",column,event,asctime(tmp)); } fclose(fp); }