Ignore:
Timestamp:
Feb 6, 2002, 9:18:30 PM (24 years ago)
Author:
sandervl
Message:

Wine resync

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shlwapi/url_odin.cpp

    r6615 r7820  
    1 /* $Id: url_odin.cpp,v 1.3 2001-08-31 19:56:34 phaller Exp $ */
     1/* $Id: url_odin.cpp,v 1.4 2002-02-06 20:18:30 sandervl Exp $ */
    22
    33/*
     
    4141
    4242ODINDEBUGCHANNEL(SHLWAPI-URL)
    43 
    44 
    45 /*****************************************************************************
    46  * Defines                                                                   *
    47  *****************************************************************************/
    48 
    49 
    50 typedef struct tagURLSCHEME
    51 {
    52   LPSTR pszName;       /* such as http://                    */
    53   BOOL  flagOpaque;    /* has a double-slash '//             */
    54   BOOL  flagNoHistory; /* usually not in history of browsers */
    55   DWORD dwType;        /* URL type                           */
    56 
    57 } URLSCHEME, *PURLSCHEME;
    58 
    59 
    60 typedef enum tagURLIS
    61 {
    62   URLIS_APPLIABLE,   /* Attempt to determine a valid scheme for the URL. */
    63   URLIS_DIRECTORY,   /* Does the URL string end with a directory?        */
    64   URLIS_FILEURL,     /* Is the URL a file URL?                           */
    65   URLIS_HASQUERY,    /* Does the URL have an appended query string?      */
    66   URLIS_NOHISTORY,   /* Is the URL a "No History" URL?                   */
    67   URLIS_OPAQUE,      /* Is the URL opaque?                               */
    68   URLIS_URL          /* Is the URL valid?                                */
    69 } URLIS;
    70 
    71 
    72 static URLSCHEME arrUrlSchemes[] =
    73 { /* scheme     opaque hist   type */
    74   {"http://",   FALSE, FALSE, 0},
    75   {"https://",  FALSE, FALSE, 0},
    76   {"shttp://",  FALSE, FALSE, 0},
    77   {"file://",   FALSE, FALSE, 0},
    78   {"ftp://",    FALSE, FALSE, 0},
    79   {"telnet://", FALSE, TRUE,  0},
    80   {"news://",   FALSE, TRUE,  0},
    81   {"snews://",  FALSE, TRUE,  0},
    82   {"mailto:",   TRUE,  TRUE,  0},
    83   {"gopher://", FALSE, FALSE, 0},
    84   {"wais://",   FALSE, FALSE, 0},
    85 };
    86 
    87 
    88 
    89 
    90 /*****************************************************************************
    91  * Name      : UrlApplyScheme
    92  * Purpose   : Takes a URL string, determines a scheme for it, and returns a
    93  *             string with an appropriate prefix.
    94  * Parameters: pszIn   [in]     A NULL-terminated URL string.
    95  *             pszOut  [out]    A buffer to receive a NULL-terminated string,
    96  *                              set to the URL specified by pszIn, converted
    97  *                              to the standard scheme://URL_string format.
    98  *             pcchOut [in/out] Address of a value set to the number of
    99  *                              characters in the pszOut buffer. When the
    100  *                              function returns, the value depends on whether
    101  *                              the function is successful or returns
    102  *                              E_POINTER. For other return values, the value
    103  *                              of this parameter is meaningless.
    104  *             dwFlags [in]     Flags that specify how to determine the
    105  *                              scheme. The following flags can be combined.
    106  *                              URL_APPLY_DEFAULT
    107  *                                Apply the default scheme if UrlApplyScheme
    108  *                                can't determine one. The default prefix is
    109  *                                stored in the registry but is typically "http".
    110  *                              URL_APPLY_GUESSSCHEME
    111  *                                Attempt to determine the scheme by examining
    112  *                                pszIn.
    113  *                              URL_APPLY_GUESSFILE
    114  *                                Attempt to determine a file URL from pszIn.
    115  *                              URL_APPLY_FORCEAPPLY
    116  *                                Force UrlApplyScheme to determine a scheme
    117  *                                for pszIn.
    118  * Variables :
    119  * Result    : S_OK      A scheme was determined. pszOut points to a string
    120  *                       containing the URL with the scheme's prefix. The value
    121  *                       of pcchOut is set to the number of characters in the
    122  *                       string, not counting the terminating NULL character.
    123  *             S_FALSE   There were no errors, but no prefix was prepended.
    124  *             E_POINTER The buffer was too small. The value of pcchOut is
    125  *                       set to the minimum number of characters that the
    126  *                       buffer must be able to contain, including the
    127  *                       terminating NULL character.
    128  *             Other errors - A standard OLE error value is returned.
    129  * Remark    : If the URL has a valid scheme, the string will not be modified.
    130  *             However, almost any combination of two or more characters
    131  *             followed by a colon will be parsed as a scheme. Valid
    132  *             characters include some common punctuation marks, such as ".".
    133  *             If your input string fits this description, UrlApplyScheme may
    134  *             treat it as valid and not apply a scheme. To force the function
    135  *             to apply a scheme to a URL, set the URL_APPLY_FORCEAPPLY and
    136  *             URL_APPLY_DEFAULT flags in dwFlags. This combination of flags
    137  *             forces the function to apply a scheme to the URL. Typically,
    138  *             the function will not be able to determine a valid scheme. The
    139  *             second flag guarantees that, if no valid scheme can be
    140  *             determined, the function will apply the default scheme to the URL.
    141  * Status    : PARTIALLY IMPLEMENTED UNTESTED
    142  *
    143  * Author    : Patrick Haller [Thu, 2000/04/20 19:46]
    144  *****************************************************************************/
    145 
    146 ODINFUNCTION4(HRESULT, UrlApplySchemeA,
    147               LPCSTR,  pszIn,
    148               LPSTR,   pszOut,
    149               LPDWORD, pcchOut,
    150               DWORD,   dwFlags)
    151 {
    152   dprintf(("not implemented correctly (In=%s).",
    153           pszIn));
    154 
    155   strncpy(pszOut,
    156           pszIn,
    157           *pcchOut);
    158   *pcchOut = lstrlenA(pszIn);
    159 
    160   return S_OK;
    161 }
    162 
    163 
    164 /*****************************************************************************
    165  * Name      : UrlCombine
    166  * Purpose   : Takes a relative URL and its base and returns a URL in canonical form.
    167  * Parameters: pszBase     [in]  Pointer to a string with the base URL.
    168  *             pszRelative [in]  Pointer to a string with the relative URL.
    169  *             pszCombined [out] Pointer to a buffer to receive a
    170  *                               NULL-terminated string containing the combined URL.
    171  *             pcchCombined [in/out] Pointer to a value set to the number of
    172  *                               characters in the pszCombined buffer. When the
    173  *                               function returns, the value depends on whether
    174  *                               the function is successful or returns E_POINTER.
    175  *                               For other return values, the value of this
    176  *                               parameter is meaningless.
    177  *             dwFlags     [in]  Flags that specify how the URL will be converted
    178  *                               to canonical form. The following flags can be combined.
    179  *                               URL_DONT_SIMPLIFY
    180  *                                 Treat '/./' and '/../' in a URL string as literal
    181  *                                 characters, not as shorthand for
    182  *                                 navigation. See Remarks for further discussion.
    183  *                               URL_ESCAPE_PERCENT
    184  *                                 Convert any occurrence of '%' to its escape sequence.
    185  *                               URL_ESCAPE_SPACES_ONLY
    186  *                                 Replace only spaces with escape sequences. This flag
    187  *                                 takes precedence over
    188  *                                 URL_ESCAPE_UNSAFE, but does not apply to opaque URLs.
    189  *                               URL_ESCAPE_UNSAFE
    190  *                                 Replace unsafe values with their escape sequences.
    191  *                                 This flag applies to all URLs,
    192  *                                 including opaque URLs.
    193  *                               URL_PLUGGABLE_PROTOCOL
    194  *                                 Combine URLs with client-defined pluggable protocols,
    195  *                                 according to the W3C specification. This flag does not
    196  *                                 apply to standard protocols such as ftp, http,
    197  *                                 gopher, and so on. If this flag is set,
    198  *                                 UrlCombine will not simplify URLs, so there is
    199  *                                 no need to also set URL_DONT_SIMPLIFY.
    200  *                               URL_UNESCAPE
    201  *                                 Unescape any escape sequences that the URLs contain,
    202  *                                 with two exceptions. The escape sequences
    203  *                                 for '?' and '#' will not be unescaped.
    204  *                                 If one of the URL_ESCAPE_XXX flags is also
    205  *                                 set, the two URLs will unescaped, then
    206  *                                 combined, then escaped.
    207  * Variables :
    208  * Result    : S_OK      pszCombined points to a string containing the
    209  *                       combined URLs. The value of pcchCombined is set to
    210  *                       the number of characters in the string, not counting
    211  *                       the terminating NULL character.
    212  *             E_POINTER The buffer was too small. The value of pcchCombined
    213  *                       is set to the minimum number of characters that the
    214  *                       buffer must be able to contain, including the
    215  *                       terminating NULL character.
    216  *             Other errors A standard OLE error value is returned.
    217  * Remark    : SHLWAPI.
    218  * Status    : STUB UNTESTED
    219  *
    220  * Author    : Patrick Haller [Tue, 2000/04/25 02:02]
    221  *****************************************************************************/
    222 
    223 ODINFUNCTION5(HRESULT,UrlCombineA,
    224               LPCSTR, pszBase,
    225               LPCSTR, pszRelative,
    226               LPSTR,  pszCombined,
    227               LPDWORD,pcchCombined,
    228               DWORD,  dwFlags)
    229 {
    230   dprintf(("not implemented."));
    231 
    232   return S_OK;
    233 }
    234 
    235 
    236 /**
    237  * @status      stub
    238  */
    239 ODINFUNCTION5(HRESULT, UrlCombineW,
    240               LPCWSTR, pszBase,
    241               LPCWSTR, pszRelative,
    242               LPWSTR,  pszCombined,
    243               LPDWORD, pcchCombined,
    244               DWORD,   dwFlags)
    245 {
    246   dprintf(("not implemented."));
    247 
    248   return S_OK;
    249 }
    250 
    251 
    252 /*****************************************************************************
    253  * Name      : UrlCompare
    254  * Purpose   : Does a case-sensitive comparison of two URL strings.
    255  * Parameters: pszURL1      [in] NULL-terminated string with the first URL.
    256  *             pszURL2      [in] NULL-terminated string with the second URL.
    257  *             fIgnoreSlash [in] Value that is set to TRUE to have UrlCompare
    258  *                               ignore a trailing '/' character on either or
    259  *                               both URLs.
    260  * Variables :
    261  * Result    : Returns zero if the two strings are equal, apart from a
    262  *             trailing '\' character if fIgnoreSlash is set to TRUE.
    263  *             Returns a negative integer if the string pointed to by pszURL1
    264  *             is less than the string pointed to by pszURL2. Otherwise, it
    265  *             returns a positive integer.
    266  * Remark    : SHLWAPI.
    267  *             For the best results, you should first canonicalize the URLs
    268  *             with UrlCanonicalize. Then, compare the canonicalized URLs with
    269  *             UrlCompare.
    270  * Status    : PARTIALLY IMPLEMENTED UNTESTED
    271  *
    272  * Author    : Patrick Haller [Tue, 2000/04/25 02:02]
    273  *****************************************************************************/
    274 
    275 ODINFUNCTION3(int,    UrlCompareA,
    276               LPCSTR, pszURL1,
    277               LPCSTR, pszURL2,
    278               BOOL,   fIgnoreSlash)
    279 {
    280   dprintf(("not correctly implemented."));
    281 
    282   return strcmp(pszURL1,
    283                 pszURL2);
    284 }
    285 
    286 /**
    287  * @status      stub
    288  */
    289 ODINFUNCTION3(int,     UrlCompareW,
    290               LPCWSTR, pszURL1,
    291               LPCWSTR, pszURL2,
    292               BOOL,    fIgnoreSlash)
    293 {
    294   dprintf(("not correctly implemented."));
    295 
    296   return wcscmp((const wchar_t *)pszURL1,
    297                 (const wchar_t *)pszURL2);
    298 }
    29943
    30044
     
    34589
    34690
    347 /*****************************************************************************
    348  * Name      : UrlGetLocation
    349  * Purpose   : Retrieves the location from a URL.
    350  * Parameters: pszURL [in] Pointer to a NULL-terminated string that contains
    351  *             the location.
    352  * Variables :
    353  * Result    : Returns a pointer to a NULL-terminated string with the
    354  *             location, or NULL otherwise.
    355  * Remark    : SHLWAPI.
    356  *             The location is the segment of the URL starting with a ? or #
    357  *             character. If a file URL has a query string, the returned
    358  *             string includes the query string.
    359  * Status    : STUB UNTESTED
    360  *
    361  * Author    : Patrick Haller [Tue, 2000/04/25 02:02]
    362  *****************************************************************************/
    363 
    364 ODINFUNCTION1(LPCSTR, UrlGetLocationA,
    365               LPCSTR, pszURL)
    366 {
    367   dprintf(("not implemented."));
    368 
    369   return pszURL;
    370 }
    371 
    372 
    373 /**
    374  * @status      stub
    375  */
    376 ODINFUNCTION1(LPCWSTR, UrlGetLocationW,
    377               LPCWSTR, pszURL)
    378 {
    379   dprintf(("not implemented."));
    380 
    381   return pszURL;
    382 }
    383 
    384 
    385 /*****************************************************************************
    386  * Name      : UrlGetPart
    387  * Purpose   : Takes a URL string and returns a specified part.
    388  * Parameters: pszIn   [in]     NULL-terminated string that contains the URL.
    389  *             pszOut  [out]    A buffer that will receive a NULL-terminated
    390  *                              string with the specified part.
    391  *             pcchOut [in/out] Address of a value set to the number of
    392  *                              characters in the pszOut buffer. When the
    393  *                              function returns, the value depends on whether
    394  *                              the function is successful or returns E_POINTER.
    395  *                              For other return values, the value of this
    396  *                              parameter is meaningless.
    397  *             dwPart  [in]     Flags that specify which part of the URL to retrieve.
    398  *                              It can have one of the following values.
    399  *               Flag                Description
    400  *               URL_PART_HOSTNAME   The host name.
    401  *               URL_PART_PASSWORD   The password.
    402  *               URL_PART_PORT       The port number.
    403  *               URL_PART_QUERY      The query portion of the URL.
    404  *               URL_PART_SCHEME     The URL scheme.
    405  *               URL_PART_USERNAME   The username.
    406  *
    407  *             dwFlags [in]     Flag that can be set to keep the URL scheme,
    408  *                              in addition to the part that is specified by dwPart.
    409  *               Flag                    Description
    410  *               URL_PARTFLAG_KEEPSCHEME Keep the URL scheme.
    411  * Variables :
    412  * Result    :
    413  * Remark    : SHLWAPI.
    414  *             Returns an OLE success code if successful. The value pointed to
    415  *             by pcchOut will be set to the number of characters written to
    416  *             the output buffer, excluding the terminating NULL. If the buffer
    417  *             was too small, E_POINTER is returned, and the value pointed to
    418  *             by pcchOut will be set to the minimum number of characters that
    419  *             the buffer must be able to contain, including the terminating
    420  *             NULL character. Otherwise, an OLE error value is returned.
    421  * Status    : STUB UNTESTED
    422  *
    423  * Author    : Patrick Haller [Tue, 2000/04/25 02:02]
    424  *****************************************************************************/
    425 
    426 ODINFUNCTION5(HRESULT, UrlGetPartA,
    427               LPCSTR,  pszIn,
    428               LPSTR,   pszOut,
    429               LPDWORD, pcchOut,
    430               DWORD,   dwPart,
    431               DWORD,   dwFlags)
    432 {
    433   dprintf(("not implemented."));
    434 
    435   return S_OK;
    436 }
    437 
    438 
    439 /**
    440  * @status      stub
    441  */
    442 ODINFUNCTION5(HRESULT, UrlGetPartW,
    443               LPCWSTR, pszIn,
    444               LPWSTR,  pszOut,
    445               LPDWORD, pcchOut,
    446               DWORD,   dwPart,
    447               DWORD,   dwFlags)
    448 {
    449   dprintf(("not implemented."));
    450 
    451   return S_OK;
    452 }
    45391
    45492
     
    469107
    470108
    471 /*****************************************************************************
    472  * Name      : UrlIs
    473  * Purpose   : Tests whether or not a URL is a specified type.
    474  * Parameters: pszUrl [in] Pointer to a string containing the URL.
    475  *             UrlIs  [in] Type of URL to be tested for.
    476  *                         UrlIs can take one of the following values:
    477  *               URLIS_APPLIABLE Attempt to determine a valid scheme for the URL.
    478  *               URLIS_DIRECTORY Does the URL string end with a directory?
    479  *               URLIS_FILEURL   Is the URL a file URL?
    480  *               URLIS_HASQUERY  Does the URL have an appended query string?
    481  *               URLIS_NOHISTORY Is the URL a "No History" URL?
    482  *               URLIS_OPAQUE    Is the URL opaque?
    483  *               URLIS_URL       Is the URL valid?
    484  * Variables :
    485  * Result    : For all but one of the URL types, UrlIs returns TRUE if the URL
    486  *             is the specified type, or FALSE if not. If UrlIs is set to
    487  *             URLIS_APPLIABLE, UrlIs will attempt to determine the URL scheme.
    488  *             If the function is able to determine a scheme, it returns TRUE,
    489  *             or FALSE otherwise.
    490  * Remark    : SHLWAPI.
    491  * Status    : STUB UNTESTED
    492  *
    493  * Author    : Patrick Haller [Tue, 2000/04/25 02:02]
    494  *****************************************************************************/
    495 
    496 ODINFUNCTION2(BOOL,   UrlIsA,
    497               LPCSTR, pszUrl,
    498               URLIS,  UrlIs)
    499 {
    500   dprintf(("not implemented."));
    501 
    502   return TRUE;
    503 }
    504 
    505 
    506 /**
    507  * @status      stub
    508  */
    509 ODINFUNCTION2(BOOL,    UrlIsW,
    510               LPCWSTR, pszUrl,
    511               URLIS,   UrlIs)
    512 {
    513   dprintf(("not implemented."));
    514 
    515   return TRUE;
    516 }
    517 
    518 /*****************************************************************************
    519  * Name      : UrlIsNoHistory
    520  * Purpose   : Returns whether or not a URL is a No History URL.
    521  * Parameters: pszURL [in] NULL-terminated string with the URL.
    522  * Variables :
    523  * Result    : Returns a non-zero value if the URL is a No History URL, or zero otherwise.
    524  * Remark    : SHLWAPI.
    525  *             A No History URL is a URL that browsers typically do not
    526  *             include in their navigation history.
    527  * Status    : STUB UNTESTED
    528  *
    529  * Author    : Patrick Haller [Tue, 2000/04/25 02:02]
    530  *****************************************************************************/
    531 
    532 ODINFUNCTION1(BOOL,  UrlIsNoHistoryA,
    533               LPCSTR,pszURL)
    534 {
    535   return UrlIsA(pszURL, URLIS_NOHISTORY);
    536 }
    537 
    538 
    539 /**
    540  * @status      stub
    541  */
    542 ODINFUNCTION1(BOOL,   UrlIsNoHistoryW,
    543               LPCWSTR,pszURL)
    544 {
    545   return UrlIsW(pszURL, URLIS_NOHISTORY);
    546 }
    547 
    548 
    549 /*****************************************************************************
    550  * Name      : UrlIsOpaque
    551  * Purpose   : Returns whether a URL is opaque.
    552  * Parameters: pszURL [in] NULL-terminated string with the URL.
    553  * Variables :
    554  * Result    : Returns a non-zero value if the URL is opaque, or zero
    555  *             otherwise.
    556  * Remark    : SHLWAPI.
    557  *             A URL that has a scheme that is not followed by two slashes (//)
    558  *             is opaque. For example, mailto:xyz@somecompany.com is an opaque
    559  *             URL. Opaque URLs cannot be separated into the standard
    560  *             URL heirarchy.
    561  * Status    : STUB UNTESTED
    562  *
    563  * Author    : Patrick Haller [Tue, 2000/04/25 02:02]
    564  *****************************************************************************/
    565 
    566 ODINFUNCTION1(BOOL,   UrlIsOpaqueA,
    567               LPCSTR, pszURL)
    568 {
    569   return UrlIsA(pszURL, URLIS_OPAQUE);
    570 }
    571 
    572 
    573 /**
    574  * @status      stub
    575  */
    576 ODINFUNCTION1(BOOL,   UrlIsOpaqueW,
    577               LPCWSTR,pszURL)
    578 {
    579   return UrlIsW(pszURL, URLIS_OPAQUE);
    580 }
    581 
    582 
Note: See TracChangeset for help on using the changeset viewer.