### Install Debian Package Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Installs the generated .deb file using apt-get and verifies the installation path. ```text $ sudo apt-get install ./kits/debian/bullseye/lzhuf_2022.10.08-1.0_amd64.deb Reading package lists... Done Building dependency tree... Done Reading state information... Done Note, selecting 'lzhuf' instead of './kits/debian/bullseye/lzhuf_2022.10.08-1.0_amd64.deb' The following NEW packages will be installed: lzhuf 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/7,704 B of archives. After this operation, 36.9 kB of additional disk space will be used. Get:1 /mnt/aviary/home/malmberg/work/d-rats/lzhuf/kits/debian/bullseye/lzhuf_2022.10.08-1.0_amd64.deb lzhuf amd64 2022.10.08-1.0 [7,704 B] Selecting previously unselected package lzhuf. (Reading database ... 193355 files and directories currently installed.) Preparing to unpack .../lzhuf_2022.10.08-1.0_amd64.deb ... Unpacking lzhuf (2022.10.08-1.0) ... Setting up lzhuf (2022.10.08-1.0) ... Processing triggers for man-db (2.9.4-2) ... $ command -v lzhuf /usr/bin/lzhuf ``` -------------------------------- ### Setup WiX environment Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Add WiX tools to the system path for MSI generation. ```batch .\msbuild_setup.bat ``` -------------------------------- ### Install and Verify Debian Packages Source: https://context7.com/ham-radio-software/lzhuf/llms.txt Commands to install a local .deb package and verify the installation. ```bash # Install from local .deb file sudo apt-get install ./kits/debian/bullseye/lzhuf_2022.10.08-1.0_amd64.deb # Verify installation command -v lzhuf # Output: /usr/bin/lzhuf # View man page man lzhuf ``` -------------------------------- ### Compile and Link MSI packages Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Use candle and light to compile and link 32-bit and 64-bit MSI installers, generate checksums, and organize output files. ```batch candle lzhuf_x86.wxs Windows Installer XML Toolset Compiler version 3.11.2.4516 Copyright (c) .NET Foundation and contributors. All rights reserved. lzhuf_x86.wxs light.exe lzhuf_x86.wixobj Windows Installer XML Toolset Linker version 3.11.2.4516 Copyright (c) .NET Foundation and contributors. All rights reserved. candle -arch x64 lzhuf_x64.wxs Windows Installer XML Toolset Compiler version 3.11.2.4516 Copyright (c) .NET Foundation and contributors. All rights reserved. lzhuf_x64.wxs light.exe lzhuf_x64.wixobj Windows Installer XML Toolset Linker version 3.11.2.4516 Copyright (c) .NET Foundation and contributors. All rights reserved. certutil -hashfile ./lzhuf_x64.msi MD5 > lzhuf_md5.txt certutil -hashfile ./lzhuf_x86.msi MD5 >> lzhuf_md5.txt if not exist ".\kits\" mkdir kits if not exist ".\kits\windows\" mkdir kits\windows move lzhuf_x64.msi kits\windows move lzhuf_x86.msi kits\windows move lzhuf_md5.txt kits\windows ``` -------------------------------- ### Build MSI package on Windows Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Execute the build batch script to generate MSI installation packages. ```batch packaging/build_msi.bat ``` -------------------------------- ### Generate MD5 checksum for binary Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Create an MD5 hash file for the installed binary using the current user and architecture environment variables. ```bash md5sum /usr/local/bin/lzhuf > lzhuf_$USER_platform_$ARCH.txt ``` -------------------------------- ### Install Git pre-commit hook Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Configure the pre-commit hook to run automated tests before committing changes. ```bash cp tests/pre-commit .git/hooks chmod 755 .git/hooks/pre-commit ``` -------------------------------- ### Generate GUID for WIX Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Generate a unique identifier for WIX configuration files. ```batch uuidgen 90df1c51-94ec-45b0-99e7-deae057c2482 ``` -------------------------------- ### Configure QEMU for Multi-arch Docker Builds Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Registers QEMU user-static binaries to enable cross-platform emulation in Docker. ```bash docker run --rm --privileged multiarch/qemu-user-static \ --reset -p yes --credential yes ``` -------------------------------- ### Deploy LZHUF binary on Linux Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Copy the LZHUF binary to the local system bin directory. ```bash cp ./lzhuf /usr/local/bin/ ``` -------------------------------- ### Verify QEMU Configuration Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Checks the binfmt_misc configuration for aarch64 to ensure emulation is enabled. ```text cat /proc/sys/fs/binfmt_misc/qemu-aarch64 enabled interpreter /usr/bin/qemu-aarch64-static flags: OCF offset 0 magic 7f454c460201010000000000000000000200b700 mask ffffffffffffff00fffffffffffffffffeffffff ``` -------------------------------- ### List Built Debian Packages Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Displays the contents of the build output directory for a specific distribution. ```text $ ls kits/ubuntu/jammy lzhuf_2022.10.08_amd64.deb lzhuf_2022.10.08.dsc lzhuf_2022.10.08.debian.tar.xz lzhuf_2022.10.08.orig.tar.gz md5sum.txt ``` -------------------------------- ### Build lzhuf from Source Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Cleans previous build artifacts and compiles the software. ```text make clean make ``` -------------------------------- ### Build LZHUF with MSBuild Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Compile the project for both 32-bit and 64-bit configurations using MSBuild. ```batch msbuild lzhuf.vcxproj -t:build -p:Configuration=Release -p:Platform=Win32 msbuild lzhuf.vcxproj -t:build -p:Configuration=Release -p:Platform=x64make ``` -------------------------------- ### Execute Debian Build Script Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Runs the packaging script to build all Debian packages in a chroot environment. ```text packaging/build_all_debian.sh ``` -------------------------------- ### Build and Package lzhuf Source: https://context7.com/ham-radio-software/lzhuf/llms.txt Commands for building the tool on Linux/Windows and generating distribution packages. ```bash # Linux/Unix build make clean make # The LZHUF preprocessor define is required # gcc -c -DLZHUF lzhuf.c main.c # gcc lzhuf.o main.o -o lzhuf # Windows build with Visual Studio msbuild lzhuf.vcxproj -t:build -p:Configuration=Release -p:Platform=Win32 msbuild lzhuf.vcxproj -t:build -p:Configuration=Release -p:Platform=x64 # Create MSI installer packages (Windows) packaging/build_msi.bat # Build Debian packages in Docker packaging/build_all_debian.sh ``` -------------------------------- ### Test LZHUF on Windows Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Verify compression and decompression functionality using the Windows file comparison utility. ```batch Release\lzhuf e tests\test_data.ref test_data.lzh fc test_data.lzh tests/test_data.lzh_ref Comparing files test_data.lzh and TESTS/TEST_DATA.LZH_REF FC: no differences encountered x64\Release\lzhuf d test_data.lzh test_data.src fc test_data.src tests/test_data.ref Comparing files test_data.src and TESTS/TEST_DATA.REF FC: no differences encountered ``` -------------------------------- ### lzhuf Command Line Interface Source: https://context7.com/ham-radio-software/lzhuf/llms.txt Provides basic file compression and decompression using 'e' for encode and 'd' for decode. ```APIDOC ## lzhuf Command Line Interface ### Description The lzhuf command-line tool provides simple file compression and decompression using the `e` (encode) and `d` (decode) commands. ### Method Command Line Execution ### Endpoint N/A ### Parameters N/A ### Request Example ```bash # Compress a file into lzh format lzhuf e input_file.txt output_file.lzh # Decompress a lzh format file to original lzhuf d compressed_file.lzh restored_file.txt # Example workflow - compress and verify ./lzhuf e tests/test_data.ref test_data.lzh ./lzhuf d test_data.lzh test_data.src diff test_data.src tests/test_data.ref # Should show no differences ``` ### Response N/A ``` -------------------------------- ### Compress and Decompress Files using lzhuf CLI Source: https://context7.com/ham-radio-software/lzhuf/llms.txt Use the lzhuf command-line tool to compress files into .lzh format and decompress them back to their original form. Verify integrity by comparing decompressed output with the original. ```bash # Compress a file into lzh format lzhuf e input_file.txt output_file.lzh # Decompress a lzh format file to original lzhuf d compressed_file.lzh restored_file.txt # Example workflow - compress and verify ./lzhuf e tests/test_data.ref test_data.lzh ./lzhuf d test_data.lzh test_data.src diff test_data.src tests/test_data.ref # Should show no differences ``` -------------------------------- ### AllocStruct Source: https://context7.com/ham-radio-software/lzhuf/llms.txt Allocates and initializes a new lzhufstruct structure for compression/decompression operations. ```APIDOC ## AllocStruct ### Description Allocates and initializes a new lzhufstruct structure containing all buffers required for compression and decompression operations including LZSS trees and Huffman coding tables. ### Method C Function Call ### Endpoint N/A ### Parameters N/A ### Request Example ```c #include "lzhuf.h" int main() { // Allocate the compression/decompression structure struct lzhufstruct *huf = AllocStruct(); if (huf == NULL) { fprintf(stderr, "Failed to allocate lzhuf structure\n"); return 1; } // Use huf for Encode() or Decode() operations... // Always free when done FreeStruct(huf); return 0; } ``` ### Response #### Success Response (Pointer to lzhufstruct) - **huf** (struct lzhufstruct*) - Pointer to the allocated and initialized structure. #### Response Example N/A (Success is indicated by a non-NULL pointer) ``` -------------------------------- ### Test lzhuf Compression and Decompression Source: https://github.com/ham-radio-software/lzhuf/blob/main/README.md Verifies compression and decompression integrity using diff against reference files. ```text ./lzhuf e tests/test_data.ref test_data.lzh diff test_data.lzh tests/test_data.lzh_ref ./lzhuf d test_data.lzh test_data.src diff test_data.src tests/test_data.ref ``` -------------------------------- ### Encode Source: https://context7.com/ham-radio-software/lzhuf/llms.txt Compresses an input file into the lzhuf format, compatible with Winlink systems. ```APIDOC ## Encode ### Description Compresses an input file into the lzhuf format compatible with Winlink systems. Returns 0 on success or an error code (errno or -1) on failure. The function writes a 4-byte little-endian file size header followed by the compressed data. ### Method C Function Call ### Endpoint N/A ### Parameters - **usock** (int) - Optional - Socket descriptor for logging (0 for standalone use). - **input_path** (const char *) - Required - Path to the input file to be compressed. - **output_path** (const char *) - Required - Path for the output compressed file. - **huf** (struct lzhufstruct *) - Required - Pointer to an allocated lzhufstruct. - **b2f** (int) - Optional - Set to 1 for B2F protocol (adds CRC), 0 for standard. ### Request Example ```c #include "lzhuf.h" int compress_file(const char *input_path, const char *output_path) { struct lzhufstruct *huf = AllocStruct(); // Initialize encoding state huf->codesize = 0; huf->getbuf = 0; huf->getlen = 0; huf->putbuf = 0; huf->putlen = 0; huf->code = 0; huf->len = 0; int result = Encode(0, input_path, output_path, huf, 0); if (result != 0) { fprintf(stderr, "Compression failed with error: %d\n", result); } else { // Access compression statistics if (huf->iFileSize > 0) { long ratio = (huf->iFileSize - huf->codesize) * 100L / huf->iFileSize; printf("Compressed %ld bytes to %ld bytes (%ld%% reduction)\n", huf->iFileSize, huf->codesize, ratio); } } FreeStruct(huf); return result; } ``` ### Response #### Success Response (0) - **Return Value** (int) - 0 indicates successful compression. #### Error Response (-1 or errno) - **Return Value** (int) - An error code indicating failure. #### Response Example ``` Compressed 1024 bytes to 512 bytes (50% reduction) ``` ``` -------------------------------- ### Allocate lzhuf Structure Source: https://context7.com/ham-radio-software/lzhuf/llms.txt Allocates and initializes a `lzhufstruct` for compression/decompression. Ensure to free the structure using `FreeStruct` when done to prevent memory leaks. ```c #include "lzhuf.h" int main() { // Allocate the compression/decompression structure struct lzhufstruct *huf = AllocStruct(); if (huf == NULL) { fprintf(stderr, "Failed to allocate lzhuf structure\n"); return 1; } // Use huf for Encode() or Decode() operations... // Always free when done FreeStruct(huf); return 0; } ``` -------------------------------- ### lzhufstruct Data Structure Source: https://context7.com/ham-radio-software/lzhuf/llms.txt The primary C structure for managing compression state, file handles, and algorithm buffers. ```c #include "lzhuf.h" // Key structure fields: struct lzhufstruct { FILE *iFile; // Input file handle FILE *oFile; // Output file handle struct lzhufdata *data; // Internal buffer data int data_type; // 0=single buffer, 1=multiple small buffers // LZSS tree pointers int *dad; // Parent nodes [N+1] int *lson; // Left children [N+1] int *rson; // Right children [N+257] unsigned char *text_buf; // Ring buffer [N+F-1] // Huffman coding tables unsigned int *freq; // Frequency table [T+1] int *prnt; // Parent nodes [T+N_CHAR] int *son; // Child nodes [T] // Compression statistics and state long codesize; // Output code size int match_position; // LZSS match position int match_length; // LZSS match length unsigned getbuf; // Bit input buffer unsigned char getlen; // Bits remaining in getbuf unsigned putbuf; // Bit output buffer unsigned char putlen; // Bits in putbuf unsigned long iFileSize; // Input file size unsigned long oFileSize; // Output file size }; // Constants used in the algorithm: // N = 2048 - Ring buffer size // F = 60 - Lookahead buffer size // THRESHOLD = 2 - Minimum match length for compression // N_CHAR = 314 - Number of character codes (256 - THRESHOLD + F) // T = 627 - Size of Huffman table (N_CHAR * 2 - 1) ``` -------------------------------- ### Encode File using lzhuf Source: https://context7.com/ham-radio-software/lzhuf/llms.txt Compresses a file using the `Encode` function, writing a 4-byte little-endian file size header and compressed data. Set `b2f` to 1 for B2F protocol support (includes CRC). ```c #include "lzhuf.h" int compress_file(const char *input_path, const char *output_path) { struct lzhufstruct *huf = AllocStruct(); // Initialize encoding state huf->codesize = 0; huf->getbuf = 0; huf->getlen = 0; huf->putbuf = 0; huf->putlen = 0; huf->code = 0; huf->len = 0; // Parameters: // usock: socket descriptor for logging (0 for standalone use) // iFile: input filename // oFile: output filename // lzhuf: allocated structure // b2f: set to 1 for B2F protocol (adds CRC), 0 for standard int result = Encode(0, input_path, output_path, huf, 0); if (result != 0) { fprintf(stderr, "Compression failed with error: %d\n", result); } else { // Access compression statistics if (huf->iFileSize > 0) { long ratio = (huf->iFileSize - huf->codesize) * 100L / huf->iFileSize; printf("Compressed %ld bytes to %ld bytes (%ld%% reduction)\n", huf->iFileSize, huf->codesize, ratio); } } FreeStruct(huf); return result; } ``` -------------------------------- ### Decode Source: https://context7.com/ham-radio-software/lzhuf/llms.txt Decompresses an lzhuf-encoded file back to its original form. ```APIDOC ## Decode ### Description Decompresses an lzhuf-encoded file back to its original form. Returns 0 on success or an error code on failure. Reads the 4-byte little-endian file size header and handles endianness conversion automatically. ### Method C Function Call ### Endpoint N/A ### Parameters - **usock** (int) - Optional - Socket descriptor for logging (0 for standalone use). - **compressed_path** (const char *) - Required - Path to the compressed input file. - **output_path** (const char *) - Required - Path for the decompressed output file. - **huf** (struct lzhufstruct *) - Required - Pointer to an allocated lzhufstruct. - **b2f** (int) - Optional - Set to 1 if B2F protocol was used during compression. ### Request Example ```c #include "lzhuf.h" int decompress_file(const char *compressed_path, const char *output_path) { struct lzhufstruct *huf = AllocStruct(); // Initialize decoding state huf->codesize = 0; huf->getbuf = 0; huf->getlen = 0; huf->putbuf = 0; huf->putlen = 0; huf->code = 0; huf->len = 0; int result = Decode(0, compressed_path, output_path, huf, 0); if (result != 0) { fprintf(stderr, "Decompression failed with error: %d\n", result); } FreeStruct(huf); return result; } ``` ### Response #### Success Response (0) - **Return Value** (int) - 0 indicates successful decompression. #### Error Response (-1 or errno) - **Return Value** (int) - An error code indicating failure. #### Response Example N/A ``` -------------------------------- ### FreeStruct Source: https://context7.com/ham-radio-software/lzhuf/llms.txt Releases all memory associated with a lzhufstruct structure. ```APIDOC ## FreeStruct ### Description Releases all memory associated with a lzhufstruct structure, including the internal data buffers for LZSS trees and Huffman tables. ### Method C Function Call ### Endpoint N/A ### Parameters - **lzhuf** (struct lzhufstruct*) - Required - Pointer to the lzhufstruct to be freed. ### Request Example ```c #include "lzhuf.h" void cleanup_compression(struct lzhufstruct *lzhuf) { if (lzhuf != NULL) { // Properly deallocates all internal buffers based on data_type // Handles both single-block and multi-block allocations FreeStruct(lzhuf); } } ``` ### Response N/A ``` -------------------------------- ### Decode File using lzhuf Source: https://context7.com/ham-radio-software/lzhuf/llms.txt Decompresses an lzhuf-encoded file using the `Decode` function. It reads a 4-byte little-endian file size header and automatically handles endianness conversion. Set `b2f` to 1 if the B2F protocol was used during compression. ```c #include "lzhuf.h" int decompress_file(const char *compressed_path, const char *output_path) { struct lzhufstruct *huf = AllocStruct(); // Initialize decoding state huf->codesize = 0; huf->getbuf = 0; huf->getlen = 0; huf->putbuf = 0; huf->putlen = 0; huf->code = 0; huf->len = 0; // Parameters: // usock: socket descriptor for logging (0 for standalone use) // iFile: compressed input filename // oFile: decompressed output filename // lzhuf: allocated structure // b2f: set to 1 if B2F protocol was used during compression int result = Decode(0, compressed_path, output_path, huf, 0); if (result != 0) { fprintf(stderr, "Decompression failed with error: %d\n", result); } FreeStruct(huf); return result; } ``` -------------------------------- ### Free lzhuf Structure Source: https://context7.com/ham-radio-software/lzhuf/llms.txt Releases memory associated with a `lzhufstruct`. This function handles deallocation of internal buffers for LZSS trees and Huffman tables. ```c #include "lzhuf.h" void cleanup_compression(struct lzhufstruct *lzhuf) { if (lzhuf != NULL) { // Properly deallocates all internal buffers based on data_type // Handles both single-block and multi-block allocations FreeStruct(lzhuf); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.