/* Hook outputs */
- /* Callback implementing a custom asynchronous OAuth flow. */
+ /*
+ * Callback implementing a custom asynchronous OAuth flow. The signature is
+ * platform-dependent: PQ_SOCKTYPE is SOCKET on Windows, and int everywhere
+ * else.
+ */
PostgresPollingStatusType (*async) (PGconn *conn,
struct PGoauthBearerRequest *request,
- SOCKTYPE *altsock);
+ PQ_SOCKTYPE *altsock);
/* Callback to clean up custom allocations. */
void (*cleanup) (PGconn *conn, struct PGoauthBearerRequest *request);
hook. When the callback cannot make further progress without blocking,
it should return either <symbol>PGRES_POLLING_READING</symbol> or
<symbol>PGRES_POLLING_WRITING</symbol> after setting
- <literal>*pgsocket</literal> to the file descriptor that will be marked
+ <literal>*altsock</literal> to the file descriptor that will be marked
ready to read/write when progress can be made again. (This descriptor
is then provided to the top-level polling loop via
<function>PQsocket()</function>.) Return <symbol>PGRES_POLLING_OK</symbol>
int expires_in; /* seconds until user code expires */
} PGpromptOAuthDevice;
-/* for PGoauthBearerRequest.async() */
+/*
+ * For PGoauthBearerRequest.async(). This macro just allows clients to avoid
+ * depending on libpq-int.h or Winsock for the "socket" type; it's undefined
+ * immediately below.
+ */
#ifdef _WIN32
-#define SOCKTYPE uintptr_t /* avoids depending on winsock2.h for SOCKET */
+#define PQ_SOCKTYPE uintptr_t /* avoids depending on winsock2.h for SOCKET */
#else
-#define SOCKTYPE int
+#define PQ_SOCKTYPE int
#endif
typedef struct PGoauthBearerRequest
* blocking during the original call to the PQAUTHDATA_OAUTH_BEARER_TOKEN
* hook, it may be returned directly, but one of request->async or
* request->token must be set by the hook.
+ *
+ * The (PQ_SOCKTYPE *) in the signature is a placeholder for the platform's
+ * native socket type: (SOCKET *) on Windows, and (int *) everywhere else.
*/
PostgresPollingStatusType (*async) (PGconn *conn,
struct PGoauthBearerRequest *request,
- SOCKTYPE * altsock);
+ PQ_SOCKTYPE * altsock);
/*
* Callback to clean up custom allocations. A hook implementation may use
void *user;
} PGoauthBearerRequest;
-#undef SOCKTYPE
+#undef PQ_SOCKTYPE
extern char *PQencryptPassword(const char *passwd, const char *user);
extern char *PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm);