Page 1 of 1

ucs1 / ucs2

Posted: Tue Feb 04, 2014 2:59 pm
by mx_w
Hi All,

i had a look at the protocol, and i have a few questions about the strings. for example this struct:

Code: Select all

struct CITP_PINF_PLoc

It carries three strings with variable length in it. The spec says the ucs1 are
Open arrays of ucs1 or ucs2 are null terminated strings.
but in c99 open arrays ( they call it "flexible array member" ) must be the last element of a struct.

So - to avoid massively shooting down other lighting consoles :D - let us assume we have for the above case

Code: Select all

Type = "LightingConsole" (16 incl. \0)
Name = "MyCoolName" (11 incl. \0)
State = "Idle" (5 incl. \0)

How is the struct supposed to be in layout?
Do the strings have a specified size, like eg 256?

Code: Select all


Or a dynamic layout like

Code: Select all


and if so, are the strings concatenated or does the parser expect
three pointers with the strings appended to the end?

Best regards + thank you very much,

Re: ucs1 / ucs2

Posted: Sun Mar 09, 2014 8:59 am
by lasso

I realize the use of the keyword struct is probably what is causing the confusion here, so I will remove that from the spec. The second sentence of the first paragraph under section 2 is supposed to clarify this, but... well.

Anyway, the message definitions are not to be interpreted as C structs - they describe the contents of a binary data stream. I would recommend never memcpy'ing network data straight into C structs.