From 57eab1050221835ef6b704fc051e5fa06aaed1ab Mon Sep 17 00:00:00 2001 From: A2va <49582555+A2va@users.noreply.github.com> Date: Sat, 8 Feb 2025 10:46:10 +0100 Subject: [PATCH] Add C definition Inline MAX_PATH, MAX_DEFAULTCHAR, MAX_LEADBYTES --- libc/isystem/windowsesque.h | 1 + libc/nt/files.h | 2 ++ libc/nt/nls.h | 35 +++++++++++++++++++++++++++++++++++ libc/nt/registry.h | 2 ++ libc/nt/struct/cpinfoex.h | 10 +++------- 5 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 libc/nt/nls.h diff --git a/libc/isystem/windowsesque.h b/libc/isystem/windowsesque.h index 239d9a4fb..4b27c516c 100644 --- a/libc/isystem/windowsesque.h +++ b/libc/isystem/windowsesque.h @@ -12,6 +12,7 @@ #include "libc/nt/files.h" #include "libc/nt/ipc.h" #include "libc/nt/memory.h" +#include "libc/nt/nls.h" #include "libc/nt/paint.h" #include "libc/nt/process.h" #include "libc/nt/registry.h" diff --git a/libc/nt/files.h b/libc/nt/files.h index 6959a0d13..2b844c32f 100644 --- a/libc/nt/files.h +++ b/libc/nt/files.h @@ -49,6 +49,7 @@ COSMOPOLITAN_C_START_ intptr_t LoadResource(int64_t hModule, int64_t hResInfo); uint32_t SetHandleCount(uint32_t uNumber); uint32_t GetLogicalDrives(void); +uint32_t GetLogicalDriveStringsA(uint32_t nBufferLength, char *lpBuffer); bool32 FlushFileBuffers(int64_t hFile); int64_t ReOpenFile(int64_t hOriginalFile, uint32_t dwDesiredAccess, @@ -205,6 +206,7 @@ uint32_t GetFinalPathNameByHandle(int64_t hFile, char16_t *out_path, uint32_t GetFullPathName(const char16_t *lpFileName, uint32_t nBufferLength, char16_t *lpBuffer, char16_t **lpFilePart); +uint32_t GetShortPathName(const char16_t *lpszLongPath, char16_t *out_lpszShortPath, uint32_t cchBuffer); bool32 GetOverlappedResult(int64_t hFile, struct NtOverlapped *lpOverlapped, uint32_t *lpNumberOfBytesTransferred, bool32 bWait); diff --git a/libc/nt/nls.h b/libc/nt/nls.h new file mode 100644 index 000000000..4e2761519 --- /dev/null +++ b/libc/nt/nls.h @@ -0,0 +1,35 @@ +#ifndef COSMOPOLITAN_LIBC_NT_NLS_H_ +#define COSMOPOLITAN_LIBC_NT_NLS_H_ +#include "libc/nt/struct/cpinfoex.h" +/* ░░░░ + ▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░ + ▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░ + ▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░ + ▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█ + ▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓ + ░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█ + ▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓ + ▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒ + ▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█ + ▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓ + ░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█ + ▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓ + ░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓ + ▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████ + ▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███ + ▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███ + ▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██ + ▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██ + ▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███ + ░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██ +╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗ +│ cosmopolitan § new technology » internationalization ─╬─│┼ +╚────────────────────────────────────────────────────────────────────────────│*/ +COSMOPOLITAN_C_START_ + +uint32_t GetOEMCP(); +uint32_t GetACP(); +bool32 GetCPInfoEx(uint32_t CodePage, uint32_t dwFlags, struct NtCpInfoEx *out_lpCPInfoEx) paramsnonnull((3)); + +COSMOPOLITAN_C_END_ +#endif /* COSMOPOLITAN_LIBC_NT_NLS_H_ */ \ No newline at end of file diff --git a/libc/nt/registry.h b/libc/nt/registry.h index d7f8abb99..a03abfc57 100644 --- a/libc/nt/registry.h +++ b/libc/nt/registry.h @@ -51,6 +51,8 @@ int RegOpenKey(int64_t hKey, const char16_t *opt_lpSubKey, int RegOpenKeyEx(int64_t hKey, const char16_t *opt_lpSubKey, uint32_t opt_ulOptions, int samDesired, int64_t *out_phkResult) paramsnonnull((5)); +int RegOpenKeyExA(int64_t hKey, const char *opt_lpSubKey, uint32_t opt_ulOptions, + int samDesired, int64_t *out_phkResult) paramsnonnull((5)); int RegCloseKey(int64_t hKey); int RegGetValue(int64_t hkey, const char16_t *opt_lpSubKey, diff --git a/libc/nt/struct/cpinfoex.h b/libc/nt/struct/cpinfoex.h index 1f5d587c9..754501bb5 100644 --- a/libc/nt/struct/cpinfoex.h +++ b/libc/nt/struct/cpinfoex.h @@ -1,17 +1,13 @@ #ifndef COSMOPOLITAN_LIBC_NT_STRUCT_CPINFOEX_H_ #define COSMOPOLITAN_LIBC_NT_STRUCT_CPINFOEX_H_ -#define MAX_LEADBYTES 12 -#define MAX_DEFAULTCHAR 2 -#define MAX_PATH 260 - struct NtCpInfoEx { uint32_t MaxCharSize; - uint8_t DefaultChar[MAX_DEFAULTCHAR]; - uint8_t LeadByte[MAX_LEADBYTES]; + uint8_t DefaultChar[2]; + uint8_t LeadByte[12]; char16_t UnicodeDefaultChar; uint32_t CodePage; - char16_t CodePageName[MAX_PATH] + char16_t CodePageName[260]; }; #endif /* COSMOPOLITAN_LIBC_NT_STRUCT_CPINFOEX_H_ */