1 /* $NetBSD: ttl.h,v 1.1 2024/02/18 20:57:39 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16 #ifndef DNS_TTL_H 17 #define DNS_TTL_H 1 18 19 /*! \file dns/ttl.h */ 20 21 /*** 22 *** Imports 23 ***/ 24 25 #include <inttypes.h> 26 #include <stdbool.h> 27 28 #include <isc/lang.h> 29 #include <isc/types.h> 30 31 ISC_LANG_BEGINDECLS 32 33 /*** 34 *** Functions 35 ***/ 36 37 isc_result_t 38 dns_ttl_totext(uint32_t src, bool verbose, bool upcase, isc_buffer_t *target); 39 /*%< 40 * Output a TTL or other time interval in a human-readable form. 41 * The time interval is given as a count of seconds in 'src'. 42 * The text representation is appended to 'target'. 43 * 44 * If 'verbose' is false, use the terse BIND 8 style, like "1w2d3h4m5s". 45 * 46 * If 'verbose' is true, use a verbose style like the SOA comments 47 * in "dig", like "1 week 2 days 3 hours 4 minutes 5 seconds". 48 * 49 * If 'upcase' is true, we conform to the BIND 8 style in which 50 * the unit letter is capitalized if there is only a single unit 51 * letter to print (for example, "1m30s", but "2M") 52 * 53 * If 'upcase' is false, unit letters are always in lower case. 54 * 55 * Returns: 56 * \li ISC_R_SUCCESS 57 * \li ISC_R_NOSPACE 58 */ 59 60 isc_result_t 61 dns_counter_fromtext(isc_textregion_t *source, uint32_t *ttl); 62 /*%< 63 * Converts a counter from either a plain number or a BIND 8 style value. 64 * 65 * Returns: 66 *\li ISC_R_SUCCESS 67 *\li DNS_R_SYNTAX 68 */ 69 70 isc_result_t 71 dns_ttl_fromtext(isc_textregion_t *source, uint32_t *ttl); 72 /*%< 73 * Converts a ttl from either a plain number or a BIND 8 style value. 74 * 75 * Returns: 76 *\li ISC_R_SUCCESS 77 *\li DNS_R_BADTTL 78 */ 79 80 ISC_LANG_ENDDECLS 81 82 #endif /* DNS_TTL_H */ 83