Exemple #1
0
TWAMPTimestamp get_timestamp()
{
    struct timeval tv;
    gettimeofday(&tv, NULL);
    TWAMPTimestamp ts;
    timeval_to_timestamp(&tv, &ts);
    return ts;
}
Exemple #2
0
tstamp_t timestamp_now(void) {
   struct timeval tv;

   if (current_time)
      return current_time;
   gettimeofday(&tv, NULL);
   return timeval_to_timestamp(&tv);
}
Exemple #3
0
void log_event(log_event_t event, void *data, size_t size) {
    if(logfile == -1) {
        __android_log_write(ANDROID_LOG_WARN, "RIL", "logger-ril: log file not open");        
        
        return;
    }
    
    struct timeval time;
    gettimeofday(&time, NULL);
    
    log_entry_header_t *hdr = (log_entry_header_t *) data;
    hdr->type = event;
    hdr->data_size = size - sizeof(log_entry_header_t);
    hdr->timestamp = timeval_to_timestamp(&time);
    
    if(write(logfile, data, size) == -1) {
        __android_log_print(ANDROID_LOG_WARN, "RIL", "logger-ril: event write failed: %s", strerror(errno));   
    }
}
Exemple #4
0
tstamp_t datestring_to_timestamp(char *s) {
   struct timespec ts;
   struct tm tmv;
   int year, month, day, hh, mm, ss;
   int save_daylight = daylight;
   long save_timezone = timezone;

   sscanf(s, "%d/%d/%d:%d:%d:%d", &year, &month, &day, &hh, &mm, &ss);
   tmv.tm_year = (year >= 1970) ? year - 1900 : 70;
   tmv.tm_mon = (month > 0 && month < 13) ? month - 1 : 0;
   tmv.tm_mday = (day > 0 && day < 32) ? day : 1;
   tmv.tm_hour = (hh >= 0 && hh < 24) ? hh : 0;
   tmv.tm_min = (mm >= 0 && mm < 60) ? mm : 0;
   tmv.tm_sec = (ss >= 0 && ss < 62) ? ss : 0;
   tmv.tm_isdst = 0;
   daylight = 0;
   timezone = 0;
   ts.tv_sec = mktime(&tmv);
   ts.tv_nsec = 0;
   daylight = save_daylight;
   timezone = save_timezone;
   return timeval_to_timestamp((struct timeval *)&ts);
}