Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd1146dc

Browse files
oauth: Rename macro to avoid collisions on Windows
Our json parsing defined the macros OPTIONAL and REQUIRED to decorate thestructs with for increased readability. This however collides with macrosin the <windef.h> header on Windows.../src/interfaces/libpq/fe-auth-oauth-curl.c:398:9: warning: "OPTIONAL" redefined 398 | #define OPTIONAL false | ^~~~~~~~In file included from D:/a/_temp/msys64/ucrt64/include/windef.h:9, from D:/a/_temp/msys64/ucrt64/include/windows.h:69, from D:/a/_temp/msys64/ucrt64/include/winsock2.h:23, from ../src/include/port/win32_port.h:60, from ../src/include/port.h:24, from ../src/include/c.h:1331, from ../src/include/postgres_fe.h:28, from ../src/interfaces/libpq/fe-auth-oauth-curl.c:16:include/minwindef.h:65:9: note: this is the location of the previous definition 65 | #define OPTIONAL | ^~~~~~~~Rename to avoid compilation errors in anticipation of implementingsupport for Windows.Reported-by: Dave Cramer (on PostgreSQL Hacking Discord)
1 parent03366b6 commitd1146dc

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

‎src/interfaces/libpq/fe-auth-oauth-curl.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ struct json_field
394394
};
395395

396396
/* Documentation macros for json_field.required. */
397-
#defineREQUIRED true
398-
#defineOPTIONAL false
397+
#definePG_OAUTH_REQUIRED true
398+
#definePG_OAUTH_OPTIONAL false
399399

400400
/* Parse state for parse_oauth_json(). */
401401
structoauth_parse
@@ -844,8 +844,8 @@ static bool
844844
parse_provider(structasync_ctx*actx,structprovider*provider)
845845
{
846846
structjson_fieldfields[]= {
847-
{"issuer",JSON_TOKEN_STRING, {&provider->issuer},REQUIRED},
848-
{"token_endpoint",JSON_TOKEN_STRING, {&provider->token_endpoint},REQUIRED},
847+
{"issuer",JSON_TOKEN_STRING, {&provider->issuer},PG_OAUTH_REQUIRED},
848+
{"token_endpoint",JSON_TOKEN_STRING, {&provider->token_endpoint},PG_OAUTH_REQUIRED},
849849

850850
/*----
851851
* The following fields are technically REQUIRED, but we don't use
@@ -857,8 +857,8 @@ parse_provider(struct async_ctx *actx, struct provider *provider)
857857
* - id_token_signing_alg_values_supported
858858
*/
859859

860-
{"device_authorization_endpoint",JSON_TOKEN_STRING, {&provider->device_authorization_endpoint},OPTIONAL},
861-
{"grant_types_supported",JSON_TOKEN_ARRAY_START, {.array=&provider->grant_types_supported},OPTIONAL},
860+
{"device_authorization_endpoint",JSON_TOKEN_STRING, {&provider->device_authorization_endpoint},PG_OAUTH_OPTIONAL},
861+
{"grant_types_supported",JSON_TOKEN_ARRAY_START, {.array=&provider->grant_types_supported},PG_OAUTH_OPTIONAL},
862862

863863
{0},
864864
};
@@ -955,24 +955,24 @@ static bool
955955
parse_device_authz(structasync_ctx*actx,structdevice_authz*authz)
956956
{
957957
structjson_fieldfields[]= {
958-
{"device_code",JSON_TOKEN_STRING, {&authz->device_code},REQUIRED},
959-
{"user_code",JSON_TOKEN_STRING, {&authz->user_code},REQUIRED},
960-
{"verification_uri",JSON_TOKEN_STRING, {&authz->verification_uri},REQUIRED},
961-
{"expires_in",JSON_TOKEN_NUMBER, {&authz->expires_in_str},REQUIRED},
958+
{"device_code",JSON_TOKEN_STRING, {&authz->device_code},PG_OAUTH_REQUIRED},
959+
{"user_code",JSON_TOKEN_STRING, {&authz->user_code},PG_OAUTH_REQUIRED},
960+
{"verification_uri",JSON_TOKEN_STRING, {&authz->verification_uri},PG_OAUTH_REQUIRED},
961+
{"expires_in",JSON_TOKEN_NUMBER, {&authz->expires_in_str},PG_OAUTH_REQUIRED},
962962

963963
/*
964964
* Some services (Google, Azure) spell verification_uri differently.
965965
* We accept either.
966966
*/
967-
{"verification_url",JSON_TOKEN_STRING, {&authz->verification_uri},REQUIRED},
967+
{"verification_url",JSON_TOKEN_STRING, {&authz->verification_uri},PG_OAUTH_REQUIRED},
968968

969969
/*
970970
* There is no evidence of verification_uri_complete being spelled
971971
* with "url" instead with any service provider, so only support
972972
* "uri".
973973
*/
974-
{"verification_uri_complete",JSON_TOKEN_STRING, {&authz->verification_uri_complete},OPTIONAL},
975-
{"interval",JSON_TOKEN_NUMBER, {&authz->interval_str},OPTIONAL},
974+
{"verification_uri_complete",JSON_TOKEN_STRING, {&authz->verification_uri_complete},PG_OAUTH_OPTIONAL},
975+
{"interval",JSON_TOKEN_NUMBER, {&authz->interval_str},PG_OAUTH_OPTIONAL},
976976

977977
{0},
978978
};
@@ -1010,9 +1010,9 @@ parse_token_error(struct async_ctx *actx, struct token_error *err)
10101010
{
10111011
boolresult;
10121012
structjson_fieldfields[]= {
1013-
{"error",JSON_TOKEN_STRING, {&err->error},REQUIRED},
1013+
{"error",JSON_TOKEN_STRING, {&err->error},PG_OAUTH_REQUIRED},
10141014

1015-
{"error_description",JSON_TOKEN_STRING, {&err->error_description},OPTIONAL},
1015+
{"error_description",JSON_TOKEN_STRING, {&err->error_description},PG_OAUTH_OPTIONAL},
10161016

10171017
{0},
10181018
};
@@ -1069,8 +1069,8 @@ static bool
10691069
parse_access_token(structasync_ctx*actx,structtoken*tok)
10701070
{
10711071
structjson_fieldfields[]= {
1072-
{"access_token",JSON_TOKEN_STRING, {&tok->access_token},REQUIRED},
1073-
{"token_type",JSON_TOKEN_STRING, {&tok->token_type},REQUIRED},
1072+
{"access_token",JSON_TOKEN_STRING, {&tok->access_token},PG_OAUTH_REQUIRED},
1073+
{"token_type",JSON_TOKEN_STRING, {&tok->token_type},PG_OAUTH_REQUIRED},
10741074

10751075
/*---
10761076
* We currently have no use for the following OPTIONAL fields:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp