media/mtransport/third_party/nICEr/src/net/nr_resolver.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/mtransport/third_party/nICEr/src/net/nr_resolver.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,85 @@
     1.4 +/*
     1.5 +Copyright (c) 2007, Adobe Systems, Incorporated
     1.6 +Copyright (c) 2013, Mozilla
     1.7 +
     1.8 +All rights reserved.
     1.9 +
    1.10 +Redistribution and use in source and binary forms, with or without
    1.11 +modification, are permitted provided that the following conditions are
    1.12 +met:
    1.13 +
    1.14 +* Redistributions of source code must retain the above copyright
    1.15 +  notice, this list of conditions and the following disclaimer.
    1.16 +
    1.17 +* Redistributions in binary form must reproduce the above copyright
    1.18 +  notice, this list of conditions and the following disclaimer in the
    1.19 +  documentation and/or other materials provided with the distribution.
    1.20 +
    1.21 +* Neither the name of Adobe Systems, Network Resonance, Mozilla nor
    1.22 +  the names of its contributors may be used to endorse or promote
    1.23 +  products derived from this software without specific prior written
    1.24 +  permission.
    1.25 +
    1.26 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.27 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    1.28 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.29 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    1.30 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.31 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    1.32 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.33 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    1.34 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    1.35 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    1.36 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.37 +*/
    1.38 +
    1.39 +#include <nr_api.h>
    1.40 +#include "nr_resolver.h"
    1.41 +
    1.42 +int nr_resolver_create_int(void *obj, nr_resolver_vtbl *vtbl, nr_resolver **resolverp)
    1.43 +{
    1.44 +  int _status;
    1.45 +  nr_resolver *resolver=0;
    1.46 +
    1.47 +  if (!(resolver=RCALLOC(sizeof(nr_resolver))))
    1.48 +    ABORT(R_NO_MEMORY);
    1.49 +
    1.50 +  resolver->obj=obj;
    1.51 +  resolver->vtbl=vtbl;
    1.52 +
    1.53 +  *resolverp=resolver;
    1.54 +  _status=0;
    1.55 +abort:
    1.56 +  return(_status);
    1.57 +}
    1.58 +
    1.59 +int nr_resolver_destroy(nr_resolver **resolverp)
    1.60 +{
    1.61 +  nr_resolver *resolver;
    1.62 +
    1.63 +  if(!resolverp || !*resolverp)
    1.64 +    return(0);
    1.65 +
    1.66 +  resolver=*resolverp;
    1.67 +  *resolverp=0;
    1.68 +
    1.69 +  resolver->vtbl->destroy(&resolver->obj);
    1.70 +
    1.71 +  RFREE(resolver);
    1.72 +
    1.73 +  return(0);
    1.74 +}
    1.75 +
    1.76 +int nr_resolver_resolve(nr_resolver *resolver,
    1.77 +                        nr_resolver_resource *resource,
    1.78 +                        int (*cb)(void *cb_arg, nr_transport_addr *addr),
    1.79 +                        void *cb_arg,
    1.80 +                        void **handle)
    1.81 +{
    1.82 +  return resolver->vtbl->resolve(resolver->obj, resource, cb, cb_arg, handle);
    1.83 +}
    1.84 +
    1.85 +int nr_resolver_cancel(nr_resolver *resolver, void *handle)
    1.86 +{
    1.87 +  return resolver->vtbl->cancel(resolver->obj, handle);
    1.88 +}

mercurial