Tech Off Thread

8 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

please help me ! how to convert c struct to c#

Back to Forum: Tech Off
  • User profile image
    neatrain

    this is a c code ,how to convert c struct to c# and how to use the callback function :



    #define IAXC_EVENT_BUFSIZ 256

    struct iaxc_ev_levels {
     float input;
     float output;
    };

    struct iaxc_ev_text {
     int type;
     int callNo; /* call number for IAX text */
     char message[IAXC_EVENT_BUFSIZ];
    };

    struct iaxc_ev_call_state {
     int callNo;
     int state;
     int format;
     char remote[IAXC_EVENT_BUFSIZ];
     char remote_name[IAXC_EVENT_BUFSIZ];
     char local[IAXC_EVENT_BUFSIZ];
     char local_context[IAXC_EVENT_BUFSIZ];
    };

    struct iaxc_netstat {
            int jitter;
            int losspct;
            int losscnt;
            int packets;
            int delay;
            int dropped;
            int ooo;
    };

    struct iaxc_ev_netstats {
     int callNo;
     int rtt;
     struct iaxc_netstat local;
     struct iaxc_netstat remote;
    };

    struct iaxc_ev_url {
     int callNo;
     int type;
     char url[IAXC_EVENT_BUFSIZ];
    };

    struct iaxc_ev_video {
     int callNo;
     int format;
     int width;
     int height;
     unsigned char *data;
    };

    struct iaxc_ev_registration {
        int id;
        int reply;
        int msgcount;
    };

    typedef struct iaxc_event_struct {
     struct iaxc_event_struct *next;
     int type;
     union {
      struct iaxc_ev_levels   levels;
      struct iaxc_ev_text   text;
      struct iaxc_ev_call_state  call;
      struct iaxc_ev_netstats  netstats;
      struct iaxc_ev_url          url;
      struct iaxc_ev_video  video;
      struct iaxc_ev_registration reg;
     } ev;
    } iaxc_event;

    typedef int (WINAPI *iaxc_event_callback_t)(iaxc_event e);
    EXPORT void STDCL iaxc_set_event_callback(iaxc_event_callback_t func);



    please help me ,thanks!!!

  • User profile image
    Matthew van Eerde

    Use LayoutKind.Explicit... there are various examples if you search in the Techoff

    For example this one

  • User profile image
    neatrain

    thank u ,but I don't know that how to convert  "struct iaxc_event_struct *next;".

  • User profile image
    Rossj

    Hint - you're not the first person to want to wrap iaxclient.dll with C#. Others have been there before ou ...

  • User profile image
    neatrain

    Rossj wrote:
    Hint - you're not the first person to want to wrap iaxclient.dll with C#. Others have been there before ou ...


    yeah, can u help me?

  • User profile image
    lorad

    Pointers simply become IntPtr's it does not matter what it points to....

  • User profile image
    Rossj

    neatrain wrote:
    
    Rossj wrote:Hint - you're not the first person to want to wrap iaxclient.dll with C#. Others have been there before ou ...


    yeah, can u help me?


    I meant 30 seconds googling for iaxclient and c# brought back a couple of pre-written wrappers...

  • User profile image
    phreaks

    Rossj wrote:
    
    neatrain wrote: 
    Rossj wrote: Hint - you're not the first person to want to wrap iaxclient.dll with C#. Others have been there before ou ...


    yeah, can u help me?


    I meant 30 seconds googling for iaxclient and c# brought back a couple of pre-written wrappers...


    Like this one...
    http://www.thenorth.com/northern.nsf/html/nct_iaxclientwrapper

    [6]

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.