Document of c-modernization-kit (porter) 1.0.0
Loading...
Searching...
No Matches
compress.h File Reference

データ圧縮・解凍モジュールの内部ヘッダー。 More...

#include <stddef.h>
#include <stdint.h>
#include <porter_const.h>
Include dependency graph for compress.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define POTR_COMPRESS_HEADER_SIZE   4U
 圧縮ペイロード先頭に付加する元サイズフィールドのバイト数。
#define POTR_COMPRESS_BUF_SIZE   (POTR_COMPRESS_HEADER_SIZE + POTR_MAX_MESSAGE_SIZE + 64U)
 圧縮後の最大バッファサイズ (元データ + ヘッダー + DEFLATE オーバーヘッド)。

Functions

int potr_compress (uint8_t *dst, size_t *dst_len, const uint8_t *src, size_t src_len)
 データを圧縮します。
int potr_decompress (uint8_t *dst, size_t *dst_len, const uint8_t *src, size_t src_len)
 圧縮データを解凍します。

Detailed Description

データ圧縮・解凍モジュールの内部ヘッダー。

Author
c-modernization-kit sample team
Date
2026/03/05
Version
1.0.0

プラットフォームごとに異なる圧縮 API を共通インターフェースで抽象化します。

OS 使用ライブラリ フォーマット
Linux zlib (deflate/inflate, windowBits = -15) raw DEFLATE
Windows Compression API (MSZIP | COMPRESS_RAW) raw DEFLATE

両 OS とも raw DEFLATE (RFC 1951) を出力するため、クロスプラットフォーム互換 通信が可能です。

圧縮ペイロードのフォーマット:

[元サイズ: uint32_t (ネットワークバイトオーダー)] [raw DEFLATE データ]

Definition in file compress.h.

Macro Definition Documentation

◆ POTR_COMPRESS_HEADER_SIZE

#define POTR_COMPRESS_HEADER_SIZE   4U

圧縮ペイロード先頭に付加する元サイズフィールドのバイト数。

Definition at line 39 of file compress.h.

Referenced by potr_compress(), potr_decompress(), and potrOpenService().

◆ POTR_COMPRESS_BUF_SIZE

#define POTR_COMPRESS_BUF_SIZE   (POTR_COMPRESS_HEADER_SIZE + POTR_MAX_MESSAGE_SIZE + 64U)

圧縮後の最大バッファサイズ (元データ + ヘッダー + DEFLATE オーバーヘッド)。

Definition at line 42 of file compress.h.

Function Documentation

◆ potr_compress()

int potr_compress ( uint8_t * dst,
size_t * dst_len,
const uint8_t * src,
size_t src_len )
extern

データを圧縮します。

Parameters
[out]dst圧縮後データを格納するバッファ。 先頭 4 バイトに元サイズ (NBO) が書き込まれます。
[in,out]dst_len入力: dst のバッファサイズ。 出力: 書き込んだバイト数。
[in]src圧縮前データへのポインタ。
[in]src_len圧縮前データのバイト数。
Returns
成功時は 0、失敗時は -1 を返します。

Definition at line 29 of file compress_linux.c.

References POTR_COMPRESS_HEADER_SIZE.

Referenced by potrSend().

Here is the caller graph for this function:

◆ potr_decompress()

int potr_decompress ( uint8_t * dst,
size_t * dst_len,
const uint8_t * src,
size_t src_len )
extern

圧縮データを解凍します。

Parameters
[out]dst解凍後データを格納するバッファ。
[in,out]dst_len入力: dst のバッファサイズ。 出力: 書き込んだバイト数。
[in]src圧縮後データへのポインタ (先頭 4 バイトは元サイズ)。
[in]src_len圧縮後データのバイト数 (ヘッダーを含む)。
Returns
成功時は 0、失敗時は -1 を返します。

Definition at line 74 of file compress_linux.c.

References POTR_COMPRESS_HEADER_SIZE.

Referenced by n1_recv_deliver(), and recv_deliver().

Here is the caller graph for this function: