hashsum.c: Return nonzero from `checkhash' on errors.
[u/mdw/catacomb] / pgen-stdev.c
CommitLineData
d38c2e8d 1/* -*-c-*-
2 *
b817bfc6 3 * $Id: pgen-stdev.c,v 1.4 2004/04/08 01:36:15 mdw Exp $
d38c2e8d 4 *
5 * Standard event handlers
6 *
7 * (c) 1999 Straylight/Edgeware
8 */
9
45c0fd36 10/*----- Licensing notice --------------------------------------------------*
d38c2e8d 11 *
12 * This file is part of Catacomb.
13 *
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
45c0fd36 18 *
d38c2e8d 19 * Catacomb 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 Library General Public License for more details.
45c0fd36 23 *
d38c2e8d 24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 * MA 02111-1307, USA.
28 */
29
d38c2e8d 30/*----- Header files ------------------------------------------------------*/
31
32#include <stdio.h>
33#include <stdlib.h>
34#include <string.h>
35
36#include "pgen.h"
37
38/*----- Main code ---------------------------------------------------------*/
39
40/* --- @pgen_evspin@ --- *
41 *
42 * Displays a spinning baton to show progress.
43 */
44
45int pgen_evspin(int rq, pgen_event *ev, void *p)
46{
47 static char spinner[] = "/-\\|";
48 static char *q = spinner;
49
50 switch (rq) {
51 case PGEN_PASS:
52 case PGEN_FAIL:
d38c2e8d 53 putchar(*q++);
54 putchar('\b');
55 fflush(stdout);
56 if (!*q)
57 q = spinner;
58 break;
960547de 59 case PGEN_DONE:
60 case PGEN_ABORT:
61 putchar(' ');
62 putchar('\b');
63 fflush(stdout);
64 break;
d38c2e8d 65 }
66 return (0);
67}
68
69/* --- @pgen_ev@ --- *
70 *
71 * Traditional event handler, shows dots for each test.
72 */
73
74int pgen_ev(int rq, pgen_event *ev, void *p)
75{
76 switch (rq) {
77 case PGEN_BEGIN:
78 printf("Searching for %s: ", ev->name);
79 fflush(stdout);
80 break;
81 case PGEN_FAIL:
82 putchar('.');
83 fflush(stdout);
84 break;
85 case PGEN_PASS:
86 putchar('+');
87 fflush(stdout);
88 break;
89 case PGEN_DONE:
90 puts("+ ok");
91 break;
92 case PGEN_ABORT:
93 puts(" failed");
94 break;
95 }
96 return (0);
97}
98
df0292de 99/* --- @pgen_subev@ --- *
100 *
101 * Subsidiary event handler, mainly for Lim-Lee searches and so on.
102 */
103
104int pgen_subev(int rq, pgen_event *ev, void *p)
105{
106 switch (rq) {
107 case PGEN_BEGIN:
108 printf("[%s: ", ev->name);
109 fflush(stdout);
110 break;
111 case PGEN_FAIL:
112 putchar('.');
113 fflush(stdout);
114 break;
115 case PGEN_PASS:
116 putchar('+');
117 fflush(stdout);
118 break;
119 case PGEN_DONE:
120 fputs("+]", stdout);
121 fflush(stdout);
122 break;
123 case PGEN_ABORT:
124 fputs(" failed]", stdout);
125 fflush(stdout);
126 break;
127 }
128 return (0);
129}
130
d38c2e8d 131/*----- That's all, folks -------------------------------------------------*/