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 87 of file thread.c.

Referenced by getaddrinfo().

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

◆ pqGetpwuid()

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

Definition at line 65 of file thread.c.

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

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