">">

A quality product of
logo
Mib Software

httpsync logo

getpacklist.pl


This is an example of conditional packing list generation, as described in HTTPsync Conditional and "Access Protected" Packing Lists

#!/usr/bin/perl -- -*-perl-*-
# ------------------------------------------------------------
# getpacklist.pl, cgi interface to get a packing list useful
# for use with httpsync.  See http://www.mibsoftware.com/httpsync/
#
# This software is placed in the public domain.
#
# Expects URL encoded FORM values (i.e. method=GET)
#  u = user name.  Checked against a list.
#  d = document name.  Checked against a list.
# ------------------------------------------------------------
$| = 1;
# Split the name-value pairs
@pairs = split(/&/, $ENV{'QUERY_STRING'});

foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair); 
    # Un-Webify plus signs and %-encoding
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ tr/([|~"'`%\\])/ /;

    $FORM{$name} = $value;
}
if ($FORM{u} eq "test") {
    print "Content-type: text/plain\n\n";
# note: the lists available must already have a "R" line.
    system("cat ../userkt/inn/dev/inn2.0-beta/$FORM{d}");
} else {
    print "Status: 403 Forbidden\n";

    # Print out a content-type for HTTP/1.0 compatibility
    print "Content-type: text/plain\n\n";
    print "Access denied\n";
}
Other topics
HTTPsync Conditional and "Access Protected" Packing Lists

Up to HTTPsync Usage

Up to HTTPsync home

Inquiries [DocID: /httpsync/0011.htm]
Copyright 1998, 1999, 2000, 2001 Forrest J. Cavalier III, Mib Software