//------------------------------------------------------------------------------------------
-// read a ber value from the buffer and compare with test value.
-// Advances buffer to first character after BER value.
-
// read a ber value from the buffer and compare with test value.
// Advances buffer to first character after BER value.
//
0
};
+//
+ui32_t
+Kumu::get_BER_length_for_value(ui64_t val)
+{
+ for ( ui32_t i = 0; i < 9; i++ )
+ {
+ if ( ( val & ber_masks[i] ) == 0 )
+ return i + 1;
+ }
+
+ ui64Printer tmp_i(val);
+ DefaultLogSink().Error("BER integer encoding not supported for large value %s\n", tmp_i.c_str());
+ return 0;
+}
//
bool
{ // sanity check BER length
if ( ber_len > 9 )
{
- DefaultLogSink().Error("BER size %u exceeds maximum size of 9\n", ber_len);
+ DefaultLogSink().Error("BER integer length %u exceeds maximum size of 9\n", ber_len);
return false;
}
- if ( val & ber_masks[ber_len - 1] )
+ if ( ( val & ber_masks[ber_len - 1] ) != 0 )
{
ui64Printer tmp_i(val);
- DefaultLogSink().Error("BER size %u too small for value %s\n", tmp_i.c_str());
+ DefaultLogSink().Error("BER integer length %u too small for value %s\n", ber_len, tmp_i.c_str());
return false;
}
}
}
}
+//
+void
+Kumu::Timestamp::AddSeconds(i32_t seconds)
+{
+ SYSTEMTIME current_st;
+ FILETIME current_ft;
+ ULARGE_INTEGER current_ul;
+
+ if ( seconds != 0 )
+ {
+ TIMESTAMP_TO_SYSTIME(*this, ¤t_st);
+ SystemTimeToFileTime(¤t_st, ¤t_ft);
+ memcpy(¤t_ul, ¤t_ft, sizeof(current_ul));
+ current_ul.QuadPart += ( seconds_to_ns100(1) * (i64_t)seconds );
+ memcpy(¤t_ft, ¤t_ul, sizeof(current_ft));
+ FileTimeToSystemTime(¤t_ft, ¤t_st);
+ SYSTIME_TO_TIMESTAMP(¤t_st, *this);
+ }
+}
+
#else // KM_WIN32
#include <time.h>
}
}
+//
+void
+Kumu::Timestamp::AddSeconds(i32_t seconds)
+{
+ Kumu::TAI::caltime ct;
+ Kumu::TAI::tai t;
+
+ if ( seconds != 0 )
+ {
+ TIMESTAMP_TO_CALTIME(*this, &ct)
+ t = ct;
+ t.add_seconds(seconds);
+ ct = t;
+ CALTIME_TO_TIMESTAMP(&ct, *this)
+ }
+}
+
#endif // KM_WIN32