71 #if defined( MBG_TGT_WIN32 ) 156 __attribute__( ( format( printf, 3, 4 ) ) )
162 va_start( args, fmt );
211 for ( i = 0; i < n; i++ )
216 if ( i >= ( INT_MAX - 1 ) )
244 int mday,
int month )
246 int n =
snprintf_safe( s, max_len,
"%02u.%02u.", mday, month );
269 int mday,
int month,
int year )
321 int hour,
int min,
int sec )
349 int hour,
int min,
int sec,
int sec100 )
539 struct tm tm = { 0 };
544 mbg_str_date( s, max_len, tm.tm_mday, tm.tm_mon + 1, tm.tm_year ) :
566 struct tm tm = { 0 };
571 mbg_str_time( s, max_len, tm.tm_hour, tm.tm_min, tm.tm_sec ) :
595 struct tm tm = { 0 };
601 n =
mbg_str_date( s, max_len, tm.tm_mday , tm.tm_mon + 1, tm.tm_year );
603 n +=
mbg_str_time( &s[n], max_len - n, tm.tm_hour, tm.tm_min, tm.tm_sec );
711 ldiv_t ldt = ldiv( labs( pt->
utc_offs ) / 60, 60 );
741 if ( n < ( max_len - 1 ) )
770 if ( n < ( max_len - 1 ) )
776 if ( n < ( max_len - 1 ) )
778 const char *cp =
"UTC";
882 const DMS *pdms,
int prec )
926 const POS *ppos,
int prec )
970 size_t l = strlen( short_name );
988 if ( l >
sizeof( dev_name ) )
991 for ( i = 0; i < l; i++ )
993 if ( short_name[i] ==
'_' )
999 dev_name[i] = short_name[i];
1002 strncpy_safe( sernum, &short_name[i],
sizeof( sernum ) );
1012 n =
snprintf_safe( s, max_len,
"%s, S/N %s", dev_name, sernum );
1014 if ( fw_rev_num || asic_ver_num )
1036 if ( fw_rev_num || asic_ver_num )
1047 #if defined( MBG_TGT_WIN32 ) 1049 BOOL APIENTRY DllMain( HANDLE hModule,
1050 DWORD ul_reason_for_call,
1056 #endif // defined( MBG_TGT_WIN32 ) DMS longitude
Longitude broken down to degrees, minutes, seconds.
#define PCPS_HRT_FRAC_SCALE
Scale to be used to print PCPS_TIME_STAMP::frac values.
int mbg_str_tm_gps_date_time(char *s, int max_len, const TM_GPS *pt)
Write a full date and time string to a string buffer.
uint8_t year
year of the century, 0..99
#define _pcps_fw_rev_num_minor(_v)
#define _pcps_fw_rev_num_major(_v)
int mbgutil_check_version(int header_version)
Check if the DLL/shared library is compatible with a given version.
char * strncpy_safe(char *dst, const char *src, size_t max_len)
A portable, safe implementation of strncpy()
uint8_t mday
day of month, 0..31
uint8_t sec100
hundredths of seconds, 0..99, 10 ms resolution
#define _pcps_asic_version_major(_v)
Extract the major part of an ASIC version number.
int mbg_snprintf(char *s, size_t max_len, const char *fmt,...)
A portable, safer implementation of snprintf().
Local date and time computed from GPS time.
int mbg_str_ucap(char *s, int max_len, const PCPS_HR_TIME *pt)
Write time capture / user capture time stamp to a string buffer.
PCPS_SECONDS sec
seconds since 1970, usually UTC scale
int8_t sec
seconds, 0..59, or 60 in case of inserted leap second
#define _int_from_size_t(_n)
int mbg_strchar(char *s, size_t max_len, char c, size_t n)
Write a character multiple times to a string buffer.
int mbg_str_pos(char *s, int max_len, const POS *ppos, int prec)
Write geographic coordinates to a string buffer.
int sn_cpy_str_safe(char *dst, size_t max_len, const char *src)
A function to copy a string safely, returning the number of characters copied.
#define mbg_rc_is_success(_rc)
DMS latitude
Latitude broken down to degrees, minutes, seconds.
static __mbg_inline bool device_id_is_serial(const char *dev_id)
Check if a device ID refers to a serial port.
int8_t mday
day of month, 1..31
#define PCPS_ASIC_STR_FMT
int16_t year
year number, 0..9999
int mbg_str_time(char *s, int max_len, int hour, int min, int sec)
Write a time string "hh:mm:ss" to a string buffer.
#define PCPS_HRT_FRAC_SCALE_FMT
Format specifier used to print PCPS_TIME_STAMP::frac values.
int mbg_str_pos_dms(char *s, int max_len, const DMS *pdms, int prec)
Write a geographic coordinate in degrees - minutes - seconds to a string buffer.
int32_t utc_offs
UTC offs [sec] (loc_time = tstamp + utc_offs)
static __mbg_inline time_t cvt_to_time_t(mbg_time_t t)
PCPS_TIME_STATUS_X status
status bits, see PCPS_TIME_STATUS_FLAGS
Geographic longitude or latitude in [degrees, minutes, seconds].
int mbg_str_pcps_hr_date_time_loc(char *s, int max_len, const PCPS_HR_TIME *pt)
Write local date and time given as PCPS_HR_TIME structure to a string buffer.
#define MBG_ERR_LIB_NOT_COMPATIBLE
Installed shared library version not compatible with version used at build time.
int mbg_str_dev_name(char *s, int max_len, const char *short_name, uint16_t fw_rev_num, PCI_ASIC_VERSION asic_ver_num)
Write device info to a string buffer.
int mbg_str_pcps_hr_time_frac(char *s, int max_len, uint32_t frac)
Print binary PCPS_FRAC_32 fractions in decimal to a string buffer.
uint16_t prefix
'N', 'E', 'S' or 'W'
uint16_t deg
[0...90 (lat) or 0...180 (lon)]
PCPS_FRAC_32 frac
binary fractions of second, see PCPS_FRAC_32
char PCPS_SN_STR[(16+1)]
A buffer for a serial number string, including terminating 0.
PCPS_TIME_STAMP tstamp
High resolution time stamp (UTC)
#define MBG_GRP_SERNUM_LEN
const char * str_not_avail
int vsnprintf_safe(char *s, size_t max_len, const char *fmt, va_list args)
A portable, safe implementation of vsnprintf()
int mbg_str_pcps_hr_tstamp_loc(char *s, int max_len, const PCPS_HR_TIME *pt)
Write a high resolution local time stamp including fractions to a string buffer.
int mbg_str_pcps_hr_date_time_utc(char *s, int max_len, const PCPS_HR_TIME *pt)
Write UTC date and time given as PCPS_HR_TIME structure to a string buffer.
char MBG_DEV_NAME[10+(16+1)+1]
A string buffer for a unique device ID.
int mbg_str_date(char *s, int max_len, int mday, int month, int year)
Write a date string "dd.mm.yyyy" to a string buffer.
int mbg_str_pos_alt(char *s, int max_len, double alt)
Write a position's altitude parameter to a string buffer.
int mbg_str_time_long(char *s, int max_len, int hour, int min, int sec, int sec100)
Write a long time string "hh:mm:ss.cc" to a string buffer.
int mbg_str_pcps_hr_time(char *s, int max_len, uint32_t sec)
Write time derived from seconds-since-epoch to a string buffer.
#define MBG_SUCCESS
Error codes used with Meinberg devices and drivers.
int mbgutil_get_version(void)
Get the version number of the precompiled DLL/shared object library.
static __mbg_inline int mbg_gmtime(struct tm *p_tm, const time_t *p_time)
A geographic position represented in different formats.
int mbg_str_pcps_hr_time_raw(char *s, int max_len, const PCPS_HR_TIME *pt)
Write a raw high resolution time stamp plus converted local time to a string buffer.
int mbg_str_pcps_hr_tstamp_utc(char *s, int max_len, const PCPS_HR_TIME *pt)
Write a high resolution UTC time stamp including fractions to a string buffer.
static __mbg_inline int pcps_exp_year(int year, int year_lim)
Expand a 2-digit year number to a 4-digit year number.
static __mbg_inline uint32_t bin_frac_32_to_dec_frac(uint32_t bin, uint32_t scale)
Convert a 32 bit binary fraction to a scaled decimal.
static const char str_inv_cnv[]
High resolution time including status and local time offset.
int mbg_str_date_short(char *s, int max_len, int mday, int month)
Write a short date string "dd.mm." to a string buffer.
int mbg_str_pcps_date(char *s, int max_len, const PCPS_TIME *pt)
Write the date given as PCPS_TIME structure to a string buffer.
static int mbg_date_time_dist
int mbg_str_pcps_date_time(char *s, int max_len, const PCPS_TIME *pt, const char *tz_str)
Write date and time given as PCPS_TIME structure to a string buffer.
uint32_t PCI_ASIC_VERSION
A data type to hold the PCI ASIC version code.
PCPS_SIG_VAL signal
signal strength, see PCPS_SIG_VAL_DEFS, or capture input channel number
Local calendar date and time, plus sync status.
LLA lla
Longitude, latitude and altitude, depending on the ellipsoid used for reference.
A high resolution time stamp.
int mbg_str_time_short(char *s, int max_len, int hour, int min)
Write a short time string "hh:mm" to a string buffer.
int mbg_str_pcps_time(char *s, int max_len, const PCPS_TIME *pt)
Write the time given as PCPS_TIME structure to a string buffer.
int snprintf_safe(char *s, size_t max_len, const char *fmt,...)
A portable, safe implementation of snprintf()
#define _pcps_asic_version_minor(_v)
Extract the minor part of an ASIC version number.
int mbg_str_pcps_hr_date(char *s, int max_len, uint32_t sec)
Write date derived from seconds-since-epoch to a string buffer.
double sec
[0...59.99999...]
static uint16_t mbg_year_lim
uint8_t min
minutes, 0..59
#define _convert_asic_version_number(_n)
Version number conversion macro.
int mbg_strncpy(char *s, size_t max_len, const char *src)
A portable, safe implementation of strncpy()
static int do_str_pcps_hr_date_time(char *s, int max_len, const time_t *p_t)
int mbg_str_pcps_time_short(char *s, int max_len, const PCPS_TIME *pt)
Write the short time given as PCPS_TIME structure to a string buffer.
int mbg_str_pcps_hr_time_offs(char *s, int max_len, const PCPS_HR_TIME *pt, const char *info)
Print the UTC offset from a PCPS_HR_TIME structure to a string buffer.
uint8_t month
month, 1..12
int mbg_str_pcps_date_short(char *s, int max_len, const PCPS_TIME *pt)
Write the short date given as PCPS_TIME structure to a string buffer.
int mbg_str_pcps_tstamp_raw(char *s, int max_len, const PCPS_TIME_STAMP *pt)
Write a raw high resolution time stamp to a string buffer.
uint8_t sec
seconds, 0..59, or 60 if leap second
int mbg_str_pcps_time_long(char *s, int max_len, const PCPS_TIME *pt)
Write the time including sec100ths given as PCPS_TIME structure to a string buffer.
#define MBGUTIL_COMPAT_VERSION