]> bicyclesonthemoon.info Git - ott/enhance/blobdiff - bluenh-cgi.c
Online bluenh seems to work ok.
[ott/enhance] / bluenh-cgi.c
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