]> bicyclesonthemoon.info Git - ott/enhance/commitdiff
Online interface for bluenh. Something is no yes.
authorb <rowerynaksiezycu@gmail.com>
Sun, 4 Dec 2022 16:49:45 +0000 (16:49 +0000)
committerb <rowerynaksiezycu@gmail.com>
Sun, 4 Dec 2022 16:49:45 +0000 (16:49 +0000)
bluenh-cgi.c
makefile
makefile.1.mak
settings-release.txt
settings.txt

index 130b3d837040616fa90ce5b1403ea2c7161373f0..1374aaf3bc15d9c5429580d271bf0624c76fec78 100644 (file)
@@ -1,3 +1,156 @@
+/*
+bluenh-cgi.c is autogenerated from bluenh-cgi.1.c
+Online interface for npb
+04.12.2022
+
+Copyright (C) 2013, 2014, 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 <cgi.h>
+
+#include "online-core.h"
+#include "nh.h"
+
+int bluenh (char *inpix, char *outpix, unsigned a, unsigned b, unsigned c, unsigned d, unsigned e, unsigned f);
+
+int main (int argc, char *argv[])
+{
+       s_cgi *cgi;
+       char in_tmp[256];
+       char out_tmp[256];
+       char *in_path;
+       char *t;
+       unsigned a, b, c, d, e, f;
+       
+       int r=0;
+       int r1=0;
+       int r2=0;
+       int r3=0;
+       
+       do {
+               make_tmp_path(in_tmp, 256, 0, "_in");
+               make_tmp_path(out_tmp, 256, 0, "_out");
+               
+               cgi=cgiInit();
+               
+               r = get_file(cgi,"inpix", in_tmp, &in_path);
+               if (r)
+                       break;
+               
+               t = cgiGetValue(cgi, "a");
+               if (t != NULL)
+                       sscanf(t,"%u",&a);
+               else
+                       a = 0;
+               
+               t = cgiGetValue(cgi, "b");
+               if (t != NULL)
+                       sscanf(t,"%u",&b);
+               else
+                       b = 0;
+               
+               t = cgiGetValue(cgi, "c");
+               if (t != NULL)
+                       sscanf(t,"%u",&c);
+               else
+                       c = 0;
+               
+               t = cgiGetValue(cgi, "d");
+               if (t != NULL)
+                       sscanf(t,"%u",&d);
+               else
+                       d = 0;
+               
+               t = cgiGetValue(cgi, "e");
+               if (t != NULL)
+                       sscanf(t,"%u",&e);
+               else
+                       e = 0;
+               
+               t = cgiGetValue(cgi, "f");
+               if (t != NULL)
+                       sscanf(t,"%u",&f);
+               else
+                       f = 0;
+               
+               r = bluenh(in_path, out_tmp, a, b, c, d, e, f);
+               if (r)
+                       break;
+               
+               r1 = send_file(out_tmp, "image/png", 0);
+       } while (0);
+       if (r)
+       {
+               r1 = send_data(nh, nh_size, "image/png", 500);
+       }
+       r2 = rm(in_tmp);
+       r3 = rm(out_tmp);
+       if (r)
+               return r;
+       if (r1)
+               return r1;
+       if (r2)
+               return r2;
+       if (r3)
+               return r3;
+       return 0;
+}
+
+int bluenh (char *inpix, char *outpix, unsigned a, unsigned b, unsigned c, unsigned d, unsigned e, unsigned f)
+{
+       char ca[4];
+       char cb[4];
+       char cc[4];
+       char cd[4];
+       char ce[4];
+       char cf[4];
+       
+       pid_t sub;
+       int r;
+       
+       snprintf(ca, 4, "%u", a);
+       snprintf(cb, 4, "%u", b);
+       snprintf(cc, 4, "%u", c);
+       snprintf(cd, 4, "%u", d);
+       snprintf(ce, 4, "%u", e);
+       snprintf(cf, 4, "%u", f);
+       
+       sub = fork();
+       if (sub == 0)
+       {
+               r = execl(BLUENH_PATH, inpix, outpix, ca, cb, cc, cd, ce, cf, (char *)0);
+               exit(r);
+       }
+       waitpid(sub, &r, 0);
+       return r;
+}
+
+/*
+
+
+
+
 //  //  //Download images and 
    //  // ENHANCE them!
   //  //  
@@ -9,7 +162,6 @@
 //  //  //
    //  // ~~bicyclesonthemoon
 
-#include <cgi.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -123,4 +275,6 @@ void mustard(int mustard)
                fclose(pix);
        }
        exit(mustard);
-}
\ No newline at end of file
+}
+
+*/
\ No newline at end of file
index 0fff0b41ef51970a63e3d36315cff794ba6055f5..4c96e89b4c3d0eff1c83f0cea869a343a00b8c84 100644 (file)
--- a/makefile
+++ b/makefile
@@ -23,20 +23,30 @@ TARGET    = release
 # make -B TARGET=target_name makefile
 endif
 
