"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/lib/dns/dbiterator.c" (7 Sep 2020, 2967 Bytes) of package /linux/misc/dns/bind9/9.11.23/bind-9.11.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "dbiterator.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 
   13 /*! \file */
   14 
   15 #include <config.h>
   16 
   17 #include <stdbool.h>
   18 
   19 #include <isc/util.h>
   20 
   21 #include <dns/dbiterator.h>
   22 #include <dns/name.h>
   23 
   24 void
   25 dns_dbiterator_destroy(dns_dbiterator_t **iteratorp) {
   26     /*
   27      * Destroy '*iteratorp'.
   28      */
   29 
   30     REQUIRE(iteratorp != NULL);
   31     REQUIRE(DNS_DBITERATOR_VALID(*iteratorp));
   32 
   33     (*iteratorp)->methods->destroy(iteratorp);
   34 
   35     ENSURE(*iteratorp == NULL);
   36 }
   37 
   38 isc_result_t
   39 dns_dbiterator_first(dns_dbiterator_t *iterator) {
   40     /*
   41      * Move the node cursor to the first node in the database (if any).
   42      */
   43 
   44     REQUIRE(DNS_DBITERATOR_VALID(iterator));
   45 
   46     return (iterator->methods->first(iterator));
   47 }
   48 
   49 isc_result_t
   50 dns_dbiterator_last(dns_dbiterator_t *iterator) {
   51     /*
   52      * Move the node cursor to the first node in the database (if any).
   53      */
   54 
   55     REQUIRE(DNS_DBITERATOR_VALID(iterator));
   56 
   57     return (iterator->methods->last(iterator));
   58 }
   59 
   60 isc_result_t
   61 dns_dbiterator_seek(dns_dbiterator_t *iterator, dns_name_t *name) {
   62     /*
   63      * Move the node cursor to the node with name 'name'.
   64      */
   65 
   66     REQUIRE(DNS_DBITERATOR_VALID(iterator));
   67 
   68     return (iterator->methods->seek(iterator, name));
   69 }
   70 
   71 isc_result_t
   72 dns_dbiterator_prev(dns_dbiterator_t *iterator) {
   73     /*
   74      * Move the node cursor to the previous node in the database (if any).
   75      */
   76 
   77     REQUIRE(DNS_DBITERATOR_VALID(iterator));
   78 
   79     return (iterator->methods->prev(iterator));
   80 }
   81 
   82 isc_result_t
   83 dns_dbiterator_next(dns_dbiterator_t *iterator) {
   84     /*
   85      * Move the node cursor to the next node in the database (if any).
   86      */
   87 
   88     REQUIRE(DNS_DBITERATOR_VALID(iterator));
   89 
   90     return (iterator->methods->next(iterator));
   91 }
   92 
   93 isc_result_t
   94 dns_dbiterator_current(dns_dbiterator_t *iterator, dns_dbnode_t **nodep,
   95                dns_name_t *name)
   96 {
   97     /*
   98      * Return the current node.
   99      */
  100 
  101     REQUIRE(DNS_DBITERATOR_VALID(iterator));
  102     REQUIRE(nodep != NULL && *nodep == NULL);
  103     REQUIRE(name == NULL || dns_name_hasbuffer(name));
  104 
  105     return (iterator->methods->current(iterator, nodep, name));
  106 }
  107 
  108 isc_result_t
  109 dns_dbiterator_pause(dns_dbiterator_t *iterator) {
  110     /*
  111      * Pause iteration.
  112      */
  113 
  114     REQUIRE(DNS_DBITERATOR_VALID(iterator));
  115 
  116     return (iterator->methods->pause(iterator));
  117 }
  118 
  119 isc_result_t
  120 dns_dbiterator_origin(dns_dbiterator_t *iterator, dns_name_t *name) {
  121 
  122     /*
  123      * Return the origin to which returned node names are relative.
  124      */
  125 
  126     REQUIRE(DNS_DBITERATOR_VALID(iterator));
  127     REQUIRE(iterator->relative_names);
  128     REQUIRE(dns_name_hasbuffer(name));
  129 
  130     return (iterator->methods->origin(iterator, name));
  131 }
  132 
  133 void
  134 dns_dbiterator_setcleanmode(dns_dbiterator_t *iterator, bool mode) {
  135     REQUIRE(DNS_DBITERATOR_VALID(iterator));
  136 
  137     iterator->cleaning = mode;
  138 }