sts.c
changeset 145 63a5269fb113
parent 144 f064cd793f8d
child 156 2898369b1cdc
equal deleted inserted replaced
144:f064cd793f8d 145:63a5269fb113
     4  */
     4  */
     5 
     5 
     6 #include <stdio.h>
     6 #include <stdio.h>
     7 #include <stdlib.h>
     7 #include <stdlib.h>
     8 #include <string.h>
     8 #include <string.h>
     9 #include <math.h>
       
    10 #include <time.h>
     9 #include <time.h>
    11 #include <errno.h>
    10 #include <errno.h>
    12 
    11 
    13 void usage (char *name)
    12 void usage (char *name)
    14 {
    13 {
    18 
    17 
    19 time_t parse (char *buf)
    18 time_t parse (char *buf)
    20 {
    19 {
    21     time_t sec = 0;
    20     time_t sec = 0;
    22     time_t milli = 0;
    21     time_t milli = 0;
    23     double value;
       
    24 
    22 
    25     if (sscanf (buf, "%ld.%ld", &sec, &milli) != 2) {
    23     if (sscanf (buf, "%ld.%ld", &sec, &milli) != 2) {
    26         fprintf (stderr, "  sec: %ld, ", sec);
    24         fprintf (stderr, "  sec: %ld, ", sec);
    27         fprintf (stderr, "milli: %ld\n", milli);
    25         fprintf (stderr, "milli: %ld\n", milli);
    28     }
    26     }
    29 
    27 
    30     value = (milli / 1000000);
    28     return sec;
    31     return sec + (time_t) (floor (value));
       
    32 }
    29 }
    33 
    30 
    34 time_t getboottime ()
    31 time_t getboottime ()
    35 {
    32 {
    36     char buf[80];
    33     char buf[80];