Commit f8595357 authored by Mikhail Maroukhine's avatar Mikhail Maroukhine Committed by Alexandre Julliard

user32: Add constness to params and variables.

parent 7b28ae53
...@@ -404,7 +404,7 @@ BOOL get_icon_size( HICON handle, SIZE *size ) ...@@ -404,7 +404,7 @@ BOOL get_icon_size( HICON handle, SIZE *size )
* The following macro functions account for the irregularities of * The following macro functions account for the irregularities of
* accessing cursor and icon resources in files and resource entries. * accessing cursor and icon resources in files and resource entries.
*/ */
typedef BOOL (*fnGetCIEntry)( LPVOID dir, int n, typedef BOOL (*fnGetCIEntry)( LPCVOID dir, int n,
int *width, int *height, int *bits ); int *width, int *height, int *bits );
/********************************************************************** /**********************************************************************
...@@ -412,7 +412,7 @@ typedef BOOL (*fnGetCIEntry)( LPVOID dir, int n, ...@@ -412,7 +412,7 @@ typedef BOOL (*fnGetCIEntry)( LPVOID dir, int n,
* *
* Find the icon closest to the requested size and bit depth. * Find the icon closest to the requested size and bit depth.
*/ */
static int CURSORICON_FindBestIcon( LPVOID dir, fnGetCIEntry get_entry, static int CURSORICON_FindBestIcon( LPCVOID dir, fnGetCIEntry get_entry,
int width, int height, int depth ) int width, int height, int depth )
{ {
int i, cx, cy, bits, bestEntry = -1; int i, cx, cy, bits, bestEntry = -1;
...@@ -452,11 +452,11 @@ static int CURSORICON_FindBestIcon( LPVOID dir, fnGetCIEntry get_entry, ...@@ -452,11 +452,11 @@ static int CURSORICON_FindBestIcon( LPVOID dir, fnGetCIEntry get_entry,
return bestEntry; return bestEntry;
} }
static BOOL CURSORICON_GetResIconEntry( LPVOID dir, int n, static BOOL CURSORICON_GetResIconEntry( LPCVOID dir, int n,
int *width, int *height, int *bits ) int *width, int *height, int *bits )
{ {
CURSORICONDIR *resdir = dir; const CURSORICONDIR *resdir = dir;
ICONRESDIR *icon; const ICONRESDIR *icon;
if ( resdir->idCount <= n ) if ( resdir->idCount <= n )
return FALSE; return FALSE;
...@@ -474,7 +474,7 @@ static BOOL CURSORICON_GetResIconEntry( LPVOID dir, int n, ...@@ -474,7 +474,7 @@ static BOOL CURSORICON_GetResIconEntry( LPVOID dir, int n,
* *
* FIXME: parameter 'color' ignored. * FIXME: parameter 'color' ignored.
*/ */
static int CURSORICON_FindBestCursor( LPVOID dir, fnGetCIEntry get_entry, static int CURSORICON_FindBestCursor( LPCVOID dir, fnGetCIEntry get_entry,
int width, int height, int depth ) int width, int height, int depth )
{ {
int i, maxwidth, maxheight, cx, cy, bits, bestEntry = -1; int i, maxwidth, maxheight, cx, cy, bits, bestEntry = -1;
...@@ -514,11 +514,11 @@ static int CURSORICON_FindBestCursor( LPVOID dir, fnGetCIEntry get_entry, ...@@ -514,11 +514,11 @@ static int CURSORICON_FindBestCursor( LPVOID dir, fnGetCIEntry get_entry,
return bestEntry; return bestEntry;
} }
static BOOL CURSORICON_GetResCursorEntry( LPVOID dir, int n, static BOOL CURSORICON_GetResCursorEntry( LPCVOID dir, int n,
int *width, int *height, int *bits ) int *width, int *height, int *bits )
{ {
CURSORICONDIR *resdir = dir; const CURSORICONDIR *resdir = dir;
CURSORDIR *cursor; const CURSORDIR *cursor;
if ( resdir->idCount <= n ) if ( resdir->idCount <= n )
return FALSE; return FALSE;
...@@ -529,7 +529,7 @@ static BOOL CURSORICON_GetResCursorEntry( LPVOID dir, int n, ...@@ -529,7 +529,7 @@ static BOOL CURSORICON_GetResCursorEntry( LPVOID dir, int n,
return TRUE; return TRUE;
} }
static CURSORICONDIRENTRY *CURSORICON_FindBestIconRes( CURSORICONDIR * dir, static const CURSORICONDIRENTRY *CURSORICON_FindBestIconRes( const CURSORICONDIR * dir,
int width, int height, int depth ) int width, int height, int depth )
{ {
int n; int n;
...@@ -541,7 +541,7 @@ static CURSORICONDIRENTRY *CURSORICON_FindBestIconRes( CURSORICONDIR * dir, ...@@ -541,7 +541,7 @@ static CURSORICONDIRENTRY *CURSORICON_FindBestIconRes( CURSORICONDIR * dir,
return &dir->idEntries[n]; return &dir->idEntries[n];
} }
static CURSORICONDIRENTRY *CURSORICON_FindBestCursorRes( CURSORICONDIR *dir, static const CURSORICONDIRENTRY *CURSORICON_FindBestCursorRes( const CURSORICONDIR *dir,
int width, int height, int depth ) int width, int height, int depth )
{ {
int n = CURSORICON_FindBestCursor( dir, CURSORICON_GetResCursorEntry, int n = CURSORICON_FindBestCursor( dir, CURSORICON_GetResCursorEntry,
...@@ -551,38 +551,38 @@ static CURSORICONDIRENTRY *CURSORICON_FindBestCursorRes( CURSORICONDIR *dir, ...@@ -551,38 +551,38 @@ static CURSORICONDIRENTRY *CURSORICON_FindBestCursorRes( CURSORICONDIR *dir,
return &dir->idEntries[n]; return &dir->idEntries[n];
} }
static BOOL CURSORICON_GetFileEntry( LPVOID dir, int n, static BOOL CURSORICON_GetFileEntry( LPCVOID dir, int n,
int *width, int *height, int *bits ) int *width, int *height, int *bits )
{ {
CURSORICONFILEDIR *filedir = dir; const CURSORICONFILEDIR *filedir = dir;
CURSORICONFILEDIRENTRY *entry; const CURSORICONFILEDIRENTRY *entry;
BITMAPINFOHEADER *info; const BITMAPINFOHEADER *info;
if ( filedir->idCount <= n ) if ( filedir->idCount <= n )
return FALSE; return FALSE;
entry = &filedir->idEntries[n]; entry = &filedir->idEntries[n];
/* FIXME: check against file size */ /* FIXME: check against file size */
info = (BITMAPINFOHEADER *)((char *)dir + entry->dwDIBOffset); info = (const BITMAPINFOHEADER *)((const char *)dir + entry->dwDIBOffset);
*width = entry->bWidth; *width = entry->bWidth;
*height = entry->bHeight; *height = entry->bHeight;
*bits = info->biBitCount; *bits = info->biBitCount;
return TRUE; return TRUE;
} }
static CURSORICONFILEDIRENTRY *CURSORICON_FindBestCursorFile( CURSORICONFILEDIR *dir, static const CURSORICONFILEDIRENTRY *CURSORICON_FindBestCursorFile( const CURSORICONFILEDIR *dir,
int width, int height, int depth ) int width, int height, int depth )
{ {
int n = CURSORICON_FindBestCursor( dir, CURSORICON_GetFileEntry, int n = CURSORICON_FindBestCursor( (LPCVOID) dir, CURSORICON_GetFileEntry,
width, height, depth ); width, height, depth );
if ( n < 0 ) if ( n < 0 )
return NULL; return NULL;
return &dir->idEntries[n]; return &dir->idEntries[n];
} }
static CURSORICONFILEDIRENTRY *CURSORICON_FindBestIconFile( CURSORICONFILEDIR *dir, static const CURSORICONFILEDIRENTRY *CURSORICON_FindBestIconFile( const CURSORICONFILEDIR *dir,
int width, int height, int depth ) int width, int height, int depth )
{ {
int n = CURSORICON_FindBestIcon( dir, CURSORICON_GetFileEntry, int n = CURSORICON_FindBestIcon((LPCVOID) dir, CURSORICON_GetFileEntry,
width, height, depth ); width, height, depth );
if ( n < 0 ) if ( n < 0 )
return NULL; return NULL;
...@@ -684,7 +684,7 @@ static BOOL create_icon_bitmaps( const BITMAPINFO *bmi, int width, int height, ...@@ -684,7 +684,7 @@ static BOOL create_icon_bitmaps( const BITMAPINFO *bmi, int width, int height,
BOOL monochrome = is_dib_monochrome( bmi ); BOOL monochrome = is_dib_monochrome( bmi );
unsigned int size = bitmap_info_size( bmi, DIB_RGB_COLORS ); unsigned int size = bitmap_info_size( bmi, DIB_RGB_COLORS );
BITMAPINFO *info; BITMAPINFO *info;
void *color_bits, *mask_bits; const void *color_bits, *mask_bits;
BOOL ret = FALSE; BOOL ret = FALSE;
HDC hdc = 0; HDC hdc = 0;
...@@ -695,8 +695,8 @@ static BOOL create_icon_bitmaps( const BITMAPINFO *bmi, int width, int height, ...@@ -695,8 +695,8 @@ static BOOL create_icon_bitmaps( const BITMAPINFO *bmi, int width, int height,
memcpy( info, bmi, size ); memcpy( info, bmi, size );
info->bmiHeader.biHeight /= 2; info->bmiHeader.biHeight /= 2;
color_bits = (char *)bmi + size; color_bits = (const char*)bmi + size;
mask_bits = (char *)color_bits + mask_bits = (const char*)color_bits +
get_dib_width_bytes( bmi->bmiHeader.biWidth, get_dib_width_bytes( bmi->bmiHeader.biWidth,
bmi->bmiHeader.biBitCount ) * abs(info->bmiHeader.biHeight); bmi->bmiHeader.biBitCount ) * abs(info->bmiHeader.biHeight);
...@@ -997,15 +997,15 @@ static HCURSOR CURSORICON_CreateIconFromANI( const LPBYTE bits, DWORD bits_size, ...@@ -997,15 +997,15 @@ static HCURSOR CURSORICON_CreateIconFromANI( const LPBYTE bits, DWORD bits_size,
icon_data = fram_chunk.data + (2 * sizeof(DWORD)); icon_data = fram_chunk.data + (2 * sizeof(DWORD));
for (i=0; i<header.num_frames; i++) for (i=0; i<header.num_frames; i++)
{ {
DWORD chunk_size = *(DWORD *)(icon_chunk + sizeof(DWORD)); const DWORD chunk_size = *(const DWORD *)(icon_chunk + sizeof(DWORD));
struct cursoricon_frame *frame = &info->frames[i]; struct cursoricon_frame *frame = &info->frames[i];
CURSORICONFILEDIRENTRY *entry; const CURSORICONFILEDIRENTRY *entry;
BITMAPINFO *bmi; const BITMAPINFO *bmi;
entry = CURSORICON_FindBestIconFile( (CURSORICONFILEDIR *) icon_data, entry = CURSORICON_FindBestIconFile((const CURSORICONFILEDIR *) icon_data,
width, height, depth ); width, height, depth );
bmi = (BITMAPINFO *) (icon_data + entry->dwDIBOffset); bmi = (const BITMAPINFO *) (icon_data + entry->dwDIBOffset);
info->hotspot.x = entry->xHotspot; info->hotspot.x = entry->xHotspot;
info->hotspot.y = entry->yHotspot; info->hotspot.y = entry->yHotspot;
if (!header.width || !header.height) if (!header.width || !header.height)
...@@ -1115,8 +1115,8 @@ static HICON CURSORICON_LoadFromFile( LPCWSTR filename, ...@@ -1115,8 +1115,8 @@ static HICON CURSORICON_LoadFromFile( LPCWSTR filename,
INT width, INT height, INT depth, INT width, INT height, INT depth,
BOOL fCursor, UINT loadflags) BOOL fCursor, UINT loadflags)
{ {
CURSORICONFILEDIRENTRY *entry; const CURSORICONFILEDIRENTRY *entry;
CURSORICONFILEDIR *dir; const CURSORICONFILEDIR *dir;
DWORD filesize = 0; DWORD filesize = 0;
HICON hIcon = 0; HICON hIcon = 0;
LPBYTE bits; LPBYTE bits;
...@@ -1136,7 +1136,7 @@ static HICON CURSORICON_LoadFromFile( LPCWSTR filename, ...@@ -1136,7 +1136,7 @@ static HICON CURSORICON_LoadFromFile( LPCWSTR filename,
goto end; goto end;
} }
dir = (CURSORICONFILEDIR*) bits; dir = (const CURSORICONFILEDIR*) bits;
if ( filesize < sizeof(*dir) ) if ( filesize < sizeof(*dir) )
goto end; goto end;
...@@ -1179,8 +1179,8 @@ static HICON CURSORICON_Load(HINSTANCE hInstance, LPCWSTR name, ...@@ -1179,8 +1179,8 @@ static HICON CURSORICON_Load(HINSTANCE hInstance, LPCWSTR name,
HANDLE handle = 0; HANDLE handle = 0;
HICON hIcon = 0; HICON hIcon = 0;
HRSRC hRsrc; HRSRC hRsrc;
CURSORICONDIR *dir; const CURSORICONDIR *dir;
CURSORICONDIRENTRY *dirEntry; const CURSORICONDIRENTRY *dirEntry;
LPBYTE bits; LPBYTE bits;
WORD wResId; WORD wResId;
POINT hotspot; POINT hotspot;
...@@ -1536,11 +1536,11 @@ BOOL WINAPI SetSystemCursor(HCURSOR hcur, DWORD id) ...@@ -1536,11 +1536,11 @@ BOOL WINAPI SetSystemCursor(HCURSOR hcur, DWORD id)
INT WINAPI LookupIconIdFromDirectoryEx( LPBYTE xdir, BOOL bIcon, INT WINAPI LookupIconIdFromDirectoryEx( LPBYTE xdir, BOOL bIcon,
INT width, INT height, UINT cFlag ) INT width, INT height, UINT cFlag )
{ {
CURSORICONDIR *dir = (CURSORICONDIR*)xdir; const CURSORICONDIR *dir = (const CURSORICONDIR*)xdir;
UINT retVal = 0; UINT retVal = 0;
if( dir && !dir->idReserved && (dir->idType & 3) ) if( dir && !dir->idReserved && (dir->idType & 3) )
{ {
CURSORICONDIRENTRY* entry; const CURSORICONDIRENTRY* entry;
const HDC hdc = GetDC(0); const HDC hdc = GetDC(0);
const int depth = (cFlag & LR_MONOCHROME) ? const int depth = (cFlag & LR_MONOCHROME) ?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment