dns_transmit_start (struct dns_transmit *d, const char servers[64],
                    int flagrecursive, const char *q, const char qtype[2],
                    const char localip[4])
{
    unsigned int len = 0;

    const char s1[] = "\0\0\1\0\0\1\0\0\0\0\0\0";
    const char s2[] = "\0\0\0\0\0\1\0\0\0\0\0\0gcc-bug-workaround";

    dns_transmit_free (d);
    errno = error_io;

    len = dns_domain_length (q);
    d->querylen = len + 18;
    d->query = alloc (d->querylen);
    if (!d->query)
        return -1;

    uint16_pack_big (d->query, len + 16);
    byte_copy (d->query + 2, 12, flagrecursive ? s1 : s2);
    byte_copy (d->query + 14, len, q);
    byte_copy (d->query + 14 + len, 2, qtype);
    byte_copy (d->query + 16 + len, 2, DNS_C_IN);

    byte_copy (d->qtype, 2, qtype);
    d->servers = servers;
    byte_copy (d->localip, 4, localip);

    d->udploop = flagrecursive ? 1 : 0;

    if (len + 16 > 512)
        return firsttcp (d);

    return firstudp (d);
}
dns_transmit_start (struct dns_transmit *d, const char servers[64],
                    int flagrecursive, const char *q, const char qtype[2],
                    const char localip[4])
{
    unsigned int len = 0;

    const char s1[] = "\0\0\1\0\0\1\0\0\0\0\0\0";
    const char s2[] = "\0\0\0\0\0\1\0\0\0\0\0\0gcc-bug-workaround";

    dns_transmit_free (d);
    errno = error_io;

    len = dns_domain_length (q);
    d->querylen = len + 18;
    d->query = alloc (d->querylen);
    if (!d->query)
        return -1;

    uint16_pack_big (d->query, len + 16);
    byte_copy (d->query + 2, 12, flagrecursive ? s1 : s2);
    byte_copy (d->query + 14, len, q);
    byte_copy (d->query + 14 + len, 2, qtype);
    byte_copy (d->query + 16 + len, 2, DNS_C_IN);

    byte_copy (d->qtype, 2, qtype);
    d->servers = servers;
    byte_copy (d->localip, 4, localip);

    d->udploop = flagrecursive ? 1 : 0;

    if (len + 16 > 512)
        return firsttcp (d);

    return firstudp (d);
}