-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathllms.txt
More file actions
63 lines (52 loc) · 2.32 KB
/
llms.txt
File metadata and controls
63 lines (52 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# llms.txt - Guidance for Large Language Models
# Project: Python-CStruct
python-cstruct is a Python module for defining, parsing, and serializing
C-style binary structures using C syntax (`struct`, `union`, `enum`).
It allows users to describe structured binary layouts and convert
between raw bytes and Python objects.
python-cstruct is a Python library for defining and parsing binary data using
C-style syntax (`struct`, `union`, `enum`). It converts C definitions into
Python classes that can pack and unpack raw bytes deterministically.
## What This Project Is
- A binary parsing and serialization library
- Based on C syntax embedded as strings
- Produces Python objects with `.pack()` / `.unpack()`
- Suitable for files, protocols, and low-level data formats
## What This Project Is NOT
- NOT a general Python–C FFI or ABI binding
- NOT a replacement for `ctypes.Structure`
- NOT an automatic structure inference tool
## Core APIs & Concepts
- `MemCStruct`: base class for C `struct` / `union` definitions
- `CEnum`: base class for C `enum` definitions
- `cstruct.parse()`: parse C definitions at runtime
- Fields are accessed as Python attributes
- Layout is deterministic and explicit
## Endianness
- Explicitly controlled via:
- `LITTLE_ENDIAN`
- `BIG_ENDIAN`
- `NATIVE_ORDER`
- Do NOT assume platform defaults
## Typical Usage
1. Define a C struct/union/enum as a string
2. Bind it to a Python class or parse it dynamically
3. Pack Python objects into bytes or unpack bytes into objects
4. Access fields as attributes
## Examples (Authoritative)
- MBR partition parsing:
https://python-cstruct.readthedocs.io/en/latest/examples/fdisk/
- Logged users (`who`) example:
https://python-cstruct.readthedocs.io/en/latest/examples/who/
- Flexible Array Member (FAM):
https://python-cstruct.readthedocs.io/en/latest/examples/flexible_array/
- libc integration (ctypes):
https://python-cstruct.readthedocs.io/en/latest/examples/dir/
## API Reference (Source of Truth)
https://python-cstruct.readthedocs.io/en/latest/api/module/
## Guidance for Code Generation
- Use real API names (`MemCStruct`, `CEnum`, `cstruct.parse`)
- Always specify byte order when relevant
- Follow the official documentation if uncertain
If there is any conflict between assumptions and the documentation or source
code, the documentation and source code take precedence.