Skip to content
Snippets Groups Projects
Commit f6e4eb7e authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Be explicit in more ANSI/Wide functions.

Also, fix macro name collision with GetDiskFreeSpaceEx
parent 31076f88
No related branches found
No related tags found
No related merge requests found
Pipeline #5880 passed
......@@ -47,7 +47,7 @@ COM_HANDLE comOpen(const char* device)
sprintf(dp, "\\\\.\\%s", device);
}
if((handle=CreateFile(dp
if((handle=CreateFileA(dp
,GENERIC_READ|GENERIC_WRITE /* Access */
,0 /* Share mode */
,NULL /* Security attributes */
......
......@@ -417,7 +417,7 @@ BOOL NT_SetConsoleDisplayMode(HANDLE hOutputHandle, DWORD dwNewMode)
BOOL ret;
const char KERNEL32_NAME[] = "kernel32.dll";
hKernel32 = LoadLibrary(KERNEL32_NAME);
hKernel32 = LoadLibraryA(KERNEL32_NAME);
if (hKernel32 == NULL)
return FALSE;
......@@ -448,7 +448,7 @@ BOOL NT_GetConsoleDisplayMode(DWORD* mode)
BOOL ret;
const char KERNEL32_NAME[] = "kernel32.dll";
hKernel32 = LoadLibrary(KERNEL32_NAME);
hKernel32 = LoadLibraryA(KERNEL32_NAME);
if (hKernel32 == NULL)
return FALSE;
......@@ -792,7 +792,7 @@ void win32_setcursortype(int type)
void win32_settitle(const char *title)
{
SetConsoleTitle(title);
SetConsoleTitleA(title);
}
void win32_copytext(const char *text, size_t buflen)
......
......@@ -1129,7 +1129,7 @@ get_syncterm_filename(char *fn, int fnlen, int type, bool shared)
if (!we_got_this) {
#ifdef CSIDL_FLAG_CREATE
if (type == SYNCTERM_DEFAULT_TRANSFER_PATH) {
switch (SHGetFolderPath(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT,
switch (SHGetFolderPathA(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT,
fn)) {
case E_FAIL:
case E_INVALIDARG:
......@@ -1145,7 +1145,7 @@ get_syncterm_filename(char *fn, int fnlen, int type, bool shared)
MKDIR(fn);
return fn;
}
switch (SHGetFolderPath(NULL, (shared ? CSIDL_COMMON_APPDATA : CSIDL_APPDATA) | CSIDL_FLAG_CREATE, NULL,
switch (SHGetFolderPathA(NULL, (shared ? CSIDL_COMMON_APPDATA : CSIDL_APPDATA) | CSIDL_FLAG_CREATE, NULL,
SHGFP_TYPE_CURRENT, fn)) {
case E_FAIL:
case E_INVALIDARG:
......
......@@ -890,7 +890,7 @@ uint64_t getfilesizetotal(const char *inpath)
/****************************************************************************/
#if defined(_WIN32)
typedef BOOL(WINAPI * GetDiskFreeSpaceEx_t)
(LPCTSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER);
(LPCSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER);
#endif
/* Unit should be a power-of-2 (e.g. 1024 to report kilobytes) or 1 (to report bytes) */
......@@ -906,15 +906,14 @@ static uint64_t getdiskspace(const char* path, uint64_t unit, bool freespace)
ULARGE_INTEGER avail;
ULARGE_INTEGER size;
static HINSTANCE hK32;
GetDiskFreeSpaceEx_t GetDiskFreeSpaceEx;
GetDiskFreeSpaceEx_t GDFSE;
if(hK32 == NULL)
hK32 = LoadLibrary("KERNEL32");
GetDiskFreeSpaceEx
= (GetDiskFreeSpaceEx_t)GetProcAddress(hK32,"GetDiskFreeSpaceExA");
hK32 = LoadLibraryA("KERNEL32");
GDFSE = (GetDiskFreeSpaceEx_t)GetProcAddress(hK32,"GetDiskFreeSpaceExA");
if (GetDiskFreeSpaceEx!=NULL) { /* Windows 95-OSR2 or later */
if(!GetDiskFreeSpaceEx(
if (GDFSE!=NULL) { /* Windows 95-OSR2 or later */
if(!GDFSE(
path, /* pointer to the directory name */
&avail, /* receives the number of bytes on disk avail to the caller */
&size, /* receives the number of bytes on disk */
......@@ -929,7 +928,7 @@ static uint64_t getdiskspace(const char* path, uint64_t unit, bool freespace)
/* Windows 95 (old way), limited to 2GB */
sprintf(root,"%.3s",path);
if(!GetDiskFreeSpace(
if(!GetDiskFreeSpaceA(
root, /* pointer to root path */
(PDWORD)&SectorsPerCluster, /* pointer to sectors per cluster */
(PDWORD)&BytesPerSector, /* pointer to bytes per sector */
......
......@@ -707,7 +707,7 @@ DLLEXPORT char* socket_strerror(int error_number, char* buf, size_t buflen)
buf[buflen - 1] = 0;
if(error_number > 0 && error_number < WSABASEERR)
error_number += WSABASEERR;
if(!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, // dwFlags
if(!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, // dwFlags
NULL, // lpSource
error_number, // dwMessageId
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // dwLanguageId
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment