openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/nss-pam-ldapd/0.9.8-r0/nss-pam-ldapd-0.9.8/common/nslcd-prot.c
TFILE* nslcd_client_open()
{
    int sock;
    struct sockaddr_un addr;
    TFILE* fp;
    int flags;
    /* create a socket */
    if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
        return NULL;
    /* create socket address structure */
    memset(&addr, 0, sizeof(struct sockaddr_un));
    addr.sun_family = AF_UNIX;
    strncpy(addr.sun_path, NSLCD_SOCKET, sizeof(addr.sun_path));
    addr.sun_path[sizeof(addr.sun_path) - 1] = '\0';
    /* close the file descriptor on exec (ignore errors) */
    flags = fcntl(sock, F_GETFL);
    if (flags >= 0)
        (void)fcntl(sock, F_SETFD, flags | FD_CLOEXEC);
    /* connect to the socket */
    if (connect(sock, (struct sockaddr*)&addr, SUN_LEN(&addr)) < 0)
    {
        (void)close(sock);
        return NULL;
    }
    /* create a stream object */
    if ((fp = tio_fdopen(sock, READ_TIMEOUT, WRITE_TIMEOUT, READBUFFER_MINSIZE,
                         READBUFFER_MAXSIZE, WRITEBUFFER_MINSIZE,
                         WRITEBUFFER_MAXSIZE)) == NULL)
    {
        (void)close(sock);
        return NULL;
    }
    /* return the stream */
    return fp;
}
/* returns a socket to the server or NULL on error (see errno),
   socket should be closed with fclose() */
returns a socket to the server or NULL on error ,
socket should be closed with fclose()
returns a socket to the server or NULL on error socket should be closed with fclose ()
TFILE* nslcd_client_open()
{
    int sock;
    struct sockaddr_un addr;
    TFILE* fp;
    int flags;
    if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
        return NULL;
    memset(&addr, 0, sizeof(struct sockaddr_un));
    addr.sun_family = AF_UNIX;
    strncpy(addr.sun_path, NSLCD_SOCKET, sizeof(addr.sun_path));
    addr.sun_path[sizeof(addr.sun_path) - 1] = '\0';
    flags = fcntl(sock, F_GETFL);
    if (flags >= 0)
        (void)fcntl(sock, F_SETFD, flags | FD_CLOEXEC);
    if (connect(sock, (struct sockaddr*)&addr, SUN_LEN(&addr)) < 0)
    {
        (void)close(sock);
        return NULL;
    }
    if ((fp = tio_fdopen(sock, READ_TIMEOUT, WRITE_TIMEOUT, READBUFFER_MINSIZE,
                         READBUFFER_MAXSIZE, WRITEBUFFER_MINSIZE,
                         WRITEBUFFER_MAXSIZE)) == NULL)
    {
        (void)close(sock);
        return NULL;
    }
    return fp;
}
TFILE * nslcd_client_open ( ) { int sock ; struct sockaddr_un addr ; TFILE * fp ; int flags ; if ( ( sock = socket ( PF_UNIX , SOCK_STREAM , 0 ) ) < 0 ) return NULL ; memset ( & addr , 0 , sizeof ( struct sockaddr_un ) ) ; addr . sun_family = AF_UNIX ; strncpy ( addr . sun_path , NSLCD_SOCKET , sizeof ( addr . sun_path ) ) ; addr . sun_path [ sizeof ( addr . sun_path ) - 1 ] = ' \0 ' ; flags = fcntl ( sock , F_GETFL ) ; if ( flags >= 0 ) ( void ) fcntl ( sock , F_SETFD , flags | FD_CLOEXEC ) ; if ( connect ( sock , ( struct sockaddr * ) & addr , SUN_LEN ( & addr ) ) < 0 ) { ( void ) close ( sock ) ; return NULL ; } if ( ( fp = tio_fdopen ( sock , READ_TIMEOUT , WRITE_TIMEOUT , READBUFFER_MINSIZE , READBUFFER_MAXSIZE , WRITEBUFFER_MINSIZE , WRITEBUFFER_MAXSIZE ) ) == NULL ) { ( void ) close ( sock ) ; return NULL ; } return fp ; }
returns a socket to the server or NULL on error (see errno),
socket should be closed with fclose()
returns a socket to the server or NULL on error ( see errno ) socket should be closed with fclose ()
/* create a socket */ /* create socket address structure */ /* close the file descriptor on exec (ignore errors) */ /* connect to the socket */ /* create a stream object */ /* return the stream */