This program prints annotations in readable form. Its first argument is an annotator name, and its second argument is a record name.
1 #include <stdio.h> 2 #include <ecg/db.h> 3 4 main(argc, argv) 5 int argc; 6 char *argv[]; 7 { 8 DB_Anninfo a; 9 DB_Annotation annot; 10 11 if (argc < 3) { 12 fprintf(stderr, "usage: %s annotator record\n", argv[0]); 13 exit(1); 14 } 15 a.name = argv[1]; a.stat = READ; 16 (void)sampfreq(argv[2]); 17 if (annopen(argv[2], &a, 1) < 0) exit(2); 18 while (getann(0, &annot) == 0) 19 printf("%s (%ld) %s %d %d %d %s\n", 20 timstr(-(annot.time)), 21 annot.time, 22 annstr(annot.anntyp), 23 annot.subtyp, annot.chan, annot.num, 24 (annot.aux != NULL && *annot.aux > 0) ? 25 annot.aux+1 : ""); 26 exit(0); 27 }
Notes:
sampfreq
here sets the internal variables needed
by timstr
below.
timstr(annot.time)
instead, we would obtain the elapsed time from
the beginning of the record.
aux
string is non-empty. It makes the assumption that aux
is a
printable ASCII string; the printable part follows the length
byte.
Go to the first, previous, next, last section, table of contents.