]> bicyclesonthemoon.info Git - ott/enhance/commitdiff
t-1 online. That's all tools!
authorb <rowerynaksiezycu@gmail.com>
Mon, 5 Dec 2022 23:11:40 +0000 (23:11 +0000)
committerb <rowerynaksiezycu@gmail.com>
Mon, 5 Dec 2022 23:11:40 +0000 (23:11 +0000)
enhance.1.conf
makefile
makefile.1.mak
online-core.1.h
settings-release.txt
settings.txt
t-1-cgi.c [new file with mode: 0644]
t-1.1.htm [new file with mode: 0644]
t1.png [new file with mode: 0644]

index 58a2c9ca9b7a59824361e6386324d0db592cd95f..ef0a1741cb3a04a062701e1fddff057c006072b2 100644 (file)
@@ -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;
 
 <Directory ###CONF_bin;>
        Require all granted
index cc4fa8954ab94860d255b4f37b084cfbf4d0bb5a..a3d17aa28983fd7e18ffea2f149be95d3bd00eab 100644 (file)
--- 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=\
index 6ebb2c7f8ab72c2dce9d5fd4fb597cba7687c666..95031ca5950e2251fa0b54080beb4b6039be46dc 100644 (file)
@@ -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=\
index 73424078b3cf31c54fb23184da0f910aa62500d9..c5bf909d4456dc5d0c2753f5041c65cad4e65907 100644 (file)
@@ -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);
index 2596c29dad9d7da96fc08aed6ac6dfc68debb358..42c9e506aa4272976443b5aa0487f00a094180d2 100644 (file)
@@ -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
index e2668ba637363d7cce99a12a991ff046c4acbf3b..5cccada780237f3265671c0e0e66c1461ba5b0b4 100644 (file)
@@ -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 (file)
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 <http://www.gnu.org/licenses/>.
+
+Requires cgilib (http://www.infodrom.org/projects/cgilib/)
+*/
+
+#include <stdio.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+#include <cgi.h>
+
+#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 (file)
index 0000000..a271ac4
--- /dev/null
+++ b/t-1.1.htm
@@ -0,0 +1,15 @@
+            <h1>Remap t-1</h1>\r
+               <form method="post" action="/enhance/t-1" enctype="multipart/form-data">\r
+                       Remap by file upload<br>\r
+                       File: <input class="pt" type="file" name="inpix2"><br>\r
+                       <br>\r
+                       Remap by URL(s):<br>\r
+                       URL: <input class="pt" type="text" name="inpix"><br>\r
+                       <br>\r
+                       Original filename: <input class="pt" type="text" name="b64"><br>\r
+                       Palette sizes:\r
+                       1: <input class="pt" type="text" name="p0" size="2" value="3">, 2: <input class="pt" type="text" name="p1" size="2" value="85"><br>\r
+                       <br>\r
+                       <input class="pk" type="submit" value="REMAP!"><br>\r
+               </form>\r
+               <br>\r
diff --git a/t1.png b/t1.png
new file mode 100644 (file)
index 0000000..7e83749
Binary files /dev/null and b/t1.png differ