<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Message</TITLE>

<META content="MSHTML 6.00.6000.16544" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=984245214-05052011><FONT face=Arial color=#0000ff size=2>I 
guess DOCUMENTATION_ONLY is defined in an external tool such as doxygen. 
Applications wouldn't define this. My point is that if the "pseudo" members are 
documented, someone will soon or later use them. If this header translation is 
for your personal </FONT></SPAN></DIV>
<DIV><SPAN class=984245214-05052011><FONT face=Arial color=#0000ff size=2>use 
only, then all is fine...</FONT></SPAN></DIV>
<DIV><SPAN class=984245214-05052011></SPAN><SPAN 
class=984245214-05052011> </SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV></DIV>
  <DIV class=OutlookMessageHeader lang=fr dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Message d'origine-----<BR><B>De :</B> 
  fpc-pascal-bounces@lists.freepascal.org 
  [mailto:fpc-pascal-bounces@lists.freepascal.org] <B>De la part de</B> 
  ik<BR><B>Envoyé :</B> jeudi 5 mai 2011 16:15<BR><B>À :</B> 
  FPC-Pascal users discussions<BR><B>Objet :</B> Re: RE : RE : RE : RE : 
  [fpc-pascal] How to translate this union ?<BR><BR></FONT></DIV>
  <DIV dir=ltr><BR><BR>
  <DIV class=gmail_quote>On Thu, May 5, 2011 at 17:05, Ludo Brands <SPAN 
  dir=ltr><<A 
  href="mailto:ludo.brands@free.fr">ludo.brands@free.fr</A>></SPAN> 
