ctypes structure with a variable-size field at the end
gatch breizh <[email protected]>
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I would like to know how to write a ctypes::Structure with a variable-size
field at the end.
It occurs in many protocols to have a data field with a size early defined.
I have been searching a solution through the web (very usual question) for a
while but without any success ...
Attempt #1: Append a new field to the list _fields_ does NOT work...
<code>
class LV(Structure):
_fields_ = [('Length', c_ushort)]
lv = LV()
lv.Length = 5
lv._fields_.append(('Value', c_ubyte * 5) # ==> added but not usable
<end of code>
Attempt #2: use of ctypes.resize() seems to fail for ctypes.Structure
First, is it possible? if so, how to write it?
I Hope someone could help me!
Thanks.
.: Gatch, Python 2.5.4, CTypes 1.0.3
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
ctypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ctypes-users