other-licenses/android/resolv_cache.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/other-licenses/android/resolv_cache.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,77 @@
     1.4 +/*
     1.5 + * Copyright (C) 2008 The Android Open Source Project
     1.6 + * All rights reserved.
     1.7 + *
     1.8 + * Redistribution and use in source and binary forms, with or without
     1.9 + * modification, are permitted provided that the following conditions
    1.10 + * are met:
    1.11 + *  * Redistributions of source code must retain the above copyright
    1.12 + *    notice, this list of conditions and the following disclaimer.
    1.13 + *  * Redistributions in binary form must reproduce the above copyright
    1.14 + *    notice, this list of conditions and the following disclaimer in
    1.15 + *    the documentation and/or other materials provided with the
    1.16 + *    distribution.
    1.17 + *
    1.18 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.19 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    1.20 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
    1.21 + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    1.22 + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    1.23 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    1.24 + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
    1.25 + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
    1.26 + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    1.27 + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    1.28 + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.29 + * SUCH DAMAGE.
    1.30 + */
    1.31 +
    1.32 +/*
    1.33 + * This version of this file is derived from Android 2.3 "Gingerbread",
    1.34 + * which contains uncredited changes by Android/Google developers.  It has
    1.35 + * been modified in 2011 for use in the Android build of Mozilla Firefox by
    1.36 + * Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
    1.37 + * and Steve Workman <sjhworkman@gmail.com>).
    1.38 + * These changes are offered under the same license as the original NetBSD
    1.39 + * file, whose copyright and license are unchanged above.
    1.40 + */
    1.41 +
    1.42 +#ifndef _RESOLV_CACHE_H_
    1.43 +#define _RESOLV_CACHE_H_
    1.44 +
    1.45 +struct resolv_cache;  /* forward */
    1.46 +
    1.47 +/* get cache instance, can be NULL if cache is disabled
    1.48 + * (e.g. through an environment variable) */
    1.49 +extern struct resolv_cache*  __get_res_cache(void);
    1.50 +
    1.51 +/* this gets called everytime we detect some changes in the DNS configuration
    1.52 + * and will flush the cache */
    1.53 +extern void   _resolv_cache_reset( unsigned  generation );
    1.54 +
    1.55 +typedef enum {
    1.56 +    RESOLV_CACHE_UNSUPPORTED,  /* the cache can't handle that kind of queries */
    1.57 +                               /* or the answer buffer is too small */
    1.58 +    RESOLV_CACHE_NOTFOUND,     /* the cache doesn't know about this query */
    1.59 +    RESOLV_CACHE_FOUND         /* the cache found the answer */
    1.60 +} ResolvCacheStatus;
    1.61 +
    1.62 +extern ResolvCacheStatus
    1.63 +_resolv_cache_lookup( struct resolv_cache*  cache,
    1.64 +                      const void*           query,
    1.65 +                      int                   querylen,
    1.66 +                      void*                 answer,
    1.67 +                      int                   answersize,
    1.68 +                      int                  *answerlen );
    1.69 +
    1.70 +/* add a (query,answer) to the cache, only call if _resolv_cache_lookup
    1.71 + * did return RESOLV_CACHE_NOTFOUND
    1.72 + */
    1.73 +extern void
    1.74 +_resolv_cache_add( struct resolv_cache*  cache,
    1.75 +                   const void*           query,
    1.76 +                   int                   querylen,
    1.77 +                   const void*           answer,
    1.78 +                   int                   answerlen );
    1.79 +
    1.80 +#endif /* _RESOLV_CACHE_H_ */

mercurial