Rudiments
Public Member Functions | Static Public Member Functions
serviceentry Class Reference

List of all members.

Public Member Functions

 serviceentry ()
 serviceentry (const serviceentry &s)
serviceentryoperator= (const serviceentry &s)
 ~serviceentry ()
bool initialize (const char *servicename, const char *protocol)
bool initialize (int32_t port, const char *protocol)
const char * getName () const
int32_t getPort () const
const char * getProtocol () const
const char *const getAliasList () const
void print () const

Static Public Member Functions

static bool getAliasList (const char *servicename, const char *protocol, char ***aliaslist)
static bool getPort (const char *servicename, const char *protocol, int32_t *port)
static bool getName (int32_t port, const char *protocol, char **name)
static bool getAliasList (int32_t port, const char *protocol, char ***aliaslist)
static bool needsMutex ()
static void setMutex (mutex *mtx)

Detailed Description

The serviceentry class provides methods for retrieving entries from the service file (/etc/services on unix).


Constructor & Destructor Documentation

serviceentry::serviceentry ( )

Creates an instance of the serviceentry class.

serviceentry::serviceentry ( const serviceentry s)

Creates an instance of the serviceentry class that is a copy of "s".

serviceentry::~serviceentry ( )

Deletes this instance of the serviceentry class.


Member Function Documentation

static bool serviceentry::getAliasList ( const char *  servicename,
const char *  protocol,
char ***  aliaslist 
) [static]

Sets "aliaslist" to a NULL-terminated list of aliases for "servicename" using "protocol" (tcp, udp, etc.). Note that "aliaslist" is allocated internally and returned. The calling program must free each element and the array itself.

Returns true on success and false otherwise.

static bool serviceentry::getAliasList ( int32_t  port,
const char *  protocol,
char ***  aliaslist 
) [static]

Sets "aliaslist" to a NULL-terminated list of aliases for the service that a server listening on "port", using "protocol" (tcp, udp, etc.) would be serving. Note that "aliaslist" is allocated internally and returned. The calling program must free each element and the array itself.

Returns true on success and false otherwise.

const char* const serviceentry::getAliasList ( ) const

Returns a NULL-terminated list of aliases for the service entry.

const char* serviceentry::getName ( ) const

Returns the name of the service entry.

static bool serviceentry::getName ( int32_t  port,
const char *  protocol,
char **  name 
) [static]

Sets "name" to the name of the service that a server listening on "port", using "protocol" (tcp, udp, etc.) would be serving. Note that "name" is allocated internally and returned. The calling program must free the buffer.

static bool serviceentry::getPort ( const char *  servicename,
const char *  protocol,
int32_t *  port 
) [static]

Sets "port" to the port that the server for "servicename" using "protocol" (tcp, udp, etc.) would listen on.

int32_t serviceentry::getPort ( ) const

Returns the port that a server for this service entry would listen on.

const char* serviceentry::getProtocol ( ) const

Returns the protocol (tcp, udp, etc.) for this service entry.

bool serviceentry::initialize ( int32_t  port,
const char *  protocol 
)

Looks up a service entry by the "port" that a server for would listen on and the "protocol" that it would use (tcp, udp, etc.). Returns true on success and false on failure.

bool serviceentry::initialize ( const char *  servicename,
const char *  protocol 
)

Looks up a service entry by "servicename" and "protocol" (tcp, udp, etc.). Returns true on success and false on failure.

static bool serviceentry::needsMutex ( ) [static]

Returns true if this class needs a mutex to operate safely in a threaded environment and false otherwise.

serviceentry& serviceentry::operator= ( const serviceentry s)

Makes this instance of the serviceentry class identical to "s".

void serviceentry::print ( ) const

Prints out a representation of the service entry.

static void serviceentry::setMutex ( mutex mtx) [static]

Allows you to supply a mutex is the class needs it. (see needsMutex()). If your application is not multithreaded, then there is no need to supply a mutex.