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 #ifndef DNS_TTL_H 13 #define DNS_TTL_H 1 14 15 /*! \file dns/ttl.h */ 16 17 /*** 18 *** Imports 19 ***/ 20 21 #include <inttypes.h> 22 #include <stdbool.h> 23 24 #include <isc/lang.h> 25 #include <isc/types.h> 26 27 ISC_LANG_BEGINDECLS 28 29 /*** 30 *** Functions 31 ***/ 32 33 isc_result_t 34 dns_ttl_totext(uint32_t src, bool verbose, bool upcase, isc_buffer_t *target); 35 /*%< 36 * Output a TTL or other time interval in a human-readable form. 37 * The time interval is given as a count of seconds in 'src'. 38 * The text representation is appended to 'target'. 39 * 40 * If 'verbose' is false, use the terse BIND 8 style, like "1w2d3h4m5s". 41 * 42 * If 'verbose' is true, use a verbose style like the SOA comments 43 * in "dig", like "1 week 2 days 3 hours 4 minutes 5 seconds". 44 * 45 * If 'upcase' is true, we conform to the BIND 8 style in which 46 * the unit letter is capitalized if there is only a single unit 47 * letter to print (for example, "1m30s", but "2M") 48 * 49 * If 'upcase' is false, unit letters are always in lower case. 50 * 51 * Returns: 52 * \li ISC_R_SUCCESS 53 * \li ISC_R_NOSPACE 54 */ 55 56 isc_result_t 57 dns_counter_fromtext(isc_textregion_t *source, uint32_t *ttl); 58 /*%< 59 * Converts a counter from either a plain number or a BIND 8 style value. 60 * 61 * Returns: 62 *\li ISC_R_SUCCESS 63 *\li DNS_R_SYNTAX 64 */ 65 66 isc_result_t 67 dns_ttl_fromtext(isc_textregion_t *source, uint32_t *ttl); 68 /*%< 69 * Converts a ttl from either a plain number or a BIND 8 style value. 70 * 71 * Returns: 72 *\li ISC_R_SUCCESS 73 *\li DNS_R_BADTTL 74 */ 75 76 ISC_LANG_ENDDECLS 77 78 #endif /* DNS_TTL_H */ 79