aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/message
diff options
context:
space:
mode:
authorrxu <rxu@mail.ru>2016-10-23 22:44:47 +0700
committerrxu <rxu@mail.ru>2016-10-23 22:44:47 +0700
commit51ef1ae346c08863d188e723ba41720e744a2fbd (patch)
tree84f29925ff5d59fcdc135bdbeadac0733966c7c0 /phpBB/phpbb/message
parenta02b124dd02f8c5a2d0c60820f6563311e983a4c (diff)
downloadforums-51ef1ae346c08863d188e723ba41720e744a2fbd.tar
forums-51ef1ae346c08863d188e723ba41720e744a2fbd.tar.gz
forums-51ef1ae346c08863d188e723ba41720e744a2fbd.tar.bz2
forums-51ef1ae346c08863d188e723ba41720e744a2fbd.tar.xz
forums-51ef1ae346c08863d188e723ba41720e744a2fbd.zip
[ticket/14831] Add more tests, better name for $e placeholder
PHPBB3-14831
Diffstat (limited to 'phpBB/phpbb/message')
0 files changed, 0 insertions, 0 deletions
n32' href='#n32'>32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
package printer::cups;

use strict;

use printer::data;
use run_program;
use common;


#------------------------------------------------------------------------------

sub lpstat_lpv() {

    # Get a list of remotely defined print queues, with "Description" and
    # "Location"

    # Info to return
    my @items;

    # Hash to simplify the adding of the URIs
    my $itemshash;

    # Run the "lpstat" command in a mode to give as much info about the
    # print queues as possible
    my @lpstat = run_program::rooted_get_stdout
	($::prefix, 'lpstat', '-l', '-p', '-v');
    
    my $currentitem = -1;
    for my $line (@lpstat) {
	chomp ($line);
	if (!($line =~ m!^\s*$!)) {
	    if ($line =~ m!^printer\s+(\S+)\s+(\S.*)$!) {
		# Beginning of new printer's entry
		my $name = $1;
		push(@items, {});
		$currentitem = $#items;
		$itemshash->{$name} = $currentitem;
		$items[$currentitem]{queuename} ||= $name;
	    } elsif ($line =~ m!^\s+Description:\s+(\S.*)$!) {
		# Description field
		if ($currentitem != -1) {
		    $items[$currentitem]{description} ||= $1;
		}
	    } elsif ($line =~ m!^\s+Location:\s+(\S.*)$!) {
		# Location field
		if ($currentitem != -1) {
		    $items[$currentitem]{location} ||= $1;
		}
	    } elsif ($line =~ m!^device\s+for\s+(\S+):\s+(\S.*)$!) {
		# "device for ..." line, extract URI
		my $name = $1;
		my $uri = $2;
		if (defined($itemshash->{$name})) {
		    if ($uri !~ /:/) {$uri = "file:" . $uri};
		    $currentitem = $itemshash->{$name};
		    if (($currentitem <= $#items) &&
			($items[$currentitem]{queuename} eq $name)) {
			$items[$currentitem]{uri} ||= $uri;
			if ($uri =~ m!^ipp://([^/:]+)[:/]!) {
			    $items[$currentitem]{ipp} = $1;
			}
		    }
		}
	    }
	}
    }
    return @items;
}

sub lpstat_v() {
    map {