PageRenderTime 53ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/LIBS/Extensions/inc/office10/msourl.h

http://sando.codeplex.com
C++ Header | 646 lines | 310 code | 68 blank | 268 comment | 4 complexity | 73b5a992a63d4823857476ff2b825016 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.0
  1. /****************************************************************************
  2. msourl.h
  3. Owner: SeanMc
  4. Copyright (c) 1999 Microsoft Corporation
  5. MSO's url handling interfaces.
  6. ****************************************************************************/
  7. #pragma once
  8. #ifndef MSOURL_H
  9. #define MSOURL_H
  10. #ifndef CONST_METHOD
  11. // to declare const methods in C++
  12. #if defined(__cplusplus) && !defined(CINTERFACE)
  13. #define CONST_METHOD const
  14. #else
  15. #define CONST_METHOD
  16. #endif
  17. #endif
  18. #include "wininet.h"
  19. #include "msobp.h"
  20. // list of schemes recognized via MsoUrl
  21. typedef enum
  22. {
  23. urlsNil = -1,
  24. urlsHttp, // "http"
  25. urlsHttps, // "https"
  26. urlsFtp, // "ftp"
  27. urlsFile, // "file"
  28. urlsCid, // "cid"
  29. urlsMailto, // "mailto"
  30. urlsJavascript, // "javascript"
  31. urlsOutlook, // "outlook"
  32. urlsODMA, // "::ODMA\"
  33. urlsMhtmlCompound, // "mhtml:X!Y"
  34. urlsThismessage, // "thismessage"
  35. urlsRes, // "res"
  36. urlsMk, // "mk"
  37. urlsUnknown
  38. } MSOURLSCHEME;
  39. // list of relativities understood via MsoUrl
  40. typedef enum
  41. {
  42. urlrNil = -1,
  43. urlrOpaque, // EXAMPLE: "mailto:someone@somewhere.com"
  44. urlrAbsolute, // EXAMPLE: "http://mumble.com/woo.hoo"
  45. urlrServer, // EXAMPLE: "/foo/bar/woo.hoo"
  46. urlrPage // EXAMPLE: "../foo/bar/woo.hoo"
  47. } MSOURLRELATIVITY;
  48. /* URLC (Url Component) flags, passed to IMsoUrl::HrGetCustomForm & IMsoUrl::FComponentsAreEqual. */
  49. #define msofurlcScheme 0x0001
  50. #define msofurlcUserName 0x0002
  51. #define msofurlcPassword 0x0004
  52. #define msofurlcServer 0x0008
  53. #define msofurlcPort 0x0010
  54. #define msofurlcDir 0x0020
  55. #define msofurlcFileName 0x0040
  56. #define msofurlcFileExt 0x0080
  57. #define msofurlcQuery 0x0100
  58. #define msofurlcFragment 0x0200
  59. #define msofurlcMhtml 0x0400
  60. #define msofurlcAuthority (msofurlcUserName | msofurlcPassword | msofurlcServer | msofurlcPort)
  61. #define msofurlcFileLeaf (msofurlcFileName | msofurlcFileExt)
  62. #define msofurlcPath (msofurlcDir | msofurlcFileLeaf)
  63. #define msofurlcComplete (msofurlcScheme | msofurlcAuthority | msofurlcPath | msofurlcQuery | msofurlcFragment | msofurlcMhtml)
  64. /* URL flags, passed to IMsoUrl::HrSetFromUser[Rgwch]. */
  65. #define msofurlNoFragment 0x00000001 // don't treat the '#' character as a fragment delimiter
  66. #define msofurlStripEncapsulatingDelims 0x00000002 // strip off quotes or angle brackets encapsulating the url (if present)
  67. #define msofurlConvertDriveMappedUNC 0x00000004 // convert drive mapped UNCs to pure UNC form
  68. #define msofurlConvertToShortFileName 0x00000008 // convert any local paths to 8.3 form
  69. #define msofurlConvertToLongFileName 0x00000010 // convert any local paths to long filename form
  70. #define msofurlEscapeSingleQuotes 0x00000020 // escape any single quotes found in the url
  71. #define msofurlEscapeAllPercents 0x00000040 // escape all percents (normally percents in %HH sequences are not escaped)
  72. #define msofurlStripLeadingWhitespace 0x00000080 // strip off leading whitespace (if present)
  73. #define msofurlStripTrailingWhitespace 0x00000100 // strip off trailing whitespace (if present)
  74. // if present with msofurlStripEncapsulatingDelims, strips both inside and outside delims
  75. #define msofurlApplyGuessScheme 0x00000200 // apply best guess scheme if none exists on the url
  76. #define msofurlApplyDefaultScheme 0x00000400 // apply the default scheme if none exists on the url
  77. #define msofurlCaseInsensitivePath 0x00000800 // use case-insensitive comparisons on the path component
  78. #define msofurlEnsureTrailingPathSep 0x00001000 // ensure the path component includes a trailing slash (indicating it is a directory)
  79. #define msofurlRemoveTrailingPathSep 0x00002000 // ensure the path component does not have a trailing slash (indicating a file leaf or empty path)
  80. #define msofurlAllowInvertedLocalSep 0x00004000 // let "x:/" map to { scheme:"file", path:"x:\" }, rather than { scheme:"x", path:"/" }
  81. // also applies the same logic to "//server/share"
  82. #define msofurlDontChangeSlashTypes 0x00008000 // don't change /'s to \'s or vice-versa
  83. #define msofurlNoEscape 0x00010000 // don't escape this url internally
  84. #define msofurlEnsureValidAuthority 0x00020000 // ensure the authority component is valid if present (non-empty)
  85. #define msofurlNoQuery 0x00040000 // don't treat the '?' character as a query delimiter
  86. #define msofurlEnsureBalancedQuotes 0x00080000 // ensure no unbalanced quotes at the beginning/end of the URL
  87. // use with caution: these may be valid in some cases
  88. #define msofurlEscapeAllReservedChars 0x00100000 // escape all reserved characters (any in ";/:@&=+$,") use with care -- creates very odd urls!
  89. #define msofurlDetectASPLinks 0x00200000 // client wants ASP links detected
  90. /* URLDF flags, passed to IMsoUrl::HrGetDisplayForm. */
  91. #define msofurldfUnescapeHighAnsi 0x0001 // unescape high-ANSI entities (use with extreme caution!)
  92. #define msofurldfUseLocalPathForm 0x0002 // use the local path form for local urls (return what HrGetLocalPath would return if the url is local)
  93. #define msofurldfDoNotUnescapeHash 0x0004 // do not unescape the hash character (leave it "%23" instead)
  94. #define msofurldfDoNotUnescapeLowAnsi 0x0008 // do not unescape low-ANSI entities (use with extreme caution!)
  95. /* URLCF flags, passed to IMsoUrl::HrGetCustomForm. */
  96. #define msofurlcfDisplay 0x0001 // get the display form
  97. #define msofurlcf3SlashFileSyntax 0x0002 // use the 3 slash file: syntax
  98. #define msofurlcfUseHideExtShellSetting 0x0004 // use the OS shell setting to hide extensions to include ext in leaf
  99. #define msofurlcfUseLocalPathForm 0x0008 // use the local path form for local urls (return what HrGetLocalPath would return if the url is local)
  100. /* URLE flags, passed to IMsoUrl::FExists. */
  101. #define msofurleCheckServers 0x0001 // validate against the server (if not set then server based paths return FALSE)
  102. #define msofurleFolder 0x0002 // verify that path points to a folder
  103. #define msofurleBrowsable 0x0004 // verify that path points to a browsable folder (requires msofurleFolder)
  104. #define msofurleAllowUI 0x0008 // allow UI to be raised (such as the password authentication dialog)
  105. /* URLU flags, passed to IMsoUrl::HrUpload. */
  106. #define msofurluAlertIfExist 0x0001
  107. #define msofurluFailIfExist 0x0002
  108. /* URLD flags, passed to IMsoUrl::HrDownload. */
  109. #define msofurldUseCachedVersion 0x0001 // if it already exists in the cache, use it (otherwise download it)
  110. /////////////////////////////////////////////////////////////////////////////////
  111. //
  112. // Basic url definitions:
  113. //
  114. // hierarchichal url := <scheme>://<authority>[/<path>][?<query>][#<fragment>]
  115. // authority := [<username>[:<password>]@]<server>[:<port>]
  116. // path := <dir>[/[fileleaf]]
  117. // fileleaf := <filename>[.<fileext>]
  118. //
  119. // opaque url := <scheme>:<path>[?<query>][#<fragment>]
  120. //
  121. // NOTE: every url always has a path (& dir) component (but it may be the empty string)
  122. //
  123. /////////////////////////////////////////////////////////////////////////////////
  124. //
  125. // Mhtml url definitions:
  126. //
  127. // Only-File form: mhtml:X - where X is an absolute hierarchichal url.
  128. // Compound form: mhtml:X!Y - where X is like above, Y is a CID or CLOC (Content-Location)
  129. //
  130. // NOTE: We do not return Only-File forms for these types of url's, since this can
  131. // expose a bug in IE which causes these files to be loaded with the wrong codepage.
  132. // NOTE: We only use the mhtml: prefix when we have a compound mhtml url (restating above).
  133. // Therefore Only-File url's become normal url's when accessed via url methods.
  134. //
  135. // We fixup REL url's with mhtml url's by doing the following:
  136. // mhtml:X + REL ==> mhtml:X!REL <- Only-File becomes a compound mhtml url
  137. // mhtml:X!Y + REL ==> mhtml:X!(Y+REL) <- here, Y+REL is the proper combination of these url's as single entities
  138. //
  139. /////////////////////////////////////////////////////////////////////////////////
  140. /* IMsoUrl (iurl) */
  141. #undef INTERFACE
  142. #define INTERFACE IMsoUrl
  143. DECLARE_INTERFACE_(IMsoUrl, IUnknown)
  144. {
  145. // ----- IUnknown methods
  146. MSOMETHOD (QueryInterface) (THIS_ REFIID riid, VOID **ppvObj) PURE;
  147. MSOMETHOD_(ULONG, AddRef) (THIS) PURE;
  148. MSOMETHOD_(ULONG, Release) (THIS) PURE;
  149. // ----- IMsoUrl methods
  150. /* FDebugMessage method */
  151. MSODEBUGMETHOD
  152. // is the URL valid? (was it set properly?)
  153. MSOMETHOD_(BOOL, FValid) (THIS) CONST_METHOD PURE;
  154. // set methods
  155. //
  156. // HrSetFromUser - use when you have a url from an external source other than another
  157. // MsoUrl (for instance from user typing or pasting in from some external source
  158. // or a url read in from an html file). Param grfurl allows the user to specify
  159. // special behavior (such as msofurlNoFragment specifying to interpreting the url
  160. // as having no fragment). Default grfurl is 0.
  161. // HrSetFromUserRgwch - same as HrSetFromUser but takes a rgwch & cch instead of wz.
  162. // HrSetFromCanonicalUrl - use only when you have a canonical url retrieved from
  163. // another MsoUrl. Primarily only used internally, or maybe when writing out a
  164. // url to a cache in the registry for example. When in doubt, use HrSetFromUser
  165. // (which does more robustifying and canonicalizing on the input url).
  166. //
  167. // NOTE: each set method also has a param cp which is the codepage context of the
  168. // url (i.e. the codepage of the html source file or CP_ACP for something pasted
  169. // or the document codepage for something typed in by the user).
  170. // NOTE: each set method also has a param piurlBase which is a url which represent the
  171. // base for resolving this url. Urls which are absolute or opaque may safely pass
  172. // in NULL for the base. Relative url's should however always have a valid base. If
  173. // a relative url is created without a base, the HrResolve method will assert.
  174. MSOMETHOD (HrSetFromUser) (THIS_ const WCHAR *wzUrl, DWORD cp, const IMsoUrl *piurlBase, DWORD grfurl) PURE;
  175. MSOMETHOD (HrSetFromUserRgwch) (THIS_ const WCHAR *rgwchUrl, int cchUrl, DWORD cp, const IMsoUrl *piurlBase, DWORD grfurl) PURE;
  176. MSOMETHOD (HrSetFromCanonicalUrl) (THIS_ const WCHAR *wzUrl, DWORD cp, const IMsoUrl *piurlBase) PURE;
  177. // lock/unlock methods
  178. //
  179. // Use these when you use methods returning LPCWSTR's to ensure the data is not changed
  180. // while you are accessing it. These methods ensure that no updates are done to the
  181. // url while you are using it's data. If you don't want to use this, use the methods
  182. // which copy the url data to a buffer instead (which don't require buffer locking).
  183. MSOMETHOD_(void, Lock) (THIS) CONST_METHOD PURE;
  184. MSOMETHOD_(void, Unlock) (THIS) CONST_METHOD PURE;
  185. // get url methods
  186. //
  187. // HrGetDisplayForm - use to get the unescaped "friendly" form of a url for displaying to
  188. // the user (i.e. spaces in the url are actually spaces instead of %20s).
  189. // HrGetCanonicalForm - use to get the canonical form of the url. This is the standard
  190. // form of the url.
  191. // HrGetCustomForm - use to get a url with or without certain components. For instance,
  192. // use this when you want to get a url without a fragment (if it has one) -- you would
  193. // pass in grfurlc as (msofurlcComplete & ~msofurlcFragment). Note, this returns the
  194. // components with their associated delimiters (unlike the component access methods below).
  195. //
  196. // NOTE: the HrGet methods all take in a WCHAR buffer wzBuf, whose size is passed in as
  197. // the input value of pcchBuf. The length of the url put in wzBuf is returned as the
  198. // output value of pcchBuf. If NULL is passed in for wzBuf, then the requisite size
  199. // of wzBuf is returned in pcchBuf. In all cases (input/output) pcchBuf is the actual
  200. // count of characters in wzBuf not including the NULL termination character. So if
  201. // you query with NULL, you should alloc (*pcchBuf + 1) characters for wzBuf. If wzBuf
  202. // is NULL and the function succeeds, S_FALSE is returned. If wzBuf is non-NULL and
  203. // the function succeeds, S_OK is returned.
  204. //
  205. // CpGetCodePage - use to retrieve the codepage context of this url.
  206. // WzCanonicalForm - returns the same value as HrGetCanonicalForm but returns an LPCWSTR
  207. // pointer to the internal buffer rather than putting it in a user specified buffer.
  208. // Useful in certain scenarios. Url must be locked while this function is called and
  209. // while the return value is in use. Returns NULL on error.
  210. // CchCanonicalForm - returns the count of characters of the url returned by
  211. // WzCanonicalForm.
  212. MSOMETHOD (HrGetDisplayForm) (THIS_ WCHAR *wzBuf, int *pcchBuf, DWORD grfurldf) CONST_METHOD PURE;
  213. MSOMETHOD (HrGetCanonicalForm) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  214. MSOMETHOD (HrGetCustomForm) (THIS_ DWORD grfurlc, WCHAR *wzBuf, int *pcchBuf, DWORD grfurlcf) CONST_METHOD PURE;
  215. MSOMETHOD_(DWORD, CpGetCodePage) (THIS) CONST_METHOD PURE;
  216. MSOMETHOD_(LPCWSTR, WzCanonicalForm) (THIS) CONST_METHOD PURE;
  217. MSOMETHOD_(int, CchCanonicalForm) (THIS) CONST_METHOD PURE;
  218. // component accessor methods
  219. //
  220. // Note: see "Basic url definition" comment above for component definitions.
  221. //
  222. // UrlsGetScheme - returns the scheme specified in this url as an MSOURLSCHEME.
  223. // HrGetScheme - returns the scheme string (without ':' delimiter).
  224. // HrGetAuthority - returns the authority string
  225. // (with all subcomponent delimiters but without initial '/' delimiters).
  226. // HrGetUserName - returns the username string (without '@' delimiter).
  227. // HrGetPassword - returns the password string (without ':' delimiter).
  228. // HrGetServer - returns the server string.
  229. // HrGetPort - returns the port string (without ':' delimiter).
  230. // HrGetPath - returns the path string (with the initial '/' delimiter if this
  231. // is a hierarchical url). This may validly return the empty string.
  232. // (Path contains Dir & FileLeaf).
  233. // HrGetDir - returns the dir string (with the initial '/' delimiter if this
  234. // is a hierarchical url). This may validly return the empty string.
  235. // HrGetFileLeaf - returns the file leaf string (without '/' delimeter).
  236. // (FileLeaf contains FileName & FileExt).
  237. // HrGetFileName - returns the file name string (without '/' delimeter).
  238. // HrGetFileExt - returns the file ext string (without '.' delimiter).
  239. // HrGetQuery - returns the query string (without '?' delimiter).
  240. // HrGetFragment - returns the fragment string (without '#' delimiter).
  241. // (Fragment is also known as Bookmark).
  242. //
  243. // NOTE: see HrGet url note above for usage of the HrGet component methods.
  244. //
  245. // RgwchScheme - same as HrGetScheme but returns a pointer to the scheme component.
  246. // RgwchAuthority - same
  247. // RgwchUserName - same
  248. // RgwchPassword - same
  249. // RgwchServer - same
  250. // RgwchPort - same
  251. // RgwchPath - same
  252. // RgwchDir - same
  253. // RgwchFileLeaf - same
  254. // RgwchFileName - same
  255. // RgwchFileExt - same
  256. // RgwchQuery - same
  257. // RgwchFragment - same
  258. //
  259. // NOTE: the Rgwch returning functions all return NULL if the component does not
  260. // exist. Param pcch is an output parameter which will contain the length of
  261. // the returned rgwch pointer. These are not NULL terminated!
  262. MSOMETHOD_(MSOURLSCHEME, UrlsGetScheme) (THIS) CONST_METHOD PURE;
  263. MSOMETHOD (HrGetScheme) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  264. MSOMETHOD (HrGetAuthority) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  265. MSOMETHOD (HrGetUserName) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  266. MSOMETHOD (HrGetPassword) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  267. MSOMETHOD (HrGetServer) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  268. MSOMETHOD (HrGetPort) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  269. MSOMETHOD (HrGetPath) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  270. MSOMETHOD (HrGetDir) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  271. MSOMETHOD (HrGetFileLeaf) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  272. MSOMETHOD (HrGetFileName) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  273. MSOMETHOD (HrGetFileExt) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  274. MSOMETHOD (HrGetQuery) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  275. MSOMETHOD (HrGetFragment) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  276. MSOMETHOD_(LPCWSTR, RgwchScheme) (THIS_ int *pcch) CONST_METHOD PURE;
  277. MSOMETHOD_(LPCWSTR, RgwchAuthority) (THIS_ int *pcch) CONST_METHOD PURE;
  278. MSOMETHOD_(LPCWSTR, RgwchUserName) (THIS_ int *pcch) CONST_METHOD PURE;
  279. MSOMETHOD_(LPCWSTR, RgwchPassword) (THIS_ int *pcch) CONST_METHOD PURE;
  280. MSOMETHOD_(LPCWSTR, RgwchServer) (THIS_ int *pcch) CONST_METHOD PURE;
  281. MSOMETHOD_(LPCWSTR, RgwchPort) (THIS_ int *pcch) CONST_METHOD PURE;
  282. MSOMETHOD_(LPCWSTR, RgwchPath) (THIS_ int *pcch) CONST_METHOD PURE;
  283. MSOMETHOD_(LPCWSTR, RgwchDir) (THIS_ int *pcch) CONST_METHOD PURE;
  284. MSOMETHOD_(LPCWSTR, RgwchFileLeaf) (THIS_ int *pcch) CONST_METHOD PURE;
  285. MSOMETHOD_(LPCWSTR, RgwchFileName) (THIS_ int *pcch) CONST_METHOD PURE;
  286. MSOMETHOD_(LPCWSTR, RgwchFileExt) (THIS_ int *pcch) CONST_METHOD PURE;
  287. MSOMETHOD_(LPCWSTR, RgwchQuery) (THIS_ int *pcch) CONST_METHOD PURE;
  288. MSOMETHOD_(LPCWSTR, RgwchFragment) (THIS_ int *pcch) CONST_METHOD PURE;
  289. // helper functions for file management
  290. //
  291. // FIsHttp - does the url point to a http or https address?
  292. // FIsFtp - does the url point to a ftp address?
  293. // FIsLocal - does the url point to a dos addressable file address
  294. // (local drive, mapped drive or UNC drive)?
  295. // FIsUNC - does the url point to a UNC file address?
  296. // FIsODMA - does the url point to an ODMA path identifier?
  297. MSOMETHOD_(BOOL, FIsHttp) (THIS) CONST_METHOD PURE;
  298. MSOMETHOD_(BOOL, FIsFtp) (THIS) CONST_METHOD PURE;
  299. MSOMETHOD_(BOOL, FIsLocal) (THIS) CONST_METHOD PURE;
  300. MSOMETHOD_(BOOL, FIsUNC) (THIS) CONST_METHOD PURE;
  301. MSOMETHOD_(BOOL, FIsODMA) (THIS) CONST_METHOD PURE;
  302. // local path accessor methods (only work for file: url's)
  303. //
  304. // HrGetLocalPath - returns the dos path form of the file: url. Returns error
  305. // if the url is not a file: url. Behaves the same as HrGet url methods.
  306. // WzLocalPath - returns a pointer to the dos path form of the file: url. Returns NULL
  307. // if the url is not a file: url. Behaves the same as WzCanonicalForm.
  308. // CchLocalPath - returns the count of characters of the dos path returned by
  309. // WzLocalPath.
  310. //
  311. // EXAMPLE 1: "file://c:/mumble/woo.hoo" yields "c:\mumble\woo.hoo".
  312. // EXAMPLE 2: "file://server/share/mumble/woo.hoo" yields "\\server\share\mumble\woo.hoo".
  313. MSOMETHOD (HrGetLocalPath) (THIS_ WCHAR *wzBuf, int *pcchBuf) CONST_METHOD PURE;
  314. MSOMETHOD_(LPCWSTR, WzLocalPath) (THIS) CONST_METHOD PURE;
  315. MSOMETHOD_(int, CchLocalPath) (THIS) CONST_METHOD PURE;
  316. // FIsEqual - returns TRUE iff the given url is equivalent to this url.
  317. // (Equivalent to calling FComponentsAreEqual with grfurlc as msofurlcComplete).
  318. MSOMETHOD_(BOOL, FIsEqual) (THIS_ const IMsoUrl *piurl) CONST_METHOD PURE;
  319. // FComponentsAreEqual - returns TRUE iff the components specifed in grfurlc are equivalent
  320. // in this url and the given url.
  321. MSOMETHOD_(BOOL, FComponentsAreEqual) (THIS_ DWORD grfurlc, const IMsoUrl *piurl) CONST_METHOD PURE;
  322. // FSubsumes - returns TRUE iff this url's folder location is a direct
  323. // hierarchical ancestor of piurl. If two url's subsume each other, they point to
  324. // the same folder location!
  325. //
  326. // EXAMPLE 1: "http://mumble/woo/blah.htm" subsumes "http://mumble/woo/hoo/wunder.bar".
  327. // EXAMPLE 2: "http://mumble/woo/hoo/wunder.bar" does not subsume "http://mumble/woo/blah.htm".
  328. // EXAMPLE 3: "http://mumble/woo/blah.htm" does not subsume "ftp://foobarbaz/woo/hoo/wunder.bar".
  329. // EXAMPLE 4: "http://mumble/woo/hoo/blah.htm" does not subsume "http://mumble/woo/zoo/foo.gif".
  330. MSOMETHOD_(BOOL, FSubsumes) (THIS_ const IMsoUrl *piurl) CONST_METHOD PURE;
  331. // UrlrGetRelativity - returns the relativity of this url as an MSOURLRELATIVITY.
  332. MSOMETHOD_(MSOURLRELATIVITY, UrlrGetRelativity) (THIS) CONST_METHOD PURE;
  333. // HrSetRelativity - updates the relativity of this url. Returns S_OK when the
  334. // url is successfully updated or S_FALSE if the requested url cannot be set
  335. // because the base url's server or scheme is different. Returns error codes
  336. // for other failures.
  337. MSOMETHOD (HrSetRelativity) (THIS_ MSOURLRELATIVITY urlr) PURE;
  338. // HrResolve - resolves this relative url to a full path (by combining it with its base),
  339. // creates a new url and returns it in ppiurlAbsolute. On success,
  340. // *ppiurlAbsolute must be Released by the client when done. Calling this on an
  341. // absolute or opaque url is valid.
  342. //
  343. // EXAMPLE 1: this url "foo.bar" combined with base "http://woohoo/sub/hub/spiffy.htm"
  344. // yields resolved path "http://woohoo/sub/hub/foo.bar".
  345. // EXAMPLE 2: this url "/foo.bar" combined with base "http://woohoo/sub/hub/spiffy.htm"
  346. // yields resolved path "http://woohoo/foo.bar".
  347. // EXAMPLE 3: this url "../foo.bar" combined with base "http://woohoo/sub/hub/spiffy.htm"
  348. // yields resolved path "http://woohoo/sub/foo.bar".
  349. MSOMETHOD (HrResolve) (THIS_ IMsoUrl **ppiurlAbsolute) CONST_METHOD PURE;
  350. // HrRebase - rebase this url with a different base url (i.e. link fixup).
  351. // If the new base url is on a different server this just makes the url absolute.
  352. // Otherwise it maintains the current relativity state and constructs a new
  353. // relative url pointing at the same target location. If the relativity state
  354. // was not maintainable, it returns S_FALSE on success.
  355. //
  356. // EXAMPLE 1: this url "foo.bar" with old base "http://woohoo/sub/hub/spiffy.htm"
  357. // rebased with new base "http://woohoo/sub/spiffy.htm"
  358. // yields this url "hub/foo.bar".
  359. // EXAMPLE 2: this url "../foo.bar" with old base "http://woohoo/sub/hub/spiffy.htm"
  360. // rebased with new base "http://woohoo/sub/spiffy.htm"
  361. // yields this url "foo.bar".
  362. // EXAMPLE 3: this url "/foo.bar" with old base "http://woohoo/sub/hub/spiffy.htm"
  363. // rebased with new base "http://woohoo/sub/spiffy.htm"
  364. // yields this url "/foo.bar".
  365. // EXAMPLE 4: this url "foo.bar" with old base "http://woohoo/sub/hub/spiffy.htm"
  366. // rebased with new base "http://mumble/spiffy.htm"
  367. // yields this url "http://woohoo/sub/hub/foo.bar".
  368. MSOMETHOD (HrRebase) (THIS_ const IMsoUrl *piurlBase) PURE;
  369. // HrDownload - downloads this url for local data access. On success, returns the
  370. // local path to the downloaded file in wzBuf. The size of wzBuf is the
  371. // input value of pcchBuf, the length of the path put into wzBuf is the
  372. // output value of pcchBuf. The grfurld param is a set of flags used to
  373. // control the download (default is 0).
  374. MSOMETHOD (HrDownload) (THIS_ WCHAR *wzBuf, int *pcchBuf, DWORD grfurld) CONST_METHOD PURE;
  375. // HrUpload - uploads the file specified in wzFile to the location specified
  376. // by this url. The grfurlu param is a set of flags used to control the
  377. // upload (default is 0).
  378. // Returns:
  379. // S_OK if the file was uploaded successfuly
  380. // S_FALSE if the user cancel the operation (for example, he/she doesn't
  381. // want to overwrite an existing file)
  382. // E_FAIL generic failure
  383. MSOMETHOD (HrUpload) (THIS_ const WCHAR *wzFile, DWORD grfurlu) CONST_METHOD PURE;
  384. // HrDelete - deletes the file specified by this url.
  385. MSOMETHOD (HrDelete) (THIS) CONST_METHOD PURE;
  386. // FExists - returns TRUE iff the file exists. Param grfurle determines
  387. // which kind of validation to perform (default is 0 which means do not
  388. // check web servers (i.e. http/ftp) & returns FALSE if this url points
  389. // to a web server location - to validate against web servers pass the
  390. // msofurleCheckServers flag).
  391. MSOMETHOD_(BOOL, FExists) (THIS_ DWORD grfurle) CONST_METHOD PURE;
  392. // HrGetBase - returns the base url of this url in ppiurlBase.
  393. // Caller must release the returned url when done.
  394. MSOMETHOD (HrGetBase) (THIS_ const IMsoUrl **ppiurlBase) CONST_METHOD PURE;
  395. // FIsMhtml - does the url point to an mhtml file, and in the form "mhtml:X[!Y]" ?
  396. MSOMETHOD_(BOOL, FIsMhtml) (THIS) CONST_METHOD PURE;
  397. // Returns the reference to the bodypart this mhtml url is referring to
  398. MSOMETHOD_(LPCWSTR, WzMhtmlBodypart) (THIS) CONST_METHOD PURE;
  399. // Returns the cch of the reference to the bodypart this mhtml url is referring to
  400. MSOMETHOD_(int, CchMhtmlBodypart) (THIS) CONST_METHOD PURE;
  401. MSOMETHOD_(BPSC, BpscBulletProof) (THIS_ MSOBPCB *pmsobpcb) PURE;
  402. MSOMETHOD_(ULONG, Free) (THIS) PURE;
  403. };
  404. #ifndef __cplusplus
  405. // IMsoUrl wrapper/convenience functions for C clients
  406. #define IMsoUrl_QueryInterface(this, riid, ppvObj) \
  407. ( (this)->lpVtbl->QueryInterface(this, riid, ppvObj) )
  408. #define IMsoUrl_AddRef(this) \
  409. ( (this)->lpVtbl->AddRef(this) )
  410. #define IMsoUrl_Release(this) \
  411. ( (this)->lpVtbl->Free(this) )
  412. #define IMsoUrl_FValid(this) \
  413. ( (this)->lpVtbl->FValid(this) )
  414. #define IMsoUrl_HrSetFromUser(this, wzUrl, cp, piurlBase, grfurl) \
  415. ( (this)->lpVtbl->HrSetFromUser(this, wzUrl, cp, piurlBase, grfurl) )
  416. #define IMsoUrl_HrSetFromUserRgwch(this, rgwchUrl, cchUrl, cp, piurlBase, grfurl) \
  417. ( (this)->lpVtbl->HrSetFromUserRgwch(this, rgwchUrl, cchUrl, cp, piurlBase, grfurl) )
  418. #define IMsoUrl_HrSetFromCanonicalUrl(this, wzUrl, cp, piurlBase) \
  419. ( (this)->lpVtbl->HrSetFromCanonicalUrl(this, wzUrl, cp, piurlBase) )
  420. #define IMsoUrl_Lock(this) \
  421. ( (this)->lpVtbl->Lock(this) )
  422. #define IMsoUrl_Unlock(this) \
  423. ( (this)->lpVtbl->Unlock(this) )
  424. #define IMsoUrl_HrGetDisplayForm(this, wzBuf, pcchBuf, grfurldf) \
  425. ( (this)->lpVtbl->HrGetDisplayForm(this, wzBuf, pcchBuf, grfurldf) )
  426. #define IMsoUrl_HrGetCanonicalForm(this, wzBuf, pcchBuf) \
  427. ( (this)->lpVtbl->HrGetCanonicalForm(this, wzBuf, pcchBuf) )
  428. #define IMsoUrl_HrGetCustomForm(this, grfurlc, wzBuf, pcchBuf, grfurlcf) \
  429. ( (this)->lpVtbl->HrGetCustomForm(this, grfurlc, wzBuf, pcchBuf, grfurlcf) )
  430. #define IMsoUrl_CpGetCodePage(this) \
  431. ( (this)->lpVtbl->CpGetCodePage(this) )
  432. #define IMsoUrl_WzCanonicalForm(this) \
  433. ( (this)->lpVtbl->WzCanonicalForm(this) )
  434. #define IMsoUrl_CchCanonicalForm(this) \
  435. ( (this)->lpVtbl->CchCanonicalForm(this) )
  436. #define IMsoUrl_UrlsGetScheme(this) \
  437. ( (this)->lpVtbl->UrlsGetScheme(this) )
  438. #define IMsoUrl_HrGetScheme(this, wzBuf, pcchBuf) \
  439. ( (this)->lpVtbl->HrGetScheme(this, wzBuf, pcchBuf) )
  440. #define IMsoUrl_HrGetAuthority(this, wzBuf, pcchBuf) \
  441. ( (this)->lpVtbl->HrGetAuthority(this, wzBuf, pcchBuf) )
  442. #define IMsoUrl_HrGetUserName(this, wzBuf, pcchBuf) \
  443. ( (this)->lpVtbl->HrGetUserName(this, wzBuf, pcchBuf) )
  444. #define IMsoUrl_HrGetPassword(this, wzBuf, pcchBuf) \
  445. ( (this)->lpVtbl->HrGetPassword(this, wzBuf, pcchBuf) )
  446. #define IMsoUrl_HrGetServer(this, wzBuf, pcchBuf) \
  447. ( (this)->lpVtbl->HrGetServer(this, wzBuf, pcchBuf) )
  448. #define IMsoUrl_HrGetPort(this, wzBuf, pcchBuf) \
  449. ( (this)->lpVtbl->HrGetPort(this, wzBuf, pcchBuf) )
  450. #define IMsoUrl_HrGetPath(this, wzBuf, pcchBuf) \
  451. ( (this)->lpVtbl->HrGetPath(this, wzBuf, pcchBuf) )
  452. #define IMsoUrl_HrGetDir(this, wzBuf, pcchBuf) \
  453. ( (this)->lpVtbl->HrGetDir(this, wzBuf, pcchBuf) )
  454. #define IMsoUrl_HrGetFileLeaf(this, wzBuf, pcchBuf) \
  455. ( (this)->lpVtbl->HrGetFileLeaf(this, wzBuf, pcchBuf) )
  456. #define IMsoUrl_HrGetFileName(this, wzBuf, pcchBuf) \
  457. ( (this)->lpVtbl->HrGetFileName(this, wzBuf, pcchBuf) )
  458. #define IMsoUrl_HrGetFileExt(this, wzBuf, pcchBuf) \
  459. ( (this)->lpVtbl->HrGetFileExt(this, wzBuf, pcchBuf) )
  460. #define IMsoUrl_HrGetQuery(this, wzBuf, pcchBuf) \
  461. ( (this)->lpVtbl->HrGetQuery(this, wzBuf, pcchBuf) )
  462. #define IMsoUrl_HrGetFragment(this, wzBuf, pcchBuf) \
  463. ( (this)->lpVtbl->HrGetFragment(this, wzBuf, pcchBuf) )
  464. #define IMsoUrl_RgwchScheme(this, pcch) \
  465. ( (this)->lpVtbl->RgwchScheme(this, pcch) )
  466. #define IMsoUrl_RgwchAuthority(this, pcch) \
  467. ( (this)->lpVtbl->RgwchAuthority(this, pcch) )
  468. #define IMsoUrl_RgwchUserName(this, pcch) \
  469. ( (this)->lpVtbl->RgwchUserName(this, pcch) )
  470. #define IMsoUrl_RgwchPassword(this, pcch) \
  471. ( (this)->lpVtbl->RgwchPassword(this, pcch) )
  472. #define IMsoUrl_RgwchServer(this, pcch) \
  473. ( (this)->lpVtbl->RgwchServer(this, pcch) )
  474. #define IMsoUrl_RgwchPort(this, pcch) \
  475. ( (this)->lpVtbl->RgwchPort(this, pcch) )
  476. #define IMsoUrl_RgwchPath(this, pcch) \
  477. ( (this)->lpVtbl->RgwchPath(this, pcch) )
  478. #define IMsoUrl_RgwchFileLeaf(this, pcch) \
  479. ( (this)->lpVtbl->RgwchFileLeaf(this, pcch) )
  480. #define IMsoUrl_RgwchFileExt(this, pcch) \
  481. ( (this)->lpVtbl->RgwchFileExt(this, pcch) )
  482. #define IMsoUrl_RgwchQuery(this, pcch) \
  483. ( (this)->lpVtbl->RgwchQuery(this, pcch) )
  484. #define IMsoUrl_RgwchFragment(this, pcch) \
  485. ( (this)->lpVtbl->RgwchFragment(this, pcch) )
  486. #define IMsoUrl_FIsHttp(this) \
  487. ( (this)->lpVtbl->FIsHttp(this) )
  488. #define IMsoUrl_FIsFtp(this) \
  489. ( (this)->lpVtbl->FIsFtp(this) )
  490. #define IMsoUrl_FIsLocal(this) \
  491. ( (this)->lpVtbl->FIsLocal(this) )
  492. #define IMsoUrl_FIsUNC(this) \
  493. ( (this)->lpVtbl->FIsUNC(this) )
  494. #define IMsoUrl_FIsODMA(this) \
  495. ( (this)->lpVtbl->FIsODMA(this) )
  496. #define IMsoUrl_HrGetLocalPath(this, wzBuf, pcchBuf) \
  497. ( (this)->lpVtbl->HrGetLocalPath(this, wzBuf, pcchBuf) )
  498. #define IMsoUrl_WzLocalPath(this) \
  499. ( (this)->lpVtbl->WzLocalPath(this) )
  500. #define IMsoUrl_CchLocalPath(this) \
  501. ( (this)->lpVtbl->CchLocalPath(this) )
  502. #define IMsoUrl_FIsEqual(this, piurl) \
  503. ( (this)->lpVtbl->FIsEqual(this, piurl) )
  504. #define IMsoUrl_FComponentsAreEqual(this, grfurlc, piurl) \
  505. ( (this)->lpVtbl->FComponentsAreEqual(this, grfurlc, piurl) )
  506. #define IMsoUrl_FSubsumes(this, piurl) \
  507. ( (this)->lpVtbl->FSubsumes(this, piurl) )
  508. #define IMsoUrl_UrlrGetRelativity(this) \
  509. ( (this)->lpVtbl->UrlrGetRelativity(this) )
  510. #define IMsoUrl_HrSetRelativity(this, urlr) \
  511. ( (this)->lpVtbl->HrSetRelativity(this, urlr) )
  512. #define IMsoUrl_HrResolve(this, ppiurlAbsolute) \
  513. ( (this)->lpVtbl->HrResolve(this, ppiurlAbsolute) )
  514. #define IMsoUrl_HrRebase(this, piurlBase) \
  515. ( (this)->lpVtbl->HrRebase(this, piurlBase) )
  516. #define IMsoUrl_HrDownload(this, wzBuf, pcchBuf, grfurld) \
  517. ( (this)->lpVtbl->HrDownload(this, wzBuf, pcchBuf, grfurld) )
  518. #define IMsoUrl_HrUpload(this, wzFile, grfurlu) \
  519. ( (this)->lpVtbl->HrUpload(this, wzFile, grfurlu) )
  520. #define IMsoUrl_HrDelete(this) \
  521. ( (this)->lpVtbl->HrDelete(this) )
  522. #define IMsoUrl_FExists(this, grfurle) \
  523. ( (this)->lpVtbl->FExists(this, grfurle) )
  524. #define IMsoUrl_HrGetBase(this, ppiurlBase) \
  525. ( (this)->lpVtbl->HrGetBase(this, ppiurlBase) )
  526. #define IMsoUrl_FIsMhtml(this) \
  527. ( (this)->lpVtbl->FIsMhtml(this) )
  528. #define IMsoUrl_WzMhtmlBodypart(this) \
  529. ( (this)->lpVtbl->WzMhtmlBodypart(this) )
  530. #define IMsoUrl_CchMhtmlBodypart(this) \
  531. ( (this)->lpVtbl->CchMhtmlBodypart(this) )
  532. #endif // __cplusplus
  533. // Url Creation APIs
  534. //
  535. // MsoHrCreateUrl - creates an unset url in ppiurl.
  536. // MsoHrCreateUrlFromUser - same as calling MsoHrCreateUrl
  537. // followed by IMsoUrl::HrSetFromUser.
  538. // MsoHrCreateUrlFromUserRgwch - same as calling MsoHrCreateUrl
  539. // followed by IMsoUrl::HrSetFromUserRgwch.
  540. // MsoHrCreateUrlFromCanonicalUrl - same as calling MsoHrCreateUrl
  541. // followed by IMsoUrl::HrSetFromCanonicalUrl.
  542. // MsoHrCloneUrl - creates a new copy of the given url
  543. MSOAPI_(HRESULT) MsoHrCreateUrl(interface IMsoUrl **ppiurl);
  544. MSOAPI_(HRESULT) MsoHrCreateUrlFromUser(interface IMsoUrl **ppiurl,
  545. const WCHAR *wzUrl, DWORD cp, const IMsoUrl *piurlBase, DWORD grfurl);
  546. MSOAPI_(HRESULT) MsoHrCreateUrlFromUserRgwch(interface IMsoUrl **ppiurl,
  547. const WCHAR *wzUrl, int cchUrl, DWORD cp, const IMsoUrl *piurlBase, DWORD grfurl);
  548. MSOAPIX_(HRESULT) MsoHrCreateUrlFromCanonicalUrl(interface IMsoUrl **ppiurl,
  549. const WCHAR *wzUrl, DWORD cp, const IMsoUrl *piurlBase);
  550. MSOAPI_(HRESULT) MsoHrCloneUrl(interface IMsoUrl **ppiurl, const IMsoUrl *piurl);
  551. // Some useful path manipulation APIs
  552. //
  553. // MsoFIsPathSep - returns TRUE iff the character is a recognized path separator
  554. // MsoRgwchPathSepIndex - returns a ptr to the first path sep character
  555. // MsoRgwchPathSepIndexRight - returns a ptr to the last path sep character
  556. __inline MsoFIsPathSep(WCHAR wch) { return wch == L'/' || wch == L'\\'; };
  557. MSOAPIX_(WCHAR*) MsoRgwchPathSepIndex(const WCHAR *rgwch, int cch);
  558. MSOAPI_(WCHAR*) MsoRgwchPathSepIndexRight(const WCHAR *rgwch, int cch);
  559. MSOAPIX_(BOOL) MsoFWzIsResUrl(const WCHAR *wzURL);
  560. // Path buffer constants
  561. #define MSO_MAX_PATH INTERNET_MAX_URL_LENGTH
  562. #define MSO_CB_MAX_PATH (MSO_MAX_PATH*sizeof(WCHAR))
  563. #define MSO_MAX_URL_PATH INTERNET_MAX_URL_LENGTH
  564. #define MSO_CB_MAX_URL_PATH (MSO_MAX_URL_PATH*sizeof(WCHAR))
  565. #define MSO_MAX_LOCAL_PATH MAX_PATH
  566. #define MSO_CB_MAX_LOCAL_PATH (MSO_MAX_LOCAL_PATH*sizeof(WCHAR))
  567. //////////////////////////////////////////////////////////////////////////
  568. //
  569. // OPEN ISSUES:
  570. //
  571. // 1. We don't handle default ports in the equivalence comparison.
  572. // 2. We don't handle "http://server.com" & "http://www.server.com"
  573. // equivalence correctly.
  574. //
  575. //////////////////////////////////////////////////////////////////////////
  576. #endif // MSOURL_H