Signed-off-by: João Diogo Craveiro Ferreira devilj@outlook.pt --- dlls/kernel32/kernel32.spec | 1 + dlls/kernel32/locale.c | 57 +++++++++++++++++++++++++++++++++++++ include/winnls.h | 2 ++ 3 files changed, 60 insertions(+)
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index 765f65c867..dcb24ed893 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -420,6 +420,7 @@ @ stdcall -import EnumSystemCodePagesW(ptr long) @ stdcall EnumSystemFirmwareTables(long ptr long) @ stdcall EnumSystemGeoID(long long ptr) +@ stdcall EnumSystemGeoNames(long ptr long) @ stdcall EnumSystemLanguageGroupsA(ptr long ptr) @ stdcall -import EnumSystemLanguageGroupsW(ptr long ptr) @ stdcall -import EnumSystemLocalesA(ptr long) diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c index adb3b9b3d9..ea0d7dd30b 100644 --- a/dlls/kernel32/locale.c +++ b/dlls/kernel32/locale.c @@ -4645,6 +4645,63 @@ BOOL WINAPI EnumSystemGeoID(GEOCLASS geoclass, GEOID parent, GEO_ENUMPROC enumpr return TRUE; }
+/****************************************************************************** + * EnumSystemGeoNames (KERNEL32.@) + * + * Call a user's function for every location available on the system. + * + * PARAMS + * geoclass [I] Type of location desired (SYSGEOTYPE enum from "winnls.h") + * enumproc [I] Callback function to call for each location + * data [I] Any user-defined data to be passed to the enumproc callback function. + * + * RETURNS + * Success: TRUE. + * Failure: FALSE. Use GetLastError() to determine the cause. + * + * NOTES + * On failure, GetLastError() will return one of the following values: + * - ERROR_INVALID_PARAMETER: enumproc was NULL; + * - ERROR_INVALID_FLAGS: the geoclass argument was invalid. + */ +BOOL WINAPI EnumSystemGeoNames(GEOCLASS geoclass, GEO_ENUMNAMEPROC enumproc, LPARAM data) +{ + TRACE("(%d, %p, %ld)\n", geoclass, enumproc, data); + + if (!enumproc) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + if (geoclass != GEOCLASS_NATION && geoclass != GEOCLASS_REGION && geoclass != GEOCLASS_ALL) + { + SetLastError(ERROR_INVALID_FLAGS); + return FALSE; + } + + for (int i = 0; i < ARRAY_SIZE(geoinfodata); i++) + { + const struct geoinfo_t *ptr = &geoinfodata[i]; + WCHAR name[4]; + + if (ptr->kind == LOCATION_NATION && geoclass == GEOCLASS_REGION) + continue; + if (ptr->kind != LOCATION_NATION && geoclass == GEOCLASS_NATION) + continue; + + if (ptr->kind == LOCATION_REGION) + sprintfW(name, geoname_uncode_fmtW, ptr->uncode); + else + strcpyW(name, ptr->iso2W); + + if (!enumproc(name, data)) + return TRUE; + } + + return TRUE; +} + /****************************************************************************** * NormalizeString (KERNEL32.@) */ diff --git a/include/winnls.h b/include/winnls.h index 63583f9a6c..aca57030ec 100644 --- a/include/winnls.h +++ b/include/winnls.h @@ -762,6 +762,7 @@ typedef BOOL (CALLBACK *DATEFMT_ENUMPROCW)(LPWSTR); typedef BOOL (CALLBACK *DATEFMT_ENUMPROCEXA)(LPSTR,CALID); typedef BOOL (CALLBACK *DATEFMT_ENUMPROCEXW)(LPWSTR,CALID); typedef BOOL (CALLBACK *GEO_ENUMPROC)(GEOID); +typedef BOOL (CALLBACK *GEO_ENUMNAMEPROC)(PWSTR,LPARAM); typedef BOOL (CALLBACK *LANGGROUPLOCALE_ENUMPROCA)(LGRPID,LCID,LPSTR,LONG_PTR); typedef BOOL (CALLBACK *LANGGROUPLOCALE_ENUMPROCW)(LGRPID,LCID,LPWSTR,LONG_PTR); typedef BOOL (CALLBACK *LANGUAGEGROUP_ENUMPROCA)(LGRPID,LPSTR,LPSTR,DWORD,LONG_PTR); @@ -868,6 +869,7 @@ WINBASEAPI BOOL WINAPI EnumSystemCodePagesA(CODEPAGE_ENUMPROCA,DWORD); WINBASEAPI BOOL WINAPI EnumSystemCodePagesW(CODEPAGE_ENUMPROCW,DWORD); #define EnumSystemCodePages WINELIB_NAME_AW(EnumSystemCodePages) WINBASEAPI BOOL WINAPI EnumSystemGeoID(GEOCLASS,GEOID,GEO_ENUMPROC); +WINBASEAPI BOOL WINAPI EnumSystemGeoNames(GEOCLASS,GEO_ENUMNAMEPROC,LPARAM); WINBASEAPI BOOL WINAPI EnumSystemLocalesA(LOCALE_ENUMPROCA,DWORD); WINBASEAPI BOOL WINAPI EnumSystemLocalesW(LOCALE_ENUMPROCW,DWORD); #define EnumSystemLocales WINELIB_NAME_AW(EnumSystemLocales)