Sha256: c490b7280de46a1da3b14ce637575be3718a12c1376267d160b9ce0f2a80abcf

Contents?: true

Size: 1.17 KB

Versions: 16

Compression:

Stored size: 1.17 KB

Contents

/**
 * @file
 * Declares the scoped addrinfo resource.
 */
#pragma once

#include <leatherman/util/scoped_resource.hpp>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <string>
#include <cstring>

namespace facter { namespace util { namespace posix {

    /**
     * Represents a scoped addrinfo for POSIX systems.
     * Automatically frees the address information pointer when it goes out of scope.
    */
    struct scoped_addrinfo : leatherman::util::scoped_resource<addrinfo*>
    {
        /**
         * Constructs a scoped_addrinfo.
         * @param hostname The hostname to get the address information of.
         */
        explicit scoped_addrinfo(std::string const& hostname);

        /**
         * Constructs a scoped_addrinfo.
         * @param info The address info to free when destroyed.
         */
        explicit scoped_addrinfo(addrinfo* info);

        /**
         * Returns the result of any call to getaddrinfo.
         * @returns Returns the result of any call to getaddrinfo.
         */
        int result() const;

     private:
        static void free(addrinfo* info);
        int _result;
    };

}}}  // namespace facter::util::posix

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.12.1.cfacter.20181031 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.11.6.cfacter.20181031 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.12.1.cfacter.20181023 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.11.5.cfacter.20181022 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.12.0.cfacter.20181004 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.12.0.cfacter.20181001 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.12.0.cfacter.20180918 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.11.4.cfacter.20180821 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.11.3.cfacter.20180716 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.11.2.cfacter.20180612 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.9.6.cfacter.20180612 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.11.2.cfacter.20180606 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.9.6.cfacter.20180606 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
facter-3.11.0.cfacter.20180319 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp
cfacter-3.11.0.rc.20180314 ext/facter/facter/lib/inc/internal/util/posix/scoped_addrinfo.hpp