+/*
+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;
+}
+
+/*
+
+
+
+