wininet: Fix potential buffer overrun in HttpQueryInfoA.
[wine.git] / dlls / gdi32 / icm.c
blob860a6f254439aeab36c16a2be9db6e03c789ae5d
1 /*
2 * Image Color Management
4 * Copyright 2004 Marcus Meissner
5 * Copyright 2008 Hans Leidekker
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
24 #include <stdarg.h>
25 #include <string.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winnls.h"
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(icm);
38 /***********************************************************************
39 * EnumICMProfilesA (GDI32.@)
41 INT WINAPI EnumICMProfilesA(HDC hdc, ICMENUMPROCA func, LPARAM lparam)
43 FIXME("%p, %p, 0x%08lx stub\n", hdc, func, lparam);
44 return -1;
47 /***********************************************************************
48 * EnumICMProfilesW (GDI32.@)
50 INT WINAPI EnumICMProfilesW(HDC hdc, ICMENUMPROCW func, LPARAM lparam)
52 FIXME("%p, %p, 0x%08lx stub\n", hdc, func, lparam);
53 return -1;
56 /**********************************************************************
57 * GetICMProfileA (GDI32.@)
59 * Returns the filename of the specified device context's color
60 * management profile, even if color management is not enabled
61 * for that DC.
63 * RETURNS
64 * TRUE if filename is copied successfully.
65 * FALSE if the buffer length pointed to by size is too small.
67 * FIXME
68 * How does Windows assign these? Some registry key?
70 BOOL WINAPI GetICMProfileA(HDC hdc, LPDWORD size, LPSTR filename)
72 WCHAR filenameW[MAX_PATH];
73 DWORD buflen = MAX_PATH;
74 BOOL ret = FALSE;
76 TRACE("%p, %p, %p\n", hdc, size, filename);
78 if (!hdc || !size || !filename) return FALSE;
80 if (GetICMProfileW(hdc, &buflen, filenameW))
82 int len = WideCharToMultiByte(CP_ACP, 0, filenameW, -1, NULL, 0, NULL, NULL);
83 if (*size >= len)
85 WideCharToMultiByte(CP_ACP, 0, filenameW, -1, filename, *size, NULL, NULL);
86 ret = TRUE;
88 else SetLastError(ERROR_INSUFFICIENT_BUFFER);
89 *size = len;
91 return ret;
94 /**********************************************************************
95 * GetICMProfileW (GDI32.@)
97 BOOL WINAPI GetICMProfileW(HDC hdc, LPDWORD size, LPWSTR filename)
99 DWORD required;
100 WCHAR systemdir[MAX_PATH];
101 static const WCHAR profile[] =
102 {'\\','s','p','o','o','l','\\','d','r','i','v','e','r','s',
103 '\\','c','o','l','o','r','\\','s','R','G','B',' ','C','o','l','o','r',' ',
104 'S','p','a','c','e',' ','P','r','o','f','i','l','e','.','i','c','m',0};
106 TRACE("%p, %p, %p\n", hdc, size, filename);
108 if (!hdc || !size) return FALSE;
110 required = GetSystemDirectoryW(systemdir, MAX_PATH);
111 required += sizeof(profile) / sizeof(WCHAR);
113 if (*size < required)
115 *size = required;
116 SetLastError(ERROR_INSUFFICIENT_BUFFER);
117 return FALSE;
119 if (filename)
121 strcpyW(filename, systemdir);
122 strcatW(filename, profile);
124 if (GetFileAttributesW(filename) == INVALID_FILE_ATTRIBUTES)
125 WARN("color profile not found\n");
127 *size = required;
128 return TRUE;
131 /**********************************************************************
132 * GetLogColorSpaceA (GDI32.@)
134 BOOL WINAPI GetLogColorSpaceA(HCOLORSPACE colorspace, LPLOGCOLORSPACEA buffer, DWORD size)
136 FIXME("%p %p 0x%08x stub\n", colorspace, buffer, size);
137 return FALSE;
140 /**********************************************************************
141 * GetLogColorSpaceW (GDI32.@)
143 BOOL WINAPI GetLogColorSpaceW(HCOLORSPACE colorspace, LPLOGCOLORSPACEW buffer, DWORD size)
145 FIXME("%p %p 0x%08x stub\n", colorspace, buffer, size);
146 return FALSE;
149 /**********************************************************************
150 * SetICMProfileA (GDI32.@)
152 BOOL WINAPI SetICMProfileA(HDC hdc, LPSTR filename)
154 FIXME("%p %s stub\n", hdc, debugstr_a(filename));
155 return TRUE;
158 /**********************************************************************
159 * SetICMProfileW (GDI32.@)
161 BOOL WINAPI SetICMProfileW(HDC hdc, LPWSTR filename)
163 FIXME("%p %s stub\n", hdc, debugstr_w(filename));
164 return TRUE;
167 /**********************************************************************
168 * UpdateICMRegKeyA (GDI32.@)
170 BOOL WINAPI UpdateICMRegKeyA(DWORD reserved, LPSTR cmid, LPSTR filename, UINT command)
172 FIXME("0x%08x, %s, %s, 0x%08x stub\n", reserved, debugstr_a(cmid), debugstr_a(filename), command);
173 return TRUE;
176 /**********************************************************************
177 * UpdateICMRegKeyW (GDI32.@)
179 BOOL WINAPI UpdateICMRegKeyW(DWORD reserved, LPWSTR cmid, LPWSTR filename, UINT command)
181 FIXME("0x%08x, %s, %s, 0x%08x stub\n", reserved, debugstr_w(cmid), debugstr_w(filename), command);
182 return TRUE;