/* $OpenXM: OpenXM/src/kan96xx/trans/oxdecode_post.c,v 1.2 2013/09/22 02:38:25 takayama Exp $ Decompose a given multi-part post message to URL encoded one for cgi.sm1 */ /* - use some codes in plugin/oxcgi.c keyValuePairToUrlEncoding() - doPolymake.OoHG does not work over the reverse proxy. - data/testpost.sh is a test script for the input by curl. - src/polymake/cgi/cgi-polymake.sh */ #include #include #include int multipart(char *s); char *urlEncoding(char *s); int substr(char s[],int n,char a[]); char *byteArrayToUrlEncoding(unsigned char *s,int size); int isUrlEncoding3(char s); main() { char *s; int i,j,limit,len; int c; char slen[1024]; s=getenv("CONTENT_LENGTH"); if (s!=NULL) sscanf(s,"%d",&limit); else limit=-1; if (limit <= 0) { fprintf(stderr,"CONTENT_LENGTH does not seem to be set.\n"); return(-1); } s = (char *)malloc(limit+1); for (i=0; i <=). Make corrections for other use!*/ for (j=0; j 3) && (strncmp(s,"---",3)==0)) return(1); else return(0); } char *urlEncoding(char *s) { int i,j,pos,pos2; char *name; char *body; char *body2; char *msg; pos = substr(s,strlen(s),"name="); if (pos < 0) return "error: no name="; pos += 6; pos2=pos-1; for (i=pos; i + */ int isUrlEncoding3(char s) { if ((s == '.') || (s == '-') || (s == '_')) return(0); if ((s >= 'A') && (s <= 'Z')) return(0); if ((s >= 'a') && (s <= 'z')) return(0); if ((s >= '0') && (s <= '9')) return(0); if (s == ' ') return(0); return(1); } char *byteArrayToUrlEncoding(unsigned char *s,int size) { int n,i,j; char *r; n = 0; /* get Size */ for (i=0; i