Skip to content

Commit

Permalink
feat: Call extern ccxr_ functions in C code
Browse files Browse the repository at this point in the history
  • Loading branch information
IshanGrover2004 committed Jul 14, 2024
1 parent 7509562 commit ccb1b40
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib_ccx/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ static uint32_t crc32_table[] = {

int verify_crc32(uint8_t *buf, int len)
{
#ifndef DISABLE_RUST
return ccxr_verify_crc32(buf, len);
#endif /* ifndef DISABLE_RUST */
int i = 0;
int32_t crc = -1;
for (i = 0; i < len; i++)
Expand Down Expand Up @@ -151,6 +154,9 @@ void timestamp_to_vtttime(uint64_t timestamp, char *buffer)

int levenshtein_dist(const uint64_t *s1, const uint64_t *s2, unsigned s1len, unsigned s2len)
{
#ifndef DISABLE_RUST
return ccxr_levenshtein_dist(s1, s2, s1len, s2len);
#endif
unsigned int x, y, v, lastdiag, olddiag;
unsigned int *column = (unsigned *)malloc((s1len + 1) * sizeof(unsigned int));
for (y = 1; y <= s1len; y++)
Expand All @@ -172,6 +178,9 @@ int levenshtein_dist(const uint64_t *s1, const uint64_t *s2, unsigned s1len, uns

int levenshtein_dist_char(const char *s1, const char *s2, unsigned s1len, unsigned s2len)
{
#ifndef DISABLE_RUST
return ccxr_levenshtein_dist_char(s1, s2, s1len, s2len);
#endif
unsigned int x, y, v, lastdiag, olddiag;
unsigned int *column = (unsigned *)malloc((s1len + 1) * sizeof(unsigned int));
for (y = 1; y <= s1len; y++)
Expand Down
6 changes: 6 additions & 0 deletions src/lib_ccx/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ struct ccx_rational
extern int temp_debug;
volatile extern sig_atomic_t change_filename_requested;

#ifndef DISABLE_RUST
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);
#endif

int levenshtein_dist_char (const char *s1, const char *s2, unsigned s1len, unsigned s2len);
void init_boundary_time (struct ccx_boundary_time *bt);
void print_error (int mode, const char *fmt, ...);
Expand Down

0 comments on commit ccb1b40

Please sign in to comment.