ares_strerror.c (3325B)
1 /* MIT License 2 * 3 * Copyright (c) 1998 Massachusetts Institute of Technology 4 * Copyright (c) The c-ares project and its contributors 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the next 14 * paragraph) shall be included in all copies or substantial portions of the 15 * Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 * SOFTWARE. 24 * 25 * SPDX-License-Identifier: MIT 26 */ 27 28 #include "ares_private.h" 29 30 const char *ares_strerror(int code) 31 { 32 ares_status_t status = (ares_status_t)code; 33 switch (status) { 34 case ARES_SUCCESS: 35 return "Successful completion"; 36 case ARES_ENODATA: 37 return "DNS server returned answer with no data"; 38 case ARES_EFORMERR: 39 return "DNS server claims query was misformatted"; 40 case ARES_ESERVFAIL: 41 return "DNS server returned general failure"; 42 case ARES_ENOTFOUND: 43 return "Domain name not found"; 44 case ARES_ENOTIMP: 45 return "DNS server does not implement requested operation"; 46 case ARES_EREFUSED: 47 return "DNS server refused query"; 48 case ARES_EBADQUERY: 49 return "Misformatted DNS query"; 50 case ARES_EBADNAME: 51 return "Misformatted domain name"; 52 case ARES_EBADFAMILY: 53 return "Unsupported address family"; 54 case ARES_EBADRESP: 55 return "Misformatted DNS reply"; 56 case ARES_ECONNREFUSED: 57 return "Could not contact DNS servers"; 58 case ARES_ETIMEOUT: 59 return "Timeout while contacting DNS servers"; 60 case ARES_EOF: 61 return "End of file"; 62 case ARES_EFILE: 63 return "Error reading file"; 64 case ARES_ENOMEM: 65 return "Out of memory"; 66 case ARES_EDESTRUCTION: 67 return "Channel is being destroyed"; 68 case ARES_EBADSTR: 69 return "Misformatted string"; 70 case ARES_EBADFLAGS: 71 return "Illegal flags specified"; 72 case ARES_ENONAME: 73 return "Given hostname is not numeric"; 74 case ARES_EBADHINTS: 75 return "Illegal hints flags specified"; 76 case ARES_ENOTINITIALIZED: 77 return "c-ares library initialization not yet performed"; 78 case ARES_ELOADIPHLPAPI: 79 return "Error loading iphlpapi.dll"; 80 case ARES_EADDRGETNETWORKPARAMS: 81 return "Could not find GetNetworkParams function"; 82 case ARES_ECANCELLED: 83 return "DNS query cancelled"; 84 case ARES_ESERVICE: 85 return "Invalid service name or number"; 86 case ARES_ENOSERVER: 87 return "No DNS servers were configured"; 88 } 89 90 return "unknown"; 91 }