#include #include #include #define MAX_ENTRIES 10000 typedef struct { char *name; char *val; } entry; char *makeword(char *line, char stop); char *fmakeword(FILE *f, char stop, int *len); char x2c(char *what); void unescape_url(char *url); void plustospace(char *str); main(int argc, char *argv[]) { entry entries[MAX_ENTRIES]; register int x,m=0; int cl; int i, j; char *url1,*url2,*fileType,*sendFormat,*compressHost,*compressionRatio; char *tmpCmd, *outDir; printf("Content-type: text/html%c%c",10,10); if(strcmp(getenv("REQUEST_METHOD"),"POST")) { printf("This script should be referenced with a METHOD of POST.\n"); printf("If you don't understand this, see this "); printf("forms overview.%c",10); exit(1); } if(strcmp(getenv("CONTENT_TYPE"),"application/x-www-form-urlencoded")) { printf("This script can only be used to decode form results. \n"); exit(1); } cl = atoi(getenv("CONTENT_LENGTH")); for(x=0;cl && (!feof(stdin));x++) { m=x; entries[x].val = fmakeword(stdin,'&',&cl); plustospace(entries[x].val); unescape_url(entries[x].val); entries[x].name = makeword(entries[x].val,'='); if (!strcmp(entries[x].name, "url1")) url1=entries[x].val; if (!strcmp(entries[x].name, "url2")) url2=entries[x].val; if (!strcmp(entries[x].name, "fileType")) fileType=entries[x].val; if (!strcmp(entries[x].name, "compressionStatus")) sendFormat=entries[x].val; if (!strcmp(entries[x].name, "compressionRatio")) compressionRatio=entries[x].val; } if ((tmpCmd=(char *)malloc(80))==NULL){ printf("Not enough memory to allocate buffer\n"); exit(1); } sprintf(tmpCmd, "/export/projects/kyk20/roman/httpd/cgi-bin/url_get %s > \ /export/projects/kyk20/roman/httpd/kayak%s/%s/%s", url1, getenv("PATH_INFO"), fileType, url2); system(tmpCmd); printf("

File (%s) Retrieval Success!

", fileType); printf(" The file has been retrieved and stored in the server: %s.", getenv("SERVER_NAME")); printf(" It can be reached by URL: ", getenv("SERVER_NAME"),getenv("SERVER_PORT"),getenv("PATH_INFO"),fileType,url2); printf("http://%s:%s%s/%s/%s .

", getenv("SERVER_NAME"),getenv("SERVER_PORT"),getenv("PATH_INFO"),fileType,url2); if (!strcmp(sendFormat,"compression by server")) { if (!strcmp(fileType,"image")) { sprintf(tmpCmd, "/export/projects/kyk20/roman/httpd/cgi-bin/wl1.sh %s %s",url2, compressionRatio); system(tmpCmd); printf("The image file has been compressed with ratio of %s:1

", compressionRatio); printf("The compressed file has been stored as: http://%s:%s%s/%s/com%s ", getenv("SERVER_NAME"),getenv("SERVER_PORT"),getenv("PATH_INFO"),fileType,url2); printf("The decompressed image can be viewed by clicking: \ ", getenv("SERVER_NAME"),getenv("SERVER_PORT"),getenv("PATH_INFO"),fileType,url2); printf("http://%s:%s%s/%s/dec%s .

", getenv("SERVER_NAME"),getenv("SERVER_PORT"),getenv("PATH_INFO"),fileType,url2); } else { printf("No compression is currently supported for non-image files
"); } } if (!strcmp(sendFormat,"compression by client")) { printf("We assume there is no Wavelet Compression software package in your computer, \ so Compression By Client is ignored.
"); } printf(" \

[Back To Home Page]

"); }