Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get thread locale in pj strerror #4018

Merged
merged 4 commits into from
Jul 31, 2024

Conversation

LeonidGoltsblat
Copy link
Contributor

This changes are for users who use pjsip under non english Windows redactions.

  1. PJ_ERR_MSG_SIZE
    For example russian language is not so laconic as English. Windows FormatMessage function often requires more than 80 character for message buffer. Thats why I need to increase PJ_ERR_MSG_SIZE value (in fact I use 160 - twice more!), but I preffere to declare PJ_ERR_MSG_SIZE in my config_site.h file. The only change I need for this purpose is to surrond #define PJ_ERR_MSG_SIZE by #ifndef

  2. PJ_STRERROR_USE_WIN_GET_THREAD_LOCALE
    pj_strerror() calls Windows FormatMessage function with the value of languageId parameter meaning "User default language" which is language configured for user session. This is not always comfortable. For example pjlib_project errno_test() failes for non English user language because FormatMessage return national language string (for examle cyrillic string) not containing the word "invalid" which is test criteria.
    But starting from Windows XP application can set locale (and language) information on application and thread basis. It's logically to expect the program will reflect to current thread locale. My idea is to use current thread language to obtain OS error description.
    To support this I have modified platform_strerror() (for Windows platform) so that it calls FormatMessage with current thread language instead of user default language.
    For compatibility reason I have introduced PJ_STRERROR_USE_WIN_GET_THREAD_LOCALE macro wich may be set in config_site.h file. By default behaviour is not changed, but if user define PJ_STRERROR_USE_WIN_GET_THREAD_LOCALE platform_strerror() will call GetThreadLocale() to get current locale (and language).
    As an usage example: if that macro is defined, error_test() fors English thread locale before calling pj_strerror() and now test is succeeded under non English Windows redactions.

@CLAassistant
Copy link

CLAassistant commented Jul 14, 2024

CLA assistant check
All committers have signed the CLA.

@sauwming sauwming merged commit 1a82f90 into pjsip:master Jul 31, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants