7 static void show_dive(int nr, struct dive *dive)
12 tm = gmtime(&dive->when);
14 printf("At %02d:%02d:%02d %04d-%02d-%02d (%d ft max, %d minutes)\n",
15 tm->tm_hour, tm->tm_min, tm->tm_sec,
16 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
17 to_feet(dive->maxdepth), dive->duration.seconds / 60);
22 for (i = 0; i < dive->samples; i++) {
23 struct sample *s = dive->sample + i;
25 printf("%4d:%02d: %3d ft, %2d C, %4d PSI\n",
30 to_PSI(s->tankpressure));
34 static int sortfn(const void *_a, const void *_b)
36 const struct dive *a = *(void **)_a;
37 const struct dive *b = *(void **)_b;
39 if (a->when < b->when)
41 if (a->when > b->when)
46 static void report_dives(void)
50 qsort(dive_table.dives, dive_table.nr, sizeof(struct dive *), sortfn);
51 for (i = 0; i < dive_table.nr; i++)
52 show_dive(i+1, dive_table.dives[i]);
55 static void parse_argument(const char *arg)
57 const char *p = arg+1;
65 fprintf(stderr, "Bad argument '%s'\n", arg);
71 int main(int argc, char **argv)
77 for (i = 1; i < argc; i++) {
78 const char *a = argv[i];