+/*
+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!
// //
// // //
// // ~~bicyclesonthemoon
-#include <cgi.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
fclose(pix);
}
exit(mustard);
-}
\ No newline at end of file
+}
+
+*/
\ No newline at end of file
# 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\
#C_CGI=\
#bluenh-cgi.c
+
# keep these 2 lists in the same order!:
GENERATE_FROM=\
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
$(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)
# 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\
#C_CGI=\
#bluenh-cgi.c
+
# keep these 2 lists in the same order!:
GENERATE_FROM=\
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
$(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)
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
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
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)