From f6009d396d914702f2fcadea6508b4d2eb4c2ba1 Mon Sep 17 00:00:00 2001 From: b Date: Sun, 4 Dec 2022 17:05:35 +0000 Subject: [PATCH] Online bluenh seems to work ok. --- bluenh-cgi.c | 139 ++------------------------------------------------ online-core.c | 6 +-- settings.txt | 2 +- 3 files changed, 7 insertions(+), 140 deletions(-) diff --git a/bluenh-cgi.c b/bluenh-cgi.c index 1374aaf..08d41e5 100644 --- a/bluenh-cgi.c +++ b/bluenh-cgi.c @@ -49,8 +49,8 @@ int main (int argc, char *argv[]) int r3=0; do { - make_tmp_path(in_tmp, 256, 0, "_in"); - make_tmp_path(out_tmp, 256, 0, "_out"); + make_tmp_path(in_tmp, 256, 0, ""); + make_tmp_path(out_tmp, 256, 1, ".png"); cgi=cgiInit(); @@ -139,142 +139,9 @@ int bluenh (char *inpix, char *outpix, unsigned a, unsigned b, unsigned c, unsig sub = fork(); if (sub == 0) { - r = execl(BLUENH_PATH, inpix, outpix, ca, cb, cc, cd, ce, cf, (char *)0); + r = execl(BLUENH_PATH, 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! - // // - // // Requires cgilib -// // //line 146 of cgi.h - // // must be changed - // // from "extern }" - // // to "}" -// // // - // // ~~bicyclesonthemoon - -#include -#include -#include -#include -#include -#include - -#define WGET_PATH "/usr/bin/wget" -#define ENH_PATH "./bluenh" -#define ENH_PATH2 "./bluenh2" -#define RM_PATH "/bin/rm" -#define LOG_PATH "/eizm/log/bluenh/bluenh.log" -#define USERAGENT "Bluenhancement\x20(1190.bicyclesonthemoon.dnsd.info/bluenh/bluenh.htm)" -#define MSTD_PATH "/pro/bluenh/nh.png" - -int main (int argc, char *argv[]); -void mustard(int mustard); - -FILE *pix; - -char url[1024]; -char path[256]; -s_cgi *cgi; -int t; -pid_t sub; - -int main (int argc, char *argv[]) -{ - unsigned char buf[1024]; - struct stat st; - unsigned long p; - unsigned short q; - char **up; - bool enh2; - - cgi=cgiInit(); - - up=cgiGetFiles(cgi); - if (up) - { - sprintf(path,"%s",cgiGetFile(cgi,up[0])->tmpfile); - sprintf(url,"%s",cgiGetFile(cgi,up[0])->filename); - } - else - { - sprintf(url,"%s",(cgiGetValue(cgi,"inpix")!=NULL)?(cgiGetValue(cgi,"inpix")):""); - sprintf(path,"/var/tmp/%lu",(unsigned long)getpid()); - - //Why is there no spawnl() in linux? - sub=fork(); - if(sub==0) - { - t=execl(WGET_PATH,WGET_PATH,"-q","-t","2","-U",USERAGENT,"-O",path,url,(char *)0); - exit(t); - } - waitpid(sub,&t,0); - if(t)mustard(t); - } - - enh2=(cgiGetValue(cgi,"bluenh2")!=NULL); - sub=fork(); - if(sub==0) - { - 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); - exit(t); - } - waitpid(sub,&t,0); - if(t)mustard(t); - - pix=fopen(path,"rb"); - if(pix==NULL) - mustard(123); - fstat(fileno(pix),&st); - p=st.st_size/1024; - q=st.st_size%1024; - - printf("Content-Length: %lu\n",(unsigned long)(st.st_size)); - printf("Content-type: image/png\n\n"); - for(unsigned long i=0;i