From ce0455f7c490bab2a9940f0cec1a4b1e797ddfe2 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 25 Mar 2008 07:02:56 +0200 Subject: Refactor status-fd duplicate output code into a new function Based on a patch by Ian Jackson . --- src/configure.c | 18 +----------------- src/errors.c | 18 +----------------- 2 files changed, 2 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/configure.c b/src/configure.c index 9c73f8dc7..8f447fe1c 100644 --- a/src/configure.c +++ b/src/configure.c @@ -531,25 +531,9 @@ static enum conffopt promptconfaction(const char* cfgfile, const char* realold, if (!(what&cfof_prompt)) return what; - /* if there is a status pipe, send conffile-prompt there */ - if (status_pipes) { - static struct varbuf *status= NULL; - struct pipef *pipef= status_pipes; - int r; - if (status == NULL) { - status = nfmalloc(sizeof(struct varbuf)); - varbufinit(status); - } else - varbufreset(status); - - r= varbufprintf(status, "status: %s : %s : '%s' '%s' %i %i \n", + statusfd_send("status: %s : %s : '%s' '%s' %i %i ", cfgfile, "conffile-prompt", realold, realnew, useredited, distedited); - while (pipef) { - write(pipef->fd, status->buf, r); - pipef= pipef->next; - } - } do { /* Flush the terminal's input in case the user diff --git a/src/errors.c b/src/errors.c index ab2c9d272..83daa0f07 100644 --- a/src/errors.c +++ b/src/errors.c @@ -56,23 +56,7 @@ void print_error_perpackage(const char *emsg, const char *arg) { fprintf(stderr, _("%s: error processing %s (--%s):\n %s\n"), DPKG, arg, cipaction->olong, emsg); - if (status_pipes) { - static struct varbuf *status= NULL; - struct pipef *pipef= status_pipes; - int r; - if (status == NULL) { - status = nfmalloc(sizeof(struct varbuf)); - varbufinit(status); - } else - varbufreset(status); - - r= varbufprintf(status, "status: %s : %s : %s\n", arg, "error",emsg); - while (pipef) { - write(pipef->fd, status->buf, r); - pipef= pipef->next; - } - } - + statusfd_send("status: %s : %s : %s", arg, "error", emsg); nr= malloc(sizeof(struct error_report)); if (!nr) { -- cgit v1.2.3