From: b Date: Mon, 30 Dec 2013 19:20:20 +0000 (+0000) Subject: Everything is ready! X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=82acf45b46bbdb448a2d135fa7c7cfd5f9c7fafa;p=ott%2Fenhance Everything is ready! git-svn-id: svn://botcastle1b/npb@19 0d794883-4e4e-4f65-aa7a-0e7f5947bab5 --- diff --git a/npb.htm b/npb.htm index 38eab71..b137293 100644 --- a/npb.htm +++ b/npb.htm @@ -7,7 +7,7 @@

It's NewpixbOTTification time!

- NewpixbOTTify by URL (not ready!)
+ NewpixbOTTify by URL
URL: diff --git a/npbd b/npbd index acaa15d..a25865a 100755 Binary files a/npbd and b/npbd differ diff --git a/npbd.cpp b/npbd.cpp index 831d80b..41d06f7 100644 --- a/npbd.cpp +++ b/npbd.cpp @@ -11,22 +11,32 @@ #include #include +#include #include #include +#include #define WGET_PATH "/usr/bin/wget" #define NPB_PATH "./npb" +#define RM_PATH "/bin/rm" int main (int argc, char *argv[]); +void mustard(int mustard); + +FILE *pix; +unsigned char buf[1024]; +char url[1024]; +char path[256]; +//char cmd[1024]; +s_cgi *cgi; +int t; +pid_t sub; +struct stat st; +unsigned long p; +unsigned short q; + int main (int argc, char *argv[]) { - FILE *pix; - char url[1024]; - char path[256]; - //char cmd[1024]; - s_cgi *cgi; - int t; - pid_t sub; cgi=cgiInit(); sprintf(url,"%s",cgiGetValue(cgi,"inpix")); @@ -38,31 +48,56 @@ int main (int argc, char *argv[]) if(sub==0) { t=execl(WGET_PATH,WGET_PATH,"-q","-O",path,url,(char *)0); - return t; + exit(t); } waitpid(sub,&t,0); - if(t)return t; + if(t)mustard(t); sub=fork(); if(sub==0) { t=execl(NPB_PATH,NPB_PATH,path,path,"q",(char *)0); - return t; + exit(t); } waitpid(sub,&t,0); + if(t)mustard(t); - printf("Content-type: text/html\n\n"); - printf("It's NewpixbOTTification time!"); - printf("

It's NewpixbOTTification time!

"); - printf("%s
",path); - printf("%s
",url); - printf("%d
",t); - printf("%lu
",(unsigned long)sub); - printf("\n"); - + pix=fopen(path,"rb"); + if(pix==NULL) + mustard(123); + fstat(fileno(pix),&st); + p=st.st_size/1024; + q=st.st_size%1024; - - //npbpix=fopen("/var/tmp/test","wb"); - //fclose(npbpix); - return 0; + printf("Content-Length: %lu\n",(unsigned long)(st.st_size)); + printf("Content-type: image/png\n\n"); + for(unsigned long i=0;i