Struktury danych | Definicje | Funkcje | Zmienne

Dokumentacja pliku ekg/recode.c

#include "ekg2-config.h"
#include <errno.h>
#include <string.h>
#include "commands.h"
#include "dynstuff.h"
#include "dynstuff_inline.h"
#include "recode.h"
#include "stuff.h"
#include "windows.h"
#include "xmalloc.h"
#include "recode_tables.h"

Struktury danych

struct  ekg_recoder

Definicje

#define EKG_ICONV_BAD   (void*) -1
#define REINIT_RECODER(strukt, name)
#define DISPLAY_RECODER(strukt, name)

Funkcje

void * ekg_convert_string_init (const char *from, const char *to, void **rev)
void ekg_convert_string_destroy (void *ptr)
char * ekg_convert_string_p (const char *ps, void *ptr)
char * ekg_convert_string (const char *ps, const char *from, const char *to)
string_t ekg_convert_string_t_p (string_t s, void *ptr)
string_t ekg_convert_string_t (string_t s, const char *from, const char *to)
static void ekg_recode_init (struct ekg_recoder *rec)
static void ekg_recode_deinit (struct ekg_recoder *rec)
void changed_console_charset (const char *name)
int ekg_converters_display (int quiet)
static int ekg_utf8_helper (unsigned char *s, int n, unsigned short *ch)
static char * ekg_from_utf8 (char *b, const unsigned short *recode_table)
static char * ekg_to_utf8 (char *b, const unsigned short *recode_table)
static char * iso_to_ascii (struct ekg_recoder *rec, int alloc_buf, char *b)
static char * ekg_change_encoding (char *b, int alloc_buf, const unsigned char *recode_table)
static struct ekg_recoderekg_recode_get (enum ekg_recode_name enc)
static char * recode_ret (struct ekg_recoder *rec, int alloc_buf, char *buf)
static char * recode_ansi_helper_from (struct ekg_recoder *rec, int alloc_buf, char *buf)
static char * recode_ansi_helper_to (struct ekg_recoder *rec, int alloc_buf, char *buf)
static char * recode_utf8_helper_from (struct ekg_recoder *rec, int alloc_buf, char *buf)
static char * recode_utf8_helper_to (struct ekg_recoder *rec, int alloc_buf, char *buf)
static void ekg_recode_init_iconv (struct ekg_recoder *rec, const char *encoding)
void ekg_recode_inc_ref (enum ekg_recode_name enc)
void ekg_recode_dec_ref (enum ekg_recode_name enc)
char * ekg_recode_from_locale (enum ekg_recode_name enc, char *buf)
char * ekg_recode_to_locale (enum ekg_recode_name enc, char *buf)
char * ekg_recode_from_locale_dup (enum ekg_recode_name enc, const char *buf)
char * ekg_recode_to_locale_dup (enum ekg_recode_name enc, const char *buf)
const char * ekg_recode_from_locale_use (enum ekg_recode_name enc, const char *buf)
const char * ekg_recode_to_locale_use (enum ekg_recode_name enc, const char *buf)

Zmienne

static struct ekg_recoder cp_recoder
static struct ekg_recoder iso2_recoder
static struct ekg_recoder utf8_recoder
static struct ekg_recoder dummy_recoder

Dokumentacja definicji

#define DISPLAY_RECODER (   strukt,
  name 
)
Wartość:
do {                            \
                if (strukt.count)       \
                        printq( (strukt.recode_from_locale && strukt.recode_to_locale) ?                \
                                "iconv_list" : "iconv_list_bad",                                        \
                                config_console_charset, name, itoa(strukt.count), itoa(strukt.count),"");\
        } while(0);
#define EKG_ICONV_BAD   (void*) -1
#define REINIT_RECODER (   strukt,
  name 
)
Wartość:
do {                            \
                int oldcount;           \
                if ((oldcount = strukt.count)) {                                                \
                        /* int wasok = (strukt.recode_from_locale && strukt.recode_to_locale); */       \
                        ekg_recode_deinit(&strukt);                                             \
                        ekg_recode_init(&strukt);                                               \
                        strukt.count = oldcount;                                                \
                        if (!strukt.recode_from_locale || !strukt.recode_to_locale)             \
                                all_ok = 0;                                                     \
                }                                                                               \
        } while (0);

Dokumentacja funkcji

void changed_console_charset ( const char *  name  ) 
static char* ekg_change_encoding ( char *  b,
int  alloc_buf,
const unsigned char *  recode_table 
) [static]
char* ekg_convert_string ( const char *  ps,
const char *  from,
const char *  to 
)

ekg_convert_string()

Converts string to specified encoding, replacing invalid chars with question marks.

