Table for driving key data extraction.
[u/mdw/catacomb] / pgen-stdev.c
CommitLineData
d38c2e8d 1/* -*-c-*-
2 *
3 * $Id: pgen-stdev.c,v 1.1 1999/12/22 16:01:57 mdw Exp $
4 *
5 * Standard event handlers
6 *
7 * (c) 1999 Straylight/Edgeware
8 */
9
10/*----- Licensing notice --------------------------------------------------*
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.
18 *
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.
23 *
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
30/*----- Revision history --------------------------------------------------*
31 *
32 * $Log: pgen-stdev.c,v $
33 * Revision 1.1 1999/12/22 16:01:57 mdw
34 * Standard progress-reporting functions.
35 *
36 */
37
38/*----- Header files ------------------------------------------------------*/
39
40#include <stdio.h>
41#include <stdlib.h>
42#include <string.h>
43
44#include "pgen.h"
45
46/*----- Main code ---------------------------------------------------------*/
47
48/* --- @pgen_evspin@ --- *
49 *
50 * Displays a spinning baton to show progress.
51 */
52
53int pgen_evspin(int rq, pgen_event *ev, void *p)
54{
55 static char spinner[] = "/-\\|";
56 static char *q = spinner;
57
58 switch (rq) {
59 case PGEN_PASS:
60 case PGEN_FAIL:
61 case PGEN_DONE:
62 putchar(*q++);
63 putchar('\b');
64 fflush(stdout);
65 if (!*q)
66 q = spinner;
67 break;
68 }
69 return (0);
70}
71
72/* --- @pgen_ev@ --- *
73 *
74 * Traditional event handler, shows dots for each test.
75 */
76
77int pgen_ev(int rq, pgen_event *ev, void *p)
78{
79 switch (rq) {
80 case PGEN_BEGIN:
81 printf("Searching for %s: ", ev->name);
82 fflush(stdout);
83 break;
84 case PGEN_FAIL:
85 putchar('.');
86 fflush(stdout);
87 break;
88 case PGEN_PASS:
89 putchar('+');
90 fflush(stdout);
91 break;
92 case PGEN_DONE:
93 puts("+ ok");
94 break;
95 case PGEN_ABORT:
96 puts(" failed");
97 break;
98 }
99 return (0);
100}
101
102/*----- That's all, folks -------------------------------------------------*/