LCOV - code coverage report
Current view: top level - lib/addns - error.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 4 6 66.7 %
Date: 2024-04-21 15:09:00 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :   Linux DNS client library implementation
       3             :   Copyright (C) 2010 Guenther Deschner
       4             : 
       5             :      ** NOTE! The following LGPL license applies to the libaddns
       6             :      ** library. This does NOT imply that all of Samba is released
       7             :      ** under the LGPL
       8             : 
       9             :   This library is free software; you can redistribute it and/or
      10             :   modify it under the terms of the GNU Lesser General Public
      11             :   License as published by the Free Software Foundation; either
      12             :   version 2.1 of the License, or (at your option) any later version.
      13             : 
      14             :   This library is distributed in the hope that it will be useful,
      15             :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17             :   Lesser General Public License for more details.
      18             : 
      19             :   You should have received a copy of the GNU Lesser General Public
      20             :   License along with this library; if not, see <http://www.gnu.org/licenses/>.
      21             : */
      22             : 
      23             : #include "dns.h"
      24             : #include "dnserr.h"
      25             : 
      26             : typedef struct {
      27             :         const char *dns_errstr;
      28             :         DNS_ERROR dns_errcode;
      29             : } dns_err_code_struct;
      30             : 
      31             : static const dns_err_code_struct dns_errs[] =
      32             : {
      33             :         { "ERROR_DNS_SUCCESS", ERROR_DNS_SUCCESS },
      34             :         { "ERROR_DNS_RECORD_NOT_FOUND", ERROR_DNS_RECORD_NOT_FOUND },
      35             :         { "ERROR_DNS_BAD_RESPONSE", ERROR_DNS_BAD_RESPONSE },
      36             :         { "ERROR_DNS_INVALID_PARAMETER", ERROR_DNS_INVALID_PARAMETER },
      37             :         { "ERROR_DNS_NO_MEMORY", ERROR_DNS_NO_MEMORY },
      38             :         { "ERROR_DNS_INVALID_NAME_SERVER", ERROR_DNS_INVALID_NAME_SERVER },
      39             :         { "ERROR_DNS_CONNECTION_FAILED", ERROR_DNS_CONNECTION_FAILED },
      40             :         { "ERROR_DNS_GSS_ERROR", ERROR_DNS_GSS_ERROR },
      41             :         { "ERROR_DNS_INVALID_NAME", ERROR_DNS_INVALID_NAME },
      42             :         { "ERROR_DNS_INVALID_MESSAGE", ERROR_DNS_INVALID_MESSAGE },
      43             :         { "ERROR_DNS_SOCKET_ERROR", ERROR_DNS_SOCKET_ERROR },
      44             :         { "ERROR_DNS_UPDATE_FAILED", ERROR_DNS_UPDATE_FAILED },
      45             :         { NULL, ERROR_DNS_SUCCESS },
      46             : };
      47             : 
      48           4 : const char *dns_errstr(DNS_ERROR err)
      49             : {
      50           0 :         int i;
      51             : 
      52          48 :         for (i=0; dns_errs[i].dns_errstr != NULL; i++) {
      53          48 :                 if (ERR_DNS_EQUAL(err, dns_errs[i].dns_errcode)) {
      54           4 :                         return dns_errs[i].dns_errstr;
      55             :                 }
      56             :         }
      57             : 
      58           0 :         return NULL;
      59             : }

Generated by: LCOV version 1.14