return KNOT_EOK;
}
-void changeset_print(const changeset_t *changeset, FILE *outfile, bool color)
+int changeset_print(const changeset_t *changeset, FILE *outfile, bool color)
{
size_t buflen = 1024;
char *buff = malloc(buflen);
+ int ret = KNOT_EOK;
knot_dump_style_t style = KNOT_DUMP_STYLE_DEFAULT;
style.now = knot_time();
fprintf(outfile, "%s;; Removed%s\n", style.color, COL_RST(color));
}
if (changeset->soa_from != NULL && buff != NULL) {
- (void)knot_rrset_txt_dump(changeset->soa_from, &buff, &buflen, &style);
+ ret = knot_rrset_txt_dump(changeset->soa_from, &buff, &buflen, &style);
fprintf(outfile, "%s%s%s", style.color, buff, COL_RST(color));
}
- (void)zone_dump_text(changeset->remove, NULL, outfile, false, style.color);
+ if (ret >= 0 && changeset->remove != NULL) { // Can be NULL if zone-in-journal
+ ret = zone_dump_text(changeset->remove, NULL, outfile, false, style.color);
+ }
style.color = COL_GRN(color);
if (changeset->soa_to != NULL || !zone_contents_is_empty(changeset->add)) {
fprintf(outfile, "%s;; Added%s\n", style.color, COL_RST(color));
}
- if (changeset->soa_to != NULL && buff != NULL) {
- (void)knot_rrset_txt_dump(changeset->soa_to, &buff, &buflen, &style);
+ if (changeset->soa_to != NULL && buff != NULL && ret >= 0) {
+ ret = knot_rrset_txt_dump(changeset->soa_to, &buff, &buflen, &style);
fprintf(outfile, "%s%s%s", style.color, buff, COL_RST(color));
}
- (void)zone_dump_text(changeset->add, NULL, outfile, false, style.color);
+ if (ret >= 0) {
+ ret = zone_dump_text(changeset->add, NULL, outfile, false, style.color);
+ }
free(buff);
+ return ret >= 0 ? KNOT_EOK : ret;
}
uint64_t merged_ts;
} print_params_t;
-static void print_changeset(const changeset_t *chs, uint64_t timestamp, print_params_t *params)
+static int print_changeset(const changeset_t *chs, uint64_t timestamp, print_params_t *params)
{
char time_buf[64] = { 0 };
(void)knot_time_print(TIME_PRINT_UNIX, timestamp, time_buf, sizeof(time_buf));
time_buf,
COL_RST(params->color));
}
- changeset_print(chs, stdout, params->color);
+ return changeset_print(chs, stdout, params->color);
}
typedef struct {
static int print_changeset_cb(bool special, const changeset_t *ch, uint64_t timestamp, void *ctx)
{
print_params_t *params = ctx;
+ int ret = KNOT_EOK;
if (ch != NULL && params->counter++ >= params->limit) {
if (params->merge) {
return merge_changeset_cb(special, ch, timestamp, ctx);
print_changeset_debugmode(ch, timestamp);
params->changes++;
} else {
- print_changeset(ch, timestamp, params);
+ ret = print_changeset(ch, timestamp, params);
}
if (special && params->debug) {
printf("---------------------------------------------\n");
}
}
- return KNOT_EOK;
+ return ret;
}
int print_journal(char *path, knot_dname_t *name, print_params_t *params)