chiark / gitweb /
Merge some changes from 1.0.4. Very odd.
[sw-tools] / src / pres_plain.c
1 /* -*-c-*-
2  *
3  * $Id$
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 /*----- Header files ------------------------------------------------------*/
30
31 #include <errno.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35
36 #include <mLib/alloc.h>
37 #include <mLib/lbuf.h>
38
39 #include "sw.h"
40 #include "sw_arch.h"
41 #include "pres_plain.h"
42
43 /*----- Main code ---------------------------------------------------------*/
44
45 /* --- @line@ --- */
46
47 static void line(char *s, size_t len, void *p)
48 {
49   archent *e = p;
50   if (s)
51     printf("%s: %s\n", e->arch, s);
52 }
53
54 /* --- @plain_init@ --- */
55
56 int plain_init(archcons *a)
57 {
58   for (; a; a = a->cdr) {
59     archent *e = a->car;
60     lbuf *b;
61     if (!e->r)
62       continue;
63     b = xmalloc(sizeof(lbuf));
64     e->pres = b;
65     lbuf_init(b, line, e);
66   }
67   return (0);
68 }
69
70 /* --- @plain_output@ --- */
71
72 void plain_output(archent *e, const char *p, size_t sz)
73 {
74   lbuf_snarf(e->pres, p, sz);
75 }
76
77 /* --- @plain_close@ --- */
78
79 void plain_close(archent *e, int ok, const char *summ)
80 {
81   lbuf_close(e->pres);
82   lbuf_destroy(e->pres);
83   if (!ok)
84     printf("%s: %s\n", e->arch, summ);
85 }
86
87 /* --- @plain_done@ --- */
88
89 void plain_done(archcons *a)
90 {
91   for (; a; a = a->cdr) {
92     if (!a->car->r)
93       continue;
94     free(a->car->pres);
95   }
96   if (opt_flags & optFlag_beep)
97     putchar('\a');
98 }
99
100 /*----- That's all, folks -------------------------------------------------*/