]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
small example tutorial
authorJelte Jansen <jeltejan@NLnetLabs.nl>
Wed, 24 May 2006 12:54:34 +0000 (12:54 +0000)
committerJelte Jansen <jeltejan@NLnetLabs.nl>
Wed, 24 May 2006 12:54:34 +0000 (12:54 +0000)
doc/tutorial1_mx.doxygen [new file with mode: 0644]
examples/ldns-mx.c
ldns/dns.h
libdns.doxygen

diff --git a/doc/tutorial1_mx.doxygen b/doc/tutorial1_mx.doxygen
new file mode 100644 (file)
index 0000000..915e4b2
--- /dev/null
@@ -0,0 +1,47 @@
+/**
+   \page tutorial1_mx Tutorial 1: Qeurying for MX records
+   \dontinclude ldns-mx.c 
+   
+   The full source code can be found in \link examples/ldns-mx.c \endlink
+   
+   This is a simple example that queries for an MX record
+  
+   First of all, we need to include the correct header files, so
+   that all functions are available to us:
+  
+   \skip include
+   \until dns.h
+   in our main function, we declare some variables that we are going to use:
+
+   \skipline ldns_resolver
+   \until ldns_status
+
+   - The \c ldns_resolver structure keeps a list of nameservers, and can perform queries for us
+   - An \c ldns_rdf is a basic data type of dns, the RDATA. See (todo link) overview for a description about the building blocks of DNS.
+     \c domain will contain the name the user specifies when calling the program
+   - An \c ldns_pkt is a DNS packet, for instance a complete query, or an answer
+   - The \c ldns_rr_list structure contains a list of DNS Resource Records (RRs). In this case, we will store the MX records we find in the list.
+   - \c ldns_status is the basic type for status messages in ldns. Most functions will return a value of this type.
+
+   
+   First, we parse the command line argument (checks omitted on this page, see full source code), and store it in our \c domain variable:
+   \skipline ldns_dname_new_frm_str
+
+   Then, we create the resolver structure:
+   \skipline ldns_resolver_new
+
+   We tell the resolver to query for our domain, type MX, of class IN:
+   \skipline ldns_resolver_query
+   \until )
+
+   This should return a packet if everything goes well.
+
+   We get all RRs of type MX from the answer packet and store them in our list:
+   \skipline ldns_pkt_rr_list_by_type
+   \until )
+   
+   If this list is not empty, we sort and print it:
+   \skipline ldns_rr_list_sort
+   \skipline ldns_rr_list_print
+*/
index 7ddb38d89fe1d81e82ef6b91e9dc61a0fc499e69..265d0b86d991233eb6004b0299ad09c78d221a66 100644 (file)
@@ -52,7 +52,11 @@ main(int argc, char *argv[])
        /* use the resolver to send it a query for the mx 
         * records of the domain given on the command line
         */
-       p = ldns_resolver_query(res, domain, LDNS_RR_TYPE_MX, LDNS_RR_CLASS_IN, LDNS_RD);
+       p = ldns_resolver_query(res,
+                               domain,
+                               LDNS_RR_TYPE_MX,
+                               LDNS_RR_CLASS_IN,
+                               LDNS_RD);
 
        ldns_rdf_deep_free(domain);
        
@@ -62,7 +66,9 @@ main(int argc, char *argv[])
                /* retrieve the MX records from the answer section of that
                 * packet
                 */
-               mx = ldns_pkt_rr_list_by_type(p, LDNS_RR_TYPE_MX, LDNS_SECTION_ANSWER);
+               mx = ldns_pkt_rr_list_by_type(p,
+                                             LDNS_RR_TYPE_MX,
+                                             LDNS_SECTION_ANSWER);
                if (!mx) {
                        fprintf(stderr, 
                                        " *** invalid answer name %s after MX query for %s\n",
index 1e1db9c7973d4a2180eb78460fbb12b942cd9e17..a29019ecd706f446d1b0ad9c669e3beaa722c1f3 100644 (file)
  * A bunch of defines that are used in the DNS.
  */
 
+
+/**
+ * \mainpage LDNS Documentation
+ *
+ * \section introduction Introduction
+ *
+ * ldns is a general DNS library
+ */
 #ifndef LDNS_DNS_H
 #define LDNS_DNS_H
 
index 48dcb4b8a4c9c468707830d4bf5f1b602b492202..cff5cefe2df7d3fa1ccb3274dfc2796fa28c5bc0 100644 (file)
@@ -423,7 +423,7 @@ WARN_LOGFILE           =
 # directories like "/usr/src/myproject". Separate the files or directories 
 # with spaces.
 
-INPUT                  = . ldns/
+INPUT                  = . ldns/ doc/ examples/
 
 # If the value of the INPUT tag contains directories, you can use the 
 # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
@@ -432,7 +432,7 @@ INPUT                  = . ldns/
 # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp 
 # *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm
 
-FILE_PATTERNS          = *.h
+FILE_PATTERNS          = *.h *.c *.doxygen
 
 # The RECURSIVE tag can be used to turn specify whether or not subdirectories 
 # should be searched for input files as well. Possible values are YES and NO. 
@@ -461,7 +461,7 @@ EXCLUDE_PATTERNS       =
 # directories that contain example code fragments that are included (see 
 # the \include command).
 
-EXAMPLE_PATH           = 
+EXAMPLE_PATH           = examples
 
 # If the value of the EXAMPLE_PATH tag contains directories, you can use the 
 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp