merge 64-bit fixes from Fernando Lucas Rodriguez <fernando_lr@terra.es>
[debian/gcpegg] / examine.c
1 /* PROGRAM:     examine
2  * FILE:        $Header: /home/egg/src/RCS/examine.c,v 1.1 1998/07/21 11:39:04 ghn Exp $
3  * PURPOSE:     Testing data retrieval from database
4  * AUTHOR:      Greg Nelson
5  * DATE:        98-05-09
6  *
7  * REVISED:     $Log: examine.c,v $
8  * REVISED:     Revision 1.1  1998/07/21 11:39:04  ghn
9  * REVISED:     Initial revision
10  * REVISED:
11  * Copyright 1998 - Greg Nelson
12  * Redistributable under the terms of the GNU Public Licence (GPL)
13  */
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include "global.h"
18 #include "storage.h"
19
20 EggEntry eggtable[MAX_EGGS];
21
22 int main(int argc, char *argv[]) {
23   int i, j, k, trials;
24   FILE *fp;
25   EggCarton pktbuf;
26
27   pgmname = argv[0];
28
29   if (argc != 1 && argc != 2) {
30     printf("Usage: %s [infile]\n", pgmname);
31     exit(-1);
32   }
33   
34   InitStorage(NULL);
35
36   if (argc == 1) fp = stdin;
37   else fp = fopen(argv[1], "r");
38
39   trials = 0;
40   while (1) {
41     i = LoadPacket(fp, &pktbuf);
42     if (i < 0) {
43       printf("Total trials: %d\n", trials);
44       exit(-1);
45     }
46
47     printf("Packet of %d records read\n", pktbuf.hdr.numrec);
48     for (j = 0; j < pktbuf.hdr.numrec; j++) {
49       printf("Record: %d points\n  %ld: ",
50              pktbuf.hdr.samp_rec,
51              pktbuf.records[j].timestamp);
52       for (k = 0; k < pktbuf.hdr.samp_rec; k++) {
53         printf("%3d ", pktbuf.records[j].trials[k]);
54         trials++;
55       }
56       printf("\n");
57     }
58   }
59
60   return 0;
61 }