/*\
 *	Filter.
 *	Input:	a list of values for one variable for one object,
 *		as generated by hnmstool
 *	Output: a table with time, value, delta-value,
 *		delta-value/delta-time
\*/

#include <stdio.h>

main(int argc, char *argv[])
{
    char                        *cp, buf[120], uname[80], vname[80], buf2[40];
    int                         rval;
    unsigned int                last_value = 0, value, last_time = 0, time;

    for (;;) {
        cp = gets(buf);
        if (!cp)
            break;
        rval = sscanf(buf, "%d %s %s %d\n", &time, uname, vname, &value);

        if (last_time != 0 && value > last_value) {
            cftime(buf2, "%H:%M:%S", &time);
            printf("%s\t%u\t%u\t%u\t\t%u\n", buf2, time - last_time, value,
                   value - last_value,
                   (value - last_value)/(time - last_time));
        }
        last_value = value;
        last_time = time;
    }
}
