(py-indent-right, py-outdent-left): new commands, bound to C-c C-r and
[python/dscho.git] / Doc / libmacdnr.tex
blobca75971cf30a8a9fb7ea5c0b73c58fb5e0e1da69
2 \section{Built-in module \sectcode{macdnr}}
3 \bimodindex{macdnr}
5 This module provides an interface to the Macintosh Domain Name
6 Resolver. It is usually used in conjunction with the \var{mactcp} module, to
7 map hostnames to IP-addresses.
9 The \code{macdnr} module defines the following functions:
11 \renewcommand{\indexsubitem}{(in module macdnr)}
13 \begin{funcdesc}{Open}{\optional{filename}}
14 Open the domain name resolver extension. If \var{filename} is given it
15 should be the pathname of the extension, otherwise a default is
16 used. Normally, this call is not needed since the other calls will
17 open the extension automatically.
18 \end{funcdesc}
20 \begin{funcdesc}{Close}{}
21 Close the resolver extension. Again, not needed for normal use.
22 \end{funcdesc}
24 \begin{funcdesc}{StrToAddr}{hostname}
25 Look up the IP address for \var{hostname}. This call returns a dnr
26 result object of the ``address'' variation.
27 \end{funcdesc}
29 \begin{funcdesc}{AddrToName}{addr}
30 Do a reverse lookup on the 32-bit integer IP-address
31 \var{addr}. Returns a dnr result object of the ``address'' variation.
32 \end{funcdesc}
34 \begin{funcdesc}{AddrToStr}{addr}
35 Convert the 32-bit integer IP-address \var{addr} to a dotted-decimal
36 string. Returns the string.
37 \end{funcdesc}
39 \begin{funcdesc}{HInfo}{hostname}
40 Query the nameservers for a \code{HInfo} record for host
41 \var{hostname}. These records contain hardware and software
42 information about the machine in question (if they are available in
43 the first place). Returns a dnr result object of the ``hinfo''
44 variety.
45 \end{funcdesc}
47 \begin{funcdesc}{MXInfo}{domain}
48 Query the nameservers for a mail exchanger for \var{domain}. This is
49 the hostname of a host willing to accept SMTP mail for the given
50 domain. Returns a dnr result object of the ``mx'' variety.
51 \end{funcdesc}
53 \subsection{dnr result object}
55 Since the DNR calls all execute asynchronously you do not get the
56 results back immedeately. In stead, you get a dnr result object. You
57 can check this object to see whether the query is complete, and access
58 its attributes to obtain the information when it is.
60 Alternatively, you can also reference the result attributes directly,
61 this will result in an implicit wait for the query to complete.
63 The \var{rtnCode} and \var{cname} attributes are always available, the
64 others depend on the type of query (address, hinfo or mx).
66 \renewcommand{\indexsubitem}{(dnr result object method)}
68 % Add args, as in {arg1\, arg2 \optional{\, arg3}}
69 \begin{funcdesc}{wait}{}
70 Wait for the query to complete.
71 \end{funcdesc}
73 % Add args, as in {arg1\, arg2 \optional{\, arg3}}
74 \begin{funcdesc}{isdone}{}
75 Return 1 if the query is complete.
76 \end{funcdesc}
78 \begin{datadesc}{rtnCode}
79 The error code returned by the query.
80 \end{datadesc}
82 \begin{datadesc}{cname}
83 The canonical name of the host that was queried.
84 \end{datadesc}
86 \begin{datadesc}{ip0}
87 \dataline{ip1}
88 \dataline{ip2}
89 \dataline{ip3}
90 At most four integer IP addresses for this host. Unused entries are
91 zero. Valid only for address queries.
92 \end{datadesc}
94 \begin{datadesc}{cpuType}
95 \dataline{osType}
96 Textual strings giving the machine type an OS name. Valid for hinfo
97 queries.
98 \end{datadesc}
100 \begin{datadesc}{exchange}
101 The name of a mail-exchanger host. Valid for mx queries.
102 \end{datadesc}
104 \begin{datadesc}{preference}
105 The preference of this mx record. Not too useful, since the Macintosh
106 will only return a single mx record. Mx queries only.
107 \end{datadesc}
109 The simplest way to use the module to convert names to dotted-decimal
110 strings, without worrying about idle time, etc:
111 \begin{verbatim}
112 >>> def gethostname(name):
113 ... import macdnr
114 ... dnrr = macdnr.StrToAddr(name)
115 ... return macdnr.AddrToStr(dnrr.ip0)
116 \end{verbatim}