diff --git a/src/Makefile.am b/src/Makefile.am index 724e34e68b0b1f36f4628370fc43c493bec585c9..347635bcfc816e276c76894e9b019fe8beeacb71 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,7 +11,7 @@ libknotd_la_YFLAGS = -pcf_ -d libknotd_la_LFLAGS = # TODO: reentrant parser, prefix zscanner/scanner.c: zscanner/scanner.rl zscanner/scanner_body.rl - $(RAGEL) -G2 -s -o zscanner/scanner.c zscanner/scanner.rl + $(RAGEL) -s -o zscanner/scanner.c zscanner/scanner.rl knot_zcompile_SOURCES = \ libknot/rrset.c \ diff --git a/src/zcompile/zcompile.c b/src/zcompile/zcompile.c index 23447e90cfe2c2cc5fb8bb356f47aabe4ea0ac31..d7d079d492f1bc30340ac6582b1c84564b7c8b45 100644 --- a/src/zcompile/zcompile.c +++ b/src/zcompile/zcompile.c @@ -52,6 +52,8 @@ //#define dbg_zp_exec_detail(cmds) do { cmds } while (0) +static long rr_count = 0; +static long err_count = 0; struct parser { rrset_list_t *node_rrsigs; @@ -219,12 +221,18 @@ static void process_rrsigs_in_node(parser_t *parser, } } -void process_error(const scanner_t *scanner) +static void process_error(const scanner_t *s) { - fprintf(stderr, "There's been an error!\n"); + err_count++; + if (s->stop == true) { + printf("ERROR=%s\n", knot_strerror(s->error_code)); + } else { + printf("WARNG=%s\n", knot_strerror(s->error_code)); + } + fflush(stdout); } -int add_rdata_to_rr(knot_rrset_t *rrset, const scanner_t *scanner) +static int add_rdata_to_rr(knot_rrset_t *rrset, const scanner_t *scanner) { if (rrset == NULL) { dbg_zp("zp: add_rdata_to_rr: No RRSet.\n"); @@ -297,9 +305,9 @@ dbg_zp_exec_detail( return KNOT_EOK; } -void process_rr(const scanner_t *scanner) +static void process_rr(const scanner_t *scanner) { - + rr_count++; parser_t *parser = scanner->data; knot_zone_contents_t *contents = parser->current_zone; /* Create rrset. TODO will not be always needed. */ @@ -579,9 +587,14 @@ int zone_read(const char *name, const char *zonefile, const char *outfile, file_loader_t *loader = file_loader_create(zonefile, name, KNOT_CLASS_IN, 3600, process_rr, - process_error, &my_parser); + process_error, + &my_parser); file_loader_process(loader); +// knot_zone_contents_deep_free(&(my_parser.current_zone)); +// knot_zone_contents_adjust(my_parser.current_zone); file_loader_free(loader); + printf("RRs ok=%d\n", rr_count); + printf("RRs err=%d\n", err_count); } /*! @} */ diff --git a/src/zcompile/zcompile.h b/src/zcompile/zcompile.h index d4c4f24a76920b45cda8d9069263e4870edc6a97..795f92e8c21a207e4f9e03906c4d1373c52e2ad3 100644 --- a/src/zcompile/zcompile.h +++ b/src/zcompile/zcompile.h @@ -88,12 +88,6 @@ struct lex_data { #define DEFAULT_TTL 3600 -int yylex_destroy(void *scanner); -int zp_parse(void *scanner); -void zp_set_in(FILE *f, void *scanner); -int zp_lex_init(void **scanner); -int zp_lex_destroy(void *scanner); - /*! \todo Implement ZoneDB. */ typedef void namedb_type; @@ -107,52 +101,6 @@ struct rrset_list { typedef struct rrset_list rrset_list_t; -/*! - * \brief Main zoneparser structure. - */ -struct zparser { - const char *filename; /*!< File with zone. */ - uint32_t default_ttl; /*!< Default TTL. */ - uint16_t default_class; /*!< Default class. */ - knot_zone_t *current_zone; /*!< Current zone. */ - knot_node_t *origin; /*!< Origin node. */ - knot_dname_t *prev_dname; /*!< Previous dname. */ - knot_dname_t *origin_from_config; /*!< Zone origin from config. */ - knot_node_t *default_apex; /*!< Zone default apex. */ - - knot_node_t *last_node; /*!< Last processed node. */ - - char *dname_str; /*!< Temporary dname. */ - - int error_occurred; /*!< Error occured flag */ - unsigned int errors; /*!< Number of errors. */ - unsigned int line; /*!< Current line */ - - knot_rrset_t *current_rrset; /*!< Current RRSet. */ - knot_rdata_item_t *temporary_items; /*!< Temporary rdata items. */ - - knot_dname_t *root_domain; /*!< Root domain name. */ - slab_cache_t *parser_slab; /*!< Slab for parser. */ - rrset_list_t *node_rrsigs; /*!< List of RRSIGs in current node. */ - - int rdata_count; /*!< Count of parsed rdata. */ -}; - -typedef struct zparser zparser_type; - -extern zparser_type *parser; - -extern void zc_error_prev_line(const char *fmt, ...); - -/* used in zonec.lex */ - -void zc_error_prev_line(const char *fmt, ...); -void zc_warning_prev_line(const char *fmt, ...); - -/*! - * \brief Does all the processing of RR - saves to zone, assigns RRSIGs etc. - */ - /*! * \brief Parses and creates zone from given file. * @@ -167,34 +115,6 @@ void zc_warning_prev_line(const char *fmt, ...); int zone_read(const char *name, const char *zonefile, const char *outfile, int semantic_checks); -/*! - * \brief Creates zparser instance. - * - * - * \return Created zparser instance. - */ -zparser_type *zparser_create(); - -/*! - * \brief Inits zoneparser structure. - * - * \param filename Name of file with zone. - * \param ttl Default TTL. - * \param rclass Default class. - * \param origin Zone origin. - */ -void zparser_init(const char *filename, uint32_t ttl, uint16_t rclass, - knot_node_t *origin, knot_dname_t *owner_from_config); - -/*! - * \brief Frees zoneparser structure. - * - */ -void zparser_free(); - -int save_dnames_in_table(knot_dname_table_t *table, - knot_rrset_t *rrset); - #endif /* _KNOTD_ZONEPARSER_H_ */ /*! @} */