From: b Date: Mon, 5 Dec 2022 23:11:40 +0000 (+0000) Subject: t-1 online. That's all tools! X-Git-Url: http://bicyclesonthemoon.info/git-projects/?p=ott%2Fenhance;a=commitdiff_plain;h=634abf341437e44a092c42d983e52303917a6276 t-1 online. That's all tools! --- 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 0000000..7e83749 Binary files /dev/null and b/t1.png differ