Skip to content
/ struct Public
forked from amozzhuhin/struct

Python 'struct' module implementation for C

License

Notifications You must be signed in to change notification settings

souce/struct

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

struct

This is plain C library implementing same functionality as Python struct module.

Usage

// >>> from struct import *
#include <struct.h>

// >>> pack('hhl', 1, 2, 3)
uint8_t buf[100];
ssize_t size;
size = struct_pack(buf, sizeof(buf), "hhl", 1, 2, 3);

// >>> unpack('hhl', '\x00\x01\x00\x02\x00\x00\x00\x03')
short a, b;
long c;
uint8_t buf[] = { 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00 };
size = struct_unpack(buf, sizeof(buf), "hhl", &a, &b, &c);

// >>> calcsize('hhl')
ssize_t size = struct_calcsize("hhl");

For more exampes see src/tests.c.

About

Python 'struct' module implementation for C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 98.2%
  • Makefile 1.8%