From owner-freebsd-hackers Sun Oct 3 4:53:38 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.rp-plus.de (clubserv.rp-online.de [149.221.232.11]) by hub.freebsd.org (Postfix) with ESMTP id CB48A14D18 for ; Sun, 3 Oct 1999 04:53:34 -0700 (PDT) (envelope-from alex@cichlids.com) Received: from neutron.cichlids.com (as15-225.rp-plus.de [149.221.237.225]) by mail.rp-plus.de (8.9.1a/8.9.1) with ESMTP id NAA13075 for ; Sun, 3 Oct 1999 13:53:34 +0200 (METDST) Received: from cichlids.cichlids.com (cichlids.cichlids.com [192.168.0.10]) by neutron.cichlids.com (8.9.3/8.9.1) with ESMTP id NAA00816 for ; Sun, 3 Oct 1999 13:53:05 +0200 (CEST) Received: (from alex@localhost) by cichlids.cichlids.com (8.9.3/8.9.3) id NAA04596 for freebsd-hackers@freebsd.org; Sun, 3 Oct 1999 13:55:10 +0200 (CEST) (envelope-from alex) From: Alexander Langer Date: Sun, 3 Oct 1999 13:55:09 +0200 To: freebsd-hackers@freebsd.org Subject: vis(3), unvis(3), HTTP-URIs and libfetch Message-ID: <19991003135509.A4465@cichlids.cichlids.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="IJpNTDwzlM2Ie8A6" X-Mailer: Mutt 1.0pre2i X-PGP-Fingerprint: 44 28 CA 4C 46 5B D3 A8 A8 E3 BA F3 4E 60 7D 7F X-Verwirrung: Dieser Header dient der allgemeinen Verwirrung. Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Hello! in fetch(3) we read: BUGS No attempt is made to encode spaces etc. within URLs. Spaces in the docu- ment part of an URLshould be replaced with "%20" in HTTP URLs and "\ " in FTP URLs. I've started this encoding. DES told me to implement this in vis(3). This is done by the attached patch and works here. Example: /bla bla/~tst/foo?test=foo+bar&bla=$string becomes /bla%20bla/%7Etest/foo?test=foo+bar&bla=$string in a minimal application. I added a new style const, VIS_HTTPSTYLE (as VIS_CSTYLE) to vis.h, patch is also attached. So libfetch can use vis(3) with the VIS_HTTPSTYLE flag to encode HTTP-URIs, FTP-encoding could be added later easily, too. But now I'm getting problems, that's why I write here: unvis(3) wants to decode HTTPSTYLE strings. while this is no problem for unvis(), I cannot add this to int strunvis(char *dst, const char *src) because strunvis() really misses a flag param to tell it, how to decode. I need a new function - a new name. I propose something like int strunvisx(char *dst, const char *src, int flag); strunvisx (or what the name will be) checks the flag. If it is VIS_HTTPSTYLE it will use unvis() with the VIS_HTTPSTYLE flag to decode the string. If it is VIS_FTPSTYLE (implemented later), it'll use unvis() with VIS_FTPSTYLE. In every other case strunvisx() just calls strunvis(). Alex -- I doubt, therefore I might be. --IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="vis.c.diff" --- /usr/src/lib/libc/gen/vis.c Fri Jul 12 20:54:15 1996 +++ vis.c Sat Oct 2 20:20:17 1999 @@ -52,6 +52,21 @@ register int flag; { c = (unsigned char)c; + + if (flag & VIS_HTTPSTYLE) { + if (!((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') + || (c >= 'a' && c <= 'z') || c == '$' || c == '-' + || c == '_' || c == '\'' || c == '+' || c == '!' || + c == '(' || c == ')' || c == ',' || c == '"' || + c == ';' || c == '/' || c == '?' || c == ':' || + c == '@' || c == '&' || c == '=' || c == '+')) { + *dst++ = '%'; + snprintf(dst, 4, (c < 16 ? "0%X" : "%X"), c); + dst += 2; + goto done; + } + } + if (isgraph(c) || ((flag & VIS_SP) == 0 && c == ' ') || ((flag & VIS_TAB) == 0 && c == '\t') || --IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="vis.h.diff" --- /usr/src/include/vis.h Sun Aug 29 16:38:58 1999 +++ vis.h Sun Oct 3 13:45:00 1999 @@ -64,6 +64,7 @@ * other */ #define VIS_NOSLASH 0x40 /* inhibit printing '\' */ +#define VIS_HTTPSTYLE 0x80 /* http-style escape % HEX HEX */ /* * unvis return codes --IJpNTDwzlM2Ie8A6-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message