1. C structure
- Posted by Vlado Kusnirak <daduko at atlas.sk> May 29, 2003
- 502 views
------=_NextPart_8960c1d6_dcf8_468e_ad82_022a604a507f Hello, =20 how to convert this C structure into Euphoria ? This structure is used for termination table, in =2Edll for dialogic boards (for telecom=2E apps) =20 Function in this dll need a pointer where is this table structure allocated=2E =20 typedef struct DV_TPT { unsigned short tp_type; /* Flags describing this en= try */ unsigned short tp_termno; /* Termination Parameter nu= mber */ unsigned short tp_length; /* Length of terminator */ unsigned short tp_flags; /* Parameter attribute flag= */ unsigned short tp_data; /* Optional additional data= */ unsigned short rfu; /* Reserved = */ DV_TPT *tp_nextp; /* Pointer to next terminat= ion * parameter if IO_LINK set= */ }DV_TPT; =20 tpt[0]=2Etp_type =3D IO_CONT; tpt[0]=2Etp_termno =3D DX_MAXDTMF; /* Maximum number of digits= */ tpt[0]=2Etp_length =3D 4; /* terminate on 4 digits */ tpt[0]=2Etp_flags =3D TF_MAXDTMF; /* terminate if already in = buf=2E */ tpt[1]=2Etp_type =3D IO_CONT; tpt[1]=2Etp_termno =3D DX_LCOFF; /* LC off termination */ tpt[1]=2Etp_length =3D 3; /* Use 30 ms (10 ms resolut= ion * timer) */ tpt[1]=2Etp_flags =3D TF_LCOFF|TF_10MS; /* level triggered, clear h= istory, * 10 ms resolution */ tpt[2]=2Etp_type =3D IO_EOT; tpt[2]=2Etp_termno =3D DX_MAXTIME; /* Function Time */ tpt[2]=2Etp_length =3D 100; /* 10 seconds (100 ms resol= ution * timer) */ =20 tpt[2]=2Etp_flags =3D TF_MAXTIME; /* Edge-triggered */ =20 =20 =20 I've used structs=2Ee =20 constant DV_TPT =3D define_c_struct({ {"tp_type", USHORT, 1}, {"tp_termno", USHORT, 1}, {"tp_length", USHORT, 1}, {"tp_flags", USHORT, 1}, {"tp_data", USHORT, 1}, {"rfu", USHORT, 1}, {"tp_nextp", POINTER, 1} }) =20 dv_tpt =3D alloc_struct(DV_TPT) =20 poke_struct(dv_tpt,"tp_type",IO_CONT) poke_struct(dv_tpt,"tp_termno",DX_MAXDTMF) poke_struct(dv_tpt,"tp_length",1) poke_struct(dv_tpt,"tp_flags",TF_MAXDTMF) =20 =20 Is it good or not? Please help me=2E =20 Bye Vlado ------=_NextPart_8960c1d6_dcf8_468e_ad82_022a604a507f Content-type: text/html; charset=windows-1250 Content-Transfer-Encoding: quoted-printable <html><div style=3D"font-family: tahoma, arial; font-size: 12px;">Hello= ,<BR> <BR>how to convert this C structure into Euphoria ?<BR>This = structure is used for termination table,<BR>in =2Edll for dialogic boar= ds (for telecom=2E apps)<BR> <BR>Function in this dll need a point= er where is this<BR>table structure allocated=2E<BR> <BR>typedef s= truct DV_TPT {<BR> unsigned short &n= bsp; tp_type; &nbs= p; /* Flags describing this entry */<BR> &= nbsp; unsigned short tp_termno; &nbs= p; /* Termination Parameter number = */<BR> unsigned short tp_leng= th; /* Leng= th of terminator */<BR> unsigned short&nb= sp; tp_flags; &nbs= p; /* Parameter attribute flag */<BR> &nbs= p; unsigned short tp_data; &nb= sp; /* Optional additional da= ta */<BR> unsigned short rfu;=  = ; /* Reserved &nbs= p; */<BR>&n= bsp; DV_TPT = *tp_nextp; = /* Pointer to next termination<BR> =  = ; &nbs= p; &nb= sp; * parameter if IO_LINK set */<B= R>}DV_TPT;<BR> <BR> tpt[0]=2Etp_type =3D I= O_CONT;<BR> tpt[0]=2Etp_termno =3D DX_MAXDTMF; &= nbsp; /* Maximum number of digits */<BR> = tpt[0]=2Etp_length =3D 4; &nbs= p; /* terminate on 4 digits *= /<BR> tpt[0]=2Etp_flags =3D TF_MAXDTMF; &n= bsp; /* terminate if already in buf=2E */<BR> &n= bsp; tpt[1]=2Etp_type =3D IO_CONT;<BR> tpt[1]=2E= tp_termno =3D DX_LCOFF; = /* LC off termination */<BR> tpt[1]=2Etp_length =3D 3;&nbs= p; &nb= sp; /* Use 30 ms (10 ms resolution<BR> &nb= sp; &n= bsp; &= nbsp; = * timer) */<BR> tpt[1]=2Etp_flags =3D TF_LCOFF= |TF_10MS; /* level triggered, clear history,<BR>  = ; &nbs= p; &nb= sp; &n= bsp; * 10 ms resolution */<BR> tpt[2]=2Etp_type = =3D IO_EOT;<BR> tpt[2]=2Etp_termno =3D DX_MAXTIME; &n= bsp; /* Function Time */<BR> tpt[2]= =2Etp_length =3D 100; &n= bsp; /* 10 seconds (100 ms resolution<BR> =  = ; &nbs= p; &nb= sp; * timer) */<BR> <BR> tpt[2]=2Etp= _flags =3D TF_MAXTIME; /* Edg= e-triggered */<BR> <BR> <BR> <BR>I've used structs=2Ee<B= R> <BR>constant DV_TPT =3D define_c_struct({<BR> = {"tp_type", USHORT, 1},<BR> {"tp_termno", USHORT, 1}= ,<BR> {"tp_length", USHORT, 1},<BR> = {"tp_flags", USHORT, 1},<BR> {"tp_data", USHORT, 1},= <BR> {"rfu", USHORT, 1},<BR> {"tp_n= extp", POINTER, 1}<BR> })<BR> <BR> dv_tpt =3D alloc_stru= ct(DV_TPT)<BR> <BR>poke_struct(dv_tpt,"tp_type",IO_CONT)<BR>poke_s= truct(dv_tpt,"tp_termno",DX_MAXDTMF)<BR>poke_struct(dv_tpt,"tp_length",= 1)<BR>poke_struct(dv_tpt,"tp_flags",TF_MAXDTMF)<BR> <BR> <BR>= > ------=_NextPart_8960c1d6_dcf8_468e_ad82_022a604a507f--