Rudiments: protocolentry Class Reference

Rudiments

Public Member Functions | Static Public Member Functions | List of all members
protocolentry Class Reference

## Public Member Functions
| protocolentry ()
| protocolentry (const protocolentry &p)
protocolentry & | operator= (const protocolentry &p)
| ~protocolentry ()
bool | initialize (const char *protocolname)
bool | initialize (int32_t number)
const char * | getName () const
const char *const * | getAliasList () const
int32_t | getNumber () const

## Static Public Member Functions
static int32_t | getNumber (const char *protocolname)
static char * | getName (int32_t number)
static bool | needsMutex ()
static void | setMutex (threadmutex *mtx)

## Detailed Description

The protocolentry class provides methods for retrieving entries from the protocol file (/etc/protocols on unix).

## Constructor & Destructor Documentation

## ◆ protocolentry() [1/2]

protocolentry::protocolentry | ( |  | ) |

Creates an instance of the protocolentry class.

## ◆ protocolentry() [2/2]

protocolentry::protocolentry | ( | const protocolentry & | p | ) |

Creates an instance of the protocolentry class. that is identical to "p".

## ◆ ~protocolentry()

protocolentry::~protocolentry | ( |  | ) |

Deletes this instance of the protocolentry class.

## Member Function Documentation

## ◆ getAliasList()

const char* const* protocolentry::getAliasList | ( |  | ) | const

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

## ◆ getName() [1/2]

const char* protocolentry::getName | ( |  | ) | const

Returns the name of the protocol entry.

## ◆ getName() [2/2]

static char* protocolentry::getName | ( | int32_t | number | ) |
| static

Convenience method. Returns the name of the protocol associated with "number".

Note that the return value is allocated internally and returned. The calling program must free the buffer.

Returns NULL if an error occurred or if "number" is invalid.

## ◆ getNumber() [1/2]

int32_t protocolentry::getNumber | ( |  | ) | const

Returns the number associated with the protocol entry.

## ◆ getNumber() [2/2]

static int32_t protocolentry::getNumber | ( | const char * | protocolname | ) |
| static

Convenience method. Returns the number associated with "protocolname".

Returns -1 if an error occurred or if "protocolname" is invalid.

## ◆ initialize() [1/2]

bool protocolentry::initialize | ( | const char * | protocolname | ) |

Looks up a protocol entry by name. Returns true on success and false on failure.

## ◆ initialize() [2/2]

bool protocolentry::initialize | ( | int32_t | number | ) |

Looks up a protocol entry by number. Returns true on success and false on failure.

## ◆ needsMutex()

static bool protocolentry::needsMutex | ( |  | ) |
| static

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

## ◆ operator=()

protocolentry& protocolentry::operator= | ( | const protocolentry & | p | ) |

Makes this instance of the protocolentry class identical to "p".

## ◆ setMutex()

static void protocolentry::setMutex | ( | threadmutex * | 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.