File Coverage

blib/lib/UI/Dialog/Backend/Whiptail.pm
Criterion Covered Total %
statement 217 369 58.8
branch 45 122 36.8
condition 56 156 35.9
subroutine 22 29 75.8
pod 19 20 95.0
total 359 696 51.5


line stmt bran cond sub pod time code
1             package UI::Dialog::Backend::Whiptail;
2             ###############################################################################
3             # Copyright (C) 2015 Kevin C. Krinke
4             #
5             # This library is free software; you can redistribute it and/or
6             # modify it under the terms of the GNU Lesser General Public
7             # License as published by the Free Software Foundation; either
8             # version 2.1 of the License, or (at your option) any later version.
9             #
10             # This library is distributed in the hope that it will be useful,
11             # but WITHOUT ANY WARRANTY; without even the implied warranty of
12             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13             # Lesser General Public License for more details.
14             #
15             # You should have received a copy of the GNU Lesser General Public
16             # License along with this library; if not, write to the Free Software
17             # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18             ###############################################################################
19 2     2   22455 use 5.006;
  2         8  
20 2     2   10 use strict;
  2         3  
  2         50  
21 2     2   718 use FileHandle;
  2         12451  
  2         12  
22 2     2   970 use Carp;
  2         4  
  2         148  
23 2     2   962 use Time::HiRes qw( sleep );
  2         1710  
  2         14  
24 2     2   944 use UI::Dialog::Backend;
  2         5  
  2         87  