-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)
 
 CC   =gcc
 CF   =-g -Wall
 L_IL =-lIL
 L_CGI=-lcgi
 
+CHMOD=/usr/bin/chmod
+CP   =/usr/bin/cp
+MKDIR=/usr/bin/mkdir
+PERL =/usr/bin/perl
 RM   =/usr/bin/rm
 
+BIN_PATH = /botm/bin/enhance
+TMP_PATH = /botm/tmp/enhance
+
+
+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)
+
+
 STANDALONE=\
 nofading\
 info\
@@ -99,6 +109,7 @@ bluenh-cgi
 #C_CGI=\
 #bluenh-cgi.c
 
+
 # keep these 2 lists in the same order!:
 GENERATE_FROM=\
 online-core.1.h
@@ -106,11 +117,23 @@ online-core.1.h
 TO_GENERATE=\
 online-core.h
 
+DIR=\
+$(BIN_PATH)\
+$(TMP_PATH)
 
-#all: 403 npb npbd npb-ong1 npbd-ong1 bluenh bluenhd insert extract seediff insertframe mremapt-1 compare nofading nofadingd
-all: enhance $(STANDALONE) $(CGI)
+SETUID=\
+$(CGI)
+
+BIN=\
+enhance\
+$(STANDALONE)\
+$(CGI)
 
 
+#all: 403 npb npbd npb-ong1 npbd-ong1 bluenh bluenhd insert extract seediff insertframe mremapt-1 compare nofading nofadingd
+all: $(BIN)
+       
+
 makefile: makefile.1.mak $(CONFIGFILE)
        $(CONFIGURE_CMD) < makefile.1.mak > makefile 
 
@@ -140,13 +163,25 @@ f2h: f2h.c
        $(CC) $(CF) -o f2h f2h.c
 
 
