From 634abf341437e44a092c42d983e52303917a6276 Mon Sep 17 00:00:00 2001 From: b Date: Mon, 5 Dec 2022 23:11:40 +0000 Subject: [PATCH] t-1 online. That's all tools! --- enhance.1.conf | 1 + makefile | 12 ++-- makefile.1.mak | 12 ++-- online-core.1.h | 1 + settings-release.txt | 1 + settings.txt | 4 ++ t-1-cgi.c | 143 +++++++++++++++++++++++++++++++++++++++++++ t-1.1.htm | 15 +++++ t1.png | Bin 0 -> 2863 bytes 9 files changed, 181 insertions(+), 8 deletions(-) create mode 100644 t-1-cgi.c create mode 100644 t-1.1.htm create mode 100644 t1.png diff --git a/enhance.1.conf b/enhance.1.conf index 58a2c9c..ef0a174 100644 --- a/enhance.1.conf +++ b/enhance.1.conf @@ -6,6 +6,7 @@ ScriptAlias /enhance/nofading ###CONF_nofading; ScriptAlias /enhance/npb ###CONF_npb; ScriptAlias /enhance/pal ###CONF_pal; ScriptAlias /enhance/reveal ###CONF_reveal; +ScriptAlias /enhance/t-1 ###CONF_t-1; Require all granted diff --git a/makefile b/makefile index cc4fa89..a3d17aa 100644 --- a/makefile +++ b/makefile @@ -111,7 +111,8 @@ rvl.h\ df.h\ mpb.h\ mpb_503.h\ -nclr.h +nclr.h\ +t1.h CGI=\ bluenh-cgi\ @@ -119,7 +120,8 @@ nofading-cgi\ reveal-cgi\ diff-cgi\ npb-cgi\ -pal-cgi +pal-cgi\ +t-1-cgi HTM_CGI=\ bluenh.htm\ @@ -127,7 +129,8 @@ nofading.htm\ reveal.htm\ diff.htm\ npb.htm\ -pal.htm +pal.htm\ +t-1.htm HTM_CGI_1=\ bluenh.1.htm\ @@ -135,7 +138,8 @@ nofading.1.htm\ reveal.1.htm\ diff.1.htm\ npb.1.htm\ -pal.1.htm +pal.1.htm\ +t-1.htm # keep these 2 lists in the same order!: GENERATE_FROM=\ diff --git a/makefile.1.mak b/makefile.1.mak index 6ebb2c7..95031ca 100644 --- a/makefile.1.mak +++ b/makefile.1.mak @@ -111,7 +111,8 @@ rvl.h\ df.h\ mpb.h\ mpb_503.h\ -nclr.h +nclr.h\ +t1.h CGI=\ bluenh-cgi\ @@ -119,7 +120,8 @@ nofading-cgi\ reveal-cgi\ diff-cgi\ npb-cgi\ -pal-cgi +pal-cgi\ +t-1-cgi HTM_CGI=\ bluenh.htm\ @@ -127,7 +129,8 @@ nofading.htm\ reveal.htm\ diff.htm\ npb.htm\ -pal.htm +pal.htm\ +t-1.htm HTM_CGI_1=\ bluenh.1.htm\ @@ -135,7 +138,8 @@ nofading.1.htm\ reveal.1.htm\ diff.1.htm\ npb.1.htm\ -pal.1.htm +pal.1.htm\ +t-1.htm # keep these 2 lists in the same order!: GENERATE_FROM=\ diff --git a/online-core.1.h b/online-core.1.h index 7342407..c5bf909 100644 --- a/online-core.1.h +++ b/online-core.1.h @@ -40,6 +40,7 @@ Requires cgilib (http://www.infodrom.org/projects/cgilib/) // ###C_PAL_MIXDIFF_PATH: #define PAL_MIXDIFF_PATH "/botm/bin/pal_mixdiff" // ###C_PAL_UNMIX_PATH: #define PAL_UNMIX_PATH "/botm/bin/pal_unmix" // ###C_REVEAL_PATH: #define REVEAL_PATH "/botm/bin/reveal" +// ###C_REMAP_T_1_PATH: #define REMAP_T_1_PATH "/botm/bin/remap_t_1" int cp (char *src, char *dst); int wget (char *url, char *dst); diff --git a/settings-release.txt b/settings-release.txt index 2596c29..42c9e50 100644 --- a/settings-release.txt +++ b/settings-release.txt @@ -20,6 +20,7 @@ title_nofading: No fading! title_npb: It's NewpixbOTTification time! title_pal: Hidden frames title_reveal: Reveal hidden detail! +title_t-1: Remap t-1 bin_path: /botm/bin/enhance conf_path: /botm/etc/www/conf/1190 diff --git a/settings.txt b/settings.txt index e2668ba..5cccada 100644 --- a/settings.txt +++ b/settings.txt @@ -31,8 +31,10 @@ _bin_pal_mix_path = @_PATH($bin_path, pal_mix) _bin_pal_mixdiff_path = @_PATH($bin_path, pal_mixdiff) _bin_pal_unmix_path = @_PATH($bin_path, pal_unmix) _bin_pal_cgi_path = @_PATH($bin_path, pal-cgi) +_bin_remap_t_1_path = @_PATH($bin_path, remap_t_1) _bin_reveal_path = @_PATH($bin_path, reveal) _bin_reveal_cgi_path = @_PATH($bin_path, reveal-cgi) +_bin_t-1_cgi_path = @_PATH($bin_path, t-1-cgi) _conf_path = @_PATH($conf_path, $name\.conf) @@ -46,6 +48,7 @@ CONF_nofading = $_bin_nofading_cgi_path CONF_npb = $_bin_npb_cgi_path CONF_pal = $_bin_pal_cgi_path CONF_reveal = $_bin_reveal_cgi_path +CONF_t-1 = $_bin_t-1_cgi_path MAKE_CONFIGURE = CONFIGURE = $configure @@ -85,4 +88,5 @@ C_NPB_PATH = @_C_DEFINE_STR(NPB_PATH, $_bin_npb_path) C_PAL_MIX_PATH = @_C_DEFINE_STR(PAL_MIX_PATH, $_bin_pal_mix_path) C_PAL_MIXDIFF_PATH = @_C_DEFINE_STR(PAL_MIXDIFF_PATH, $_bin_pal_mixdiff_path) C_PAL_UNMIX_PATH = @_C_DEFINE_STR(PAL_UNMIX_PATH, $_bin_pal_unmix_path) +C_REMAP_T_1_PATH = @_C_DEFINE_STR(REMAP_T_1_PATH, $_bin_remap_t_1_path) C_REVEAL_PATH = @_C_DEFINE_STR(REVEAL_PATH, $_bin_reveal_path) diff --git a/t-1-cgi.c b/t-1-cgi.c new file mode 100644 index 0000000..e818ce2 --- /dev/null +++ b/t-1-cgi.c @@ -0,0 +1,143 @@ +/* +t-1-cgi.c +The online interface for remapping t-1 +05.12.2022 + +Copyright (C) 2022 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 . + +Requires cgilib (http://www.infodrom.org/projects/cgilib/) +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "online-core.h" +#include "t1.h" + +#define N0 3 +#define N1 85 + +int remap ( + char *inpix, char *outpix, + char *palette, + uint_fast8_t p0, uint_fast8_t p1 +); +int main (int argc, char *argv[]) +{ + s_cgi *cgi; + char in_tmp[256]; + char out_tmp[256]; + char *in_path; + char *t; + char *palette; + char noname[]=" "; + uint8_t p0, p1; + + int r=0; + int r1=0; + int r2=0; + int r3=0; + + do { + make_tmp_path(in_tmp, 256, 0, ""); + make_tmp_path(out_tmp, 256, 1, ".png"); + + cgi=cgiInit(); + + r = get_file(cgi,"inpix2", in_tmp, &in_path); + if (r) + r = get_file(cgi,"inpix", in_tmp, &in_path); + if (r) + break; + + t = cgiGetValue(cgi, "p0"); + if (t != NULL) + sscanf(t,"%"SCNuFAST8, &p0); + else + p0 = N0; + + t = cgiGetValue(cgi, "p1"); + if (t != NULL) + sscanf(t,"%"SCNuFAST8, &p1); + else + p1 = N1; + + palette = cgiGetValue(cgi, "b64"); + if (palette==NULL) + palette = noname; + + r = remap( + in_path, out_tmp, + palette, + p0, p1 + ); + if (r) + break; + + r1 = send_file(out_tmp, "image/png", 0); + } while (0); + if (r) + { + r1 = send_data(t1, t1_size, "image/png", 500); + } + r2 = rm(in_tmp); + r3 = rm(out_tmp); + if (r1) + return r1; + if (r2) + return r2; + if (r3) + return r3; + return 0; +} + +int remap ( + char *inpix, char *outpix, + char *palette, + uint_fast8_t p0, uint_fast8_t p1 +) +{ + char s_p0[4]; + char s_p1[4]; + + pid_t sub; + int r; + + snprintf(s_p0, 4, "%"PRIuFAST8, p0); + snprintf(s_p1, 4, "%"PRIuFAST8, p1); + + sub = fork(); + if (sub == 0) + { + r = execl( + REMAP_T_1_PATH, REMAP_T_1_PATH, + inpix, outpix, + palette, + s_p0, s_p1, + (char *) 0 + ); + exit(r); + } + waitpid(sub, &r, 0); + return r; +} diff --git a/t-1.1.htm b/t-1.1.htm new file mode 100644 index 0000000..a271ac4 --- /dev/null +++ b/t-1.1.htm @@ -0,0 +1,15 @@ +

Remap t-1

+
+ Remap by file upload
+ File:
+
+ Remap by URL(s):
+ URL:
+
+ Original filename:
+ Palette sizes: + 1: , 2:
+
+
+
+
diff --git a/t1.png b/t1.png new file mode 100644 index 0000000000000000000000000000000000000000..7e83749adbee76d72b378416c8543b56bbd34211 GIT binary patch literal 2863 zcmeHJ`#Tft8y^XyB+8Jp$@xsk*0#Lyz)_^8o;WqqeYf7g+lc zYqs(pVy#W;5gPyi=bn?jt2OHgJSucl2qY{j0g{xLkXHe#>nZCP=^GlV89=OIP$P&v z-1)qelCCk-)ylz5*A#kMS;hK-ho+XMoQ#yIrI{NNp{=2!ucKji?kwWGv6r)HfU9W` z65{S^8|GyWF*_6C4Ka7}@o_W`MLWRUe53rJ$ye=Nz5Fa3QI~x@0)hjthF=Ydh>VW8 zo{)r1CnVpyPj-bva`On(;@r|F1%3gZ(NVz_l@Dv{N>fr}J&J1Zjt836+&qGovU^SX+vy5>8J! zePVESH{n^ZUfuX@HHi3;pd!p{$5@WTYiZ5Xv9YnwL7GJuPEib}Pp))Fw_`Np<$$&@ zE1{u)$9FYPr4%?lAL;+tJrXj_?8!J|aE0s}FUz_&mmKQkF3sAx2DQ^!a=I^|QCqi` zdksW76V-U!D3D0XywU2wGLl0o5(`4hzt+{tv06IQIptY`D31T~d2IzHLcO8|m_a4d z%j^paRUg@~jqb~r*c@6z<{SJ_bBLt`2HOq|jLhf1pHek=&k0OWnmZ-HQ}6AMoJnFE z#%*xH`c7l`^WZ!Z&3Xz>6^MK{vy)e0v)H4aA2_P$P3A} zipa-jqEo|ndVAaYYIgU&x65T-c~j#vVHVXWGDwMrYJWzx9j|EndTg}Q5?*(*E%7wl z%NUt-Z+VLYog_hqIZw)1w3dvHuZw1DWqth_nmeL)4lF%U#eEoYf2-^|gpJ+mnPsv^ zj389l(WP$vU0N@&|@7tN*S^(12xj_iqZWwt|lDKIS~v{9Hm?x#cP_UiXQ z@pKL!Ewl6B5BvCz8I+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