###MAKE_RM: RM = rm\r
###MAKE_PERL: PERL = perl\r
\r
-###MAKE_BIN_PATH: BIN_PATH = /botm/bin/post\r
-###MAKE_LIB_PATH: LIB_PATH = /botm/lib/post\r
-###MAKE_TMP_PATH: TMP_PATH = /botm/tmp/post\r
+###MAKE_BIN_PATH: BIN_PATH = /botm/bin/post\r
+###MAKE_DATA_PATH: DATA_PATH = /botm/data/post\r
+###MAKE_LIB_PATH: LIB_PATH = /botm/lib/post\r
+###MAKE_TMP_PATH: TMP_PATH = /botm/tmp/post\r
\r
\r
CONFIGFILE = settings-$(TARGET).txt settings.txt\r
\r
DIR=\\r
$(BIN_PATH)\\r
+$(DATA_PATH)\\r
$(LIB_PATH)\\r
$(TMP_PATH)\r
\r
'system_encoded'
);
+use constant OK => 0;
+use constant POST_INVALID => 1;
+use constant POST_FAILED => 2;
+use constant POST_NOT_ACCEPTED => 3;
+
###PERL_VERSION: use constant VERSION => 'x.x.x';
###PERL_ENCODING_FILE: use constant ENCODING_FILE => 'UTF-8';
@ARGV = (\*STDIN);
}
-my $code = 0;
+my $code = OK;
foreach my $arg (@ARGV) {
my $r;
unless (keys %data) {
unless ($options{'quiet'} ne '') {
print "NO DATA\n";
- if ($code == 0) {
- $code = 1;
- }
+ }
+ if ($code == OK) {
+ $code = POST_INVALID;
}
print STDERR 'No data';
unless ($arg == \*STDIN) {
# }
unless ($options{'no-mirror'}) {
$r = post_to_mirror(\%options, \%post);
- if ($r == 0) {
+ if ($r == OK) {
next;
}
}
- if ($code == 0) {
+ if ($code == OK) {
$code = $r;
}
}
print 'INVALID ID '.$cmd_options->{'edit'}."\n";
}
print STDERR 'Not a valid mirror post ID: '.$cmd_options->{'edit'}."\n";
- return 1;
+ return POST_INVALID;
}
$query_data{'e'} = 'm'.$cmd_options->{'edit'};
}
print "WGET FAIL $r\n";
}
print STDERR "Failed to get edit page: wget: $r\n";
- return $r;
+ return POST_FAILED;
}
unless (open($fh, '<:encoding('.ENCODING_MIRROR.')', encode('locale_fs', $tmp_path))) {
print "FAIL open $tmp_path\n";
}
print STDERR "Failed to open edit page. $tmp_path\n";
- return 1;
+ return POST_FAILED;
}
%header = read_header_file($fh, ENCODING_MIRROR());
print 'FAIL '.$header{':status-code'}.' '.$header{':reason-phrase'}."\n";
}
print STDERR 'Failed to get edit page: '.$header{':status-code'}.' '.$header{':reason-phrase'}."\n";
- return int($header{':status-code'})
+ return POST_FAILED;
}
if (($cmd_options->{'edit'} ne '') and ($cmd_options->{'append'} ne '')) {
print "FAIL previous post\n";
}
print STDERR 'Failed getting previous post content: '.$previous_post{'error'}."\n";
- return 1;
+ return POST_FAILED;
}
if ($cmd_options->{'verbose'} ne '') {
print "PREVIOUS POST\n";
unless ($cmd_options->{'quiet'} ne '') {
print "WGET FAIL $r\n";
}
- print STDERR "Failed to open post submit response: wget: $r\n";
- return $r;
+ print STDERR "Failed to get post submit response: wget: $r\n";
+ return POST_FAILED;
}
unless (open($fh, '<:encoding('.ENCODING_MIRROR.')', encode('locale_fs', $tmp_path))) {
print "FAIL open $tmp_path\n";
}
print STDERR "Failed to open post submit response. $tmp_path\n";
- return 1;
+ return POST_FAILED;
}
%header = read_header_file($fh, ENCODING_MIRROR());
print 'FAIL '.$header{':status-code'}.' '.$header{':reason-phrase'}."\n";
}
print STDERR 'Failed to get post submit response page: '.$header{':status-code'}.' '.$header{':reason-phrase'}."\n";
- return int($header{':status-code'})
+ return POST_FAILED;
}
($r, $s) = get_mirror_post_status($fh);
print "FAIL $s\n";
}
print STDERR "Post not accepted by mirror: $s.\n";
- return 1;
+ return POST_NOT_ACCEPTED;
}
unless ($cmd_options->{'quiet'} ne '') {
unlink($tmp_path, $cookie_path, $postdata_path);
}
- return 0;
-
+ return OK;
}
sub get_mirror_post_status {
my $r = system_encoded(WGET, @arg);
-
return $r;
}
# where TARGET_NAME is the value
target: debug
-# The configuration tool
-# http://bicyclesonthemoon.info/git/botm-config
-# alternatively, copy configure.pl to source directory.
-configure: /botm/bin/config/configure.pl
bin_path: /botm/bin/test-post
lib_path: /botm/lib/test-post
tmp_path: /botm/tmp/test-post
+data_path: /botm/data/test-post
mirror_url: http://1190.botcastle1b/ott
_PERL_CONSTANT: use constant $0 => $1;
_PERL_CONSTANT_STR: @_PERL_CONSTANT($0,@_PERL_STR($1))
-MAKE_CONFIGURE = CONFIGURE = $configure
MAKE_TARGET = TARGET = $target
MAKE_CHMOD = CHMOD=$chmod
MAKE_CC = CC =$CC
MAKE_CF = CF =$CF
-MAKE_BIN_PATH = BIN_PATH = $bin_path
-MAKE_LIB_PATH = LIB_PATH = $lib_path
-MAKE_TMP_PATH = TMP_PATH = $tmp_path
+MAKE_BIN_PATH = BIN_PATH = $bin_path
+MAKE_DATA_PATH = DATA_PATH = $data_path
+MAKE_LIB_PATH = LIB_PATH = $lib_path
+MAKE_TMP_PATH = TMP_PATH = $tmp_path
PERL_DEFAULT_PASSWORD = @_PERL_CONSTANT_STR( DEFAULT_PASSWORD , $default_password)