#include
"mx.h"
#include "dns.h"
int
Reply (MXMessage* pmessage, MXCom* pcom, void* apfield)
{
int i;
STRING Domain = (STRING)MXGetValue (pmessage, "Domain",
1);
WORD Class = (WORD) MXGetValue (pmessage, "QClass", 1);
WORD ACount = (WORD) MXGetValue (pmessage, "AnswerCount",
1);
WORD RCount = (WORD) MXGetValue (pmessage, "AuthorityCount",
1);
WORD PCount = (WORD) MXGetValue (pmessage, "AdditionalCount",
1);
WORD Code = (WORD) MXGetValue (pmessage, "Code", 1);
for (i = 1; i <= ACount + PCount + RCount; i++)
{
WORD Section = (WORD) MXGetValue (pmessage,
"Section", i);
WORD Type = (WORD) MXGetValue (pmessage,
"Type", i);
STRING Value = (STRING)MXGetValue (pmessage,
"Value", i);
STRING Name = (STRING)MXGetValue (pmessage, "Name",
i);
printf ("%d %d %30s %5s %s\n", Section, i,
Name, DNSGetNameFromType (Type), Value);
}
return 1;
}
void
main ()
{
MX mx;
MXMessage* pmessage;
LONG Identity = 1000;
WORD Operation = QUERY;
WORD Type = T_MX;
WORD Class = C_IN;
BUFFERPARM Record;
Record.BufferSize = 0;
Record.BufferContent = NULL;
MXInit (&mx, MXSERVER, NULL, NULL, 0, NULL);
/*
Establish Connection with DNS Server */
DNSCom = MXOpenTCP (&mx, "dnsint.chronopost.fr",
53, IPPROTO_DNS, NULL, NULL, TRUE);
MXAddComCallBack (&mx, DNSCom, DNS_SYS, "Reply",
MXONRECV, Reply, NULL);
pmessage = MXPutMessage (DNSCom, DNS_SYS, "Query");
MXSetValue (pmessage, "Identity", 1,
&Identity);
MXSetValue (pmessage, "QClass",
1, &Class);
MXSetValue (pmessage, "QType",
1, &Type);
MXSetValue (pmessage, "Domain",
1, "chronopost.fr");
MXSetValue (pmessage, "Operation", 1, &Operation);
MXSetValue (pmessage, "RecordData", 1,
&Record);
MXDispatchEvents (&mx, 0);
MXEnd (&mx);
}
|