- // // It's NewpixbOTTification Time!
- // // Take a picture and add a newpixbot to it!
- // // Requires Dev Image Library, on Pentium III libdevil must be recompiled with --disable-ssl2 --disable-ssl3
- // //
-// // ~~bicyclesonthemoon
+ // //It's NewpixbOTTification Time!
+ // // Take a picture and add a newpixbot to it!
+ // //
+ // // Requires Dev Image Library,
+// // //on Pentium III libdevil must be
+ // // recompiled with --disable-ssl2 --disable-ssl3
+ // //
+ // // ~~bicyclesonthemoon
#define INPIX_MUSTARD 1
#define OUTPIX_MUSTARD 2
+ // //Download images and add
+ // // Newpixbots to them!
+ // //
+ // // Requires cgilib
+// // //line 146 of cgi.h
+ // // must be changed
+ // // from "extern }"
+ // // to "}"
+// // //
+ // // ~~bicyclesonthemoon
+
+#include <cgi.h>
#include <stdio.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+#define WGET_PATH "/usr/bin/wget"
+#define NPB_PATH "./npb"
+
+int main (int argc, char *argv[]);
int main (int argc, char *argv[])
{
- printf("Content-type: text/html\n\n<html><head><title>It's NewpixbOTTification time!</title></head><body><h1>It's NewpixbOTTification time!</body></html>\n");
+ 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"));
+ 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","-O",path,url,(char *)0);
+ return t;
+ }
+ waitpid(sub,&t,0);
+ if(t)return t;
+
+ sub=fork();
+ if(sub==0)
+ {
+ t=execl(NPB_PATH,NPB_PATH,path,path,"q",(char *)0);
+ return t;
+ }
+ waitpid(sub,&t,0);
+
+ printf("Content-type: text/html\n\n");
+ printf("<html><head><title>It's NewpixbOTTification time!</title></head><body>");
+ printf("<h1>It's NewpixbOTTification time!</h1>");
+ printf("%s<br>",path);
+ printf("%s<br>",url);
+ printf("%d<br>",t);
+ printf("%lu<br>",(unsigned long)sub);
+ printf("</body></html>\n");
+
+
+
+ //npbpix=fopen("/var/tmp/test","wb");
+ //fclose(npbpix);
return 0;
}
\ No newline at end of file