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