3 The online interface for the fading enhancement tool
6 Copyright (C) 2015, 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/)
34 #include "online-core.h"
38 char *inpix, char *outpix,
40 uint_fast8_t individual_channels,
41 uint_fast8_t enhance_alpha,
42 uint_fast8_t remove_alpha
45 int main (int argc, char *argv[])
53 uint_fast8_t individual_channels, enhance_alpha, remove_alpha;
61 make_tmp_path(in_tmp, 256, 0, "");
62 make_tmp_path(out_tmp, 256, 1, ".png");
66 r = get_file(cgi,"inpix", in_tmp, &in_path);
70 individual_channels = (cgiGetValue(cgi, "c")!=NULL) ? 0 : 1;
71 enhance_alpha = (cgiGetValue(cgi, "a")!=NULL) ? 1 : 0;
72 remove_alpha = (cgiGetValue(cgi, "n")!=NULL) ? 1 : 0;
74 t = cgiGetValue(cgi, "f");
76 sscanf(t,"%"SCNuFAST32, &border);
83 individual_channels, enhance_alpha, remove_alpha
87 r1 = send_file(out_tmp, "image/png", 0);
91 r1 = send_data(nf, nf_size, "image/png", 500);
107 char *inpix, char *outpix,
108 uint_fast32_t border,
109 uint_fast8_t individual_channels,
110 uint_fast8_t enhance_alpha,
111 uint_fast8_t remove_alpha
118 snprintf(s_border, 11, "%"PRIuFAST32, border);
124 NOFADING_PATH, NOFADING_PATH,
125 individual_channels ? "-c" : "-0",
126 enhance_alpha ? "-a" : "-0",
127 remove_alpha ? "-n" : "-0",
146 #include <sys/wait.h>
147 #include <sys/stat.h>
149 #define WGET_PATH "/usr/bin/wget"
150 #define ENH_PATH "./nofading"
151 #define RM_PATH "/bin/rm"
152 #define LOG_PATH "/eizm/log/nofading/nofading.log"
153 #define USERAGENT "No fading (1190.bicyclesonthemoon.dnsd.info/nofading/nofading.htm)"
154 #define MSTD_PATH "/pro/nofading/nf.png"
156 int main (int argc, char *argv[]);
157 void mustard(int mustard);
167 int main (int argc, char *argv[])
169 unsigned char buf[1024];
180 sprintf(path,"%s",cgiGetFile(cgi,up[0])->tmpfile);
181 sprintf(url,"%s",cgiGetFile(cgi,up[0])->filename);
185 sprintf(url,"%s",(cgiGetValue(cgi,"inpix")!=NULL)?(cgiGetValue(cgi,"inpix")):"");
186 sprintf(path,"/var/tmp/%lu",(unsigned long)getpid());
188 //Why is there no spawnl() in linux?
192 t=execl(WGET_PATH,WGET_PATH,"-q","-t","2","-U",USERAGENT,"-O",path,url,(char *)0);
202 t=execl(ENH_PATH,ENH_PATH,path,path,(cgiGetValue(cgi,"f")!=NULL)?(cgiGetValue(cgi,"f")):"0","q",cgiGetValue(cgi,"a")!=NULL?"0":"a",(char *)0);
208 pix=fopen(path,"rb");
211 fstat(fileno(pix),&st);
215 printf("Content-Length: %lu\n",(unsigned long)(st.st_size));
216 printf("Content-type: image/png\n\n");
217 for(unsigned long i=0;i<p;++i)
219 fread(buf,1,1024,pix);
220 fwrite(buf,1,1024,stdout);
225 fwrite(buf,1,q,stdout);
229 mustard(0);//no mustard
232 void mustard(int mustard)
236 cgiRedirect(MSTD_PATH);
241 t=execl(RM_PATH,RM_PATH,"-f",path,(char *)0);
245 pix=fopen(LOG_PATH,"at");
248 fprintf(pix,"%x %s\n",mustard,url);