3 # update.pl is generated from update.1.pl.
5 # update already ONGed frames & stuff
7 # Copyright (C) 2016, 2017, 2023, 2024 Balthasar SzczepaĆski
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU Affero General Public License as
11 # published by the Free Software Foundation, either version 3 of the
12 # License, or (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU Affero General Public License for more details.
19 # You should have received a copy of the GNU Affero General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 use Encode::Locale ('decode_argv');
25 use Encode ('encode', 'decode');
27 ###PERL_LIB: use lib /botm/lib/bsta
33 'write_index', 'write_static_viewer_page', 'write_static_goto',
34 'read_frame_data', 'read_default', 'read_words_list',
35 'read_settings', 'read_state'
38 binmode STDIN, ':encoding(UTF-8)';
39 binmode STDOUT, ':encoding(UTF-8)';
40 binmode STDERR, ':encoding(UTF-8)';
46 my %settings = read_settings();
47 my %default = read_default();
48 my %state = read_state();
49 my %all_frame_data = ();
50 my %all_words_data = ();
54 my $ong_state = int($state{'state'});
55 my $last_frame = ($ong_state > STATE->{'inactive'}) ?
65 foreach my $id (@ARGV) {
70 for (my $f=0; $f<=$last_frame; $f+=1) {
74 elsif ($id =~ /^[0-9]+$/) {
77 if ($f <= $last_frame) {
81 print "$f > $last_frame\n";
85 elsif ($id =~ /^[ic]$/) {
94 # duplicated - before AND after normal pages!
97 my $r = write_static_goto(
111 foreach my $id (@list) {
116 '', # timer value; not relevant
128 make_static_pages($id);
131 # duplicated - before AND after normal pages!
134 my $r = write_static_goto(
154 unless ($id =~ /^[0-9]+$/) {
159 unless (($f >= 0) && ($f <= $last_frame)) {
163 my $r = $all_frame_data{$f};
168 my %frame_data = read_frame_data($f);
169 $all_frame_data{$f} = \%frame_data;
176 unless ($id =~ /^[0-9]+$/) {
181 unless (($f >= 0) && ($f <= $last_frame)) {
185 my $r = $all_words_data{$f};
190 my %words_data = read_words_list($f, 1);
191 $all_words_data{$f} = \%words_data;
195 sub make_static_page {
197 unless ($id =~ /^[0-9]+$/) {
203 ($f < $last_frame) || (
204 ($ong_state >= STATE->{'end'}) &&
213 if (($f == 0) && ($ong_state > STATE->{'inactive'})) {
219 print (($r) ? " OK\n" : " FAIL\n");
222 print 'static page '.$f;
223 $r = write_static_viewer_page (
229 get_frame_data($f-1),
230 get_frame_data($f+1),
233 print (($r) ? " OK\n" : " FAIL\n");
237 sub make_static_pages {
239 unless ($id =~ /^[0-9]+$/) {
243 unless (($f >= 0) && ($f <= $last_frame)) {
247 make_static_page($f);
248 make_static_page($f-1);
249 make_static_page($f+1);
250 make_static_page($f);