libexplain  1.4.D001
Data Structures | Defines | Typedefs | Functions
libexplain/buffer/errno/gethostbyname.c File Reference
#include <libexplain/ac/errno.h>
#include <libexplain/ac/string.h>
#include <libexplain/buffer/errno/generic.h>
#include <libexplain/buffer/errno/gethostbyname.h>
#include <libexplain/buffer/gettext.h>
#include <libexplain/explanation.h>

Go to the source code of this file.

Data Structures

struct  label

Defines

#define ALLOW_UNDERSCORE   1
#define ALLOW_LEADING_UNDERSCORE   1
#define ALLOW_LEADING_HYPHEN   1
#define ALLOW_LEADING_DIGIT   1
#define ALLOW_ALL_NUMERIC   1

Typedefs

typedef struct label label

Functions

static void explain_buffer_errno_gethostbyname_system_call (explain_string_buffer_t *sb, int errnum, const char *name)
static int valid_label (const label *lp)
static labelvalidate_hostname (const char *name)
static int check_valid_hostname (explain_string_buffer_t *sb, const char *name)
void explain_buffer_errno_gethostbyname_explanation (explain_string_buffer_t *sb, int errnum, const char *syscall_name, const char *name)
void explain_buffer_errno_gethostbyname (explain_string_buffer_t *sb, int errnum, const char *name)

Define Documentation

#define ALLOW_ALL_NUMERIC   1

Definition at line 46 of file gethostbyname.c.

#define ALLOW_LEADING_DIGIT   1

Definition at line 45 of file gethostbyname.c.

#define ALLOW_LEADING_HYPHEN   1

Definition at line 44 of file gethostbyname.c.

#define ALLOW_LEADING_UNDERSCORE   1

Definition at line 41 of file gethostbyname.c.

#define ALLOW_UNDERSCORE   1

Definition at line 40 of file gethostbyname.c.


Typedef Documentation

typedef struct label label

Definition at line 49 of file gethostbyname.c.


Function Documentation

static int check_valid_hostname ( explain_string_buffer_t sb,
const char *  name 
) [static]

Definition at line 285 of file gethostbyname.c.

void explain_buffer_errno_gethostbyname ( explain_string_buffer_t sb,
int  errnum,
const char *  name 
)

The explain_buffer_errno_gethostbyname function is used to obtain an explanation of an error returned by the gethostbyname(3) system call. The least the message will contain is the value of strerror(errnum), but usually it will do much better, and indicate the underlying cause in more detail.

Parameters:
sbThe string buffer to print the message into. If a suitable buffer is specified, this function is thread safe.
errnumThe error value to be decoded, usually obtained from the errno global variable just before this function is called. This is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno.
nameThe original name, exactly as passed to the gethostbyname(3) system call.

Definition at line 487 of file gethostbyname.c.

void explain_buffer_errno_gethostbyname_explanation ( explain_string_buffer_t sb,
int  errnum,
const char *  syscall_name,
const char *  name 
)

The explain_buffer_errno_gethostbyname_explanation function is used to obtain the explanation (the part after "because") of an error returned by the gethostbyname(3) system call (and similar).

Parameters:
sbThe string buffer to print the message into. If a suitable buffer is specified, this function is thread safe.
errnumThe error value to be decoded, usually obtained from the errno global variable just before this function is called. This is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno.
syscall_nameThe name of the offending system call.
nameThe original name, exactly as passed to the gethostbyname(3) system call.

Definition at line 355 of file gethostbyname.c.

static void explain_buffer_errno_gethostbyname_system_call ( explain_string_buffer_t sb,
int  errnum,
const char *  name 
) [static]

Definition at line 29 of file gethostbyname.c.

static int valid_label ( const label lp) [static]

The valid_label function is used to determien whether or not a hostname label is correctly formed.

Parameters:
lpthe label in question.
Returns:
0 (false) if not valid, non-zero (true) if valid.

Definition at line 68 of file gethostbyname.c.

static label* validate_hostname ( const char *  name) [static]

The validate_hostname function is used to check a hostname.

Parameters:
nameThe hostname to be checked.
Returns:
0 if valid; or a field number (1 based) if invalid.

Definition at line 204 of file gethostbyname.c.