|
|
|
@ -188,7 +188,7 @@ int SER::writeHeader(void) {
|
|
|
|
|
/* allocate some memory for the upcoming timestamps */
|
|
|
|
|
if((TimeStamps = (int64_t *)malloc(sizeof(header.DateTime) * NumberOfTimeStamps)) == NULL) {
|
|
|
|
|
fprintf(stderr, "Error: failed to allocate %lu bytes for timestamps\n",
|
|
|
|
|
sizeof(header.DateTime) * NumberOfTimeStamps);
|
|
|
|
|
sizeof(header.DateTime) * (long)NumberOfTimeStamps);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -246,13 +246,13 @@ int SER::appendFrame(void *data) {
|
|
|
|
|
NumberOfTimeStamps *= 2;
|
|
|
|
|
if((TimeStamps = (int64_t *)realloc(TimeStamps, sizeof(header.DateTime) * NumberOfTimeStamps)) == NULL) {
|
|
|
|
|
fprintf(stderr, "Error: failed to re-allocate %lu bytes for timestamps\n",
|
|
|
|
|
sizeof(header.DateTime) * NumberOfTimeStamps);
|
|
|
|
|
sizeof(header.DateTime) * (long)NumberOfTimeStamps);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* save timestamp for this frame */
|
|
|
|
|
TimeStamps[FramePointer++] = currentDateTime();
|
|
|
|
|
TimeStamps[FramePointer++] = currentDateTimeUTC();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -344,7 +344,7 @@ void * SER::allocFrame(void) {
|
|
|
|
|
|
|
|
|
|
/* Try allocating new frame data. */
|
|
|
|
|
if((Frame = malloc(FrameSize)) == NULL) {
|
|
|
|
|
fprintf(stderr, "Error: failed to allocate %lu bytes for frame\n", FrameSize);
|
|
|
|
|
fprintf(stderr, "Error: failed to allocate %lu bytes for frame\n", (long)FrameSize);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
return Frame;
|
|
|
|
@ -430,10 +430,10 @@ int32_t SER::getNumberOfFrames(void) {
|
|
|
|
|
*/
|
|
|
|
|
int64_t SER::setDateTime(void) {
|
|
|
|
|
|
|
|
|
|
int64_t hundred_nano_seconds = currentDateTime();
|
|
|
|
|
int64_t hundred_nano_seconds = currentDateTimeUTC();
|
|
|
|
|
|
|
|
|
|
header.DateTime = hundred_nano_seconds;
|
|
|
|
|
header.DateTimeUTC = hundred_nano_seconds + differenceLocalUTC();
|
|
|
|
|
header.DateTimeUTC = hundred_nano_seconds;
|
|
|
|
|
header.DateTime = hundred_nano_seconds + differenceLocalUTC();
|
|
|
|
|
return header.DateTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -448,14 +448,13 @@ int64_t SER::setDateTime(void) {
|
|
|
|
|
maximum value represents 100 nanoseconds before the beginning of
|
|
|
|
|
January 1 of the year 10000.
|
|
|
|
|
*/
|
|
|
|
|
int64_t SER::currentDateTime(void) {
|
|
|
|
|
int64_t SER::currentDateTimeUTC(void) {
|
|
|
|
|
|
|
|
|
|
int64_t hundred_nano_seconds;
|
|
|
|
|
struct timeval current_time;
|
|
|
|
|
struct timezone current_zone;
|
|
|
|
|
|
|
|
|
|
/* get time since 01.01.1970 00:00 */
|
|
|
|
|
gettimeofday (¤t_time, ¤t_zone);
|
|
|
|
|
gettimeofday (¤t_time, NULL);
|
|
|
|
|
hundred_nano_seconds = (62135596800L + current_time.tv_sec) * 10000000L +
|
|
|
|
|
current_time.tv_usec * 10L;
|
|
|
|
|
return hundred_nano_seconds;
|
|
|
|
@ -486,5 +485,5 @@ int64_t SER::differenceLocalUTC(void) {
|
|
|
|
|
|
|
|
|
|
fprintf(stdout, "Debug: difference between local time and UTC is %ld hours\n",
|
|
|
|
|
(loc_ts - gmt_ts) / 3600);
|
|
|
|
|
return ((int64_t)gmt_ts - (int64_t)loc_ts) * 10000000L;
|
|
|
|
|
return ((int64_t)loc_ts - (int64_t)gmt_ts) * 10000000L;
|
|
|
|
|
}
|
|
|
|
|