home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / unix-dns.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.7 KB  |  72 lines

  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19.  
  20. /*
  21.  * dns.h --- portable nonblocking DNS for Unix
  22.  * Created: Jamie Zawinski <jwz@netscape.com>, 19-Dec-96.
  23.  */
  24.  
  25. #ifndef __UNIX_DNS_H__
  26. #define __UNIX_DNS_H__
  27.  
  28. /* Kick off an async DNS lookup;
  29.    The returned value is an id representing this transaction;
  30.     the result_callback will be run (in the main process) when we
  31.     have a result.  Returns negative if something went wrong.
  32.    If `status' is negative,`result' is an error message.
  33.    If `status' is positive, `result' is a 4-character string of
  34.    the IP address.
  35.    If `status' is 0, then the lookup was prematurely aborted
  36.     via a call to DNS_AbortHostLookup().
  37.  */
  38. extern int DNS_AsyncLookupHost(const char *name,
  39.                    int (*result_callback) (void *id,
  40.                                void *closure,
  41.                                int status,
  42.                                const char *result),
  43.                    void *closure,
  44.                    void **id_return);
  45.  
  46. /* Prematurely give up on the given host-lookup transaction.
  47.    The `id' is what was returned by DNS_AsyncLookupHost.
  48.    This causes the result_callback to be called with a negative
  49.    status.
  50.  */
  51. extern int DNS_AbortHostLookup(void *id);
  52.  
  53. /* Call this from main() to initialize the async DNS library.
  54.    Returns a file descriptor that should be selected for, or
  55.    negative if something went wrong.  Pass it the argc/argv
  56.    that your `main' was called with (it needs these pointers
  57.    in order to give its forked subprocesses sensible names.)
  58.  */
  59. extern int DNS_SpawnProcess(int argc, char **argv);
  60.  
  61. /* The main select() loop of your program should call this when the fd
  62.    that was returned by DNS_SpawnProcess comes active.  This may cause
  63.    some of the result_callback functions to run.
  64.  
  65.    If this returns negative, then a fatal error has happened, and you
  66.    should close `fd' and not select() for it again.  Call gethostbyname()
  67.    in the foreground or something.
  68.  */
  69. extern int DNS_ServiceProcess(int fd);
  70.  
  71. #endif /* __UNIX_DNS_H__ */
  72.