comp.lang.ada
 help / color / mirror / Atom feed
From: wojtek@power.com.pl (Wojtek Narczynski)
Subject: Reading a C record from socket - chicken / egg problem - now complete
Date: 23 Nov 2002 04:43:33 -0800
Date: 2002-11-23T12:43:33+00:00	[thread overview]
Message-ID: <5ad0dd8a.0211230443.4b476252@posting.google.com> (raw)

Hello,

(sorry for my previous "post", hand slipped...)

I want to read a record like this:

   typedef struct {
      unsigned char version;
      unsigned char type;
      unsigned char requestIdB1;
      unsigned char requestIdB0;
      unsigned char contentLengthB1;
      unsigned char contentLengthB0;
      unsigned char paddingLength;
      unsigned char reserved;
      unsigned char contentData[contentLength];
      unsigned char paddingData[paddingLength];
   } FCGI_Record;

from socket. The 'type' field indicates different record type, so I
could declare different record types in Ada, but when I know 'type'
the record is already in memory. How should I approach this: 1. use
Unchecked_Conversion to convert to appropriate type? 2. Copy data into
a new record of appropriate type? 3. Just live with the structure C
imposes?


Another question is: can I declare non-contiguous enumeration
subtypes, or only range x..y? I've been unable to figure out how to
declare non-contiguous subtype, so I guess this isn't allowable, but
why? How am I supposed to write a strong typing program if I am not
able to declare a type that clearly "exists" (in math sense)? For
example:

-- Doestn't work

type Animal is ( Pig, Dog, Fish );
subtype Nice_Animal is Animal ( Pig, Dog );
subtype Home_Animail is Animal ( Dog, Fish );
subtype Eatable_Animal is Animal ( Pig, Fish );

In reality I wanted to declare subtypes of request type that don't
span a contiguous range.


Thanks for your patience & regards,
Wojtek Narczynski


P.S. Another question, slightly offtopic, is there any server where I
could get posting access to this group? Currently I use Google Groups.



             reply	other threads:[~2002-11-23 12:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-23 12:43 Wojtek Narczynski [this message]
2002-11-23 14:54 ` Reading a C record from socket - chicken / egg problem - now complete Robert A Duff
2002-11-23 17:31 ` Simon Wright
2002-12-05 16:54   ` Reading a C record from socket - chicken / egg problem Wojtek Narczynski
2002-11-23 18:55 ` Reading a C record from socket - chicken / egg problem - now complete SteveD
2002-11-28 21:33 ` Craig Carey
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox