Fixed a typo in declaration of setegid(0
[pwlib.git] / samples / dnstest / main.cxx
blob6d3d4ee44fde9089bfb58aadfdff1a523e3cf73d
1 /*
2 * main.cxx
4 * PWLib application source file for DNSTest
6 * Main program entry point.
8 * Copyright 2003 Equivalence
10 * $Log$
11 * Revision 1.4 2003/09/26 13:42:16 rjongbloed
12 * Added special test to give more indicative error if try to compile without DNS support.
14 * Revision 1.3 2003/04/22 23:25:13 craigs
15 * Changed help message for SRV records
17 * Revision 1.2 2003/04/15 08:15:16 craigs
18 * Added single string form of GetSRVRecords
20 * Revision 1.1 2003/04/15 04:12:38 craigs
21 * Initial version
25 #include <ptlib.h>
26 #include <ptclib/pdns.h>
27 #include "main.h"
30 #if !P_DNS
31 #error Must have DNS support for this application
32 #endif
35 PCREATE_PROCESS(DNSTest);
37 DNSTest::DNSTest()
38 : PProcess("Equivalence", "DNSTest", 1, 0, AlphaCode, 1)
42 void Usage()
44 PError << "usage: dnstest -t MX hostname\n"
45 " dnstest -t SRV service (i.e. _ras._udp._example.com)\n"
49 void DNSTest::Main()
51 PArgList & args = GetArguments();
53 args.Parse("t:");
55 if (args.GetCount() < 1) {
56 Usage();
57 return;
60 PString type = args.GetOptionString('t');
61 if (type *= "SRV") {
62 PDNS::SRVRecordList srvRecords;
63 if (!PDNS::GetSRVRecords(args[0], srvRecords))
64 PError << "GetSRVRecords failed" << endl;
65 else
66 cout << "SRV Returned " << srvRecords << endl;
69 else if (type *= "MX") {
70 PDNS::MXRecordList mxRecords;
71 if (!PDNS::GetMXRecords(args[0], mxRecords)) {
72 PError << "GetMXRecords failed";
73 } else {
74 cout << "MX returned " << mxRecords << endl;
79 // End of File ///////////////////////////////////////////////////////////////