From: b Date: Sun, 4 Dec 2022 16:49:45 +0000 (+0000) Subject: Online interface for bluenh. Something is no yes. X-Git-Url: http://bicyclesonthemoon.info/git-projects/?p=ott%2Fenhance;a=commitdiff_plain;h=08e418e53261aab7300e925ba50f532d370967bd Online interface for bluenh. Something is no yes. --- diff --git a/bluenh-cgi.c b/bluenh-cgi.c index 130b3d8..1374aaf 100644 --- a/bluenh-cgi.c +++ b/bluenh-cgi.c @@ -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 . + +Requires cgilib (http://www.infodrom.org/projects/cgilib/) +*/ + +#include +#include +#include +#include +#include + +#include + +#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 #include #include #include @@ -123,4 +275,6 @@ void mustard(int mustard) fclose(pix); } exit(mustard); -} \ No newline at end of file +} + +*/ \ No newline at end of file diff --git a/makefile b/makefile index 0fff0b4..4c96e89 100644 --- 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) diff --git a/makefile.1.mak b/makefile.1.mak index a66bd07..3f5dce3 100644 --- a/makefile.1.mak +++ b/makefile.1.mak @@ -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) diff --git a/settings-release.txt b/settings-release.txt index 7a10d68..0cab3e3 100644 --- a/settings-release.txt +++ b/settings-release.txt @@ -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 diff --git a/settings.txt b/settings.txt index 0967788..4d4ab77 100644 --- a/settings.txt +++ b/settings.txt @@ -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)