25              
26             BEGIN {
27 2     2   13 use vars qw( $VERSION @ISA );
  2         8  
  2         125  
28 2     2   21 @ISA = qw( UI::Dialog::Backend );
29 2         8249 $VERSION = '1.11';
30             }
31              
32             #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
33             #: Constructor Method
34             #:
35              
36             sub new {
37 2     2 1 549 my $proto = shift();
38 2   33     19 my $class = ref($proto) || $proto;
39 2 50       14 my $cfg = ((ref($_[0]) eq "HASH") ? $_[0] : (@_) ? { @_ } : {});
    50          
40 2         5 my $self = {};
41 2         6 bless($self, $class);
42 2         20 $self->{'_state'} = {};
43 2         5 $self->{'_opts'} = {};
44              
45             #: Dynamic path discovery...
46 2         23 my $CFG_PATH = $cfg->{'PATH'};
47 2 50       13 if ($CFG_PATH) {
    50          
48 0 0       0 if (ref($CFG_PATH) eq "ARRAY") {
    0          
    0          
49 0         0 $self->{'PATHS'} = $CFG_PATH;
50             }
51             elsif ($CFG_PATH =~ m!:!) {
52 0         0 $self->{'PATHS'} = [ split(/:/,$CFG_PATH) ];
53             }
54             elsif (-d $CFG_PATH) {
55 0         0 $self->{'PATHS'} = [ $CFG_PATH ];
56             }
57             }
58             elsif ($ENV{'PATH'}) {
59 2         18 $self->{'PATHS'} = [ split(/:/,$ENV{'PATH'}) ];
60             }
61             else {
62 0         0 $self->{'PATHS'} = '';
63             }
64              
65 2   50     16 $self->{'_opts'}->{'literal'} = $cfg->{'literal'} || 0;
66 2   50     23 $self->{'_opts'}->{'callbacks'} = $cfg->{'callbacks'} || undef();
67 2   50     14 $self->{'_opts'}->{'debug'} = $cfg->{'debug'} || undef();
68 2   50     12 $self->{'_opts'}->{'title'} = $cfg->{'title'} || undef();
69 2   50     17 $self->{'_opts'}->{'backtitle'} = $cfg->{'backtitle'} || undef();
70 2   50     14 $self->{'_opts'}->{'width'} = $cfg->{'width'} || 65;
71 2   50     11 $self->{'_opts'}->{'height'} = $cfg->{'height'} || 10;
72 2   50     19 $self->{'_opts'}->{'listheight'} = $cfg->{'listheight'} || $cfg->{'menuheight'} || 10;
73 2   50     11 $self->{'_opts'}->{'percentage'} = $cfg->{'percentage'} || 1;
74 2   33     24 $self->{'_opts'}->{'bin'} ||= $self->_find_bin('whiptail');
75 2   50     19 $self->{'_opts'}->{'autoclear'} = $cfg->{'autoclear'} || 0;
76 2   50     14 $self->{'_opts'}->{'clearbefore'} = $cfg->{'clearbefore'} || 0;
77 2   50     11 $self->{'_opts'}->{'clearafter'} = $cfg->{'clearafter'} || 0;
78 2   50     16 $self->{'_opts'}->{'beepbin'} = $cfg->{'beepbin'} || $self->_find_bin('beep') || '/usr/bin/beep';
79 2   50     15 $self->{'_opts'}->{'beepbefore'} = $cfg->{'beepbefore'} || 0;
80 2   50     14 $self->{'_opts'}->{'beepafter'} = $cfg->{'beepafter'} || 0;
81 2   50     20 $self->{'_opts'}->{'timeout'} = $cfg->{'timeout'} || 0;
82 2   50     11 $self->{'_opts'}->{'wait'} = $cfg->{'wait'} || 0;
83 2 50       28 unless (-x $self->{'_opts'}->{'bin'}) {
84 0         0 croak("the whiptail binary could not be found at: ".$self->{'_opts'}->{'bin'});
85             }
86              
87 2   50     12 $self->{'_opts'}->{'trust-input'} = $cfg->{'trust-input'} || 0;
88              
89 2 100       8 $self->{'test_mode'} = $cfg->{'test_mode'} if exists $cfg->{'test_mode'};
90 2         10 $self->{'test_mode_result'} = '';
91              
92 2         10 return($self);
93             }
94              
95              
96             #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
97             #: Private Methods
98             #:
99             my $SIG_CODE = {};
100             sub _del_gauge {
101 0     0   0 my $CODE = $SIG_CODE->{$$};
102 0 0       0 unless (not ref($CODE)) {
103 0         0 delete($CODE->{'_GAUGE'});
104 0         0 $CODE->rv('1');
105 0         0 $CODE->rs('null');
106 0         0 $CODE->ra('null');
107 0         0 $SIG_CODE->{$$} = "";
108             }
109             }
110              
111             sub append_format_base {
112 11     11 0 24 my ($self,$args,$fmt) = @_;
113 11         33 $fmt = $self->append_format_check($args,$fmt,'backtitle','--backtitle {{backtitle}}');
114 11         22 return $fmt;
115             }
116              
117             #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
118             #: Override Inherited Methods
119             #:
120             sub command_state {
121 5     5 1 8 my $self = $_[0];
122 5         7 my $cmnd = $_[1];
123 5 50       19 if ($self->is_unit_test_mode()) {
124 5         10 $self->{'test_mode_result'} = $cmnd;
125 5         11 return 0;
126             }
127 0         0 $self->_debug("".$cmnd);
128 0         0 system($cmnd . " 2> /dev/null");
129 0         0 return($? >> 8);
130             }
131             sub command_string {
132 4     4 1 7 my $self = $_[0];
133 4         7 my $cmnd = $_[1];
134 4 50       13 if ($self->is_unit_test_mode()) {
135 4         9 $self->{'test_mode_result'} = $cmnd;
136 4 50       15 return (wantarray) ? (0,'') : '';
137             }
138 0         0 $self->_debug($cmnd);
139 0         0 $self->gen_tempfile_name(); # don't accept the first result
140 0         0 my $tmpfile = $self->gen_tempfile_name();
141 0         0 my $text;
142 0         0 system($cmnd." 2> ".$tmpfile);
143 0         0 my $rv = $? >> 8;
144 0 0 0     0 if (-f $tmpfile # don't assume the file exists
145             && open(WHIPF,"<".$tmpfile)) {
146 0         0 local $/;
147 0         0 $text = ;
148 0         0 close(WHIPF);
149 0         0 unlink($tmpfile);
150             }
151             else {
152 0         0 $text = "";
153             }
154 0 0       0 return($text) unless defined wantarray;
155 0 0       0 return (wantarray) ? ($rv,$text) : $text;
156             }
157             sub command_array {
158 2     2 1 3 my $self = $_[0];
159 2         4 my $cmnd = $_[1];
160 2 50       6 if ($self->is_unit_test_mode()) {
161 2         5 $self->{'test_mode_result'} = $cmnd;
162 2 50       8 return (wantarray) ? (0,[]) : [];
163             }
164 0         0 $self->_debug($cmnd);
165 0         0 $self->gen_tempfile_name(); # don't accept the first result
166 0         0 my $tmpfile = $self->gen_tempfile_name();
167 0         0 my $text;
168 0         0 system($cmnd." 2> ".$tmpfile);
169 0         0 my $rv = $? >> 8;
170 0 0 0     0 if (-f $tmpfile # don't assume the file exists
171             && open(WHIPF,"<".$tmpfile)) {
172 0         0 local $/;
173 0         0 $text = ;
174 0         0 close(WHIPF);
175 0         0 unlink($tmpfile);
176             }
177             else {
178 0         0 $text = "";
179             }
180 0 0       0 return([split("\n",$text)]) unless defined wantarray;
181 0 0       0 return (wantarray) ? ($rv,[split("\n",$text)]) : [split("\n",$text)];
182             }
183              
184             #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
185             #: Public Methods
186             #:
187              
188             #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
189             #: Ask a binary question (Yes/No)
190             sub yesno {
191 1     1 1 800 my $self = shift();
192 1   50     7 my $caller = (caller(1))[3] || 'main';
193 1 50 0     4 $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
194 1 50 33     14 if ($_[0] && $_[0] eq 'caller') {
195 0         0 shift(); $caller = shift();
  0         0  
196             }
197 1         7 my $args = $self->_pre($caller,@_);
198              
199 1         8 my $fmt = $self->prepare_format($args);
200 1         5 $fmt = $self->append_format_base($args,$fmt);
201 1         4 $fmt = $self->append_format($fmt,'--yesno {{text}} {{height}} {{width}}');
202             my $command = $self->prepare_command
203             ( $args, $fmt,
204 1         8 text => $self->make_kvt($args,$args->{'text'}),
205             );
206              
207 1         5 my $rv = $self->command_state($command);
208 1         4 $self->ra('null');
209 1         5 $self->rs('null');
210 1         1 my $this_rv;
211 1 50 33     11 if ($rv && $rv >= 1) {
212 0         0 $self->ra("NO");
213 0         0 $self->rs("NO");
214 0         0 $self->rv($rv);
215 0         0 $this_rv = 0;
216             }
217             else {
218 1         4 $self->ra("YES");
219 1         4 $self->rs("YES");
220 1         4 $self->rv('null');
221 1         2 $this_rv = 1;
222             }
223 1         7 $self->_post($args);
224 1         6 return($this_rv);
225             }
226              
227             #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
228             #: Text entry
229             sub inputbox {
230 2     2 1 4 my $self = shift();
231 2   100     12 my $caller = (caller(1))[3] || 'main';
232 2 100 50     13 $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
233 2 100 66     14 if ($_[0] && $_[0] eq 'caller') {
234 1         2 shift(); $caller = shift();
  1         2  
235             }
236 2         9 my $args = $self->_pre($caller,@_);
237              
238 2         8 my $fmt = $self->prepare_format($args);
239 2         6 $fmt = $self->append_format_base($args,$fmt);
240 2 100       6 if ($args->{'password'}) {
241 1         5 $fmt = $self->append_format($fmt,'--passwordbox');
242             } else {
243 1         5 $fmt = $self->append_format($fmt,'--inputbox');
244             }
245 2         7 $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}} {{entry}}');
246             my $command = $self->prepare_command
247             ( $args, $fmt,
248             text => $self->make_kvt($args,$args->{'text'}),
249 2   33     9 entry => $self->make_kvl($args,($args->{'init'}||$args->{'entry'})),
250             );
251              
252 2         11 my ($rv,$text) = $self->command_string($command);
253 2         9 $self->ra('null');
254 2         3 my $this_rv;
255 2 50 33     9 if ($rv && $rv >= 1) {
256 0         0 $self->rv($rv);
257 0         0 $self->rs('null');
258 0         0 $this_rv = 0;
259             }
260             else {
261 2         6 $self->rv('null');
262 2         7 $self->rs($text);
263 2         7 $self->ra($text);
264 2         4 $this_rv = $text;
265             }
266 2         7 $self->_post($args);
267 2         12 return($this_rv);
268             }
269             #: password boxes aren't supported by gdialog
270             sub password {
271 1     1 1 2 my $self = shift();
272 1   50     10 return($self->inputbox('caller',((caller(1))[3]||'main'),@_,'password',1));
273             }
274              
275             #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
276             #: Text box
277             sub msgbox {
278 4     4 1 10 my $self = shift();
279 4   100     22 my $caller = (caller(1))[3] || 'main';
280 4 100 50     18 $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
281 4 100 66     22 if ($_[0] && $_[0] eq 'caller') {
282 1         2 shift(); $caller = shift();
  1         1  
283             }
284 4         20 my $args = $self->_pre($caller,@_);
285 4   50     20 $args->{'msgbox'} ||= 'msgbox';
286              
287 4         13 my $fmt = $self->prepare_format($args);
288 4         10 $fmt = $self->append_format_base($args,$fmt);
289 4         12 $fmt = $self->append_format($fmt,'--scrolltext');
290 4 100       12 if ($args->{'infobox'}) {
291 1         5 $fmt = $self->append_format($fmt,'--infobox');
292             }
293             else {
294 3         11 $fmt = $self->append_format($fmt,'--msgbox');
295             }
296 4         13 $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}}');
297             my $command = $self->prepare_command
298             ( $args, $fmt,
299 4         17 text => $self->make_kvt($args,$args->{'text'}),
300             );
301              
302 4         15 my $rv = $self->command_state($command);
303 4         14 $self->ra('null');
304 4         11 $self->rs('null');
305 4         6 my $this_rv;
306 4 50 33     14 if ($rv && $rv >= 1) {
307 0         0 $self->rv($rv);
308 0         0 $this_rv = 0;
309             }
310             else {
311 4 0 0     10 if ( ($args->{'msgbox'} eq "infobox")
      33        
312             && ($args->{'timeout'} || $args->{'wait'})
313             ) {
314             my $s = int(($args->{'wait'}) ? $args->{'wait'} :
315 0 0       0 ($args->{'timeout'}) ? ($args->{'timeout'} / 1000.0) : 1.0);
    0          
316 0         0 sleep($s);
317             }
318 4         13 $self->rv('null');
319 4         8 $this_rv = 1;
320             }
321 4         13 $self->_post($args);
322 4         20 return($this_rv);
323             }
324             sub infobox {
325 1     1 1 3 my $self = shift();
326 1   50     9 return($self->msgbox('caller',((caller(1))[3]||'main'),@_,'infobox',1));
327             }
328              
329             #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
330             #: File box
331             sub textbox {
332 1     1 1 3 my $self = shift();
333 1   50     8 my $caller = (caller(1))[3] || 'main';
334 1 50 0     8 $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
335 1 50 33     9 if ($_[0] && $_[0] eq 'caller') {
336 0         0 shift(); $caller = shift();
  0         0  
337             }
338 1         6 my $args = $self->_pre($caller,@_);
339              
340 1         6 my $fmt = $self->prepare_format($args);
341 1         5 $fmt = $self->append_format_base($args,$fmt);
342 1         6 $fmt = $self->append_format($fmt,'--scrolltext');
343 1         4 $fmt = $self->append_format($fmt,'--textbox');
344 1         5 $fmt = $self->append_format($fmt,'{{path}} {{height}} {{width}}');
345             my $command = $self->prepare_command
346             ( $args, $fmt,
347 1   50     9 path => $self->make_kvl($args,($args->{'path'}||'.')),
348             );
349              
350 1         5 my ($rv,$text) = $self->command_string($command);
351 1         6 $self->ra('null');
352 1         4 $self->rs('null');
353 1         2 my $this_rv;
354 1 50 33     5 if ($rv && $rv >= 1) {
355 0         0 $self->rv($rv);
356 0         0 $this_rv = 0;
357             }
358             else {
359 1         4 $self->rv('null');
360 1         2 $this_rv = 1;
361             }
362 1         4 $self->_post($args);
363 1         6 return($this_rv);
364             }
365              
366             #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
367             #: Lists
368             sub menu {
369 1     1 1 2 my $self = shift();
370 1   50     8 my $caller = (caller(1))[3] || 'main';
371 1 50 0     4 $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
372 1 50 33     8 if ($_[0] && $_[0] eq 'caller') {
373 0         0 shift(); $caller = shift();
  0         0  
374             }
375 1         5 my $args = $self->_pre($caller,@_);
376              
377             $args->{'listheight'} = $args->{'menuheight'}
378 1 50       4 if exists $args->{'menuheight'};
379              
380 1         5 my $fmt = $self->prepare_format($args);
381 1         4 $fmt = $self->append_format_base($args,$fmt);
382 1         4 $fmt = $self->append_format($fmt,'--separate-output');
383 1         11 $fmt = $self->append_format($fmt,'--menu');
384 1         4 $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}} {{listheight}} {{list}}');
385             my $command = $self->prepare_command
386             ( $args, $fmt,
387 1         6 text => $self->make_kvt($args,$args->{'text'}),
388             );
389              
390 1         5 my ($rv,$selected) = $self->command_string($command);
391 1         2 my $this_rv;
392 1 50 33     5 if ($rv && $rv >= 1) {
393 0         0 $self->rv($rv);
394 0         0 $self->rs('null');
395 0         0 $self->ra('null');
396 0         0 $this_rv = 0;
397             }
398             else {
399 1         4 $self->rv('null');
400 1         3 $self->rs($selected);
401 1         3 $self->ra($selected);
402 1         6 $this_rv = $selected;
403             }
404             }
405             sub checklist {
406 2     2 1 4 my $self = shift();
407 2   100     13 my $caller = (caller(1))[3] || 'main';
408 2 100 50     13 $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
409 2 100 66     18 if ($_[0] && $_[0] eq 'caller') {
410 1         2 shift(); $caller = shift();
  1         2  
411             }
412 2         9 my $args = $self->_pre($caller,@_);
413              
414             $args->{'listheight'} = $args->{'menuheight'}
415 2 50       7 if exists $args->{'menuheight'};
416              
417 2         7 my $fmt = $self->prepare_format($args);
418 2         6 $fmt = $self->append_format_base($args,$fmt);
419 2         7 $fmt = $self->append_format($fmt,'--separate-output');
420 2 100 66     19 if (defined $args->{radiolist} && $args->{radiolist}) {
421 1         4 $fmt = $self->append_format($fmt,'--radiolist');
422             } else {
423 1         4 $fmt = $self->append_format($fmt,'--checklist');
424             }
425 2         6 $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}} {{listheight}} {{list}}');
426             my $command = $self->prepare_command
427             ( $args, $fmt,
428 2         10 text => $self->make_kvt($args,$args->{'text'}),
429             );
430              
431 2         9 my ($rv,$selected) = $self->command_array($command);
432 2         4 my $this_rv;
433 2 50 33     7 if ($rv && $rv >= 1) {
434 0         0 $self->rv($rv);
435 0         0 $self->ra('null');
436 0         0 $self->rs('null');
437 0         0 $this_rv = 0;
438             }
439             else {
440 2         7 $self->rv('null');
441 2         3 $self->ra(@{$selected});
  2         9  
442 2         3 $self->rs(join("\n",@{$selected}));
  2         8  
443 2         4 $this_rv = $selected;
444             }
445 2         6 $self->_post($args);
446 2 50       7 return($this_rv) unless ref($this_rv) eq "ARRAY";
447 2         2 return(@{$this_rv});
  2         12  
