]> bicyclesonthemoon.info Git - ott/enhance/commitdiff
Online bluenh seems to work ok.
authorb <rowerynaksiezycu@gmail.com>
Sun, 4 Dec 2022 17:05:35 +0000 (17:05 +0000)
committerb <rowerynaksiezycu@gmail.com>
Sun, 4 Dec 2022 17:05:35 +0000 (17:05 +0000)
bluenh-cgi.c
online-core.c
settings.txt

index 1374aaf3bc15d9c5429580d271bf0624c76fec78..08d41e59608c1e0c9ae01c9ff2b3fec172814571 100644 (file)
@@ -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 <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-
-#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<p;++i)
-       {
-               fread(buf,1,1024,pix);
-               fwrite(buf,1,1024,stdout);
-       }
-       if(q!=0)
-       {
-               fread(buf,1,q,pix);
-               fwrite(buf,1,q,stdout);
-       }
-       fclose(pix);
-       fflush(stdout);
-       mustard(0);//no mustard
-}
-
-void mustard(int mustard)
-{
-       if(mustard)
-       {
-               cgiRedirect(MSTD_PATH);
-       }
-       sub=fork();
-       if(sub==0)
-       {
-               t=execl(RM_PATH,RM_PATH,"-f",path,(char *)0);
-               exit(t);
-       }
-       waitpid(sub,&t,0);
-       pix=fopen(LOG_PATH,"at");
-       if(pix!=NULL)
-       {
-               fprintf(pix,"%x %s\n",mustard,url);
-               fclose(pix);
-       }
-       exit(mustard);
-}
-
-*/
\ No newline at end of file
index 3adb21c2617030bdd33a95e69926873500f432b0..fa41b32e4eb44a35e31eddb3628337011e448131 100644 (file)
@@ -47,7 +47,7 @@ int cp (char *src, char *dst)
        sub = fork();
        if (sub == 0)
        {
-               r = execl(CP_PATH, src, dst, (char *)0);
+               r = execl(CP_PATH, CP_PATH, src, dst, (char *)0);
                exit(r);
        }
        waitpid(sub, &r, 0);
@@ -63,7 +63,7 @@ int rm (char *dst)
        sub = fork();
        if (sub == 0)
        {
-               r = execl(RM_PATH, "-f", dst, (char *)0);
+               r = execl(RM_PATH, RM_PATH, "-f", dst, (char *)0);
                exit(r);
        }
        waitpid(sub, &r, 0);
@@ -79,7 +79,7 @@ int wget (char *url, char *dst)
        sub = fork();
        if (sub == 0)
        {
-               r = execl(WGET_PATH, "-q", "-t", "2", "-U", USERAGENT, "-O", dst, url, (char *)0);
+               r = execl(WGET_PATH, WGET_PATH, "-q", "-t", "2", "-U", USERAGENT, "-O", dst, url, (char *)0);
                exit(r);
        }
        waitpid(sub, &r, 0);
index 4d4ab770aff50b11df17e442c322015196021f19..6153ddedb302676555ace23a5043954bb613f9a3 100644 (file)
@@ -45,7 +45,7 @@ C_CP_PATH   = @_C_DEFINE_STR(CP_PATH,   $cp)
 C_WGET_PATH = @_C_DEFINE_STR(WGET_PATH, $wget)
 C_RM_PATH   = @_C_DEFINE_STR(RM_PATH,   $rm)
 
-C_TEMP_PATH = @_C_DEFINE_STR(TEMP_PATH, $_tmp_path)
+C_TEMP_PATH = @_C_DEFINE_STR(TEMP_PATH, $tmp_path)
 
 C_BLUENH_PATH = @_C_DEFINE_STR(BLUENH_PATH, $_bin_bluenh_path)
 C_NPB_PATH    = @_C_DEFINE_STR(NPB_PATH,    $_bin_npb_path)