Branch: Tag:

2003-07-30

2003-07-30 15:17:56 by Anders Johansson <anders@roxen.com>

Forwardported additions from 7.2. "Added some global functions that map to either a global async_client or a client object."

Rev: lib/modules/Protocols.pmod/DNS.pmod:1.70

1: - // $Id: DNS.pmod,v 1.69 2002/12/01 22:54:25 nilsson Exp $ + // $Id: DNS.pmod,v 1.70 2003/07/30 15:17:56 anders Exp $   // Not yet finished -- Fredrik Hubinette      //! Domain Name System
1031:    function(string,mapping,mixed...:void) callback,    mixed ... args)    { -  for(int e=next_client ? 5 : 256;e>=0;e--) +  for(int e=next_client ? 100 : 256;e>=0;e--)    {    int lid = random(65536);    if(!catch { requests[lid]++; })
1173:    }   };    +  + async_client global_async_client; +  + #define GAC(X) \ + void async_##X( string host, function callback, mixed ... args ) \ + { \ +  if( !global_async_client ) \ +  global_async_client = async_client(); \ +  global_async_client->X(host,callback,@args); \ + } +  + GAC(ip_to_host); + //! method void async_ip_to_host(string ip, function cb, mixed ... cba) +  + GAC(host_to_ip); + //! method void async_host_to_ip(string host, function cb, mixed ... cba) +  + GAC(get_mx_all); + //! method void async_get_mx_all(string host, function cb, mixed ... cba) +  + GAC(get_mx); + //! method void async_get_mx(string host, function cb, mixed ... cba) +  +  + client global_client; +  + #define GC(X) \ + mixed X( string host ) \ + { \ +  if( !global_client ) \ +  global_client = client(); \ +  return global_client->X(host); \ + } +  + GC(gethostbyname); + //! method array gethostbyname(string host) +  + GC(gethostbyaddr); + //! method array gethostbyaddr(string host) +  + GC(get_mx); + //! method string get_mx(string host) +  + GC(get_primary_mx); + //! method string get_primary_mx(string host)