wrote:<BR>
  <BLOCKQUOTE class=gmail_quote 
  style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
    <DIV><SPAN><FONT face=Arial color=#0000ff size=2></FONT></SPAN>
    <DIV></DIV>
    <DIV><FONT face=Arial><FONT color=#0000ff><FONT 
    size=2>O<SPAN>K </SPAN><SPAN>. You have avoided using macros but are 
    loosing the access to "pseudo" members su_len,su_family,su_port and 
    su_scope_id. The DOCUMENTATION_ONLY suggests that these members are 
    documented parts of the interface. Also it will be up to the user to figure 
    out where to get su_len according to 
    SU_HAVE_SOCKADDR_SA_LEN.</SPAN></FONT></FONT></FONT></DIV></DIV></BLOCKQUOTE>
  <DIV><BR>I can not find them in the preprocessor code (the define and the 
  "document only" members), that's why I avoided them at this point. but if I'll 
  find them required, I'll invest more time to add them.<BR> </DIV>
  <BLOCKQUOTE class=gmail_quote 
  style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
    <DIV>
    <DIV><FONT face=Arial><FONT color=#0000ff><FONT 
    size=2><SPAN></SPAN></FONT></FONT></FONT><FONT face=Arial><FONT 
    color=#0000ff><FONT size=2><SPAN></SPAN></FONT></FONT></FONT><FONT 
    face=Arial><FONT color=#0000ff><FONT 
    size=2><SPAN></SPAN></FONT></FONT></FONT> </DIV>
    <DIV><FONT face=Arial><FONT color=#0000ff><FONT 
    size=2><SPAN></SPAN></FONT></FONT></FONT> </DIV>
    <DIV><FONT face=Tahoma><FONT size=2>
    <DIV class=im><FONT face=Arial><FONT 
    color=#0000ff><SPAN> </SPAN></FONT></FONT>-----Message 
    d'origine-----<BR><B>De :</B> <A 
    href="mailto:fpc-pascal-bounces@lists.freepascal.org" 
    target=_blank>fpc-pascal-bounces@lists.freepascal.org</A> [mailto:<A 
    href="mailto:fpc-pascal-bounces@lists.freepascal.org" 
    target=_blank>fpc-pascal-bounces@lists.freepascal.org</A>] <B>De la part 
    de</B> ik<BR></DIV><B>Envoyé :</B> jeudi 5 mai 2011 15:19
    <DIV class=im><BR><B>À :</B> FPC-Pascal users 
    discussions<BR></DIV><B>Objet :</B> Re: RE : RE : RE : [fpc-pascal] How 
    to translate this union ?<BR><BR></FONT></FONT></DIV>
    <DIV>
    <DIV></DIV>
    <DIV class=h5>
    <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
      <DIV dir=ltr><BR>I've done the following at the moment:<BR><BR>{$IFDEF 
      SU_HAVE_SOCKADDR_SA_LEN}<BR>// 
      #define               
      su_len          su_sa.sa_len 
      <- unsupported for now<BR>{$ELSE}<BR>// 
      #define               
      su_len          su_array[0] 
      <- unsupported for now<BR>{$ENDIF}<BR>// 
      #define               
      su_family       su_sa.sa_family <- 
      unsupported for now<BR>// 
      #define               
      su_port         su_sin.sin_port 
      <- unsupported for now<BR>// 
      #define               
      su_scope_id     su_array32[6] <- unsupported for 
      now  <BR><BR>su_sockaddr_u  = 
      record<BR>                     
      case Byte 
      of<BR>                       
      0 : (su_dummy   : 
      cshort);                  
      //< Dummy member to 
      initialize<BR>                       
      1 : (su_array   : array[0..31] of char);    // 
      Presented as 
      chars<BR>                       
      2 : (su_array16 : array[0..15] of cuint16); // Presented as 16-bit 
      ints<BR>                       
      3 : (su_array32 : array[0..8]  of cuint32); // Presented as 32-bit 
      ints<BR>                       
      4 : (su_sa      : 
      sockaddr);                
      // Address in struct sockaddr 
      format<BR>                       
      5 : (su_sin     : 
      sockaddr_in);             
      // Address in IPv4 format<BR>{$IFDEF 
      SU_HAVE_IN6}<BR>                       
      6 : (su_sin6    : 
      sockaddr_in6);            
      // Address in IPv6 
      format<BR>{$ENDIF}<BR>                   
      end;<BR><BR><BR>As I understood by you and C developers that I talked to, 
      the macro create a shortcut to be used.<BR><BR>Thanks,<BR><BR>Ido<BR><BR>
      <DIV class=gmail_quote>On Sat, Apr 30, 2011 at 11:53, Ludo Brands <SPAN 
      dir=ltr><<A href="mailto:ludo.brands@free.fr" 
      target=_blank>ludo.brands@free.fr</A>></SPAN> wrote:<BR>
      <BLOCKQUOTE class=gmail_quote 
      style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
        <DIV>
        <DIV><FONT face=Arial color=#0000ff size=2><SPAN>Using macros, the 
        translation looks like</SPAN></FONT></DIV>
        <DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
        <DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2>{$MACRO 
        ON}<BR>{$ifndef DOCUMENTATION_ONLY}<BR>{$if SU_HAVE_SOCKADDR_SA_LEN 
        <>0}<BR>  {$define su_len:=su_sa.sa_len}<BR>{$else}<BR>  
        {$define su_len:=su_array[0]}<BR>{$endif}<BR>{$define 
        su_family:=su_sa.sa_family}<BR>{$define 
        su_port:=su_sin.sin_port}<BR>{$define 
        su_scope_id:=su_array32[6]}<BR>{$endif}<BR><SPAN>type</SPAN></FONT></FONT></FONT></DIV>
        <DIV><FONT face=Arial><FONT color=#0000ff><FONT 
        size=2><SPAN>    su_sockaddr_u = 
        record<BR>        case longint 
        of<BR>          {$ifdef 
        DOCUMENTATION_ONLY}<BR>          
        0 : ( su_len : byte 
        );<BR>          1 : ( 
        su_family : byte 
        );<BR>          2 : ( 
        su_port : word 
        );<BR>          
        {$else}<BR>          3 : ( 
        su_dummy : smallint 
        );<BR>          
        {$endif}<BR>          4 : ( 
        su_array : array[0..31] of char 
        );<BR>          5 : ( 
        su_array16 : array[0..15] of word 
        );<BR>          6 : ( 
        su_array32 : array[0..7] of longword 
        );<BR>          7 : ( su_sa 
        : sockaddr );<BR>          
        8 : ( su_sin : sockaddr_in 
        );<BR>          {$if 
        SU_HAVE_IN6 
        <>0}<BR>          9 : 
        ( su_sin6 : sockaddr_in6 
        );<BR>          
        {$endif}<BR>          
        {$ifdef 
        DOCUMENTATION_ONLY}<BR>          
        10 : ( su_scope_id : longword 
        );<BR>          
        {$endif}<BR>        
        end;<BR></SPAN></FONT></FONT></FONT></DIV>
        <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
          <DIV></DIV>
          <DIV lang=fr dir=ltr align=left><FONT face=Tahoma size=2>
          <DIV>-----Message d'origine-----<BR><B>De :</B> <A 
          href="mailto:fpc-pascal-bounces@lists.freepascal.org" 
          target=_blank>fpc-pascal-bounces@lists.freepascal.org</A> [mailto:<A 
          href="mailto:fpc-pascal-bounces@lists.freepascal.org" 
          target=_blank>fpc-pascal-bounces@lists.freepascal.org</A>] <B>De la 
          part de</B> Ludo Brands<BR></DIV><B>Envoyé :</B> samedi 30 avril 
          2011 10:29 
          <DIV><BR><B>À :</B> 'FPC-Pascal users 
          discussions'<BR></DIV><B>Objet :</B> RE : RE : [fpc-pascal] How 
          to translate this union ?<BR><BR></FONT></DIV>
          <DIV>
          <DIV></DIV>
          <DIV>
          <DIV><SPAN><FONT face=Arial color=#0000ff size=2>Forget my previous 
          reply. I found the original header file on sourceforge. 
          </FONT></SPAN></DIV>
          <DIV><SPAN><FONT face=Arial color=#0000ff 
          size=2></FONT></SPAN> </DIV>
          <DIV><SPAN><FONT face=Arial color=#0000ff size=2>I have alse a better 
          understanding now of what the code is supposed to do: in case 
          DOCUMENTATION_ONLY is not defined,  a reference to, for example, 
          su_sockaddr_u.su_family will be subsstituted by 
          su_sockaddr_u.susa.sa_family. </FONT></SPAN></DIV>
          <DIV><SPAN><FONT face=Arial color=#0000ff size=2>You could use macros 
          and do a {$define su_family:=susa.sa_family} with the following 
          limitations:</FONT></SPAN></DIV>
          <DIV><SPAN><FONT face=Arial color=#0000ff size=2>- if you have 
          variables or other record members named su_family, not part of the 
          su_sockaddr_u record, they will be renamed also. </FONT></SPAN></DIV>
          <DIV><SPAN><FONT face=Arial color=#0000ff size=2>- it works only for 
          the units that include your .inc file.</FONT></SPAN></DIV>
          <DIV><SPAN></SPAN> </DIV>
          <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
            <DIV></DIV>
            <DIV lang=fr dir=ltr align=left><FONT face=Tahoma 
            size=2>-----Message d'origine-----<BR><B>De :</B> <A 
            href="mailto:fpc-pascal-bounces@lists.freepascal.org" 
            target=_blank>fpc-pascal-bounces@lists.freepascal.org</A> [mailto:<A 
            href="mailto:fpc-pascal-bounces@lists.freepascal.org" 
            target=_blank>fpc-pascal-bounces@lists.freepascal.org</A>] <B>De la 
            part de</B> Ludo Brands<BR><B>Envoyé :</B> samedi 30 avril 2011 
            09:18<BR><B>À :</B> 'FPC-Pascal users 
            discussions'<BR><B>Objet :</B> RE : [fpc-pascal] How to 
            translate this union ?<BR><BR></FONT></DIV>
            <DIV><SPAN><FONT face=Arial color=#0000ff size=2>Can you post the 
            original c code? You point to a file that seems to be a reworked 
            output from h2pas. As it is now, it indeed doesn't make any sense. I 
            would think the su_len,su_family,su_port should make up a record but 
            they aren't.</FONT></SPAN></DIV>
            <DIV><SPAN><FONT face=Arial color=#0000ff 
            size=2></FONT></SPAN> </DIV>
            <DIV><SPAN><FONT face=Arial color=#0000ff size=2>I suggest you move 
            the #defines inside the union declaration to somewhere before the 
            union declaration. It'll double up the ifdef's but make the code so 
            much more readable.</FONT></SPAN></DIV>
            <DIV><SPAN><FONT face=Arial color=#0000ff 
            size=2></FONT></SPAN> </DIV>
            <DIV><SPAN><FONT face=Arial color=#0000ff 
            size=2></FONT></SPAN> </DIV>
            <DIV></DIV>
            <DIV><FONT face=Tahoma size=2>-----Message 
            d'origine-----<BR><B>De :</B> <A 
            href="mailto:fpc-pascal-bounces@lists.freepascal.org" 
            target=_blank>fpc-pascal-bounces@lists.freepascal.org</A> [mailto:<A 
            href="mailto:fpc-pascal-bounces@lists.freepascal.org" 
            target=_blank>fpc-pascal-bounces@lists.freepascal.org</A>] <B>De la 
            part de</B> ik<BR><B>Envoyé :</B> vendredi 29 avril 2011 
            22:15<BR><B>À :</B> FPC-Pascal users 
            discussions<BR><B>Objet :</B> [fpc-pascal] How to translate 
            this union ?<BR><BR></FONT></DIV>
            <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
              <DIV dir=ltr>Hello list,<BR><BR>I'm trying to translate the <A 
              href="https://github.com/ik5/sofia-sip/blob/master/src/lib/sui.inc#L199" 
              target=_blank>following union</A> to Pascal, but I do not 
              understand it, and so does h2pas.<BR>How to translate it 
              ?<BR><BR>Thanks,<BR><BR>Ido<BR><BR><BR clear=all>
              <DIV dir=ltr>LINESIP - Opening the source for communication<BR><A 
              href="http://www.linesip.com" 
              target=_blank>http://www.linesip.com</A><BR><A 
              href="http://www.linesip.co.il" 
              target=_blank>http://www.linesip.co.il</A><BR><BR></DIV><BR></DIV></BLOCKQUOTE></BLOCKQUOTE></DIV></DIV></BLOCKQUOTE></DIV><BR>_______________________________________________<BR>fpc-pascal 
        maillist  -  <A href="mailto:fpc-pascal@lists.freepascal.org" 
        target=_blank>fpc-pascal@lists.freepascal.org</A><BR><A 
        href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" 
        target=_blank>http://lists.freepascal.org/mailman/listinfo/fpc-pascal</A><BR></BLOCKQUOTE></DIV><BR></DIV></BLOCKQUOTE></DIV></DIV></DIV><BR>_______________________________________________<BR>fpc-pascal 
    maillist  -  <A 
    href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</A><BR><A 
    href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" 
    target=_blank>http://lists.freepascal.org/mailman/listinfo/fpc-pascal</A><BR></BLOCKQUOTE></DIV><BR></DIV></BLOCKQUOTE></BODY></HTML>