2 bluenh-cgi.c is autogenerated from bluenh-cgi.1.c
3 Online interface for npb
6 Copyright (C) 2013, 2014, 2022 Balthasar SzczepaĆski
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Affero General Public License as
10 published by the Free Software Foundation, either version 3 of the
11 License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Affero General Public License for more details.
18 You should have received a copy of the GNU Affero General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 Requires cgilib (http://www.infodrom.org/projects/cgilib/)
32 #include "online-core.h"
35 int bluenh (char *inpix, char *outpix, unsigned a, unsigned b, unsigned c, unsigned d, unsigned e, unsigned f);
37 int main (int argc, char *argv[])
44 unsigned a, b, c, d, e, f;
52 make_tmp_path(in_tmp, 256, 0, "_in");
53 make_tmp_path(out_tmp, 256, 0, "_out");
57 r = get_file(cgi,"inpix", in_tmp, &in_path);
61 t = cgiGetValue(cgi, "a");
67 t = cgiGetValue(cgi, "b");
73 t = cgiGetValue(cgi, "c");
79 t = cgiGetValue(cgi, "d");
85 t = cgiGetValue(cgi, "e");
91 t = cgiGetValue(cgi, "f");
97 r = bluenh(in_path, out_tmp, a, b, c, d, e, f);
101 r1 = send_file(out_tmp, "image/png", 0);
105 r1 = send_data(nh, nh_size, "image/png", 500);
120 int bluenh (char *inpix, char *outpix, unsigned a, unsigned b, unsigned c, unsigned d, unsigned e, unsigned f)
132 snprintf(ca, 4, "%u", a);
133 snprintf(cb, 4, "%u", b);
134 snprintf(cc, 4, "%u", c);
135 snprintf(cd, 4, "%u", d);
136 snprintf(ce, 4, "%u", e);
137 snprintf(cf, 4, "%u", f);
142 r = execl(BLUENH_PATH, inpix, outpix, ca, cb, cc, cd, ce, cf, (char *)0);
154 // // //Download images and
157 // // Requires cgilib
158 // // //line 146 of cgi.h
159 // // must be changed
160 // // from "extern }"
163 // // ~~bicyclesonthemoon
169 #include <sys/wait.h>
170 #include <sys/stat.h>
172 #define WGET_PATH "/usr/bin/wget"
173 #define ENH_PATH "./bluenh"
174 #define ENH_PATH2 "./bluenh2"
175 #define RM_PATH "/bin/rm"
176 #define LOG_PATH "/eizm/log/bluenh/bluenh.log"
177 #define USERAGENT "Bluenhancement\x20(1190.bicyclesonthemoon.dnsd.info/bluenh/bluenh.htm)"
178 #define MSTD_PATH "/pro/bluenh/nh.png"
180 int main (int argc, char *argv[]);
181 void mustard(int mustard);
191 int main (int argc, char *argv[])
193 unsigned char buf[1024];
205 sprintf(path,"%s",cgiGetFile(cgi,up[0])->tmpfile);
206 sprintf(url,"%s",cgiGetFile(cgi,up[0])->filename);
210 sprintf(url,"%s",(cgiGetValue(cgi,"inpix")!=NULL)?(cgiGetValue(cgi,"inpix")):"");
211 sprintf(path,"/var/tmp/%lu",(unsigned long)getpid());
213 //Why is there no spawnl() in linux?
217 t=execl(WGET_PATH,WGET_PATH,"-q","-t","2","-U",USERAGENT,"-O",path,url,(char *)0);
224 enh2=(cgiGetValue(cgi,"bluenh2")!=NULL);
228 t=execl(enh2?ENH_PATH2:ENH_PATH,enh2?ENH_PATH2:ENH_PATH,path,path,cgiGetValue(cgi,"a")!=NULL?cgiGetValue(cgi,"a"):"0",cgiGetValue(cgi,"b")!=NULL?cgiGetValue(cgi,"b"):"127",cgiGetValue(cgi,"c")!=NULL?cgiGetValue(cgi,"c"):"255",cgiGetValue(cgi,"d")!=NULL?cgiGetValue(cgi,"d"):"0",cgiGetValue(cgi,"e")!=NULL?cgiGetValue(cgi,"e"):"127",cgiGetValue(cgi,"f")!=NULL?cgiGetValue(cgi,"f"):"255","q",(char *)0);
234 pix=fopen(path,"rb");
237 fstat(fileno(pix),&st);
241 printf("Content-Length: %lu\n",(unsigned long)(st.st_size));
242 printf("Content-type: image/png\n\n");
243 for(unsigned long i=0;i<p;++i)
245 fread(buf,1,1024,pix);
246 fwrite(buf,1,1024,stdout);
251 fwrite(buf,1,q,stdout);
255 mustard(0);//no mustard
258 void mustard(int mustard)
262 cgiRedirect(MSTD_PATH);
267 t=execl(RM_PATH,RM_PATH,"-f",path,(char *)0);
271 pix=fopen(LOG_PATH,"at");
274 fprintf(pix,"%x %s\n",mustard,url);