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/nslcd/common.c
int write_address(TFILE* fp, MYLDAP_ENTRY* entry, const char* attr,
                  const char* addr)
{
    int32_t tmpint32;
    struct in_addr ipv4addr;
    struct in6_addr ipv6addr;
    /* try to parse the address as IPv4 first, fall back to IPv6 */
    if (inet_pton(AF_INET, addr, &ipv4addr) > 0)
    {
        /* write address type */
        WRITE_INT32(fp, AF_INET);
        /* write the address length */
        WRITE_INT32(fp, sizeof(struct in_addr));
        /* write the address itself (in network byte order) */
        WRITE(fp, &ipv4addr, sizeof(struct in_addr));
    }
    else if (inet_pton(AF_INET6, addr, &ipv6addr) > 0)
    {
        /* write address type */
        WRITE_INT32(fp, AF_INET6);
        /* write the address length */
        WRITE_INT32(fp, sizeof(struct in6_addr));
        /* write the address itself (in network byte order) */
        WRITE(fp, &ipv6addr, sizeof(struct in6_addr));
    }
    else
    {
        /* failure, log but write simple invalid address
           (otherwise the address list is messed up) */
        /* TODO: have error message in correct format */
        log_log(LOG_WARNING, "%s: %s: \"%s\" unparsable", myldap_get_dn(entry),
                attr, addr);
        /* write an illegal address type */
        WRITE_INT32(fp, -1);
        /* write an emtpy address */
        WRITE_INT32(fp, 0);
    }
    /* we're done */
    return 0;
}
/* this writes a single address to the stream */
this writes a single address to the stream
this writes a single address to the stream
int write_address(TFILE* fp, MYLDAP_ENTRY* entry, const char* attr,
                  const char* addr)
{
    int32_t tmpint32;
    struct in_addr ipv4addr;
    struct in6_addr ipv6addr;
    if (inet_pton(AF_INET, addr, &ipv4addr) > 0)
    {
        WRITE_INT32(fp, AF_INET);
        WRITE_INT32(fp, sizeof(struct in_addr));
        WRITE(fp, &ipv4addr, sizeof(struct in_addr));
    }
    else if (inet_pton(AF_INET6, addr, &ipv6addr) > 0)
    {
        WRITE_INT32(fp, AF_INET6);
        WRITE_INT32(fp, sizeof(struct in6_addr));
        WRITE(fp, &ipv6addr, sizeof(struct in6_addr));
    }
    else
    {
        log_log(LOG_WARNING, "%s: %s: \"%s\" unparsable", myldap_get_dn(entry),
                attr, addr);
        WRITE_INT32(fp, -1);
        WRITE_INT32(fp, 0);
    }
    return 0;
}
int write_address ( TFILE * fp , MYLDAP_ENTRY * entry , const char * attr , const char * addr ) { int32_t tmpint32 ; struct in_addr ipv4addr ; struct in6_addr ipv6addr ; if ( inet_pton ( AF_INET , addr , & ipv4addr ) > 0 ) { WRITE_INT32 ( fp , AF_INET ) ; WRITE_INT32 ( fp , sizeof ( struct in_addr ) ) ; WRITE ( fp , & ipv4addr , sizeof ( struct in_addr ) ) ; } else if ( inet_pton ( AF_INET6 , addr , & ipv6addr ) > 0 ) { WRITE_INT32 ( fp , AF_INET6 ) ; WRITE_INT32 ( fp , sizeof ( struct in6_addr ) ) ; WRITE ( fp , & ipv6addr , sizeof ( struct in6_addr ) ) ; } else { log_log ( LOG_WARNING , " \" \" " , myldap_get_dn ( entry ) , attr , addr ) ; WRITE_INT32 ( fp , -1 ) ; WRITE_INT32 ( fp , 0 ) ; } return 0 ; }
this writes a single address to the stream
this writes a single address to the stream
/* try to parse the address as IPv4 first, fall back to IPv6 */ /* write address type */ /* write the address length */ /* write the address itself (in network byte order) */ /* write address type */ /* write the address length */ /* write the address itself (in network byte order) */ /* failure, log but write simple invalid address
           (otherwise the address list is messed up) */ /* TODO: have error message in correct format */ /* write an illegal address type */ /* write an emtpy address */ /* we're done */