]> bicyclesonthemoon.info Git - ott/post/commitdiff
error code, drop config config, data dir
authorb <rowerynaksiezycu@gmail.com>
Sun, 9 Jul 2023 22:01:16 +0000 (22:01 +0000)
committerb <rowerynaksiezycu@gmail.com>
Sun, 9 Jul 2023 22:01:16 +0000 (22:01 +0000)
makefile
makefile.1.mak
sendpost.1.pl
settings-debug.txt
settings-release.txt
settings.txt

index 277394e6d9bb2ec554f25595c85e6385b241c5f4..731ea39330dd7ff8f3127cff80a2661e31df5dca 100644 (file)
--- a/makefile
+++ b/makefile
@@ -31,9 +31,10 @@ MKDIR=/usr/bin/mkdir
 RM   =/usr/bin/rm
 PERL =/usr/bin/perl
 
-BIN_PATH = /botm/bin/test-post
-LIB_PATH = /botm/lib/test-post
-TMP_PATH = /botm/tmp/test-post
+BIN_PATH  = /botm/bin/test-post
+DATA_PATH = /botm/data/test-post
+LIB_PATH  = /botm/lib/test-post
+TMP_PATH  = /botm/tmp/test-post
 
 
 CONFIGFILE = settings-$(TARGET).txt settings.txt
@@ -51,6 +52,7 @@ sendpost.pl
 
 DIR=\
 $(BIN_PATH)\
+$(DATA_PATH)\
 $(LIB_PATH)\
 $(TMP_PATH)
 
index f258dde8ff36adc314297c759d51ca2f90586a4b..5a25251732c0d6cf409fd53a84d6bcfcc2bbc0fe 100644 (file)
@@ -31,9 +31,10 @@ PERL = perl
 ###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
@@ -51,6 +52,7 @@ sendpost.pl
 \r
 DIR=\\r
 $(BIN_PATH)\\r
+$(DATA_PATH)\\r
 $(LIB_PATH)\\r
 $(TMP_PATH)\r
 \r
index ff301cb35ba4afd8a7e687a9a2f0f2998f7ca270..906eac19dddb70b3e9b427cf4a0c1db4ae6c8525 100644 (file)
@@ -31,6 +31,11 @@ use botm_common (
        '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';
@@ -161,7 +166,7 @@ if ((scalar @ARGV) == 0) {
        @ARGV = (\*STDIN);
 }
 
-my $code = 0;
+my $code = OK;
 foreach my $arg (@ARGV) {
        my $r;
        
@@ -181,9 +186,9 @@ foreach my $arg (@ARGV) {
                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) {
@@ -213,11 +218,11 @@ foreach my $arg (@ARGV) {
        # }
        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;
        }
 }
@@ -383,7 +388,7 @@ sub post_to_mirror {
                                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'};
        }
@@ -410,7 +415,7 @@ sub post_to_mirror {
                        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))) {
@@ -418,7 +423,7 @@ sub post_to_mirror {
                        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());
@@ -432,7 +437,7 @@ sub post_to_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 '')) {
@@ -442,7 +447,7 @@ sub post_to_mirror {
                                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";
@@ -510,8 +515,8 @@ sub post_to_mirror {
                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))) {
@@ -519,7 +524,7 @@ sub post_to_mirror {
                        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());
@@ -533,7 +538,7 @@ sub post_to_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);
@@ -544,7 +549,7 @@ sub post_to_mirror {
                        print "FAIL $s\n";
                }
                print STDERR "Post not accepted by mirror: $s.\n";
-               return 1;
+               return POST_NOT_ACCEPTED;
        }
        
        unless ($cmd_options->{'quiet'} ne '') {
@@ -562,8 +567,7 @@ sub post_to_mirror {
                unlink($tmp_path, $cookie_path, $postdata_path);
        }
        
-       return 0;
-       
+       return OK;
 }
 
 sub get_mirror_post_status {
@@ -731,7 +735,6 @@ sub wget {
        
        my $r = system_encoded(WGET, @arg);
        
-       
        return $r;
 }
 
index 0f754a94ea0d2ec8c6c4568a85d1ba96695b7332..3fb83903a171a36d1a5b56f02252ef54d3e991e4 100644 (file)
@@ -2,14 +2,11 @@
 # 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
 
index 01c2ca7d5cf2e3ed79243303bf34bb81451c1fc1..59c0959c385c597871d2934f1bcb3301d710862a 100644 (file)
@@ -2,14 +2,11 @@
 # where TARGET_NAME is the value
 target: release
 
-# 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/post
 lib_path: /botm/lib/post
 tmp_path: /botm/tmp/post
+data_path: /botm/data/post
 
 # TODO: wget doesn't accept my https :(
 mirror_url: http://1190.bicyclesonthemoon.info/ott
index e323205afdf1249f1cff9ab67d2b83cfef2e9b45..b8820721664d3f0c22e48ab36a3c61515be065e8 100644 (file)
@@ -24,7 +24,6 @@ _PERL_USE_2: use $0 $1;
 _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
@@ -36,9 +35,10 @@ MAKE_RM     = RM   =$rm
 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)