<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Den 26-12-2011 15:41, ik skrev:
    <blockquote
cite="mid:CAOccsKD6GssZQKqzZmgXDQm8ZVE8Fj3g-VMAJV0kENcRvNaWxw@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <div dir="ltr">Hello,<br>
        <br>
        I'm trying to translate the following to Pascal:<br>
        ------------<br>
        struct xt_option_call {<br>
            const char *arg, *ext_name;<br>
            const struct xt_option_entry *entry;<br>
            void *data;<br>
            unsigned int xflags;<br>
            bool invert;<br>
            uint8_t nvals;<br>
            union {<br>
                uint8_t u8, u8_range[2], syslog_level, protocol;<br>
                uint16_t u16, u16_range[2], port, port_range[2];<br>
                uint32_t u32, u32_range[2];<br>
                uint64_t u64, u64_range[2];<br>
                double dbl;<br>
                struct {<br>
                    union nf_inet_addr haddr, hmask;<br>
                    uint8_t hlen;<br>
                };<br>
                struct {<br>
                    uint8_t tos_value, tos_mask;<br>
                };<br>
                struct {<br>
                    uint32_t mark, mask;<br>
                };<br>
                uint8_t ethermac[6];<br>
            } val;<br>
            /* Wished for a world where the ones below were gone: */<br>
            union {<br>
                struct xt_entry_match **match;<br>
                struct xt_entry_target **target;<br>
            };<br>
            void *xt_entry;<br>
            void *udata;<br>
        };<br>
        <br>
        ------<br>
        h2pas does not capable of translating it, and I'm not sure that
        I know to make the "case" statement that will be equivalent for
        this complex union.<br>
        How can I translate it ?<br>
        <br>
        Thanks,<br>
        Ido<br>
      </div>
    </blockquote>
    I think the following should do it:<br>
    uses ctypes;<br>
    <br>
    {$PACKRECORDS C}<br>
    <br>
    type<br>
     xt_option_call_union = record<br>
      case integer of<br>
       0: (u8: cuint8);<br>
       1: (u8_range: array[0..1] of cuint8);<br>
       2: (sysloc_level: cuint8);<br>
       3: (protocol: cuint8);<br>
       4: (u16: cuint16);<br>
       5: (u16_range: array[0..1] of cuint16);<br>
       6: (port: cuint16);<br>
       7: (port_range: array[0..1] of cuint16);<br>
       8: (u32: cuint32);<br>
       9: (u32_range: array[0..1] of cuint32);<br>
       10: (u64: cuint64);<br>
       11: (u64_range: array[0..1] of cuint64);<br>
       12: (dbl: cdouble);<br>
       13: (haddr: nf_inet_addr; hlen: cuint8);<br>
       14: (hmask: nf_inet_addr);<br>
       15: (tos_value, tos_mask: cuint8);<br>
       16: (mark, mask: cuint32);<br>
       17: (ethermac: array[0..5] of cuint8);<br>
     end;<br>
    <br>
     xt_option_call = record<br>
      arg,<br>
      ext_name: pchar;<br>
      entry: ^xt_option_entry;<br>
      data: pointer;<br>
      xflags: cuint;<br>
      invert: cbool;<br>
      nvals: cuint8;<br>
      val: xt_option_call_union;<br>
      case integer of<br>
       0: (match: ^Pxt_entry_match; xt_entry, udata: pointer);<br>
       1: (target: ^Pxt_entry_target);<br>
     end;<br>
  </body>
</html>