448             }
449             sub radiolist {
450 1     1 1 3 my $self = shift();
451 1   50     10 return($self->checklist('caller',((caller(1))[3]||'main'),@_,'radiolist',1));
452             }
453              
454             #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
455             #: progress meter
456             sub gauge_start {
457 0     0 1   my $self = shift();
458 0   0       my $caller = (caller(1))[3] || 'main';
459 0 0 0       $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
460 0 0 0       if ($_[0] && $_[0] eq 'caller') {
461 0           shift(); $caller = shift();
  0            
462             }
463 0           my $args = $self->_pre($caller,@_);
464              
465 0   0       $self->{'_GAUGE'} ||= {};
466 0           $self->{'_GAUGE'}->{'ARGS'} = $args;
467              
468 0 0         if (defined $self->{'_GAUGE'}->{'FH'}) {
469 0           $self->rv(129);
470 0           $self->_post($args);
471 0           return(0);
472             }
473              
474 0           my $fmt = $self->prepare_format($args);
475 0           $fmt = $self->append_format($fmt,'--gauge');
476 0           $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}} {{percentage}}');
477             my $command = $self->prepare_command
478             ( $args, $fmt,
479             text => $self->make_kvt($args,$args->{'text'}),
480 0   0       percentage => $self->make_kvl($args,$args->{'percentage'}||'0'),
481             );
482              
483 0   0       $self->{'_GAUGE'}->{'PERCENT'} = ($args->{'percentage'} || '0');
484 0           $self->{'_GAUGE'}->{'FH'} = new FileHandle;
485 0           $self->{'_GAUGE'}->{'FH'}->open("| $command");
486 0           my $rv = $? >> 8;
487 0           $self->{'_GAUGE'}->{'FH'}->autoflush(1);
488 0   0       $self->rv($rv||'null');
489 0           $self->ra('null');
490 0           $self->rs('null');
491 0           my $this_rv;
492 0 0 0       if ($rv && $rv >= 1) {
493 0           $this_rv = 0;
494             }
495             else {
496 0           $this_rv = 1;
497             }
498 0           return($this_rv);
499             }
500             sub gauge_inc {
501 0     0 1   my $self = $_[0];
502 0   0       my $incr = $_[1] || 1;
503              
504 0 0         return(0) unless defined $self->{'_GAUGE'}->{'FH'};
505              
506 0           my $fh = $self->{'_GAUGE'}->{'FH'};
507 0           $self->{'_GAUGE'}->{'PERCENT'} += $incr;
508 0           $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge;
  0            
509 0           print $fh $self->{'_GAUGE'}->{'PERCENT'}."\n";
510 0 0         return(((defined $self->{'_GAUGE'}->{'FH'}) ? 1 : 0));
511             }
512             sub gauge_dec {
513 0     0 1   my $self = $_[0];
514 0   0       my $decr = $_[1] || 1;
515              
516 0 0         return(0) unless defined $self->{'_GAUGE'}->{'FH'};
517              
518 0           my $fh = $self->{'_GAUGE'}->{'FH'};
519 0           $self->{'_GAUGE'}->{'PERCENT'} -= $decr;
520 0           $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge;
  0            
521 0           print $fh $self->{'_GAUGE'}->{'PERCENT'}."\n";
522 0 0         return(((defined $self->{'_GAUGE'}->{'FH'}) ? 1 : 0));
523             }
524             sub gauge_set {
525 0     0 1   my $self = $_[0];
526 0   0       my $perc = $_[1] || $self->{'_GAUGE'}->{'PERCENT'} || 1;
527              
528 0           my $fh = $self->{'_GAUGE'}->{'FH'};
529 0 0         return(0) unless $self->{'_GAUGE'}->{'FH'};
530              
531 0           $self->{'_GAUGE'}->{'PERCENT'} = $perc;
532 0           $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge;
  0            
533 0           print $fh $self->{'_GAUGE'}->{'PERCENT'}."\n";
534 0 0         return(((defined $self->{'_GAUGE'}->{'FH'}) ? 1 : 0));
535             }
536             sub gauge_text {
537 0     0 1   my $self = $_[0];
538 0   0       my $mesg = $_[1] || return(0);
539              
540 0           my $fh = $self->{'_GAUGE'}->{'FH'};
541 0 0         return(0) unless $self->{'_GAUGE'}->{'FH'};
542              
543 0           $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge;
  0            
544 0           print $fh "\nXXX\n\n".$mesg."\n\nXXX\n\n".$self->{'_GAUGE'}->{'PERCENT'}."\n";
545 0 0         return(((defined $self->{'_GAUGE'}->{'FH'}) ? 1 : 0));
546             }
547             sub gauge_stop {
548 0     0 1   my $self = $_[0];
549              
550 0 0         return(0) unless $self->{'_GAUGE'}->{'FH'};
551              
552 0           my $args = $self->{'_GAUGE'}->{'ARGS'};
553 0           my $fh = $self->{'_GAUGE'}->{'FH'};
554 0           $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge;
  0            
555 0           $self->{'_GAUGE'}->{'FH'}->close();
556 0           delete($self->{'_GAUGE'}->{'FH'});
557 0           delete($self->{'_GAUGE'}->{'ARGS'});
558 0           delete($self->{'_GAUGE'}->{'PERCENT'});
559 0           delete($self->{'_GAUGE'});
560 0           $self->rv('null');
561 0           $self->rs('null');
562 0           $self->ra('null');
563 0           $self->_post($args);
564 0           return(1);
565             }
566              
567              
568             1;