-#test: test.c core.h core.c
-#      $(CC) $(CF) -o test test.c core.c $(LF)
+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 | mktree
+       $(RM) -rf $(BIN_PATH)/*
+       $(CP) -p $(BIN) $(BIN_PATH)
+endif
+
+install: cp_bin
 
 clean:
        $(RM) -f enhance $(C_STANDALONE) $(STANDALONE) $(TO_GENERATE) f2h $(H_PNG) $(H_SUBTOOL) $(CGI)
 
-PHONY: all clean
+PHONY: all clean install setuid mktree cp_bin 
 
 #npbd-ong1: npb npbd-ong1.cpp makefile
 #      $(CC) $(CF) -o npbd-ong1 npbd-ong1.cpp $(LF2)
index a66bd07d999e121800bf5a8616988178252c1b7a..3f5dce3bc75306e55f60d128021cc8b760a73fe8 100644 (file)
@@ -23,20 +23,30 @@ TARGET = debug ###MAKE_TARGET:
 # make -B TARGET=target_name makefile
 endif
 
-CONFIGFILE = settings-$(TARGET).txt settings.txt
-
-# The configuration tool
-# http://bicyclesonthemoon.info/git/botm-config 
-CONFIGURE = /botm/bin/config/configure.pl ###MAKE_CONFIGURE:
-CONFIGURE_CMD = $(PERL) $(CONFIGURE) $(CONFIGFILE)
 
 ###MAKE_CC:    CC=gcc
 ###MAKE_CF:    CF=-g -Wall
 ###MAKE_L_IL:  L_IL=-lIL
 ###MAKE_L_CGI: L_CGI=-lcgi
 
+###MAKE_CHMOD: CHMOD = chmod
+###MAKE_CP:    CP    = cp
+###MAKE_MKDIR: MKDIR = mkdir
+###MAKE_PERL:  PERL  = perl
 ###MAKE_RM:    RM    = rm
 
+###MAKE_BIN_PATH: BIN_PATH = /botm/bin/ottmirror
+###MAKE_TMP_PATH: TMP_PATH = /botm/tmp/ottmirror
+
+
+CONFIGFILE = settings-$(TARGET).txt settings.txt
+
+# The configuration tool
+# http://bicyclesonthemoon.info/git/botm-config 
+CONFIGURE = /botm/bin/config/configure.pl ###MAKE_CONFIGURE:
+CONFIGURE_CMD = $(PERL) $(CONFIGURE) $(CONFIGFILE)
+
+
 STANDALONE=\
 nofading\
 info\
@@ -99,6 +109,7 @@ bluenh-cgi
 #C_CGI=\
 #bluenh-cgi.c
 
+
 # keep these 2 lists in the same order!:
 GENERATE_FROM=\
 online-core.1.h
@@ -106,11 +117,23 @@ online-core.1.h
 TO_GENERATE=\
 online-core.h
 
+DIR=\
+$(BIN_PATH)\
+$(TMP_PATH)
 
-#all: 403 npb npbd npb-ong1 npbd-ong1 bluenh bluenhd insert extract seediff insertframe mremapt-1 compare nofading nofadingd
-all: enhance $(STANDALONE) $(CGI)
+SETUID=\
+$(CGI)
+
+BIN=\
+enhance\
+$(STANDALONE)\
+$(CGI)
 
 
+#all: 403 npb npbd npb-ong1 npbd-ong1 bluenh bluenhd insert extract seediff insertframe mremapt-1 compare nofading nofadingd
+all: $(BIN)
+       
+
 makefile: makefile.1.mak $(CONFIGFILE)
        $(CONFIGURE_CMD) < makefile.1.mak > makefile 
 
@@ -140,13 +163,25 @@ f2h: f2h.c
        $(CC) $(CF) -o f2h f2h.c
 
 
-#test: test.c core.h core.c
-#      $(CC) $(CF) -o test test.c core.c $(LF)
+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 | mktree
+       $(RM) -rf $(BIN_PATH)/*
+       $(CP) -p $(BIN) $(BIN_PATH)
+endif
+
+install: cp_bin
 
 clean:
        $(RM) -f enhance $(C_STANDALONE) $(STANDALONE) $(TO_GENERATE) f2h $(H_PNG) $(H_SUBTOOL) $(CGI)
 
-PHONY: all clean
+PHONY: all clean install setuid mktree cp_bin 
 
 #npbd-ong1: npb npbd-ong1.cpp makefile
 #      $(CC) $(CF) -o npbd-ong1 npbd-ong1.cpp $(LF2)
index 7a10d68905d124e0d6d5b8e5c13e5ddb1b51fc1c..0cab3e35e51545d642a57380cf514396fc20688d 100644 (file)
@@ -17,6 +17,9 @@ bin_path: /botm/bin/enhance
 tmp_path: /botm/tmp/enhance
 
 cp: /usr/bin/cp
+chmod: /usr/bin/chmod
+mkdir: /usr/bin/mkdir
+perl: /usr/bin/perl
 rm: /usr/bin/rm
 wget: /usr/bin/wget
 
index 0967788b4e7683d393e00243693a0b16b665950e..4d4ab770aff50b11df17e442c322015196021f19 100644 (file)
@@ -25,6 +25,10 @@ _bin_npb_path    = @_PATH($bin_path, npb)
 MAKE_CONFIGURE = CONFIGURE = $configure
 MAKE_TARGET    = TARGET    = $target
 
+MAKE_CHMOD  = CHMOD=$chmod
+MAKE_CP     = CP   =$cp
+MAKE_MKDIR  = MKDIR=$mkdir
+MAKE_PERL   = PERL =$perl
 MAKE_RM     = RM   =$rm
 
 MAKE_CC    = CC   =$CC
@@ -32,6 +36,8 @@ MAKE_CF    = CF   =$CF
 MAKE_L_IL  = L_IL =$L_IL
 MAKE_L_CGI = L_CGI=$L_CGI
 
+MAKE_BIN_PATH = BIN_PATH = $bin_path
+MAKE_TMP_PATH = TMP_PATH = $tmp_path
 
 C_USERAGENT = @_C_DEFINE_STR(USERAGENT, $useragent)