Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Add time units module in lib_ccxr #1623

Merged
3 changes: 2 additions & 1 deletion docs/CHANGES.TXT
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
0.95 (to be released)
-----------------
- New: Add time units module in lib_ccxr (#1623)
- New: Add bits and levenshtein module in lib_ccxr (#1627)
- New: [FEAT] Add constants module in lib_ccxr (#1624)
- New: Add constants module in lib_ccxr (#1624)
- New: Add log module in lib_ccxr (#1622)
- New: Create `lib_ccxr` and `libccxr_exports` (#1621)
- Fix: Unexpected behavior of get_write_interval (#1609)
Expand Down
3 changes: 3 additions & 0 deletions src/lib_ccx/ccx_common_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ int fdprintf(int fd, const char *fmt, ...)
void millis_to_time(LLONG milli, unsigned *hours, unsigned *minutes,
unsigned *seconds, unsigned *ms)
{
#ifndef DISABLE_RUST
return ccxr_millis_to_time(milli, hours, minutes, seconds, ms);
#endif /* ifndef DISABLE_RUST */
// LLONG milli = (LLONG) ((ccblock*1000)/29.97);
*ms = (unsigned)(milli % 1000); // milliseconds
milli = (milli - *ms) / 1000; // Remainder, in seconds
Expand Down
5 changes: 5 additions & 0 deletions src/lib_ccx/ccx_common_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
int cc608_parity(unsigned int byte);
int fdprintf(int fd, const char *fmt, ...);
void millis_to_time(LLONG milli, unsigned *hours, unsigned *minutes,unsigned *seconds, unsigned *ms);

#ifndef DISABLE_RUST
extern void ccxr_millis_to_time(LLONG milli, unsigned *hours, unsigned *minutes,unsigned *seconds, unsigned *ms);
#endif // !DISABLE_RUST

void freep(void *arg);
void dbg_print(LLONG mask, const char *fmt, ...);
unsigned char *debug_608_to_ASC(unsigned char *ccdata, int channel);
Expand Down
15 changes: 15 additions & 0 deletions src/lib_ccx/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ int verify_crc32(uint8_t *buf, int len)

int stringztoms(const char *s, struct ccx_boundary_time *bt)
{
#ifndef DISABLE_RUST
return ccxr_stringztoms(s, bt);
#endif
unsigned ss = 0, mm = 0, hh = 0;
int value = -1;
int colons = 0;
Expand Down Expand Up @@ -133,6 +136,10 @@ int stringztoms(const char *s, struct ccx_boundary_time *bt)
}
void timestamp_to_srttime(uint64_t timestamp, char *buffer)
{
#ifndef DISABLE_RUST
return ccxr_timestamp_to_srttime(timestamp, buffer);
#endif

uint64_t p = timestamp;
uint8_t h = (uint8_t)(p / 3600000);
uint8_t m = (uint8_t)(p / 60000 - 60 * h);
Expand All @@ -142,6 +149,10 @@ void timestamp_to_srttime(uint64_t timestamp, char *buffer)
}
void timestamp_to_vtttime(uint64_t timestamp, char *buffer)
{
#ifndef DISABLE_RUST
return ccxr_timestamp_to_vtttime(timestamp, buffer);
#endif

uint64_t p = timestamp;
uint8_t h = (uint8_t)(p / 3600000);
uint8_t m = (uint8_t)(p / 60000 - 60 * h);
Expand Down Expand Up @@ -202,6 +213,10 @@ int levenshtein_dist_char(const char *s1, const char *s2, unsigned s1len, unsign

void millis_to_date(uint64_t timestamp, char *buffer, enum ccx_output_date_format date_format, char millis_separator)
{
#ifndef DISABLE_RUST
return ccxr_millis_to_date(timestamp, buffer, date_format, millis_separator);
#endif

time_t secs;
unsigned int millis;
char c_temp[80];
Expand Down
4 changes: 4 additions & 0 deletions src/lib_ccx/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ volatile extern sig_atomic_t change_filename_requested;
extern int ccxr_verify_crc32(uint8_t *buf, int len);
extern int ccxr_levenshtein_dist(const uint64_t *s1, const uint64_t *s2, unsigned s1len, unsigned s2len);
extern int ccxr_levenshtein_dist_char(const char *s1, const char *s2, unsigned s1len, unsigned s2len);
extern void ccxr_timestamp_to_srttime(uint64_t timestamp, char *buffer);
extern void ccxr_timestamp_to_vtttime(uint64_t timestamp, char *buffer);
extern void ccxr_millis_to_date(uint64_t timestamp, char *buffer, enum ccx_output_date_format date_format, char millis_separator);
extern int ccxr_stringztoms(const char *s, struct ccx_boundary_time *bt);
#endif

int levenshtein_dist_char (const char *s1, const char *s2, unsigned s1len, unsigned s2len);
Expand Down
Loading
Loading