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.
14 8574
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? - #ifndef _ARTNET_H_
-
#define _ARTNET_H_
- #define uchar unsigned char
-
#define ushort unsigned short int
-
#define ulong unsigned int
Give us the full command or piece of code that you're trying to convert.
- Miller
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? - #ifndef _ARTNET_H_
-
#define _ARTNET_H_
- #define uchar unsigned char
-
#define ushort unsigned short int
-
#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.
ok thanks that helps alot.
- typedef struct {
-
uchar IP[4]; // IP address
-
ushort Port; // UDP port BYTE-SWAPPED MANUALLY
-
} T_Addr;
- #define uchar unsigned char
-
#define ushort unsigned short int
-
#define ulong unsigned int
-
-
typedef struct S_ArtDmx {
-
uchar ID[8];
-
ushort OpCode;
-
uchar VersionH;
-
uchar Version;
-
uchar Sequence;
-
uchar Physical;
-
ushort Universe;
-
ushort Length;
-
uchar Data[MaxDataLength];
-
} T_ArtDmx;
Could some one help me convert that to PERL?
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
Ok thank you that helps, but one question what is the diffrence between hash and pack/unpack
Ok thank you that helps, but one question what is the diffrence between hash and pack/unpack
a hash (in perl) is essentially an array, pack/unpack are functions.
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
You say i need to use pack if i am going to be sending the info over the net, well could you explain to me that why i could not use hash over the net to send it?
I think i have the idea to the pack and unpack functions i am using but it still is not working write. First here is the code i need to transfer to PERL. - #define uchar unsigned char
-
#define ushort unsigned short int
-
#define ulong unsigned int
Im at the understanding that is saying i need to define the varible uchar and the others as an unsigned char. In PERL i think i do that by using pack with the C operator so the code i have looks like, - $uchar = "2131Adam2113";
-
pack 'C', $uchar;
-
print $uchar;
But for some reason i get the output of 2131Adam2113 instead of just char like Adam???
A hash is an perl internal data structure. It's essentially just an associative array.
Whenever you send a C struct across the net, it often must be serialized in some way. And then the receiving end must decrypt the serialization and turn it back into a C struct.
pack and unpack are the functions that are most often used to serialize data in perl for network programming.
- Miller
thanks i actually just found that out before u replied.
Sign in to post your reply or Sign up for a free account.
Similar topics
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
|
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...
|
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...
|
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? ...
|
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
{
|
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
{
|
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 ...
|
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...
|
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.
...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |