| 1 | /* -*-c-*- |
| 2 | * |
| 3 | * $Id: pres_plain.c,v 1.2 1999/07/16 12:49:59 mdw Exp $ |
| 4 | * |
| 5 | * Plain output style for remote builds |
| 6 | * |
| 7 | * (c) 1999 EBI |
| 8 | */ |
| 9 | |
| 10 | /*----- Licensing notice --------------------------------------------------* |
| 11 | * |
| 12 | * This file is part of sw-tools. |
| 13 | * |
| 14 | * sw-tools is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | * (at your option) any later version. |
| 18 | * |
| 19 | * sw-tools is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with sw-tools; if not, write to the Free Software Foundation, |
| 26 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 27 | */ |
| 28 | |
| 29 | /*----- Revision history --------------------------------------------------* |
| 30 | * |
| 31 | * $Log: pres_plain.c,v $ |
| 32 | * Revision 1.2 1999/07/16 12:49:59 mdw |
| 33 | * Improve exit status display. New interface from `doto' project. |
| 34 | * |
| 35 | * Revision 1.1.1.1 1999/06/02 16:53:35 mdw |
| 36 | * Initial import. |
| 37 | * |
| 38 | */ |
| 39 | |
| 40 | /*----- Header files ------------------------------------------------------*/ |
| 41 | |
| 42 | #include <errno.h> |
| 43 | #include <stdio.h> |
| 44 | #include <stdlib.h> |
| 45 | #include <string.h> |
| 46 | |
| 47 | #include <mLib/alloc.h> |
| 48 | #include <mLib/lbuf.h> |
| 49 | |
| 50 | #include "sw.h" |
| 51 | #include "sw_arch.h" |
| 52 | #include "pres_plain.h" |
| 53 | |
| 54 | /*----- Main code ---------------------------------------------------------*/ |
| 55 | |
| 56 | /* --- @line@ --- */ |
| 57 | |
| 58 | static void line(char *s, void *p) |
| 59 | { |
| 60 | archent *e = p; |
| 61 | if (s) |
| 62 | printf("%s: %s\n", e->arch, s); |
| 63 | } |
| 64 | |
| 65 | /* --- @plain_init@ --- */ |
| 66 | |
| 67 | int plain_init(archcons *a) |
| 68 | { |
| 69 | for (; a; a = a->cdr) { |
| 70 | archent *e = a->car; |
| 71 | lbuf *b; |
| 72 | if (!e->r) |
| 73 | continue; |
| 74 | b = xmalloc(sizeof(lbuf)); |
| 75 | e->pres = b; |
| 76 | lbuf_init(b, line, e); |
| 77 | } |
| 78 | return (0); |
| 79 | } |
| 80 | |
| 81 | /* --- @plain_output@ --- */ |
| 82 | |
| 83 | void plain_output(archent *e, const char *p, size_t sz) |
| 84 | { |
| 85 | lbuf_snarf(e->pres, p, sz); |
| 86 | } |
| 87 | |
| 88 | /* --- @plain_close@ --- */ |
| 89 | |
| 90 | void plain_close(archent *e, int ok, const char *summ) |
| 91 | { |
| 92 | lbuf_close(e->pres); |
| 93 | if (!ok) |
| 94 | printf("%s: %s\n", e->arch, summ); |
| 95 | } |
| 96 | |
| 97 | /* --- @plain_done@ --- */ |
| 98 | |
| 99 | void plain_done(archcons *a) |
| 100 | { |
| 101 | for (; a; a = a->cdr) { |
| 102 | if (!a->car->r) |
| 103 | continue; |
| 104 | free(a->car->pres); |
| 105 | } |
| 106 | if (opt_flags & optFlag_beep) |
| 107 | putchar('\a'); |
| 108 | } |
| 109 | |
| 110 | /*----- That's all, folks -------------------------------------------------*/ |