V
Vlado Mandic
Hi,
I know this is a pure C# newsgroup, but I might get better luck here then somewhere else...
I need to use a function from a DLL written in C...Actual DLLImports are not a problem, but what is causing me headache is wrapping the structures used by the C DLL in C#.
How to defined and marshal all that mess?
I'm posting below the actual C defines, can anyone point me on how to properly define and marshal them in C#?
struct argtuple { int argdesc; char *arg; };
struct errinfo {
int errnum;
char *errstr;
UINT64 timestamp;
int threadID;
int processID;
int activityID;
char *hostName;
char *programName;
int MsgId;
char *form;
int argcount;
argtuple **arglist; };
struct vallist { struct vallist *next; char value[1]; };
struct attrlist { struct attrlist *next; vallist *values; char name[65]; };
struct resid { char resnum[32]; unsigned long mseq; };
struct resource { attrlist *attrs; resid id; };
struct residlist { struct residlist *next; resid id; };
struct reslist { struct reslist *next; resource res; };
struct resdb_ops {
errinfo *(*create)(struct resdb *resdb, resource *res);
errinfo *(*ro_delete)(struct resdb *resdb, resource *res);
errinfo *(*update)(struct resdb *resdb, resource *res);
errinfo *(*append)(struct resdb *resdb, resource *res);
errinfo *(*retrieve)(struct resdb *resdb, resource *res);
errinfo *(*retlist)(struct resdb *resdb, residlist *rids, attrlist *show, reslist **rlp);
errinfo *(*getids)(struct resdb *resdb, attrlist *query, int nids, residlist **rlp);
errinfo *(*modtime)(struct resdb *resdb, time_t *mtimep);
errinfo *(*rdbclose)(struct resdb *resdb);
errinfo *(*noio)(struct resdb *resdb, int forbidden);
errinfo *(*btrans)(struct resdb *resdb);
errinfo *(*etrans)(struct resdb *resdb);
errinfo *(*vrf_notrans)(struct resdb *resdb); };
struct resdb {
struct resdb *next;
struct resdb_ops *ops;
char * rd_private;
char * rd_public; };
enum rap_direction {
RAP_TOSERVER = 0,
RAP_FROMSERVER = 1,
RAP_FROMMASTER = 2,
rap_direction_Dummy = INT_MIN };
typedef enum rap_direction rap_direction;
I know this is a pure C# newsgroup, but I might get better luck here then somewhere else...
I need to use a function from a DLL written in C...Actual DLLImports are not a problem, but what is causing me headache is wrapping the structures used by the C DLL in C#.
How to defined and marshal all that mess?
I'm posting below the actual C defines, can anyone point me on how to properly define and marshal them in C#?
struct argtuple { int argdesc; char *arg; };
struct errinfo {
int errnum;
char *errstr;
UINT64 timestamp;
int threadID;
int processID;
int activityID;
char *hostName;
char *programName;
int MsgId;
char *form;
int argcount;
argtuple **arglist; };
struct vallist { struct vallist *next; char value[1]; };
struct attrlist { struct attrlist *next; vallist *values; char name[65]; };
struct resid { char resnum[32]; unsigned long mseq; };
struct resource { attrlist *attrs; resid id; };
struct residlist { struct residlist *next; resid id; };
struct reslist { struct reslist *next; resource res; };
struct resdb_ops {
errinfo *(*create)(struct resdb *resdb, resource *res);
errinfo *(*ro_delete)(struct resdb *resdb, resource *res);
errinfo *(*update)(struct resdb *resdb, resource *res);
errinfo *(*append)(struct resdb *resdb, resource *res);
errinfo *(*retrieve)(struct resdb *resdb, resource *res);
errinfo *(*retlist)(struct resdb *resdb, residlist *rids, attrlist *show, reslist **rlp);
errinfo *(*getids)(struct resdb *resdb, attrlist *query, int nids, residlist **rlp);
errinfo *(*modtime)(struct resdb *resdb, time_t *mtimep);
errinfo *(*rdbclose)(struct resdb *resdb);
errinfo *(*noio)(struct resdb *resdb, int forbidden);
errinfo *(*btrans)(struct resdb *resdb);
errinfo *(*etrans)(struct resdb *resdb);
errinfo *(*vrf_notrans)(struct resdb *resdb); };
struct resdb {
struct resdb *next;
struct resdb_ops *ops;
char * rd_private;
char * rd_public; };
enum rap_direction {
RAP_TOSERVER = 0,
RAP_FROMSERVER = 1,
RAP_FROMMASTER = 2,
rap_direction_Dummy = INT_MIN };
typedef enum rap_direction rap_direction;