]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - config/cfgroot/general-functions.pl
Implement wireless client on RED.
[people/teissler/ipfire-2.x.git] / config / cfgroot / general-functions.pl
index f94cdbf16c49b31054125ff12c6fea9119b2cfbd..3a04369e357a652b13985afd2dc9a91a996d3367 100644 (file)
@@ -144,6 +144,10 @@ sub age
        my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
                $atime, $mtime, $ctime, $blksize, $blocks) = stat $_[0];
        my $now = time;
+       my $timestring = '';
+       my $dset = 0;           # Day is set, when > 0
+       my $hset = 0;           # Hour is set, when > 0
+       my $mset = 0;           # Minute is set, when > 0
 
        my $totalsecs = $now - $mtime;
        my $days = int($totalsecs / 86400);
@@ -153,7 +157,50 @@ sub age
        my $mins = $totalmins % 60;
        my $secs = $totalsecs % 60;
 
-       return "${days}d ${hours}h ${mins}m ${secs}s";
+       if      ($days > 1) { 
+               ${timestring} .= ${days}.' '.$Lang::tr{'days'}.', ';
+               $dset = 1; 
+       }
+       elsif   ($days == 1) { 
+               ${timestring} .= ${days}.' '.$Lang::tr{'day'}.', ';
+               $dset = 1; 
+       }
+
+       if      (($hours > 1) && !($dset)) { 
+               ${timestring} .= ${hours}.' '.$Lang::tr{'hours'}.', ';
+               $hset = 1;
+       }
+       elsif   (($hours == 1) && !($dset)) { 
+               ${timestring} .= ${hours}.' '.$Lang::tr{'hour'}.', ';
+               $hset = 1;
+       }
+       elsif ($dset) {
+               ${timestring} .= ${hours}.' '.$Lang::tr{'age shour'}.', ';
+               $hset = 1;
+       }
+
+       if      ((($mins > 1) || ($mins == 0)) && !($dset || $hset)) { 
+               ${timestring} .= ${mins}.' '.$Lang::tr{'minutes'}.', ';
+               $mset = 1;
+       }
+       elsif   (($mins == 1) && !($dset || $hset)) { 
+               ${timestring} .= ${mins}.' '.$Lang::tr{'minute'}.', ';
+               $mset = 1;
+       }
+       else {
+               ${timestring} .= ${mins}.' '.$Lang::tr{'age sminute'}.', '; 
+               $mset = 1;
+       }
+
+       if      ((($secs > 1) || ($secs == 0)) && !($dset || $hset || $mset)) { 
+               ${timestring} .= ${secs}.' '.$Lang::tr{'age seconds'};
+       }
+       elsif   (($secs == 1) && !($dset || $hset || $mset)) { 
+               ${timestring} .= $secs.' '.$Lang::tr{'age second'};
+       }
+       else    { ${timestring} .= $secs.' '.$Lang::tr{'age ssecond'}; }
+
+       return ${timestring};
 }
 
 sub validip
@@ -933,4 +980,27 @@ sub GetIcmpDescription ($) {
     'Experimental');
     if ($index>41) {return 'unknown'} else {return @icmp_description[$index]};
 }
+
+sub RedIsWireless() {
+       # This function checks if a network device is a wireless device.
+
+       my %settings = ();
+       &readhash("${General::swroot}/ethernet/settings", \%settings);
+
+       # Find the name of the network device.
+       my $device = $settings{'RED_DEV'};
+
+       # Exit, if no device is configured.
+       return 0 if ($device eq "");
+
+       # Return 1 if the device is a wireless one.
+       my $path = "/sys/class/net/$device/wireless";
+       if (-d $path) {
+               return 1;
+       }
+
+       # Otherwise return zero.
+       return 0;
+}
+
 1;