473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

What's your choice when handle complicated C structures.

Hi all,

Recently I am writing a small network application with python.

The protocol is binary based and defined in c header files.

Now I'm using the upack function of 'struct' module, but it's really
annoying to write fmt strings for complicated structures.

What will be your choice when handling binary structures?
Nov 5 '08 #1
4 1258
一首诗 schrieb:
Hi all,

Recently I am writing a small network application with python.

The protocol is binary based and defined in c header files.

Now I'm using the upack function of 'struct' module, but it's really
annoying to write fmt strings for complicated structures.

What will be your choice when handling binary structures?
You can try gccxml + ctypes instead.

Diez
Nov 5 '08 #2
Recently I am writing a small network application with python.
>
The protocol is binary based and defined in c header files.

Now I'm using the upack function of 'struct' module, but it's really
annoying to write fmt strings for complicated structures.

What will be your choice when handling binary structures?
I would write a couple of wrapper functions around unpack of struct so
that the actual unpacking is less annoying but otherwise would
continue using the same approach as what you describe.

Cheers,
Daniel
--
Psss, psss, put it down! - http://www.cafepress.com/putitdown
Nov 5 '08 #3
On Tue, 04 Nov 2008 16:52:17 -0800, 一首诗 wrote:
Now I'm using the upack function of 'struct' module, but it's really
annoying to write fmt strings for complicated structures.

What will be your choice when handling binary structures?
http://construct.wikispaces.com/

Ciao,
Marc 'BlackJack' Rintsch
Nov 5 '08 #4
一首诗 wrote:
Hi all,

Recently I am writing a small network application with python.

The protocol is binary based and defined in c header files.

Now I'm using the upack function of 'struct' module, but it's really
annoying to write fmt strings for complicated structures.

What will be your choice when handling binary structures?
I use numpy and its nested dtypes. But then, I use numpy for damn near everything.

http://numpy.scipy.org/

Construct also looks appropriate.

http://construct.wikispaces.com/

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Nov 5 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
14
by: Mark | last post by:
Yes, my family business wants to create an accounting database to keep track of invoices, production, inventory, man hours, etc.... There will be two kinds of users to access the database, on two...
4
by: Bob | last post by:
Hallo, I have to make a web application in Javascript/ASP for tenniscourt reservation (based on Access database). I would like to do everything with one page, because the user must be able to...
0
by: Anthony Yott | last post by:
Newbie here in regards to XSD I've read some articles that state you should avoid the use of xsd:choice for interoperability (e.g. .NET Web Service called from java, delphi, vb 6, etc) when...
39
by: windandwaves | last post by:
Hi Folk I have to store up to eight boolean bits of information about an item in my database. e.g. with restaurant drive-through facility yellow windows
53
by: jaso | last post by:
Can you give any comments on this code? I used one goto, is it bad? #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <assert.h> #define NOT_NULL 1
6
by: LurfysMa | last post by:
I am working on an electronic flashcard application. I have one version up and running using Visual Basic (6.0) and Access 2000. My long-range plans are to put it up on a website and sell...
5
by: Dominik Czechowski | last post by:
Hi everyone! I have two tables, T1 and T2 defined as follows: create table T1(c1 integer not null, primary key (c1)); create table T2(c1 integer not null, c2 varchar(100) not null, primary...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.