<commit_before>#ifndef WDNS_MSG_H
#define WDNS_MSG_H

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

/* Macros. */

#define WDNS_FLAGS_QR(msg)		((((msg).flags) >> 15) & 0x01)
#define WDNS_FLAGS_OPCODE(msg)		((((msg).flags) >> 11) & 0x0f)
#define WDNS_FLAGS_AA(msg)		((((msg).flags) >> 10) & 0x01)
#define WDNS_FLAGS_TC(msg)		((((msg).flags) >> 9) & 0x01)
#define WDNS_FLAGS_RD(msg)		((((msg).flags) >> 8) & 0x01)
#define WDNS_FLAGS_RA(msg)		((((msg).flags) >> 7) & 0x01)
#define WDNS_FLAGS_Z(msg)		((((msg).flags) >> 6) & 0x01)
#define WDNS_FLAGS_AD(msg)		((((msg).flags) >> 5) & 0x01)
#define WDNS_FLAGS_CD(msg)		((((msg).flags) >> 4) & 0x01)
#define WDNS_FLAGS_RCODE(msg)		((msg).rcode)

/* Data structures and definitions. */

typedef enum {
	wdns_msg_success,
	wdns_msg_err_failure,
	wdns_msg_err_invalid_compression_pointer,
	wdns_msg_err_invalid_length_octet,
	wdns_msg_err_invalid_opcode,
	wdns_msg_err_invalid_rcode,
	wdns_msg_err_len,
	wdns_msg_err_malloc,
	wdns_msg_err_name_len,
	wdns_msg_err_name_overflow,
	wdns_msg_err_out_of_bounds,
	wdns_msg_err_overflow,
	wdns_msg_err_parse_error,
	wdns_msg_err_qdcount,
	wdns_msg_err_unknown_opcode,
	wdns_msg_err_unknown_rcode,
} wdns_msg_status;

typedef struct {
	uint8_t			len;
	uint8_t			*data;
} wdns_name_t;

typedef struct {
	uint16_t		len;
	uint8_t			data[];
} wdns_rdata_t;

typedef struct {
	uint32_t		rrttl;
	uint16_t		rrtype;
	uint16_t		rrclass;
	wdns_name_t		name;
	wdns_rdata_t		*rdata;
} wdns_rr_t;

typedef struct {
	uint32_t		rrttl;
	uint16_t		rrtype;
	uint16_t		rrclass;
	uint16_t		n_rdatas;
	wdns_name_t		name;
	wdns_rdata_t		**rdatas;
} wdns_rrset_t;

typedef struct {
	uint16_t		n_rrsets;
	wdns_rrset_t		*rrsets;
} wdns_rrset_array_t;

typedef struct {
	bool			present;
	uint8_t			version;
	uint16_t		flags;
	uint16_t		size;
	wdns_rdata_t		*options;
} wdns_edns_t;

typedef struct {
	wdns_rrset_array_t	sections[4];
	wdns_edns_t		edns;
	uint16_t		id;
	uint16_t		flags;
	uint16_t		rcode;
} wdns_message_t;

/* Function prototypes. */<commit_msg>msg: add rrs and n_rrs fields to wdns_rrset_array_t<commit_after>#ifndef WDNS_MSG_H
#define WDNS_MSG_H

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

/* Macros. */

#define WDNS_FLAGS_QR(msg)		((((msg).flags) >> 15) & 0x01)
#define WDNS_FLAGS_OPCODE(msg)		((((msg).flags) >> 11) & 0x0f)
#define WDNS_FLAGS_AA(msg)		((((msg).flags) >> 10) & 0x01)
#define WDNS_FLAGS_TC(msg)		((((msg).flags) >> 9) & 0x01)
#define WDNS_FLAGS_RD(msg)		((((msg).flags) >> 8) & 0x01)
#define WDNS_FLAGS_RA(msg)		((((msg).flags) >> 7) & 0x01)
#define WDNS_FLAGS_Z(msg)		((((msg).flags) >> 6) & 0x01)
#define WDNS_FLAGS_AD(msg)		((((msg).flags) >> 5) & 0x01)
#define WDNS_FLAGS_CD(msg)		((((msg).flags) >> 4) & 0x01)
#define WDNS_FLAGS_RCODE(msg)		((msg).rcode)

/* Data structures and definitions. */

typedef enum {
	wdns_msg_success,
	wdns_msg_err_failure,
	wdns_msg_err_invalid_compression_pointer,
	wdns_msg_err_invalid_length_octet,
	wdns_msg_err_invalid_opcode,
	wdns_msg_err_invalid_rcode,
	wdns_msg_err_len,
	wdns_msg_err_malloc,
	wdns_msg_err_name_len,
	wdns_msg_err_name_overflow,
	wdns_msg_err_out_of_bounds,
	wdns_msg_err_overflow,
	wdns_msg_err_parse_error,
	wdns_msg_err_qdcount,
	wdns_msg_err_unknown_opcode,
	wdns_msg_err_unknown_rcode,
} wdns_msg_status;

typedef struct {
	uint8_t			len;
	uint8_t			*data;
} wdns_name_t;

typedef struct {
	uint16_t		len;
	uint8_t			data[];
} wdns_rdata_t;

typedef struct {
	uint32_t		rrttl;
	uint16_t		rrtype;
	uint16_t		rrclass;
	wdns_name_t		name;
	wdns_rdata_t		*rdata;
} wdns_rr_t;

typedef struct {
	uint32_t		rrttl;
	uint16_t		rrtype;
	uint16_t		rrclass;
	uint16_t		n_rdatas;
	wdns_name_t		name;
	wdns_rdata_t		**rdatas;
} wdns_rrset_t;

typedef struct {
	uint16_t		n_rrs;
	uint16_t		n_rrsets;
	wdns_rr_t		*rrs;
	wdns_rrset_t		*rrsets;
} wdns_rrset_array_t;

typedef struct {
	bool			present;
	uint8_t			version;
	uint16_t		flags;
	uint16_t		size;
	wdns_rdata_t		*options;
} wdns_edns_t;

typedef struct {
	wdns_rrset_array_t	sections[4];
	wdns_edns_t		edns;
	uint16_t		id;
	uint16_t		flags;
	uint16_t		rcode;
} wdns_message_t;

/* Function prototypes. */
{'fraction_non_alphanumeric': 0.12276462058965684, 'fraction_numerical': 0.03479942000966651, 'mean_word_length': 5.367692307692308, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4277447', 'n_tokens_mistral': 2214, 'n_tokens_neox': 2056, 'n_words': 329}