(root)/
glibc-2.38/
resolv/
ns_samename.c
       1  /* Check if two domain names are equal after trailing dot normalization.
       2   * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
       3   * Copyright (c) 1995,1999 by Internet Software Consortium.
       4   *
       5   * Permission to use, copy, modify, and distribute this software for any
       6   * purpose with or without fee is hereby granted, provided that the above
       7   * copyright notice and this permission notice appear in all copies.
       8   *
       9   * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
      10   * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
      11   * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
      12   * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
      13   * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
      14   * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
      15   * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
      16   * SOFTWARE.
      17   */
      18  
      19  #include <arpa/nameser.h>
      20  #include <string.h>
      21  
      22  /* Determines whether domain name A is the same as domain name B.
      23     Returns -1 on error, 0 if names differ, 1 if names are the
      24     same.  */
      25  int
      26  __libc_ns_samename (const char *a, const char *b)
      27  {
      28    char ta[NS_MAXDNAME], tb[NS_MAXDNAME];
      29  
      30    if (__libc_ns_makecanon (a, ta, sizeof ta) < 0 ||
      31        __libc_ns_makecanon (b, tb, sizeof tb) < 0)
      32      return -1;
      33    if (__strcasecmp (ta, tb) == 0)
      34      return 1;
      35    else
      36      return 0;
      37  }
      38  libc_hidden_def (__libc_ns_samename)