d38c2e8d |
1 | /* -*-c-*- |
2 | * |
df0292de |
3 | * $Id: pgen-stdev.c,v 1.3 2000/08/18 19:16:12 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 $ |
df0292de |
33 | * Revision 1.3 2000/08/18 19:16:12 mdw |
34 | * New event handler for showing in detail sub-prime generation. |
35 | * |
960547de |
36 | * Revision 1.2 2000/07/09 21:31:34 mdw |
37 | * Delete the spinner when the search finishes. |
38 | * |
d38c2e8d |
39 | * Revision 1.1 1999/12/22 16:01:57 mdw |
40 | * Standard progress-reporting functions. |
41 | * |
42 | */ |
43 | |
44 | /*----- Header files ------------------------------------------------------*/ |
45 | |
46 | #include <stdio.h> |
47 | #include <stdlib.h> |
48 | #include <string.h> |
49 | |
50 | #include "pgen.h" |
51 | |
52 | /*----- Main code ---------------------------------------------------------*/ |
53 | |
54 | /* --- @pgen_evspin@ --- * |
55 | * |
56 | * Displays a spinning baton to show progress. |
57 | */ |
58 | |
59 | int pgen_evspin(int rq, pgen_event *ev, void *p) |
60 | { |
61 | static char spinner[] = "/-\\|"; |
62 | static char *q = spinner; |
63 | |
64 | switch (rq) { |
65 | case PGEN_PASS: |
66 | case PGEN_FAIL: |
d38c2e8d |
67 | putchar(*q++); |
68 | putchar('\b'); |
69 | fflush(stdout); |
70 | if (!*q) |
71 | q = spinner; |
72 | break; |
960547de |
73 | case PGEN_DONE: |
74 | case PGEN_ABORT: |
75 | putchar(' '); |
76 | putchar('\b'); |
77 | fflush(stdout); |
78 | break; |
d38c2e8d |
79 | } |
80 | return (0); |
81 | } |
82 | |
83 | /* --- @pgen_ev@ --- * |
84 | * |
85 | * Traditional event handler, shows dots for each test. |
86 | */ |
87 | |
88 | int pgen_ev(int rq, pgen_event *ev, void *p) |
89 | { |
90 | switch (rq) { |
91 | case PGEN_BEGIN: |
92 | printf("Searching for %s: ", ev->name); |
93 | fflush(stdout); |
94 | break; |
95 | case PGEN_FAIL: |
96 | putchar('.'); |
97 | fflush(stdout); |
98 | break; |
99 | case PGEN_PASS: |
100 | putchar('+'); |
101 | fflush(stdout); |
102 | break; |
103 | case PGEN_DONE: |
104 | puts("+ ok"); |
105 | break; |
106 | case PGEN_ABORT: |
107 | puts(" failed"); |
108 | break; |
109 | } |
110 | return (0); |
111 | } |
112 | |
df0292de |
113 | /* --- @pgen_subev@ --- * |
114 | * |
115 | * Subsidiary event handler, mainly for Lim-Lee searches and so on. |
116 | */ |
117 | |
118 | int pgen_subev(int rq, pgen_event *ev, void *p) |
119 | { |
120 | switch (rq) { |
121 | case PGEN_BEGIN: |
122 | printf("[%s: ", ev->name); |
123 | fflush(stdout); |
124 | break; |
125 | case PGEN_FAIL: |
126 | putchar('.'); |
127 | fflush(stdout); |
128 | break; |
129 | case PGEN_PASS: |
130 | putchar('+'); |
131 | fflush(stdout); |
132 | break; |
133 | case PGEN_DONE: |
134 | fputs("+]", stdout); |
135 | fflush(stdout); |
136 | break; |
137 | case PGEN_ABORT: |
138 | fputs(" failed]", stdout); |
139 | fflush(stdout); |
140 | break; |
141 | } |
142 | return (0); |
143 | } |
144 | |
d38c2e8d |
145 | /*----- That's all, folks -------------------------------------------------*/ |