From 5e676ed1108621da709b45a9aba6e091ff324728 Mon Sep 17 00:00:00 2001 From: IshanGrover2004 Date: Mon, 8 Jul 2024 05:56:38 +0530 Subject: [PATCH] feat: Add extern functions in C and use in proper place --- src/lib_ccx/ccx_common_common.c | 3 +++ src/lib_ccx/ccx_common_common.h | 5 +++++ src/lib_ccx/utility.c | 15 +++++++++++++++ src/lib_ccx/utility.h | 4 ++++ 4 files changed, 27 insertions(+) diff --git a/src/lib_ccx/ccx_common_common.c b/src/lib_ccx/ccx_common_common.c index 91a765283..f150da7d2 100644 --- a/src/lib_ccx/ccx_common_common.c +++ b/src/lib_ccx/ccx_common_common.c @@ -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 diff --git a/src/lib_ccx/ccx_common_common.h b/src/lib_ccx/ccx_common_common.h index b26c6965a..d9f6c3218 100644 --- a/src/lib_ccx/ccx_common_common.h +++ b/src/lib_ccx/ccx_common_common.h @@ -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); diff --git a/src/lib_ccx/utility.c b/src/lib_ccx/utility.c index 2be551f5c..b1a0c22af 100644 --- a/src/lib_ccx/utility.c +++ b/src/lib_ccx/utility.c @@ -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; @@ -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); @@ -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); @@ -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]; diff --git a/src/lib_ccx/utility.h b/src/lib_ccx/utility.h index a11e71329..6fc6eafa1 100644 --- a/src/lib_ccx/utility.h +++ b/src/lib_ccx/utility.h @@ -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);