From: b Date: Tue, 13 Jun 2023 23:08:45 +0000 (+0000) Subject: use temp file, when send post function X-Git-Tag: v1.0.0~6 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=3e4ee675aa9d3d2a7d9ada48a521ab424505f553;p=ott%2Fpost use temp file, when send post function --- diff --git a/botm-common b/botm-common index 148c226..c484395 160000 --- a/botm-common +++ b/botm-common @@ -1 +1 @@ -Subproject commit 148c2263126c655c3f457c7552842113babe19a0 +Subproject commit c4843959c15d793dca50517c28dee25ddecbe275 diff --git a/makefile b/makefile index a9cc2c6..1878986 100644 --- a/makefile +++ b/makefile @@ -28,6 +28,7 @@ RM =/usr/bin/rm BIN_PATH = /botm/bin/test-post LIB_PATH = /botm/lib/test-post +TMP_PATH = /botm/tmp/test-post CONFIGFILE = settings-$(TARGET).txt settings.txt @@ -46,7 +47,11 @@ sendpost DIR=\ $(BIN_PATH)\ -$(LIB_PATH) +$(LIB_PATH)\ +$(TMP_PATH) + +HIDDEN_DIR=\ +$(TMP_PATH) SETUID= @@ -78,7 +83,7 @@ setuid: $(SETUID) mktree: $(MKDIR) -p $(DIR) -# $(CHMOD) g-r,g-w,g-x,o-r,o-w,o-x $(HIDDEN_DIR) + $(CHMOD) g-r,g-w,g-x,o-r,o-w,o-x $(HIDDEN_DIR) ifdef BIN_PATH cp_bin: $(BIN) setuid exec | mktree diff --git a/makefile.1.mak b/makefile.1.mak index 772aa5e..c2c6e97 100644 --- a/makefile.1.mak +++ b/makefile.1.mak @@ -28,6 +28,7 @@ endif ###MAKE_BIN_PATH: BIN_PATH = /botm/bin/post ###MAKE_LIB_PATH: LIB_PATH = /botm/lib/post +###MAKE_TMP_PATH: TMP_PATH = /botm/tmp/post CONFIGFILE = settings-$(TARGET).txt settings.txt @@ -46,7 +47,11 @@ sendpost DIR=\ $(BIN_PATH)\ -$(LIB_PATH) +$(LIB_PATH)\ +$(TMP_PATH) + +HIDDEN_DIR=\ +$(TMP_PATH) SETUID= @@ -78,7 +83,7 @@ setuid: $(SETUID) mktree: $(MKDIR) -p $(DIR) -# $(CHMOD) g-r,g-w,g-x,o-r,o-w,o-x $(HIDDEN_DIR) + $(CHMOD) g-r,g-w,g-x,o-r,o-w,o-x $(HIDDEN_DIR) ifdef BIN_PATH cp_bin: $(BIN) setuid exec | mktree diff --git a/sendpost.1.pl b/sendpost.1.pl index dda1ce9..c857849 100644 --- a/sendpost.1.pl +++ b/sendpost.1.pl @@ -24,6 +24,7 @@ use Encode qw(encode decode); use botm_common ( 'read_data_file', 'write_data_file', 'merge_url', + 'make_temp_path' ); ###PERL_ENCODING_FILE_IN: use constant ENCODING_FILE_IN => 'UTF-8'; @@ -35,6 +36,8 @@ use botm_common ( ###PERL_DEFAULT_SUBJECT: use constant DEFAULT_SUBJECT => 'Re: 1190: "Time"'; ###PERL_DEFAULT_USERNAME: use constant DEFAULT_USERNAME => 'username'; +###PERL_TMP_PATH: use constant TMP_PATH => '/botm/tmp/post'; + ###PERL_MIRROR_URL: use constant MIRROR_URL => 'https://1190.bicyclesonthemoon.info/ott'; use constant HELP_TEXT => @@ -111,28 +114,39 @@ if ($options{'mirror-url'} eq '') { $options{'mirror-url'} = MIRROR_URL; } -post_to_mirror(); -exit 0; -print "options:\n"; -my $a = write_data_file(\*STDOUT, ENCODING_STD_OUT, 0, \%options); -print "$a\n"; +# print "OPTIONS:\n"; +# my $a = write_data_file(\*STDOUT, ENCODING_STD_OUT, 0, \%options); -foreach my $arg (@ARGV) { - print "\nFILE $arg\n"; - my %data = read_data_file($arg, 'utf8', 1); - foreach my $ind (keys %data) { - print $ind.'='.$data{$ind}."\n"; - } +if ((scalar @ARGV) == 0) { + @ARGV = (\*STDIN); } -# if ((scalar @ARGV) == 0) { - # print "\nSTDIN\n"; - # my $fh; - # my %data = read_data_file(\*STDIN, 'utf8', 1); + +foreach my $arg (@ARGV) { + # print "\nFILE $arg\n"; + my %data = read_data_file($arg, ENCODING_FILE_IN, $options{'data-only'}); # foreach my $ind (keys %data) { # print $ind.'='.$data{$ind}."\n"; # } -# } + + my %post = prepare_post(\%options, \%data); + # foreach my $ind (keys %post) { + # print $ind.'='.$post{$ind}."\n"; + # } + + # unless ($options{'mirror'}) { + # if (post_to_ott (\%options, \%post)) { + # next; + # } + # } + unless ($options{'no-mirror'}) { + post_to_mirror(\%options, \%post); + } +} + + + + sub prepare_post { (my $cmd_options, my $file_data) = @_; @@ -255,8 +269,16 @@ sub prepare_post { sub post_to_mirror { (my $cmd_options, my $post) = @_; - my $post_url = merge_url($options{'mirror-url'}, 'post'); + my $post_url = merge_url($cmd_options->{'mirror-url'}, 'post'); + + my $tmp_path = make_temp_path(TMP_PATH, 'sendpost.htm'); + my $cookie_path = make_temp_path(TMP_PATH, 'sendpost.cookie.txt'); + my $postdata_path = make_temp_path(TMP_PATH, 'sendpost.postdata.txt'); + print $post_url."\n"; + print $tmp_path."\n"; + print $cookie_path."\n"; + print $postdata_path."\n"; } diff --git a/settings-debug.txt b/settings-debug.txt index 38f43eb..42b9345 100644 --- a/settings-debug.txt +++ b/settings-debug.txt @@ -9,6 +9,7 @@ configure: /botm/bin/config/configure.pl bin_path: /botm/bin/test-post lib_path: /botm/lib/test-post +tmp_path: /botm/tmp/test-post mirror_url: http://1190.botcastle1b/ott diff --git a/settings-release.txt b/settings-release.txt index 456017b..cfdb6cf 100644 --- a/settings-release.txt +++ b/settings-release.txt @@ -9,6 +9,7 @@ configure: /botm/bin/config/configure.pl bin_path: /botm/bin/post lib_path: /botm/lib/post +tmp_path: /botm/tmp/post mirror_url: https://1190.bicyclesonthemoon.info/ott @@ -21,6 +22,7 @@ default_subject: Re: 1190: "Time" default_username: _ default_password: _ + cp: /usr/bin/cp chmod: /usr/bin/chmod mkdir: /usr/bin/mkdir diff --git a/settings.txt b/settings.txt index df9c303..42c656a 100644 --- a/settings.txt +++ b/settings.txt @@ -32,6 +32,7 @@ MAKE_RM = RM =$rm MAKE_BIN_PATH = BIN_PATH = $bin_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) @@ -41,9 +42,10 @@ PERL_ENCODING_FILE_IN = @_PERL_CONSTANT_STR( ENCODING_FILE_IN , $encoding_file_ PERL_ENCODING_FILE_OUT = @_PERL_CONSTANT_STR( ENCODING_FILE_OUT, $encoding_file_out) PERL_ENCODING_STD_IN = @_PERL_CONSTANT_STR( ENCODING_STD_IN , $encoding_std_in) PERL_ENCODING_STD_OUT = @_PERL_CONSTANT_STR( ENCODING_STD_OUT , $encoding_std_out) -PERL_MIRROR_URL = @_PERL_CONSTANT_STR( MIRROR_URL , $mirror_url); +PERL_MIRROR_URL = @_PERL_CONSTANT_STR( MIRROR_URL , $mirror_url) +PERL_TMP_PATH = @_PERL_CONSTANT_STR( TMP_PATH , $tmp_path) -PERL_LIB = @_PERL_USE_2(lib, '$lib_path') +PERL_LIB = @_PERL_USE_2(lib, @_PERL_STR($lib_path)) RUN_PERL = @_SHEBANG($perl) \ No newline at end of file