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 options module in lib_ccxr #1559

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ src/rust/CMakeCache.txt
src/rust/Makefile
src/rust/cmake_install.cmake
src/rust/target/
src/rust/lib_ccxr/target/
windows/ccx_rust.lib
windows/*/debug/*
windows/*/CACHEDIR.TAG
windows/.rustc_info.json
windows/.rustc_info.json
8 changes: 8 additions & 0 deletions src/lib_ccx/lib_ccx.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include "ccx_decoders_708.h"
#include "ccx_decoders_isdb.h"

#ifndef DISABLE_RUST
extern void ccxr_init_basic_logger();
#endif

struct ccx_common_logging_t ccx_common_logging;
static struct ccx_decoders_common_settings_t *init_decoder_setting(
struct ccx_s_options *opt)
Expand Down Expand Up @@ -100,6 +104,10 @@ struct lib_ccx_ctx *init_libraries(struct ccx_s_options *opt)
ccx_common_logging.log_ftn = &mprint;
ccx_common_logging.gui_ftn = &activity_library_process;

#ifndef DISABLE_RUST
ccxr_init_basic_logger();
#endif

struct lib_ccx_ctx *ctx = malloc(sizeof(struct lib_ccx_ctx));
if (!ctx)
ccx_common_logging.fatal_ftn(EXIT_NOT_ENOUGH_MEMORY, "init_libraries: Not enough memory allocating lib_ccx_ctx context.");
Expand Down
33 changes: 33 additions & 0 deletions src/lib_ccx/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
int temp_debug = 0; // This is a convenience variable used to enable/disable debug on variable conditions. Find references to understand.
volatile sig_atomic_t change_filename_requested = 0;

#ifndef DISABLE_RUST
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

static uint32_t crc32_table[] = {
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9,
0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
Expand Down Expand Up @@ -86,6 +93,10 @@ 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 @@ -130,6 +141,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 @@ -139,6 +154,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 @@ -193,6 +212,20 @@ 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
switch (date_format)
{
case ODF_NONE:
case ODF_HHMMSS:
case ODF_HHMMSSMS:
case ODF_SECONDS:
case ODF_DATE:
return ccxr_millis_to_date(timestamp, buffer, date_format, millis_separator);
default:
fatal(CCX_COMMON_EXIT_BUG_BUG, "Invalid value for date_format in millis_to_date()\n");
}
#endif

time_t secs;
unsigned int millis;
char c_temp[80];
Expand Down
Loading
Loading