Rev 1085 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include <stdio.h>
#include <stdlib.h>
#include "types.h"
#include <trace.h>
#include "util.h"
/* distribuzione degli spostamenti della testina */
#define MAXX 1000
#define PREC 1000
#define DELTA ((double)MAXX/(double)PREC)
#include "distr.c"
int dumpusr
(int event
, trc_user_event_t
*usr
)
{
static long last
=-1;
long d
;
if (event
!=TRC_USER0
) return 0;
if (last
!=-1) {
d
=abs(last
-usr
->n
);
d_insert
(d
);
}
last
=usr
->n
;
return 0;
}
int dumpfunc
(trc_event_t
*ev
)
{
if (event_class
(ev
->event
)==TRC_CLASS_USER
) dumpusr
(ev
->event
,&ev
->x.
usr);
return 0;
}
int main
(int argc
, char *argv
[])
{
FILE
*fout
;
int res
;
if (argc
!=3) {
fprintf(stderr
,"missing filename!\n");
return -1;
}
d_init
();
res
=read_trace
(argv
[1],dumpfunc
);
if (res
==0) {
fout
=fopen(argv
[2],"wt");
if (fout
!=NULL
) {
d_dump
(fout
);
fclose(fout
);
} else
fprintf(stderr
,"can't create output file!\n");
} else
fprintf(stderr
,"read_trace error\n");
return 0;
}