Add -lole32 to link libraries.
This fixes a problem when compiling with mingw-headers version 3.3
where the use of SHGetFolderPath() expands to a call to CoTaskMemFree()
which is defined in libole32.dll:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/shobjidl.h:29954: undefined reference to `__imp_CoTaskMemFree'
2 * Copyright (C) 2014 J. Ali Harlow <ali@juiblex.co.uk>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 int is_ascii_letter(char c)
31 return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
36 return c == '/' || c == '\\';
39 const char *mswin_path(const char *path)
44 if (path[0] == '/' && is_ascii_letter(path[1]) && path[2] == ':' &&
51 int path_cmp(const char *p1, const char *p2)
55 if (*p1 == *p2 || is_slash(*p1) && is_slash(*p2)) {
64 return strcmp(p1, p2);
68 int test_pfu(const char *url, const char *path)
73 s = razor_path_from_url(url);
76 path = mswin_path(path);
80 r = path_cmp(s, path);
85 fprintf(stderr, "Fail: razor_path_from_url(\"%s\")", url);
87 fprintf(stderr, " returns \"%s\", expected", s);
89 fprintf(stderr, " returns NULL, expected");
91 fprintf(stderr, " \"%s\"\n", path);
93 fprintf(stderr, " NULL\n");
104 void cleanup_on_exit(void)
106 SetConsoleOutputCP(saved_cp);
110 int main(int argc, char *argv[])
115 atexit(cleanup_on_exit);
116 saved_cp = GetConsoleOutputCP();
117 SetConsoleOutputCP(CP_UTF8);
120 r |= test_pfu("file://localhost/etc/fstab", "/etc/fstab");
121 r |= test_pfu("file:///etc/fstab", "/etc/fstab");
122 r |= test_pfu("file://localhost/c:/WINDOWS/clock.avi",
123 "/c:/WINDOWS/clock.avi");
124 r |= test_pfu("file:///c:/WINDOWS/clock.avi",
125 "/c:/WINDOWS/clock.avi");
126 r |= test_pfu("file:///path/to/the%20file.txt",
127 "/path/to/the file.txt");
128 r |= test_pfu("file:///home/s%C3%A9bastien", "/home/sébastien");
129 r |= test_pfu("file:///home/luk%C3%A1%C5%A1", "/home/lukáš");
130 r |= test_pfu("file:///var/log/22%20%e0%b8%aa%e0%b8%b4%e0%b8%87%e0%b8%ab%e0%b8%b2%e0%b8%84%e0%b8%a1%202014",
131 "/var/log/22 สิงหาคม 2014");