/usr/include/arc/HostnameResolver.h is in nordugrid-arc-dev 5.4.2-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | #ifndef __ARC_HOSTNAMERESOLVER_H__
#define __ARC_HOSTNAMERESOLVER_H__
#include <string>
#include <list>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <glibmm.h>
#ifdef WIN32
#ifndef uid_t
#define uid_t int
#endif
#ifndef gid_t
#define gid_t int
#endif
#endif
namespace Arc {
class Run;
/// Defines interface for accessing filesystems.
/** This class performs host name respolution through a proxy executable.
\ingroup common
\headerfile HostnameResolver.h arc/HostnameResolver.h
*/
class HostnameResolver {
public:
class SockAddr {
friend class HostnameResolver;
public:
SockAddr();
SockAddr(SockAddr const& other);
SockAddr& operator=(SockAddr const& other);
~SockAddr();
int Family() const { return family; }
sockaddr const* Addr() const { return addr; }
socklen_t Length() const { return length; }
private:
int family;
socklen_t length;
sockaddr *addr;
};
/// New HostnameResolver object.
HostnameResolver(void);
/// Shuts down any spawned executable.
~HostnameResolver(void);
/// Constructor which takes already existing object from global cache
static HostnameResolver* Acquire(void);
/// Destructor which returns object into global cache
static void Release(HostnameResolver* fa);
/// Check if communication with proxy works
bool ping(void);
/// Performs resolution of provided host name.
int hr_resolve(std::string const& node, std::string const& service, bool local, std::list<SockAddr>& addrs);
/// Get errno of last operation. Every operation resets errno.
int geterrno() { return errno_; };
/// Returns true if this instance is in useful condition
operator bool(void) { return (hostname_resolver_ != NULL); };
/// Returns true if this instance is not in useful condition
bool operator!(void) { return (hostname_resolver_ == NULL); };
/// Special method for using in unit tests.
static void testtune(void);
private:
Glib::Mutex lock_;
Run* hostname_resolver_;
int errno_;
public:
/// Internal struct used for communication between processes.
typedef struct {
unsigned int size;
unsigned int cmd;
} header_t;
};
/// Container for shared HostnameResolver objects.
/** HostnameResolverContainer maintains a pool of executables and can be used to
reduce the overhead in creating and destroying executables when using
HostnameResolver.
\ingroup common
\headerfile HostnameResolver.h arc/HostnameResolver.h */
class HostnameResolverContainer {
public:
/// Creates container with number of stored objects between minval and maxval.
HostnameResolverContainer(unsigned int minval, unsigned int maxval);
/// Creates container with number of stored objects between 1 and 10.
HostnameResolverContainer(void);
/// Destroys container and all stored objects.
~HostnameResolverContainer(void);
/// Get object from container.
/** Object either is taken from stored ones or new one created.
Acquired object looses its connection to container and
can be safely destroyed or returned into other container. */
HostnameResolver* Acquire(void);
/// Returns object into container.
/** It can be any object - taken from another container or created using
new. */
void Release(HostnameResolver* hr);
/// Adjust minimal number of stored objects.
void SetMin(unsigned int val);
/// Adjust maximal number of stored objects.
void SetMax(unsigned int val);
private:
Glib::Mutex lock_;
unsigned int min_;
unsigned int max_;
std::list<HostnameResolver*> hrs_;
void KeepRange(void);
};
} // namespace Arc
#endif // __ARC_HOSTNAMERESOLVER_H__
|