### Building and Installation Source: https://context7.com/uweohse/lrzsz/llms.txt Standard GNU autotools build process for compiling lrzsz from source. ```APIDOC ## Building and Installation ### Description Standard GNU autotools build process for compiling lrzsz from source. ### Commands **Configure with default options:** ```bash ./configure ``` **Configure with custom installation prefix:** ```bash ./configure --prefix=/usr/local ``` **Configure with syslog support enabled:** ```bash ./configure --enable-syslog ``` ``` -------------------------------- ### Install lrzsz Package Source: https://context7.com/uweohse/lrzsz/llms.txt This command installs the lrzsz package onto the system. It may require root privileges for system-wide installation. The installation process also automatically creates symbolic links for protocol variants. ```bash make install ``` -------------------------------- ### Simple File Transfer Example Source: https://github.com/uweohse/lrzsz/blob/master/doc/zmodem-1988-10-14.txt Illustrates a basic ZMODEM file transfer transaction. ```APIDOC ## Simple File Transfer Example ### Description A simple transaction, one file, no errors, no CHALLENGE, overlapped I/O. ### Transaction Flow Sender | Receiver ------- | -------- "rz\r" | ZRQINIT(0) | | ZRINIT ZFILE | | ZRPOS ZDATA data ... | ZEOF | | ZRINIT ZFIN | | ZFIN OO | ``` -------------------------------- ### Build lrzsz from Source (Bash) Source: https://context7.com/uweohse/lrzsz/llms.txt Shows the standard GNU autotools commands for configuring and building the lrzsz project from source code. This includes options for default configuration, custom installation paths, and enabling specific features like syslog support. ```bash # Configure with default options ./configure # Configure with custom installation prefix ./configure --prefix=/usr/local # Configure with syslog support enabled ./configure --enable-syslog ``` -------------------------------- ### Basic lrzsz Command Usage Source: https://context7.com/uweohse/lrzsz/llms.txt Examples of sending commands with lrzsz, including waiting for completion, returning immediately, and using retry counts. ```APIDOC ## Basic lrzsz Command Usage ### Description Examples of sending commands with lrzsz, including waiting for completion, returning immediately, and using retry counts. ### Method `sz` command with various options. ### Examples **Send command and wait for completion, return exit status:** ```bash sz -c "ls -la /tmp" ``` **Send command and return immediately (don't wait for execution):** ```bash sz -i "process_files.sh" ``` **Send command with retry count:** ```bash sz -C 5 -c "backup_database.sh" ``` **Multiple commands in a transfer session:** ```bash sz -c "cd /data" sz -ya *.log sz -c "cleanup.sh" ``` ``` -------------------------------- ### Transfer Multiple Files and Execute Commands (sz) Source: https://context7.com/uweohse/lrzsz/llms.txt Demonstrates sending multiple files and executing commands within a single transfer session. It includes changing directories, transferring log files, and running a cleanup script. ```bash sz -c "cd /data" sz -ya *.log sz -c "cleanup.sh" ``` -------------------------------- ### Configure lrzsz Behavior with Environment Variables (Bash) Source: https://context7.com/uweohse/lrzsz/llms.txt Demonstrates how to configure lrzsz behavior using environment variables. This allows for system-wide or session-specific adjustments to features like security, transfer parameters, and temporary directory usage. ```bash # Enable restricted mode (no absolute paths, no parent directory access) export ZMODEM_RESTRICTED=1 # Set number of null characters before ZDATA frame (for slow modems) export ZNULLS=101 # Set temporary directory for timesync protocol export TMPDIR=/var/tmp # Alternative temp directory variable export TMP=/tmp # Custom output filename when piping to sz ls -la | ONAME=listing.txt sz - ``` -------------------------------- ### Execute Command Immediately (sz) Source: https://context7.com/uweohse/lrzsz/llms.txt Sends a command to the remote system and returns immediately without waiting for the command to complete. This is suitable for background tasks or when immediate feedback is not required. ```bash sz -i "process_files.sh" ``` -------------------------------- ### POST /zmodem/command Source: https://github.com/uweohse/lrzsz/blob/master/doc/zmodem-1988-10-14.txt Initiates a remote command execution sequence using the ZMODEM protocol. ```APIDOC ## POST /zmodem/command ### Description Initiates a command download sequence where the sender requests the receiver to execute a specific command. ### Method POST ### Endpoint /zmodem/command ### Request Example { "command": "rz\r", "type": "ZCOMMAND" } ### Response #### Success Response (200) - **status** (string) - Execution status of the command - **data** (string) - Output or completion signal (ZCOMPL) ``` -------------------------------- ### Build and Test lrzsz Package Source: https://context7.com/uweohse/lrzsz/llms.txt These commands are used to build the lrzsz package from its source code and then run its self-tests to ensure integrity. 'make' compiles the code, and 'make check' executes the tests. ```bash make make check ``` -------------------------------- ### lrzsz Protocol Configuration API (C) Source: https://context7.com/uweohse/lrzsz/llms.txt Provides C structures and functions for configuring lrzsz protocol parameters and I/O modes. It includes enumerations for protocols, file information structures, I/O configurations, and I/O mode control functions. ```c #include "lrzsz.h" /* Protocol enumeration */ enum lrzsz_protocol_enum { LRZSZ_XMODEM, LRZSZ_YMODEM, LRZSZ_ZMODEM }; /* File information structure */ struct lrzsz_fileinfo { char *fname; time_t modtime; mode_t mode; size_t bytes_total; size_t bytes_sent; size_t bytes_received; size_t bytes_skipped; int eof_seen; }; /* I/O configuration */ struct lrzsz_io_config { int two_stopbits; int may_use_stderr; }; /* Main configuration structure */ struct lrzsz_config { struct lrzsz_io_config io; enum lrzsz_protocol_enum protocol; struct lrzsz_fileinfo *file; unsigned long baudrate; }; /* I/O mode control */ #define LRZSZ_IOMODE_RESET 0 #define LRZSZ_IOMODE_RAW 1 #define LRZSZ_IOMODE_UNRAW_G 2 #define LRZSZ_IOMODE_RAW_WITH_FLOWCONTROL 3 int lrzsz_iomode(int fd, int mode, struct lrzsz_config *cfg); void lrzsz_check_stderr(struct lrzsz_config *cfg); unsigned long lrzsz_get_baudrate(unsigned long speedcode); ``` -------------------------------- ### Protocol Configuration API (C) Source: https://context7.com/uweohse/lrzsz/llms.txt Structures and functions provided by the internal C API for configuring protocol parameters and I/O modes for lrzsz. ```APIDOC ## Protocol Configuration API ### Description The internal C API provides structures for configuring protocol parameters and I/O modes. ### Structures and Enums **Protocol enumeration:** ```c enum lrzsz_protocol_enum { LRZSZ_XMODEM, LRZSZ_YMODEM, LRZSZ_ZMODEM }; ``` **File information structure:** ```c struct lrzsz_fileinfo { char *fname; /* Filename */ time_t modtime; /* Modification time */ mode_t mode; /* File permissions */ size_t bytes_total; /* Total file size */ size_t bytes_sent; /* Bytes transmitted */ size_t bytes_received; /* Bytes received */ size_t bytes_skipped; /* Bytes skipped (crash recovery) */ int eof_seen; /* End of file flag */ }; ``` **I/O configuration:** ```c struct lrzsz_io_config { int two_stopbits; /* Use two stop bits */ int may_use_stderr; /* stderr available for progress */ }; ``` **Main configuration structure:** ```c struct lrzsz_config { struct lrzsz_io_config io; enum lrzsz_protocol_enum protocol; struct lrzsz_fileinfo *file; unsigned long baudrate; }; ``` ### I/O Mode Control Defines - `LRZSZ_IOMODE_RESET`: Restore original settings - `LRZSZ_IOMODE_RAW`: Raw mode for transfer - `LRZSZ_IOMODE_UNRAW_G`: YMODEM-g mode - `LRZSZ_IOMODE_RAW_WITH_FLOWCONTROL`: Raw with XON/XOFF ### Functions - `int lrzsz_iomode(int fd, int mode, struct lrzsz_config *cfg);` - `void lrzsz_check_stderr(struct lrzsz_config *cfg);` - `unsigned long lrzsz_get_baudrate(unsigned long speedcode);` ``` -------------------------------- ### ZMODEM Extended Options Source: https://github.com/uweohse/lrzsz/blob/master/doc/zmodem-1988-10-14.txt Information on extended options for file handling and retransmission. ```APIDOC ## ZMODEM Extended Options ### Description Extended options provide advanced file handling capabilities. ### Options - **ZF3**: The Extended Options are bit encoded. - **ZTSPARS**: Special processing for sparse files, or sender managed selective retransmission. Each file segment is transmitted as a separate frame, where the frames are not necessarily contiguous. The sender should end each segment with a ZCRCW data subpacket and process the expected ZACK to insure no data is lost. ZTSPARS cannot be used with ZCNL. ``` -------------------------------- ### Execute Command and Wait for Completion (sz) Source: https://context7.com/uweohse/lrzsz/llms.txt Executes a command on the remote system and waits for its completion, returning the exit status. This is useful for ensuring a command has finished before proceeding. ```bash sz -c "ls -la /tmp" ``` -------------------------------- ### Define ZMODEM Pathname in Assembly Source: https://github.com/uweohse/lrzsz/blob/master/doc/zmodem-1988-10-14.txt Demonstrates the assembly language representation of a null-terminated ASCII string used for file pathnames in the ZMODEM protocol. ```Assembly DB 'foo.bar',0 ``` -------------------------------- ### ZMODEM Transfer Options Source: https://github.com/uweohse/lrzsz/blob/master/doc/zmodem-1988-10-14.txt Describes different file transfer modes available in ZMODEM. ```APIDOC ## ZMODEM Transfer Options ### Description These options control how files are transferred and overwritten. ### Options - **ZMPROT**: Protect destination file by transferring file only if the destination file is absent. - **ZMNEW**: Transfer file if destination file is absent. Otherwise, transfer file overwriting destination if the source file is newer. - **Default**: Transfer file overwriting destination if files have different lengths or dates. ``` -------------------------------- ### ZMODEM Protocol Overview Source: https://github.com/uweohse/lrzsz/blob/master/doc/zmodem-1988-10-14.txt A summary of the ZMODEM protocol frame types and transaction flow as defined in the technical specification. ```APIDOC ## ZMODEM Protocol Frame Types ### Description This section lists the standard frame types used in ZMODEM communications for session control and data transfer. ### Frame Types - **ZRQINIT** - Request initialization - **ZRINIT** - Receive initialization - **ZSINIT** - Send initialization - **ZFILE** - File metadata transmission - **ZDATA** - Data subpacket transmission - **ZEOF** - End of file marker - **ZFIN** - Session termination - **ZABORT** - Session abort sequence ### Protocol Transactions - **Session Startup**: Initiated via ZRQINIT/ZRINIT exchange. - **File Transmission**: Managed through ZFILE and ZDATA packets. - **Session Cleanup**: Graceful termination using ZFIN. - **Error Recovery**: Handled via ZRPOS (reposition) and ZNAK (negative acknowledgment). ``` -------------------------------- ### ZMODEM File Transfer Management Options (C) Source: https://github.com/uweohse/lrzsz/blob/master/doc/zmodem-1988-10-14.txt Defines constants for ZMODEM file transfer management options, used in the ZFILE frame's ZF1 field. These options dictate how the receiver should handle existing files, such as skipping, overwriting, appending, or comparing files. ```c /* The ZMSKNOLOC bit instructs the receiver to bypass the current file if the receiver does not have a file with the same name. */ /* ZMNEWL Transfer file if destination file absent. Otherwise, transfer file overwriting destination if the source file is newer or longer. */ /* ZMCRC Compare the source and destination files. Transfer if file lengths or file polynomials differ. */ /* ZMAPND Append source file contents to the end of the existing destination file (if any). */ /* ZMCLOB Replace existing destination file (if any). */ /* ZMDIFF Transfer file if destination file absent. Otherwise, */ ``` -------------------------------- ### Perform YMODEM Batch Transfers Source: https://context7.com/uweohse/lrzsz/llms.txt YMODEM allows for batch file transfers including metadata. The sb and rb commands support block size adjustments and error-free channel optimizations. ```bash sb file1.txt file2.txt file3.dat sb -k largefile.bin rb rb -v rb -b sb -a textfile.txt sb -k highspeed.dat ``` -------------------------------- ### Execute Command with Retries (sz) Source: https://context7.com/uweohse/lrzsz/llms.txt Sends a command to the remote system with a specified number of retries. This enhances reliability for commands that might temporarily fail. ```bash sz -C 5 -c "backup_database.sh" ``` -------------------------------- ### Receive Files with ZMODEM Protocol Source: https://context7.com/uweohse/lrzsz/llms.txt The rz command receives files sent via ZMODEM. It includes options for file management, path handling, and connection security. ```bash rz rz -vv rz -b rz -a rz -p rz -y rz -r rz -E rz -t 1200 rz -R rz -R -R rz --min-bps 500 --min-bps-time 180 rz --o-sync rz --junk-path rz --tcp-client 192.168.1.100:5555 rz -B 65536 rz --stop-at 23:30 rz --stop-at +3600 ``` -------------------------------- ### Send Files with ZMODEM Protocol Source: https://context7.com/uweohse/lrzsz/llms.txt The sz command facilitates ZMODEM file transfers. It supports features like 32-bit CRC, crash recovery, binary/ASCII modes, and TCP/IP tunneling. ```bash sz *.c sz -a readme.txt config.ini sz -b -y firmware.bin image.dat sz -r large_backup.tar.gz sz -vv --try-8k datafile.zip ls -la | ONAME=dirlist.txt sz - sz --min-bps 1000 --min-bps-time 60 bigfile.iso sz -R sensitive_data.csv sz -n *.c *.h sz -t 600 -w 4096 archive.tar sz --tcp-server largefile.bin ``` -------------------------------- ### ZMODEM File Transmission Sequence Source: https://github.com/uweohse/lrzsz/blob/master/doc/zmodem-1988-10-14.txt Describes the initiation of a file transfer using ZFILE headers and the subsequent data exchange process. ```APIDOC ## POST /zmodem/file-transfer ### Description Initiates a file transfer session. The sender transmits a ZFILE header containing file metadata, followed by ZDATA subpackets. The receiver may respond with ZSKIP to skip the file, ZCRC to verify integrity, or ZRPOS to request a specific file offset for resumption. ### Method POST ### Endpoint /zmodem/file-transfer ### Request Body - **filename** (string) - Required - Name of the file being sent - **length** (integer) - Required - Total size of the file - **modification_date** (string) - Optional - File modification timestamp - **options** (object) - Optional - ZMODEM conversion and management options ### Response #### Success Response (200) - **status** (string) - Indicates acceptance of file metadata - **action** (string) - Next protocol action (e.g., 'ZDATA', 'ZSKIP', 'ZCRC') #### Response Example { "status": "accepted", "action": "ZDATA", "offset": 0 } ``` -------------------------------- ### ZMODEM Transport Options Source: https://github.com/uweohse/lrzsz/blob/master/doc/zmodem-1988-10-14.txt Details on transport options for data compression and encryption. ```APIDOC ## ZMODEM Transport Options ### Description These options specify data transformation methods during transfer. ### Options - **ZTCRYP**: Encryption. An initial null terminated string identifies the key. Details to be determined. - **ZTRLE**: Run Length encoding. Details to be determined. - **ZTLZW**: Lempel-Ziv compression. Transmitted data will be identical to that produced by compress 4.0 operating on a computer with VAX byte ordering, using 12 bit encoding. - **ZF2**: If the receiver does not implement the particular transport option, the file is copied without conversion for later processing. ``` -------------------------------- ### Perform XMODEM Single File Transfers Source: https://context7.com/uweohse/lrzsz/llms.txt XMODEM handles single file transfers with basic error checking. Both sender and receiver must specify the filename. ```bash sx document.pdf rx document.pdf sx -k largefile.bin rx -c important.dat sx -a readme.txt rx -t 300 slowfile.bin ``` -------------------------------- ### ZMODEM File Transfer Conversion Options (C) Source: https://github.com/uweohse/lrzsz/blob/master/doc/zmodem-1988-10-14.txt Defines constants for ZMODEM file transfer conversion options, used in the ZFILE frame's ZF0 field. These options control how the receiver handles file content, such as inhibiting conversion, converting line endings, or recovering interrupted transfers. ```c /* ZCBIN "Binary" transfer - inhibit conversion unconditionally */ /* ZCNL Convert received end of line to local end of line convention. */ /* ZCRECOV Recover/Resume interrupted file transfer. */ ``` -------------------------------- ### ZMODEM Session Cleanup Source: https://github.com/uweohse/lrzsz/blob/master/doc/zmodem-1988-10-14.txt Describes the graceful termination of a ZMODEM session using the ZFIN header exchange. ```APIDOC ## POST /zmodem/session/terminate ### Description Closes the ZMODEM session. The sender initiates the shutdown with a ZFIN header, and the receiver acknowledges the termination with a corresponding ZFIN header. ### Method POST ### Endpoint /zmodem/session/terminate ### Request Body - **header_type** (string) - Required - Must be 'ZFIN' ### Response #### Success Response (200) - **status** (string) - Confirmation of session closure - **ack** (string) - Receiver ZFIN acknowledgment #### Response Example { "status": "closed", "ack": "ZFIN" } ``` -------------------------------- ### POST /zmodem/file-metadata Source: https://github.com/uweohse/lrzsz/blob/master/doc/zmodem-1988-10-14.txt Transmits file metadata using the ZFILE frame format. ```APIDOC ## POST /zmodem/file-metadata ### Description Sends file information including pathname, length, modification date, and file mode as part of the ZFILE frame. ### Method POST ### Endpoint /zmodem/file-metadata ### Request Body - **pathname** (string) - Required - Null terminated ASCII string representing the file name. - **length** (decimal) - Optional - Number of data bytes in the file. - **mod_date** (octal) - Optional - Modification date in seconds from Jan 1 1970. - **file_mode** (octal) - Optional - Unix file mode bits. - **serial_number** (octal) - Optional - Serial number of the transmitting program. ### Request Example { "pathname": "foo.bar", "length": "1024", "mod_date": "5849201", "file_mode": "0100644" } ### Response #### Success Response (200) - **status** (string) - Acknowledgment of file metadata receipt ``` -------------------------------- ### Environment Variables for lrzsz Source: https://context7.com/uweohse/lrzsz/llms.txt Configuration of lrzsz behavior through environment variables for system-wide or session-specific settings. ```APIDOC ## Environment Variables ### Description Configure lrzsz behavior through environment variables for system-wide or session-specific settings. ### Variables - **`ZMODEM_RESTRICTED`**: Enable restricted mode (no absolute paths, no parent directory access). ```bash export ZMODEM_RESTRICTED=1 ``` - **`ZNULLS`**: Set number of null characters before ZDATA frame (for slow modems). ```bash export ZNULLS=101 ``` - **`TMPDIR`**: Set temporary directory for timesync protocol. ```bash export TMPDIR=/var/tmp ``` - **`TMP`**: Alternative temp directory variable. ```bash export TMP=/tmp ``` - **Custom output filename when piping to sz:** ```bash ls -la | ONAME=listing.txt sz - ``` ``` -------------------------------- ### ZMODEM Protocol Constants (C) Source: https://context7.com/uweohse/lrzsz/llms.txt Defines constants used in the ZMODEM protocol for frame types, control sequences, receiver capabilities, and file management options. These are essential for implementing or understanding ZMODEM communication. ```c #include "zmodem.h" /* Frame type indicators */ #define ZPAD '*' #define ZDLE 030 #define ZBIN 'A' #define ZHEX 'B' #define ZBIN32 'C' /* Frame types */ #define ZRQINIT 0 #define ZRINIT 1 #define ZSINIT 2 #define ZACK 3 #define ZFILE 4 #define ZSKIP 5 #define ZNAK 6 #define ZABORT 7 #define ZFIN 8 #define ZRPOS 9 #define ZDATA 10 #define ZEOF 11 #define ZFERR 12 #define ZCRC 13 #define ZFREECNT 17 #define ZCOMMAND 18 /* Receiver capability flags (ZRINIT ZF0) */ #define CANFDX 0x01 #define CANOVIO 0x02 #define CANBRK 0x04 #define CANFC32 0x20 #define ESCCTL 0x40 /* File conversion options (ZFILE ZF0) */ #define ZCBIN 1 #define ZCNL 2 #define ZCRESUM 3 /* File management options (ZFILE ZF1) */ #define ZF1_ZMNEWL 1 #define ZF1_ZMCRC 2 #define ZF1_ZMAPND 3 #define ZF1_ZMCLOB 4 #define ZF1_ZMNEW 5 #define ZF1_ZMPROT 7 #define ZF1_ZMCHNG 8 ``` -------------------------------- ### ZMODEM Protocol Constants Source: https://context7.com/uweohse/lrzsz/llms.txt Defines constants and flags used within the ZMODEM protocol for frame types, capabilities, and file management. ```APIDOC ## ZMODEM Protocol Constants ### Description The ZMODEM protocol uses specific frame types and control sequences for reliable data transfer. ### Frame Indicators - `ZPAD`: Padding character begins frames - `ZDLE`: Ctrl-X escape character - `ZBIN`: Binary frame with 16-bit CRC - `ZHEX`: HEX frame indicator - `ZBIN32`: Binary frame with 32-bit CRC ### Frame Types - `ZRQINIT`: Request receive init - `ZRINIT`: Receive init - `ZSINIT`: Send init sequence - `ZACK`: Acknowledgment - `ZFILE`: File name from sender - `ZSKIP`: Skip this file - `ZNAK`: Last packet garbled - `ZABORT`: Abort transfer - `ZFIN`: Finish session - `ZRPOS`: Resume at position - `ZDATA`: Data packets follow - `ZEOF`: End of file - `ZFERR`: Fatal error - `ZCRC`: File CRC request/response - `ZFREECNT`: Free space request - `ZCOMMAND`: Remote command ### Receiver Capability Flags (ZRINIT ZF0) - `CANFDX`: Full duplex capable - `CANOVIO`: Can receive during disk I/O - `CANBRK`: Can send break signal - `CANFC32`: 32-bit CRC capable - `ESCCTL`: Expects escaped control chars ### File Conversion Options (ZFILE ZF0) - `ZCBIN`: Binary transfer - `ZCNL`: Convert NL to local EOL - `ZCRESUM`: Resume interrupted transfer ### File Management Options (ZFILE ZF1) - `ZF1_ZMNEWL`: Transfer if newer or longer - `ZF1_ZMCRC`: Transfer if different CRC - `ZF1_ZMAPND`: Append to existing file - `ZF1_ZMCLOB`: Replace existing file - `ZF1_ZMNEW`: Transfer if source newer - `ZF1_ZMPROT`: Protect destination file - `ZF1_ZMCHNG`: Rename if destination exists ```