473,553 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting C struct to Perl

158 New Member
Hi i didnt know to post this into the C threads or Perl but what i need is to convert the comand: (typedef struct {}) in C to somthing that does the same thing in Perl.
May 31 '07 #1
14 8582
kardon33
158 New Member
I have 2 pieces of code that i do not know what it means. Could someone please explain what it is saying and if anyone could could you show me a way to do it in PERL?

Expand|Select|Wrap|Line Numbers
  1. #ifndef _ARTNET_H_
  2. #define _ARTNET_H_
Expand|Select|Wrap|Line Numbers
  1. #define uchar unsigned char
  2. #define ushort unsigned short int
  3. #define ulong unsigned int
May 31 '07 #2
miller
1,089 Recognized Expert Top Contributor
Give us the full command or piece of code that you're trying to convert.

- Miller
May 31 '07 #3
RedSon
5,000 Recognized Expert Expert
I have 2 pieces of code that i do not know what it means. Could someone please explain what it is saying and if anyone could could you show me a way to do it in PERL?

Expand|Select|Wrap|Line Numbers
  1. #ifndef _ARTNET_H_
  2. #define _ARTNET_H_
Expand|Select|Wrap|Line Numbers
  1. #define uchar unsigned char
  2. #define ushort unsigned short int
  3. #define ulong unsigned int
The first two lines can be read as "if _ARTNET_H_ is not defined then define _ARTNET_H_"

The second line can be read as "define uchar as a synonym to unsigned char" and "define ushort to be a synonym to unsigned short int" and "define ulong to be a synonym to unsigned int".

As for a PERL interpretation you will have to ask the PERL forum. Or I can just move this post over there.
May 31 '07 #4
kardon33
158 New Member
ok thanks that helps alot.
May 31 '07 #5
RedSon
5,000 Recognized Expert Expert
Merge me !
May 31 '07 #6
kardon33
158 New Member
Expand|Select|Wrap|Line Numbers
  1. typedef struct {
  2.     uchar IP[4];    // IP address
  3.     ushort Port;    // UDP port    BYTE-SWAPPED MANUALLY
  4. } T_Addr;
May 31 '07 #7
kardon33
158 New Member
Expand|Select|Wrap|Line Numbers
  1. #define uchar unsigned char
  2. #define ushort unsigned short int
  3. #define ulong unsigned int
  4.  
  5. typedef struct S_ArtDmx {
  6.     uchar ID[8];                
  7.     ushort OpCode;                  
  8.     uchar VersionH;               
  9.     uchar Version;                  
  10.     uchar Sequence;            
  11.     uchar Physical;               
  12.     ushort Universe;             
  13.     ushort Length;            
  14.     uchar Data[MaxDataLength];
  15. } T_ArtDmx;
Could some one help me convert that to PERL?
May 31 '07 #8
miller
1,089 Recognized Expert Top Contributor
If you're just creating is a struct, then the perl equivalent would be a hash. If you're sending this information over the net and need to receive it, then you're going to need pack and unpack.

- Miller
Jun 1 '07 #9
kardon33
158 New Member
Ok thank you that helps, but one question what is the diffrence between hash and pack/unpack
Jun 1 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2646
by: Vumani Dlamini | last post by:
I have data which is in this format: ### data ### area=1101 home=003 mzer=00020 mzec=101 pmpr=00000 pmpc=102 bnsr=00000 bnsc=103
1
4372
by: Giovanni Azua | last post by:
Hello all, I need to return back to TSQL two numeric values from an Extended Stored Procedure developed in C. As result my C dll program produces two float values, the TSQL side expects to have exactly: numeric(10, 5) and numeric. Given that the structure to fill-up is DBNUMERIC defined as:
1
1694
by: Majed | last post by:
hi, I'm trying to convert some .h files to API Declaration to use the function and structs. one of it is this: NTMS_GUID CurrentLibrary; // the current library NTMS_GUID MediaPool; // media pool that the media belongs to NTMS_GUID Location; // actual location of the media
2
2101
by: Con | last post by:
Hi, I'm in the process of converting some PERL to PHP. Thus, is it possible to leave the following line as is: if ($id =~ /vvvvv/g) { ... } If not, can someone provide PHP equivalent? BTW, I have checked the
4
2343
by: eight02645999 | last post by:
hi i need help with converting a piece of perl code to python ...... my $start = '\'; my $file = '\'; my $end = '\'; ..... while(<FILE>) #open a file {
7
5287
by: Angus Comber | last post by:
Hello Here is my code so far. Is this correct/incorrect/along the right lines/other? #include <stdio.h> #include <string.h> #include <search.h> struct mystruct {
1
2575
by: DaTurk | last post by:
I'm having an issue converting an unmanaged struct to a CLI managed struct. It's a value struct and this cannot be changed. public value struct UpdateItem { public: System::String ^Name;
2
1663
by: lbscprogrammer | last post by:
Hi, I'm in trouble here... I need to get this program working to proceed with my application. The program is very complex, it works fine on a 10 year old system written in IBM C/2. I am showing only what I think yu may need here, please let me know if you need anything else. I am converting it to VS 7.1 (C not C++). All my source is named .C....
4
3595
by: screamer81 | last post by:
Hello, I've a SDK functions description for a scanner and I try to convert unmanaged DLL C++ functions to c#. I converted all except one of them. This function is getting a struct parameter. int WINAPI ImgSave(_T_Scan_Param *ScanP, unsigned char *szMicr, int *num_chars, int y0, int y1, int cOcrCode_option) struct _T_Scan_Param { ...
0
7492
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7772
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7526
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6109
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5409
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3537
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1990
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1106
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.