libexplain  1.4.D001
Defines | Functions
libexplain/iconv_open_or_die.c File Reference
#include <libexplain/ac/errno.h>
#include <libexplain/ac/iconv.h>
#include <libexplain/iconv_open.h>
#include <libexplain/output.h>

Go to the source code of this file.

Defines

#define FAIL   ((iconv_t)(-1))

Functions

iconv_t explain_iconv_open_or_die (const char *tocode, const char *fromcode)
iconv_t explain_iconv_open_on_error (const char *tocode, const char *fromcode)

Define Documentation

#define FAIL   ((iconv_t)(-1))

Definition at line 26 of file iconv_open_or_die.c.


Function Documentation

iconv_t explain_iconv_open_on_error ( const char *  tocode,
const char *  fromcode 
)

The explain_iconv_open_on_error function is used to call the iconv_open(3) system call. On failure an explanation will be printed to stderr, obtained from the explain_iconv_open(3) function.

Parameters:
tocodeThe tocode, exactly as to be passed to the iconv_open(3) system call.
fromcodeThe fromcode, exactly as to be passed to the iconv_open(3) system call.
Returns:
The value returned by the wrapped iconv_open(3) system call.
Example:
This function is intended to be used in a fashion similar to the following example:
 iconv_t result = explain_iconv_open_on_error(tocode, fromcode);
 if (result < 0)
 {
     ...cope with error
     ...no need to print error message
 }

Definition at line 44 of file iconv_open_or_die.c.

iconv_t explain_iconv_open_or_die ( const char *  tocode,
const char *  fromcode 
)

The explain_iconv_open_or_die function is used to call the iconv_open(3) system call. On failure an explanation will be printed to stderr, obtained from the explain_iconv_open(3) function, and then the process terminates by calling exit(EXIT_FAILURE).

Parameters:
tocodeThe tocode, exactly as to be passed to the iconv_open(3) system call.
fromcodeThe fromcode, exactly as to be passed to the iconv_open(3) system call.
Returns:
This function only returns on success, see iconv_open(3) for more information. On failure, prints an explanation and exits, it does not return.
Example:
This function is intended to be used in a fashion similar to the following example:
 iconv_t result = explain_iconv_open_or_die(tocode, fromcode);

Definition at line 30 of file iconv_open_or_die.c.