0
  *   ˆl–Ãa¾”ji?u@?pÜŠbÑ¿Äƒy×œ_†I|¥�+ÁÇ "R    /*
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
 *
 * See the COPYRIGHT file distributed with this work for additional
 * information regarding copyright ownership.
 */

#ifndef DNS_MASTER_H
#define DNS_MASTER_H 1

/*! \file dns/master.h */

/***
 ***	Imports
 ***/

#include <inttypes.h>
#include <stdio.h>

#include <isc/lang.h>

#include <dns/types.h>

/*
 * Flags to be passed in the 'options' argument in the functions below.
 */
#define DNS_MASTER_AGETTL 0x00000001 /*%< Age the ttl based on $DATE. */
#define DNS_MASTER_MANYERRORS                                               \
	0x00000002			/*%< Continue processing on errors. \
					 */
#define DNS_MASTER_NOINCLUDE 0x00000004 /*%< Disallow $INCLUDE directives. */
#define DNS_MASTER_ZONE	     0x00000008 /*%< Loading a zone master file. */
#define DNS_MASTER_HINT	     0x00000010 /*%< Loading a hint master file. */
#define DNS_MASTER_SLAVE     0x00000020 /*%< Loading a slave master file. */
#define DNS_MASTER_CHECKNS                    \
	0x00000040 /*%<                       \
		    * Check NS records to see \
		    * if they are an address  \
		    */
#define DNS_MASTER_FATALNS                     \
	0x00000080 /*%<                        \
		    * Treat DNS_MASTER_CHECKNS \
		    * matches as fatal         \
		    */
#define DNS_MASTER_CHECKNAMES	  0x00000100
#define DNS_MASTER_CHECKNAMESFAIL 0x00000200
#define DNS_MASTER_CHECKWILDCARD                    \
	0x00000400 /* Check for internal wildcards. \
		    */
#define DNS_MASTER_CHECKMX     0x00000800
#define DNS_MASTER_CHECKMXFAIL 0x00001000

#define DNS_MASTER_RESIGN   0x00002000
#define DNS_MASTER_KEY	    0x00004000 /*%< Loading a key zone master file. */
#define DNS_MASTER_NOTTL    0x00008000 /*%< Don't require ttl. */
#define DNS_MASTER_CHECKTTL 0x00010000 /*%< Check max-zone-ttl */

ISC_LANG_BEGINDECLS

/*
 * Structures that implement the "raw" format for master dump.
 * These are provided for a reference purpose only; in the actual
 * encoding, we directly read/write each field so that the encoded data
 * is always "packed", regardless of the hardware architecture.
 */
#define DNS_RAWFORMAT_VERSION 1

/*
 * Flags to indicate the status of the data in the raw file header
 */
#define DNS_MASTERRAW_COMPAT	      0x01
#define DNS_MASTERRAW_SOURCESERIALSET 0x02
#define DNS_MASTERRAW_LASTXFRINSET    0x04

/* Common header */
struct dns_masterrawheader {
	uint32_t format;       /* must be
				* dns_masterformat_raw
				* or
				* dns_masterformat_map */
	uint32_t version;      /* compatibility for future
				* extensions */
	uint32_t dumptime;     /* timestamp on creation
				* (currently unused) */
	uint32_t flags;	       /* Flags */
	uint32_t sourceserial; /* Source serial number (used
				* by inline-signing zones) */
	uint32_t lastxfrin;    /* timestamp of last transfer
				* (used by slave zones) */
};

/* The structure for each RRset */
typedef struct {
	uint32_t totallen;	  /* length of the data for this
				   * RRset, including the
				   * "header" part */
	dns_rdataclass_t rdclass; /* 16-bit class */
	dns_rdatatype_t	 type;	  /* 16-bit type */
	dns_rdatatype_t	 covers;  /* same as type */
	dns_ttl_t	 ttl;	  /* 32-bit TTL */
	uint32_t	 nrdata;  /* number of RRs in this set */
	/* followed by encoded owner name, and then rdata */
} dns_masterrawrdataset_t;

/*
 * Method prototype: a callback to register each include file as
 * it is encountered.
 */
typedef void (*dns_masterincludecb_t)(const char *file, void *arg);

/***
 ***	Function
 ***/

isc_result_t
dns_master_loadfile(const char *master_file, dns_name_t *top,
		    dns_name_t *origin, dns_rdataclass_t zclass,
		    unsigned int options, uint32_t resign,
		    dns_rdatacallbacks_t *callbacks,
		    dns_masterincludecb_t include_cb, void *include_arg,
		    isc_mem_t *mctx, dns_