CIPP

 view release on metacpan or  search on metacpan

doc/html2ps  view on Meta::CPAN

        &skip;
      }
    } elsif($byte == 0x2c) {
      $next += 10;
      $temp = ord substr($pic,$next-1,1);
      if($temp & 0x80) {$next += 3*2**(($temp & 0x07) + 1)};
      $next++;
      &skip;
    } else {return}
  }
}
sub skip {
  $byte = ord substr($pic,$next,1);
  while($byte != 0) {
    $next += $byte + 1;
    $byte = ord substr($pic,$next,1);
  }
  $next++;
  $byte = ord substr($pic,$next,1);
}
sub run {
  &dbg("@_\n") if($opt_d);
  $pm=`@_`;
}
sub geturl {
  local($url)=@_;
  &dbg("Retrieving $url");
  if($package{'libwww-perl'} || $package{'jfriedl'}) {
    warn "\n";
    &gu();
    if($code==401) {
      &prompt("\nDocument requires username and password\n\nUsername: ",$user);
      &prompt("Password: ",$pass);
      &gu($user,$pass);
    }
    $_[1]=$cont;
  } elsif(defined $geturl) {
    &dbg("...");
    $_[1]=`$geturl '$url'`;
    if($?) {
      &dbg("\n*** Error opening $url\n");
      return 0;
    }
    &dbg("done\n");
    if($_[1]=~/\r?\n\r?\n/) {
      $_[1]=$';
      $dhead=$`;
      ($code)=$dhead=~/HTTP\/\S+ +(\d+)/i;
      ($contyp)=$dhead=~/Content-type:\s+(.*)/i;
    } else {
      $code=500;
    }
  }
  $_[0]=$url;
  $code<300;
}
sub gu {
  if($package{'libwww-perl'}) {
    require LWP::UserAgent;
    $ua=new LWP::UserAgent;
    $req = HTTP::Request->new(GET => $url);
    $req->authorization_basic(@_) if(@_);
    $ua->agent($spoof) if($spoof);
    my $res = $ua->request($req);
    $code=$res->code;
    $contyp=$res->header('content-type');
    $cont=$res->content;
  } else {
    require "www.pl";
    @opts=@_?("authorization=$_[0]:$_[1]"):();
    push(@opts,"quiet") if(!$opt_d);
    $www::useragent=$spoof if($spoof);
    ($status,$memo,%info)=&www::open_http_url(*FILE,$url,@opts);
    $code=$info{'CODE'};
    ($contyp)=$info{'HEADER'}=~/Content-type:\s+(.*)/i;
    $cont=<FILE>;
  }
}
sub pictops {
  if($opt_g) {
    $fc=1;
    $pg1="pgm";
    $pg2="|ppmtopgm";
  } else {
    $fc=3;
    $pg1="ppm";
    $pg2="";
  }
  ($type)=$URL=~/([^\?]+)\??/;
  ($type)=$type=~/\.(\w+)$/;
  $bm="";
  $ps="";
  $pm="";
  if($opt_U && $src{$URL} && !$cmd{$URL.$red.$grn.$blu}) {
    $pic=$src{$URL};
  } elsif($URL=~m|://|) {
    &geturl($URL,$pic) || return;
  } else {
    $flag=0;
    if($opt_O) {
      $orig=$URL;
      unless($orig=~s/\.\w*$/.ps/) {$orig.=".ps"};
      if(open(ORIG,"$orig")) {
        $pic=<ORIG>;
        close ORIG;
        if($pic=~/^%!/ && $pic=~/%%BoundingBox:/) {
          $flag=1;
          &dbg("Using $orig as original for $URL\n") if($opt_d);
        }
      }
    }
    if(!$flag) {
      if(open(PIC,"$URL")) {
        binmode PIC;
        $pic=<PIC>;
        close PIC;
      } else {
        &dbg("*** Error opening $URL\n");
        return;
      }
    }



( run in 0.590 second using v1.01-cache-2.11-cpan-437f7b0c052 )