|
From: | Sergio R. Caprile |
Subject: | Re: [lwip-users] Decode HTTP URI |
Date: | Tue, 22 May 2018 15:08:57 -0300 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
I guess you refer to "url_decode". Here's the one I used in my web server: #define TOUPPER(c) (((c>='a')&&(c<='z'))? (c-('a'-'A')):(c)) #define HEXNUMBER(c) ((((c)<'0')||((c)>'F')||(((c)>'9')&&((c)<'A')))? 0 :((c)>=' A')?((c)-('0'+7)):((c)-'0')) void cgi_urldecode(char *text) { char *ptr = text; char c; int val; while((c=*ptr)!= '\0'){ if(c == '+'){ *text = ' '; } else if(c == '%'){ c = *(++ptr); c = TOUPPER(c); val = (HEXNUMBER(c)<<4); c = *(++ptr); c = TOUPPER(c); val += HEXNUMBER(c); *text = (char)val; } else { *text = *ptr; } ++ptr; ++text; } *text = '\0'; } I don't know if the official server in the apps subtree has this capability (yet). You (and btw anyone else) are welcome to take any useful parts of my web server and port them to the official one. I don't have the time to do it; just acknowledge the source. http://scaprile.ldir.com.ar/cms/el-ingeniero/open-source-projects-im-working-on/lwhttpd/
[Prev in Thread] | Current Thread | [Next in Thread] |