suitcase

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

leapsecs.c (588B)


      1 #include <stdio.h>
      2 #include <tai/tai.h>
      3 #include <tai/leapsecs.h>
      4 #include <tai/caldate.h>
      5 
      6 /* XXX: breaks tai encapsulation */
      7 
      8 /* XXX: output here has to be binary; DOS redirection uses ASCII */
      9 
     10 char line[100];
     11 
     12 int main(int argc, char **argv)
     13 {
     14   struct caldate cd;
     15   struct tai t;
     16   char x[TAI_PACK];
     17   long leaps = 0;
     18 
     19   while (fgets(line,sizeof line,stdin))
     20     if (line[0] == '+')
     21       if (caldate_scan(line + 1,&cd)) {
     22 	t.x = (caldate_mjd(&cd) + 1) * 86400ULL + 4611686014920671114ULL + leaps++;
     23         tai_pack(x,&t);
     24 	fwrite(x,TAI_PACK,1,stdout);
     25       }
     26       
     27   exit(0);
     28 }