Nota:
Deprecated, in favour of ekg_convert_string_p(). Should be used only on single conversions, where charset pair won't be used again.
Parametry:
ps - string to be converted (it won't be freed).
from - input encoding (if NULL, console_charset will be assumed).
to - output encoding (if NULL, console_charset will be assumed).
Zwraca:
Pointer to allocated result on success, NULL on failure or when both encodings are equal.
Zobacz również:
ekg_convert_string_p() - more optimized version.
void ekg_convert_string_destroy ( void *  ptr  ) 

ekg_convert_string_destroy()

Frees internal data associated with given pointer, and uninitalizes iconv, if it's not needed anymore.

Nota:
If 'rev' param was used with ekg_convert_string_init(), this functions must be called two times
  • with returned value, and with rev-associated one.
Parametry:
ptr - pointer returned by ekg_convert_string_init().
Zobacz również:
ekg_convert_string_init() - init charset conversion.
ekg_convert_string_p() - main charset conversion function.
void* ekg_convert_string_init ( const char *  from,
const char *  to,
void **  rev 
)

ekg_convert_string_init()

Initialize string conversion thing for two given charsets.

Parametry:
from - input encoding (will be duped; if NULL, console_charset will be assumed).
to - output encoding (will be duped; if NULL, console_charset will be assumed).
rev - pointer to assign reverse conversion into; if NULL, no reverse converter will be initialized.
Zwraca:
Pointer that should be passed to other ekg_convert_string_*(), even if it's NULL.
Zobacz również:
ekg_convert_string_destroy() - deinits charset conversion.
ekg_convert_string_p() - main charset conversion function.
char* ekg_convert_string_p ( const char *  ps,
void *  ptr 
)

ekg_convert_string_p()

Converts string to specified encoding, using pointer returned by ekg_convert_string_init(). Invalid characters in input will be replaced with question marks.

Parametry:
ps - string to be converted (won't be freed).
ptr - pointer returned by ekg_convert_string_init().
Zwraca:
Pointer to allocated result or NULL, if some failure has occured or no conversion is needed (i.e. resulting string would be same as input).
Zobacz również:
ekg_convert_string_init() - init charset conversion.
ekg_convert_string_destroy() - deinits charset conversion.
string_t ekg_convert_string_t ( string_t  s,
const char *  from,
const char *  to 
)
string_t ekg_convert_string_t_p ( string_t  s,
void *  ptr 
)
int ekg_converters_display ( int  quiet  ) 
static char* ekg_from_utf8 ( char *  b,
const unsigned short *  recode_table 
) [static]
void ekg_recode_dec_ref ( enum ekg_recode_name  enc  ) 
static void ekg_recode_deinit ( struct ekg_recoder rec  )  [static]
char* ekg_recode_from_locale ( enum ekg_recode_name  enc,
char *  buf 
)
char* ekg_recode_from_locale_dup ( enum ekg_recode_name  enc,
const char *  buf 
)
const char* ekg_recode_from_locale_use ( enum ekg_recode_name  enc,
const char *  buf 
)
static struct ekg_recoder* ekg_recode_get ( enum ekg_recode_name  enc  )  [static, read]
void ekg_recode_inc_ref ( enum ekg_recode_name  enc  ) 
static void ekg_recode_init ( struct ekg_recoder rec  )  [static]
static void ekg_recode_init_iconv ( struct ekg_recoder rec,
const char *  encoding 
) [static]
char* ekg_recode_to_locale ( enum ekg_recode_name  enc,
char *  buf 
)
char* ekg_recode_to_locale_dup ( enum ekg_recode_name  enc,
const char *  buf 
)
const char* ekg_recode_to_locale_use ( enum ekg_recode_name  enc,
const char *  buf 
)
static char* ekg_to_utf8 ( char *  b,
const unsigned short *  recode_table 
) [static]
static int ekg_utf8_helper ( unsigned char *  s,
int  n,
unsigned short *  ch 
) [static]
static char* iso_to_ascii ( struct ekg_recoder rec,
int  alloc_buf,
char *  b 
) [static]
static char* recode_ansi_helper_from ( struct ekg_recoder rec,
int  alloc_buf,
char *  buf 
) [static]
static char* recode_ansi_helper_to ( struct ekg_recoder rec,
int  alloc_buf,
char *  buf 
) [static]
static char* recode_ret ( struct ekg_recoder rec,
int  alloc_buf,
char *  buf 
) [static]
static char* recode_utf8_helper_from ( struct ekg_recoder rec,
int  alloc_buf,
char *  buf 
) [static]
static char* recode_utf8_helper_to ( struct ekg_recoder rec,
int  alloc_buf,
char *  buf 
) [static]

Dokumentacja zmiennych

struct ekg_recoder cp_recoder [static]
struct ekg_recoder dummy_recoder [static]
struct ekg_recoder iso2_recoder [static]
struct ekg_recoder utf8_recoder [static]
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje