diff options
| author | Xavier Del Campo Romero <xavier.delcampo@orain.io> | 2020-05-20 14:35:59 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavier.delcampo@orain.io> | 2020-05-20 14:35:59 +0200 |
| commit | 9e183ec0a6951723a80e8719525ccdbaecd62e17 (patch) | |
| tree | 28cfe34fc80c14e66f89df8bbcec8e4ae55c594e /README.md | |
| parent | 71a3db14a5383b73eb719b1d3f479d32fc81ad3a (diff) | |
- C11 support is required (although only on serializer.c, so the check has
been moved there) since _Alignof is needed.
- Added support for little/big endian 64-bit integers.
- swap16, swap32 and swap64 now cast pointers to (uint8_t *) and (const uint8_t *)
from the argument list so the explicit casts are no longer needed.
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -1,13 +1,13 @@ -Serializer/deserializer library for C99 +Serializer/deserializer library for C11 ======================================= This library hopes to be useful under certain circumstances where a portable implementation is desired to read/write data streams yet endianness and alignment requirements need to be taken into account e.g.: network protocols, -file formats, etc. As the title specifies, only a C99-compliant compiler is +file formats, etc. As the title specifies, only a C11-compliant compiler is required. -Only 8-bit and 16/32-bit little-endian and big-endian values are supported. +Only 8-bit and 16/32/64-bit little-endian and big-endian values are supported. This means no support for bit fields, as some aspects of bit fields are implementation-defined. @@ -15,7 +15,7 @@ Usage ------ ```{c} -#include "serializer.h" +#include <serializer.h> #include <stdint.h> #include <stdio.h> @@ -27,25 +27,27 @@ int main() uint16_t b; uint32_t c; uint16_t d; + uint64_t e; + uint64_t f; } ex; static const uint8_t data[] = { - 0x01, 0x33, 0xFF, 0xAC, 0xBB, 0xFA, 0xFA, 0xDE, 0xDE + 0x01, 0x33, 0xFF, 0xAC, 0xBB, 0xFA, 0xFA, 0xDE, 0xDD, + 0x12, 0x33, 0xFF, 0xAC, 0xBB, 0xFA, 0xFA, 0xDE, + 0x12, 0x33, 0xFF, 0xAC, 0xBB, 0xFA, 0xFA, 0xDE, }; - deserialize("1/le2/be4/be2", &ex, sizeof ex, data, sizeof data); - printf("a=%X, b=%X, c=%X, d=%X\n", - ex.a, ex.b, ex.c, ex.d); + deserialize("1/le2/be4/be2/be8/le8", &ex, sizeof ex, data, sizeof data); + printf("a=%X, b=%X, c=%X, d=%X, e=%lX, f=%lX\n", + ex.a, ex.b, ex.c, ex.d, ex.e, ex.f); return 0; } ``` Output ------ -`a=1, b=FF33, c=ACBBFAFA, d=DEDE` +`a=1, b=FF33, c=ACBBFAFA, d=DEDD, e=1233FFACBBFAFADE, f=DEFAFABBACFF3312` TODO ---- Only deserialization is implemented. Serialization will be implemented in the future. - -64-bit support. |
