Skip to content

Commit

Permalink
feat: Add extern functions in C and use in proper place
Browse files Browse the repository at this point in the history
  • Loading branch information
IshanGrover2004 committed Jul 16, 2024
1 parent 3c18f29 commit 5e676ed
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
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

0 comments on commit 5e676ed

Please sign in to comment.