CCSDS 124.0-B-1 C 1.0.0
CCSDS 124.0-B-1 Lossless Compression
Loading...
Searching...
No Matches
cli.c File Reference

CCSDS 124.0-B-1 unified command line interface. More...

#include "ccsds124.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

static void print_version (void)
 Print help message with usage information.
 
static void print_help (const char *prog_name)
 
static void make_decompress_filename (char *output, size_t output_len, const char *input)
 Create output filename for decompression.
 
static int do_compress (const char *input_path, int packet_size, int pt_period, int ft_period, int rt_period, int robustness)
 Compress a file.
 
static int do_decompress (const char *input_path, int packet_size, int robustness)
 Decompress a file.
 
int main (int argc, char **argv)
 CLI entry point.
 

Variables

static const char * BANNER
 ASCII art banner for help output.
 

Detailed Description

CCSDS 124.0-B-1 unified command line interface.

Definition in file cli.c.

Function Documentation

◆ do_compress()

static int do_compress ( const char *  input_path,
int  packet_size,
int  pt_period,
int  ft_period,
int  rt_period,
int  robustness 
)
static

Compress a file.

Parameters
[in]input_pathInput file path.
[in]packet_sizePacket size in bytes.
[in]pt_periodNew mask period.
[in]ft_periodSend mask period.
[in]rt_periodUncompressed period.
[in]robustnessRobustness level (0-7).
Returns
0 on success, 1 on error.

Definition at line 141 of file cli.c.

References ccsds124_compress(), ccsds124_compressor_init(), and CCSDS124_OK.

Referenced by main().

◆ do_decompress()

static int do_decompress ( const char *  input_path,
int  packet_size,
int  robustness 
)
static

Decompress a file.

Parameters
[in]input_pathCompressed input file path.
[in]packet_sizeOriginal packet size in bytes.
[in]robustnessRobustness level (0-7).
Returns
0 on success, 1 on error.

Definition at line 257 of file cli.c.

References ccsds124_decompress(), ccsds124_decompressor_init(), CCSDS124_OK, and make_decompress_filename().

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

CLI entry point.

Parameters
[in]argcArgument count.
[in]argvArgument vector.
Returns
0 on success, 1 on error.

Definition at line 366 of file cli.c.

References do_compress(), do_decompress(), print_help(), and print_version().

◆ make_decompress_filename()

static void make_decompress_filename ( char *  output,
size_t  output_len,
const char *  input 
)
static

Create output filename for decompression.

Removes .pkt extension if present, then appends .depkt.

Parameters
[out]outputOutput buffer.
[in]output_lenBuffer size.
[in]inputInput filename.

Definition at line 110 of file cli.c.

Referenced by do_decompress().

◆ print_help()

static void print_help ( const char *  prog_name)
static

Definition at line 60 of file cli.c.

References BANNER, CCSDS124_VERSION_MAJOR, CCSDS124_VERSION_MINOR, and CCSDS124_VERSION_PATCH.

Referenced by main().

◆ print_version()

static void print_version ( void  )
static

Print help message with usage information.

Parameters
[in]prog_nameProgram name for usage example.

Definition at line 53 of file cli.c.

References CCSDS124_VERSION_MAJOR, CCSDS124_VERSION_MINOR, and CCSDS124_VERSION_PATCH.

Referenced by main().

Variable Documentation

◆ BANNER

const char* BANNER
static
Initial value:
=
" \n"
" \n"
" ____ ____ ____ ____ ____ _ ____ _ _ \n"
" / ___/ ___/ ___|| _ \\/ ___| / |___ \\| || | \n"
"| | | | \\___ \\| | | \\___ \\ | | __) | || |_ \n"
"| |__| |___ ___) | |_| |___) | | |/ __/|__ _| \n"
" \\____\\____|____/|____/|____/ |_|_____| |_| \n"
" \n"
" by T A N A G R A S P A C E \n"
" \n"

ASCII art banner for help output.

Provides a unified command-line interface for CCSDS 124.0-B-1 compression and decompression, similar to gzip.

Usage
ccsds124 [options] <input> <packet_size> [compress_params]
Authors
Georges Labreche georg.nosp@m.es@t.nosp@m.anagr.nosp@m.aspa.nosp@m.ce.co.nosp@m.m - https://georges.fyi
Claude Code (Anthropic) norep.nosp@m.ly@a.nosp@m.nthro.nosp@m.pic..nosp@m.com
See also
https://ccsds.org/Pubs/124x0b1.pdf CCSDS 124.0-B-1 Standard

Definition at line 36 of file cli.c.

Referenced by print_help().