PostgreSQL Source Code  git master
thread.c File Reference
#include "c.h"
#include <pwd.h>
Include dependency graph for thread.c:

Go to the source code of this file.

Functions

int pqGetpwuid (uid_t uid, struct passwd *resultbuf, char *buffer, size_t buflen, struct passwd **result)
 
int pqGethostbyname (const char *name, struct hostent *resultbuf, char *buffer, size_t buflen, struct hostent **result, int *herrno)
 

Function Documentation

◆ pqGethostbyname()

int pqGethostbyname ( const char *  name,
struct hostent *  resultbuf,
char *  buffer,
size_t  buflen,
struct hostent **  result,
int *  herrno 
)

Definition at line 90 of file thread.c.

Referenced by getaddrinfo().

95 {
96 #if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(HAVE_GETHOSTBYNAME_R)
97 
98  /*
99  * broken (well early POSIX draft) gethostbyname_r() which returns 'struct
100  * hostent *'
101  */
102  *result = gethostbyname_r(name, resultbuf, buffer, buflen, herrno);
103  return (*result == NULL) ? -1 : 0;
104 #else
105 
106  /* no gethostbyname_r(), just use gethostbyname() */
107  *result = gethostbyname(name);
108 
109  if (*result != NULL)
110  *herrno = h_errno;
111 
112  if (*result != NULL)
113  return 0;
114  else
115  return -1;
116 #endif
117 }
const char * name
Definition: encode.c:521

◆ pqGetpwuid()

int pqGetpwuid ( uid_t  uid,
struct passwd *  resultbuf,
char *  buffer,
size_t  buflen,
struct passwd **  result 
)

Definition at line 68 of file thread.c.

Referenced by get_home_path(), pg_fe_getauthname(), PQconnectPoll(), and pqGetHomeDirectory().

70 {
71 #if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(HAVE_GETPWUID_R)
72  return getpwuid_r(uid, resultbuf, buffer, buflen, result);
73 #else
74  /* no getpwuid_r() available, just use getpwuid() */
75  errno = 0;
76  *result = getpwuid(uid);
77  /* paranoia: ensure we return zero on success */
78  return (*result == NULL) ? errno : 0;
79 #endif
80 }