[ragel-users] Little-endian / big-endian (alphabetic char)

Iñaki Baz Castillo ibc at aliax.net
Mon Aug 15 20:43:13 UTC 2011


Hi, trying to make a parser for a binary protocol:

  http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10#section-4.2

I get the following case:

Byte number 2 in the protocol message is as follows:

- bit 0:       FIN bit
- bits 1-7:   Payload length (means 2^N bytes).

I receive the data from the network. The data is read from a Ruby
server and then passed to a C parser built with Ragel. So within Ragel
code (actions) I must check if bit 0 (FIN) is 1 or 0.
The Ragel grammar alphabetic is "char", so I can check whether such
char is > some value (which means that first bit is 0 or 1, so I get
FIN bit value).

The question is: how can I know if I'm cheking the byte in big-endian
or in litte-endian? Probably this question makes no sense at all since
data was already received by the Ruby server, so it has been converted
to host byte order, so I must not care about it, am I right?


Thanks a lot.


-- 
Iñaki Baz Castillo
<ibc at aliax.net>

_______________________________________________
ragel-users mailing list
ragel-users at complang.org
http://www.complang.org/mailman/listinfo/ragel-users


More information about the ragel-users mailing list