summaryrefslogtreecommitdiff
path: root/src/palrt/shlwapip.h
blob: bc449c5054296e81e152e08990989a9208178918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//

//
// ===========================================================================
// File: shlwapi.h
//
// Header for ported shlwapi stuff
// ===========================================================================

#ifndef SHLWAPIP_H_INCLUDED
#define SHLWAPIP_H_INCLUDED

#define ARRAYSIZE(x)    (sizeof(x)/sizeof(x[0]))
#define SIZECHARS(sz)   (sizeof(sz)/sizeof(sz[0]))

#define SIZEOF(x)       sizeof(x)
#define PRIVATE
#define PUBLIC
#ifndef ASSERT
#define ASSERT          _ASSERTE
#endif
#define AssertMsg(f,m)  _ASSERTE(f)
#define RIP(f)          _ASSERTE(f)
#define RIPMSG(f,m)     _ASSERTE(f)

#define IsFlagSet(obj, f)           (BOOL)(((obj) & (f)) == (f))
#define IsFlagClear(obj, f)         (BOOL)(((obj) & (f)) != (f))

#define InRange(id, idFirst, idLast)      ((UINT)((id)-(idFirst)) <= (UINT)((idLast)-(idFirst)))

#define CbFromCch(cch)              ((cch)*sizeof(TCHAR))

#define IS_VALID_READ_BUFFER(p, t, n)   (p != NULL)
#define IS_VALID_WRITE_BUFFER(p, t, n)  (p != NULL)

#define IS_VALID_READ_PTR(p, t)         IS_VALID_READ_BUFFER(p, t, 1)
#define IS_VALID_WRITE_PTR(p, t)        IS_VALID_WRITE_BUFFER(p, t, 1)

#define IS_VALID_STRING_PTR(p, c)       (p != NULL)
#define IS_VALID_STRING_PTRW(p, c)      (p != NULL)

#define CharLowerW  _wcslwr

inline int StrCmpNCW(LPCWSTR pch1, LPCWSTR pch2, int n)
{
    if (n == 0)
        return 0;

    while (--n && *pch1 && *pch1 == *pch2)
    {
        pch1++;
        pch2++;
    }

    return *pch1 - *pch2;
}

typedef struct tagPARSEDURLW {
    DWORD     cbSize;
    // Pointers into the buffer that was provided to ParseURL
    LPCWSTR   pszProtocol;
    UINT      cchProtocol;
    LPCWSTR   pszSuffix;
    UINT      cchSuffix;
    UINT      nScheme;            // One of URL_SCHEME_*
    } PARSEDURLW, * PPARSEDURLW;

typedef enum {
    URL_SCHEME_INVALID     = -1,
    URL_SCHEME_UNKNOWN     =  0,
    URL_SCHEME_FTP = 1,
    URL_SCHEME_HTTP = 2,
    URL_SCHEME_FILE = 9,
    URL_SCHEME_HTTPS = 11,
} URL_SCHEME;

#define URL_ESCAPE_UNSAFE               0x20000000
#define URL_DONT_ESCAPE_EXTRA_INFO      0x02000000
#define URL_ESCAPE_SPACES_ONLY          0x04000000
#define URL_DONT_SIMPLIFY               0x08000000
#define URL_UNESCAPE_INPLACE            0x00100000
#define URL_ESCAPE_PERCENT              0x00001000
#define URL_ESCAPE_SEGMENT_ONLY         0x00002000  // Treat the entire URL param as one URL segment.

#endif  // ! SHLWAPIP_H_INCLUDED