Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

C Conversion

Posted on 2005-03-28
2
Medium Priority
?
232 Views
Last Modified: 2010-04-05
I am going through and doing a .h to delphi conversion so I an use a 3rd party dll.

I'm trying to figure out how to properly convert the following struct. The problem is that there is a data field after the union.. I'm not exactly sure how to do this in Delphi.

typedef struct
{
      ACSEventHeader_t      eventHeader;
      union
      {
            ACSUnsolicitedEvent            acsUnsolicited;
            ACSConfirmationEvent      acsConfirmation;
            CSTARequestEvent            cstaRequest;
            CSTAUnsolicitedEvent      cstaUnsolicited;
            CSTAConfirmationEvent      cstaConfirmation;
            CSTAEventReport                  cstaEventReport;
      } event;
      char      heap[CSTA_MAX_HEAP];
} CSTAEvent_t;

What I have so far:

type CSTAEvent_t = record
  eventHeader : ACSEventHeader_t;
  case Integer of
    0 : (acsUnsolicited: ACSUnsolicitedEvent);
    1 : (acsConfirmation: ACSConfirmationEvent);
    2 : (cstaRequest: CSTARequestEvent);
    3 : (cstaUnsolicited: CSTAUnsolicitedEvent);
    4 : (cstaConfirmation: CSTAConfirmationEvent);
    5 : (cstaEventReport: CSTAEventReport);
  end;

  //How do I add heap : array[1..CSTA_MAX_HEAP] of char;
0
Comment
Question by:rbohac
2 Comments
 
LVL 26

Accepted Solution

by:
Russell Libby earned 200 total points
ID: 13646870

Just make the union its own record structure

type
  CSTAEvent_t       =   record
     eventHeader:   ACSEventHeader_t;
     event: record case Integer of
        0  : (acsUnsolicited:   ACSUnsolicitedEvent);
        1  : (acsConfirmation:  ACSConfirmationEvent);
        2  : (cstaRequest:      CSTARequestEvent);
        3  : (cstaUnsolicited:  CSTAUnsolicitedEvent);
        4  : (cstaConfirmation: CSTAConfirmationEvent);
        5  : (cstaEventReport:  CSTAEventReport);
     end;
     heap:          Array [0..Pred(CSTA_MAX_HEAP)] of Char;
  end;


Regards,
Russell
0
 
LVL 6

Author Comment

by:rbohac
ID: 13653433
Excellent. Thank you!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month12 days, 12 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question