11cb0ef41Sopenharmony_ci/* MIT License 21cb0ef41Sopenharmony_ci * 31cb0ef41Sopenharmony_ci * Copyright (c) 1998 Massachusetts Institute of Technology 41cb0ef41Sopenharmony_ci * Copyright (c) The c-ares project and its contributors 51cb0ef41Sopenharmony_ci * 61cb0ef41Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 71cb0ef41Sopenharmony_ci * of this software and associated documentation files (the "Software"), to deal 81cb0ef41Sopenharmony_ci * in the Software without restriction, including without limitation the rights 91cb0ef41Sopenharmony_ci * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 101cb0ef41Sopenharmony_ci * copies of the Software, and to permit persons to whom the Software is 111cb0ef41Sopenharmony_ci * furnished to do so, subject to the following conditions: 121cb0ef41Sopenharmony_ci * 131cb0ef41Sopenharmony_ci * The above copyright notice and this permission notice (including the next 141cb0ef41Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 151cb0ef41Sopenharmony_ci * Software. 161cb0ef41Sopenharmony_ci * 171cb0ef41Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 181cb0ef41Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 191cb0ef41Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 201cb0ef41Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 211cb0ef41Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 221cb0ef41Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 231cb0ef41Sopenharmony_ci * SOFTWARE. 241cb0ef41Sopenharmony_ci * 251cb0ef41Sopenharmony_ci * SPDX-License-Identifier: MIT 261cb0ef41Sopenharmony_ci */ 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci#include "ares_setup.h" 291cb0ef41Sopenharmony_ci#include <assert.h> 301cb0ef41Sopenharmony_ci#include "ares.h" 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ciconst char *ares_strerror(int code) 331cb0ef41Sopenharmony_ci{ 341cb0ef41Sopenharmony_ci ares_status_t status = (ares_status_t)code; 351cb0ef41Sopenharmony_ci switch (status) { 361cb0ef41Sopenharmony_ci case ARES_SUCCESS: 371cb0ef41Sopenharmony_ci return "Successful completion"; 381cb0ef41Sopenharmony_ci case ARES_ENODATA: 391cb0ef41Sopenharmony_ci return "DNS server returned answer with no data"; 401cb0ef41Sopenharmony_ci case ARES_EFORMERR: 411cb0ef41Sopenharmony_ci return "DNS server claims query was misformatted"; 421cb0ef41Sopenharmony_ci case ARES_ESERVFAIL: 431cb0ef41Sopenharmony_ci return "DNS server returned general failure"; 441cb0ef41Sopenharmony_ci case ARES_ENOTFOUND: 451cb0ef41Sopenharmony_ci return "Domain name not found"; 461cb0ef41Sopenharmony_ci case ARES_ENOTIMP: 471cb0ef41Sopenharmony_ci return "DNS server does not implement requested operation"; 481cb0ef41Sopenharmony_ci case ARES_EREFUSED: 491cb0ef41Sopenharmony_ci return "DNS server refused query"; 501cb0ef41Sopenharmony_ci case ARES_EBADQUERY: 511cb0ef41Sopenharmony_ci return "Misformatted DNS query"; 521cb0ef41Sopenharmony_ci case ARES_EBADNAME: 531cb0ef41Sopenharmony_ci return "Misformatted domain name"; 541cb0ef41Sopenharmony_ci case ARES_EBADFAMILY: 551cb0ef41Sopenharmony_ci return "Unsupported address family"; 561cb0ef41Sopenharmony_ci case ARES_EBADRESP: 571cb0ef41Sopenharmony_ci return "Misformatted DNS reply"; 581cb0ef41Sopenharmony_ci case ARES_ECONNREFUSED: 591cb0ef41Sopenharmony_ci return "Could not contact DNS servers"; 601cb0ef41Sopenharmony_ci case ARES_ETIMEOUT: 611cb0ef41Sopenharmony_ci return "Timeout while contacting DNS servers"; 621cb0ef41Sopenharmony_ci case ARES_EOF: 631cb0ef41Sopenharmony_ci return "End of file"; 641cb0ef41Sopenharmony_ci case ARES_EFILE: 651cb0ef41Sopenharmony_ci return "Error reading file"; 661cb0ef41Sopenharmony_ci case ARES_ENOMEM: 671cb0ef41Sopenharmony_ci return "Out of memory"; 681cb0ef41Sopenharmony_ci case ARES_EDESTRUCTION: 691cb0ef41Sopenharmony_ci return "Channel is being destroyed"; 701cb0ef41Sopenharmony_ci case ARES_EBADSTR: 711cb0ef41Sopenharmony_ci return "Misformatted string"; 721cb0ef41Sopenharmony_ci case ARES_EBADFLAGS: 731cb0ef41Sopenharmony_ci return "Illegal flags specified"; 741cb0ef41Sopenharmony_ci case ARES_ENONAME: 751cb0ef41Sopenharmony_ci return "Given hostname is not numeric"; 761cb0ef41Sopenharmony_ci case ARES_EBADHINTS: 771cb0ef41Sopenharmony_ci return "Illegal hints flags specified"; 781cb0ef41Sopenharmony_ci case ARES_ENOTINITIALIZED: 791cb0ef41Sopenharmony_ci return "c-ares library initialization not yet performed"; 801cb0ef41Sopenharmony_ci case ARES_ELOADIPHLPAPI: 811cb0ef41Sopenharmony_ci return "Error loading iphlpapi.dll"; 821cb0ef41Sopenharmony_ci case ARES_EADDRGETNETWORKPARAMS: 831cb0ef41Sopenharmony_ci return "Could not find GetNetworkParams function"; 841cb0ef41Sopenharmony_ci case ARES_ECANCELLED: 851cb0ef41Sopenharmony_ci return "DNS query cancelled"; 861cb0ef41Sopenharmony_ci case ARES_ESERVICE: 871cb0ef41Sopenharmony_ci return "Invalid service name or number"; 881cb0ef41Sopenharmony_ci case ARES_ENOSERVER: 891cb0ef41Sopenharmony_ci return "No DNS servers were configured"; 901cb0ef41Sopenharmony_ci } 911cb0ef41Sopenharmony_ci 921cb0ef41Sopenharmony_ci return "unknown"; 931cb0ef41Sopenharmony_ci} 94