--- /dev/null
+# Copyright (C) 2023 Balthasar Szczepański
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package botm_common;
+
+use strict;
+#use warnings;
+use utf8;
+
+use Encode qw(encode decode);
+
+use Exporter;
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+
+$VERSION = 1.000000;
+@ISA = qw(Exporter);
+@EXPORT = ();
+@EXPORT_OK = qw(readdatafile);
+%EXPORT_TAGS = ();
+
+sub readdatafile {
+ (my $path, my $encoding, my $content_only) = @_;
+ my $file;
+ my %data;
+ my $eoh=0;
+
+ if ($encoding eq '') {
+ $encoding = 'utf8';
+ }
+ if ($content_only) {
+ $eoh=1;
+ }
+
+ # check if $path is actually a path or maybe a filehandle
+ # filehandles are references.
+ if(ref($path)) {
+ $file=$path;
+ unless (seek($file, 0, 0)) {
+ # return %data;
+ }
+ }
+ else {
+ unless (open ($file, "<:$encoding", $path)) {
+ return %data;
+ }
+ }
+
+ # The name of header field in previous line. Required for header fields that
+ # occupy multiple lines.
+ my $lastname='';
+
+ while (defined(my $line = <$file>)) {
+ # $line = decode($encoding, $line);
+ my $name='';
+ my $value='';
+
+ if ($eoh){
+ unless($line eq'') {
+ $data{'content'} = $data{'content'}.$line;
+ }
+ next;
+ }
+
+ $line =~ s/[\n]$//g;
+
+ # Empty line - end of header.
+ if ($line eq ''){
+ $eoh=1;
+ }
+ # Line starts with whitespace. It's a continuation of the previous line.
+ # Concatenate the field value, separated by newline.
+ elsif($line =~ /^[ \t](.*)$/){
+ if($lastname ne '') {
+ $data{$lastname} .= "\n".$1;
+ }
+ }
+ # Line starts with a name followed by colon/equal sign. Save the value
+ elsif ($line =~ /^([ -9;-<>-~]+)((:[ \t])|=)(.*)$/) {
+ $name = lc($1);
+ $value = $4;
+
+ $data{$name} = $value;
+
+ $lastname = $name;
+ }
+ }
+ # If argument was a path the file must be closed.
+ unless (ref($path)) {
+ close ($file);
+ }
+
+ return %data;
+}
+
+1
--- /dev/null
+# "makefile" is automatically generated from "makefile.1.mak"
+#
+# Copyright (C) 2023 Balthasar Szczepański
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ifndef TARGET
+TARGET = debug
+# when want to change target run this first:
+# make -B TARGET=target_name makefile
+endif
+
+CHMOD=/usr/bin/chmod
+CP =/usr/bin/cp
+MKDIR=/usr/bin/mkdir
+RM =/usr/bin/rm
+
+BIN_PATH = /botm/bin/test-post
+LIB_PATH = /botm/lib/test-post
+
+
+CONFIGFILE = settings-$(TARGET).txt settings.txt
+
+# The configuration tool
+# http://bicyclesonthemoon.info/git/botm-config
+CONFIGURE = /botm/bin/config/configure.pl
+CONFIGURE_CMD = $(PERL) $(CONFIGURE) $(CONFIGFILE)
+
+# keep these 2 lists in the same order!:
+GENERATE_FROM=\
+sendpost.1.pl
+
+TO_GENERATE=\
+sendpost
+
+DIR=\
+$(BIN_PATH)\
+$(LIB_PATH)
+
+SETUID=
+
+EXEC=\
+sendpost
+
+BIN=\
+$(EXEC)
+
+LIB=\
+botm_common.pm
+
+all: $(BIN)
+
+makefile: makefile.1.mak $(CONFIGFILE)
+ $(CONFIGURE_CMD) < makefile.1.mak > makefile
+
+
+$(TO_GENERATE): $(GENERATE_FROM) $(CONFIGFILE)
+ $(CONFIGURE_CMD) --in $(GENERATE_FROM) --out $(TO_GENERATE)
+
+
+exec: $(EXEC)
+ $(CHMOD) +x $(EXEC)
+
+setuid: $(SETUID)
+# $(CHMOD) u+s,g+s $(SETUID)
+
+
+mktree:
+ $(MKDIR) -p $(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
+ $(RM) -f $(BIN_PATH)/*
+ $(CP) -p $(BIN) $(BIN_PATH)
+endif
+
+ifdef LIB_PATH
+cp_lib: $(LIB) | mktree
+ $(RM) -f $(LIB_PATH)/*
+ $(CP) -p $(LIB) $(LIB_PATH)
+endif
+
+install: all cp_bin cp_lib
+
+clean:
+ $(RM) -f $(TO_GENERATE)
+
+PHONY: all clean install cp_bin cp_lib
+
+
+
+e:
+# CC=gcc
+# CC2=g++
+# CF=-g -Wall
+# # LF=-lIL
+# LF2=-lcgi
+
+# all: posted mpview remove post bot5 upload viewer enable
+
+# bot5: bot5.c post.awk mpost.awk makefile
+ # $(CC) $(CF) -o bot5 bot5.c
+
+# # deliver: deliver.c
+# # $(CC) $(CF) -o deliver deliver.c
+
+# remove: remove.c verify.awk
+ # $(CC) $(CF) -o remove remove.c $(LF2)
+
+# mpview: mpview.c mview.awk verify.awk makefile
+ # $(CC) $(CF) -o mpview mpview.c $(LF2)
+
+# posted: posted.c posted.awk makefile
+ # $(CC) $(CF) -o posted posted.c $(LF2)
+
+# post: post.cpp preview.awk bb2html.awk verify.awk makefile
+ # $(CC2) $(CF) -o post post.cpp $(LF2)
+
+# upload: upload.c upload.awk makefile
+ # $(CC) $(CF) -o upload upload.c $(LF2)
+
+# viewer: viewer.c makefile
+ # $(CC) $(CF) -o viewer viewer.c $(LF2)
+
+# enable: posted mpview remove post upload viewer
+ # chmod u+s posted mpview remove post upload viewer
# "makefile" is automatically generated from "makefile.1.mak"\r
-# 08.05.2023\r
# \r
# Copyright (C) 2023 Balthasar Szczepański\r
# \r
###MAKE_RM: RM = rm\r
\r
###MAKE_BIN_PATH: BIN_PATH = /botm/bin/post\r
+###MAKE_LIB_PATH: LIB_PATH = /botm/lib/post\r
\r
\r
CONFIGFILE = settings-$(TARGET).txt settings.txt\r
\r
DIR=\\r
$(BIN_PATH)\\r
+$(LIB_PATH)\r
\r
SETUID=\r
\r
BIN=\\r
$(EXEC)\r
\r
+LIB=\\r
+botm_common.pm\r
+\r
all: $(BIN)\r
\r
makefile: makefile.1.mak $(CONFIGFILE)\r
$(CP) -p $(BIN) $(BIN_PATH)\r
endif\r
\r
-install: all cp_bin\r
+ifdef LIB_PATH\r
+cp_lib: $(LIB) | mktree\r
+ $(RM) -f $(LIB_PATH)/*\r
+ $(CP) -p $(LIB) $(LIB_PATH)\r
+endif\r
+\r
+install: all cp_bin cp_lib\r
\r
clean:\r
$(RM) -f $(TO_GENERATE)\r
\r
-PHONY: all clean\r
+PHONY: all clean install cp_bin cp_lib\r
\r
\r
\r
+++ /dev/null
-#!/usr/bin/perl
-
-use strict;
-use Getopt::Long;
###RUN_PERL:
+# Copyright (C) 2023 Balthasar Szczepański
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
use strict;
+use utf8;
use Getopt::Long;
+use Encode qw(encode decode);
+
+###PERL_LIB: use lib '/botm/lib/post';
+use botm_common qw(readdatafile);
+
+###PERL_ENCODING_FILE_IN: use constant ENCODING_FILE_IN => 'UTF-8'
+###PERL_ENCODING_FILE_OUT: use constant ENCODING_FILE_OUT => 'utf8'
+###PERL_ENCODING_STD_IN: use constant ENCODING_STD_IN => 'UTF-8'
+###PERL_ENCODING_STD_OUT: use constant ENCODING_STD_OUT => 'utf8'
+
+binmode STDIN, ':encoding('.ENCODING_STD_IN.')';
+# binmode ARGV, ':encoding('.ENCODING_STD_IN.')'; # not working
+binmode STDOUT, ':encoding('.ENCODING_STD_OUT.')';
+binmode STDERR, ':encoding('.ENCODING_STD_OUT.')';
+
+my $helptext =
+ "sendpost [options] [file(s)]\n".
+ " -s, --username=USERNAME\n".
+ " -p, --password=PASSWORD\n".
+ " -t, --subject=POST_SUBJECT\n".
+ " -c, --content=POST_CONTENT\n".
+ "\n".
+ " -d, --data-only\n".
+ "\n".
+ " -B, --bbcode\n".
+ " -b, --no-bbcode\n".
+ " -S, --smilies\n".
+ " -s, --no-smilies\n".
+ " -U, --urls\n".
+ " -u, --no-urls\n".
+ " -G, --signature\n".
+ " -g, --no-signature\n".
+ " -N, --notify\n".
+ " -n, --no-notify\n".
+ "\n".
+ " -M, --mirror\n".
+ " -m, --no-mirror\n".
+ "\n".
+ " -h, --help\n";
+
+my %options = {};
+
+foreach my $arg (@ARGV) {
+ $arg = decode(ENCODING_STD_IN, $arg);
+}
+
+Getopt::Long::Configure('bundling');
+GetOptions (
+ 'username|l=s' => \$options{'username'},
+ 'password|p=s' => \$options{'password'},
+ 'subject|t=s' => \$options{'subject'},
+ 'content|c=s' => \$options{'content'},
+
+ 'data-only|d' => \$options{'data-only'},
+
+ 'bbcode|B' => \$options{ 'bbcode'},
+ 'no-bbcode|b' => \$options{'no-bbcode'},
+ 'smilies|S' => \$options{ 'smilies'},
+ 'no-smilies|s' => \$options{'no-smilies'},
+ 'urls|U' => \$options{ 'urls'},
+ 'no-urls|u' => \$options{'no-urls'},
+ 'signature|G' => \$options{ 'signature'},
+ 'no-signature|g' => \$options{'no-signature'},
+ 'notify|N' => \$options{ 'notify'},
+ 'no-notify|n' => \$options{'no-notify'},
+
+ 'mirror|M' => \$options{ 'mirror'},
+ 'no-mirror|m' => \$options{'no-mirror'},
+ 'help|h' => \$options{ 'help'}
+);
+
+if ($options{'help'} ne '') {
+ print $helptext;
+ exit 0;
+}
+
+print "options\n";
+foreach my $ind (keys %options) {
+ print $ind.'='.$options{$ind}."\n";
+}
+print;
+foreach my $arg (@ARGV) {
+ print "\nFILE $arg\n";
+ my %data = readdatafile($arg, 'utf8', 1);
+ foreach my $ind (keys %data) {
+ print $ind.'='.$data{$ind}."\n";
+ }
+}
+if ((scalar @ARGV) == 0) {
+ print "\nSTDIN\n";
+ my $fh;
+ my %data = readdatafile(\*STDIN, 'utf8', 1);
+ foreach my $ind (keys %data) {
+ print $ind.'='.$data{$ind}."\n";
+ }
+}
+
--- /dev/null
+# target name. settings file (THIS FILE) is "settings-TARGET_NAME.txt"
+# 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
+
+encoding_file_in: UTF-8
+encoding_file_out: utf8
+encoding_std_in: UTF-8
+encoding_std_out: utf8
+
+cp: /usr/bin/cp
+chmod: /usr/bin/chmod
+mkdir: /usr/bin/mkdir
+perl: /usr/bin/perl
+rm: /usr/bin/rm
configure: /botm/bin/config/configure.pl
bin_path: /botm/bin/post
+lib_path: /botm/lib/post
+
+encoding_file_in: UTF-8
+encoding_file_out: utf8
+encoding_std_in: UTF-8
+encoding_std_out: utf8
cp: /usr/bin/cp
chmod: /usr/bin/chmod
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-MAKE_CONFIGURE = CONFIGURE = $configure
-MAKE_TARGET = TARGET = $target
-
_SHEBANG: #!$0
+_PERL_USE_2: use $0 $1;
+_PERL_CONSTANT: use constant $0 => $1;
-RUN_PERL = @_SHEBANG($perl)
+MAKE_CONFIGURE = CONFIGURE = $configure
+MAKE_TARGET = TARGET = $target
MAKE_CHMOD = CHMOD=$chmod
MAKE_CP = CP =$cp
MAKE_MKDIR = MKDIR=$mkdir
MAKE_RM = RM =$rm
+MAKE_BIN_PATH = BIN_PATH = $bin_path
+MAKE_LIB_PATH = LIB_PATH = $lib_path
+
+
+PERL_ENCODING_FILE_IN = @_PERL_CONSTANT(ENCODING_FILE_IN , '$encoding_file_in')
+PERL_ENCODING_FILE_OUT = @_PERL_CONSTANT(ENCODING_FILE_OUT, '$encoding_file_out')
+PERL_ENCODING_STD_IN = @_PERL_CONSTANT(ENCODING_STD_IN , '$encoding_std_in')
+PERL_ENCODING_STD_OUT = @_PERL_CONSTANT(ENCODING_STD_OUT , '$encoding_std_out')
+PERL_LIB = @_PERL_USE_2(lib, '$lib_path')
+
-MAKE_BIN_PATH = BIN_PATH = $bin_path
\ No newline at end of file
+RUN_PERL = @_SHEBANG($perl)
\ No newline at end of file