Article View: microsoft.public.inetsdk.programming.wininet
Article #7Re: WinInet - InternetCombineURL alternative
From: justin chan
Date: Fri, 28 Sep 2001 00:31
Date: Fri, 28 Sep 2001 00:31
69 lines
3880 bytes
3880 bytes
Thanks Richard! You have been great help.. I'm just abit concerned about the corner cases, but it should be ok! :) Richard Heathfield <binary@eton.powernet.co.uk> wrote in message news:<3BB2C06D.5537E07E@eton.powernet.co.uk>... > Adam wrote: > > > > When you say "portable" most systems have wininet.dll installed. > > I just checked my Linux installation and hey, what do you know, it's not > there. In comp.programming (which is where I'm reading this), "portable" > means more than just "portable to Windows". > > > It is part > > of the OS in Win '98 and >. But for users with Win '95 - all they need is IE > > 4 or >. > > <shrug> > > > "justin chan" <jayc@start.com.au> wrote in message > > news:16379a2c.0109251629.5566caa3@posting.google.com... > > > Hi, > > > > > > Currently I'm using 'InternetCombineURL' function from WinInet to > > > combine a base and relative URL into a single URL. > > > eg. Base: http://www.myserver.com/folder/ > > > Relative: ../file.html > > > Result: http://www.myserver.com/file.html > > > > > > However, because I want to make my application portable, I'm removing > > > dependencies on WinInet. > > Excellent. > > > > > > > Does anyone know if there is an alternative to 'InternetCombineURL' > > > and does not rely on WinInet?? > > Yes, Justin, it's called "programming". :-) > > Start off with your base URL. Parse on the / character. This gives you > tokens http: (in your example), www.myserver.com, and folder. > > Build a data structure that represents that relationship: > > www.myserver.com > ^ > | > | > | > V > folder > > This rather simple example doesn't explain things very well, but > basically you'd have each node pointing to an array of child nodes and > also to a parent node (with the server node itself having a parent of > NULL). That would enable you to build up a picture of the server as you > go. > > Anyway, from that start, finding a relative path is trivial. Start at > the "current" directory - in your case, www.myserver.com/folder - and > parse, again on the / character. If you hit a . on its own, you can > discard it. If you hit on .. on their own, you need to go one place > nearer the root. If you hit a token terminated by a /, you need to > change into that directory (possibly creating a new node in your data > structure in order to represent it), and if you hit a non-empty token > not ending in / at the end, that's the file you're after. > > It's really relatively simple, but also relatively interesting, and well > worth the exercise of programming for yourself.
Technical Details
Message-ID:
<16379a2c.0109271631.5ea8b286@posting.google.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mailReferences:
<16379a2c.0109251629.5566caa3@posting.google.com> <9otpac$2e9$1@bugstomper.ihug.com.au> <3BB2C06D.5537E07E@eton.powernet.co.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1091e5,725b2bc82b6740ad X-Google-Attributes: gid1091e5,public X-Google-Thread: 108717,725b2bc82b6740ad X-Google-Attributes: gid108717,public X-Google-Thread: 115f11,725b2bc82b6740ad X-Google-Attributes: gid115f11,public X-Google-ArrivalTime: 2001-09-27 17:31:53 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail From: jayc@start.com.au (justin chan) Newsgroups: microsoft.public.inetsdk.programming.wininet,borland.public.delphi.winapi,comp.programming Subject: Re: WinInet - InternetCombineURL alternative Date: 27 Sep 2001 17:31:53 -0700 Organization: http://groups.google.com/ Lines: 69 Message-ID: <16379a2c.0109271631.5ea8b286@posting.google.com> References: <16379a2c.0109251629.5566caa3@posting.google.com> <9otpac$2e9$1@bugstomper.ihug.com.au> <3BB2C06D.5537E07E@eton.powernet.co.uk> NNTP-Posting-Host: 203.12.53.50 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1001637113 3086 127.0.0.1 (28 Sep 2001 00:31:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 28 Sep 2001 00:31:53 GMT