Back to index

glibc  2.9
Classes | Defines | Typedefs | Enumerations | Functions | Variables
iso-2022-jp.c File Reference
#include <assert.h>
#include <dlfcn.h>
#include <gconv.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "jis0201.h"
#include "jis0208.h"
#include "jis0212.h"
#include "gb2312.h"
#include "ksc5601.h"
#include "iso8859-7jp.h"
#include <iconv/loop.c>
#include <iconv/skeleton.c>

Go to the source code of this file.

Classes

struct  gap
struct  iso2022jp_data

Defines

#define ESC   0x1b
#define DEFINE_INIT   0
#define DEFINE_FINI   0
#define FROM_LOOP   from_iso2022jp_loop
#define TO_LOOP   to_iso2022jp_loop
#define FROM_LOOP_MIN_NEEDED_FROM   1
#define FROM_LOOP_MAX_NEEDED_FROM   4
#define FROM_LOOP_MIN_NEEDED_TO   4
#define FROM_LOOP_MAX_NEEDED_TO   4
#define TO_LOOP_MIN_NEEDED_FROM   4
#define TO_LOOP_MAX_NEEDED_FROM   4
#define TO_LOOP_MIN_NEEDED_TO   1
#define TO_LOOP_MAX_NEEDED_TO   6
#define FROM_DIRECTION   (dir == from_iso2022jp)
#define PREPARE_LOOP
#define EXTRA_LOOP_ARGS   , var, setp
#define EMIT_SHIFT_TO_INIT
#define SAVE_RESET_STATE(Save)
#define MIN_NEEDED_INPUT   FROM_LOOP_MIN_NEEDED_FROM
#define MAX_NEEDED_INPUT   FROM_LOOP_MAX_NEEDED_FROM
#define MIN_NEEDED_OUTPUT   FROM_LOOP_MIN_NEEDED_TO
#define MAX_NEEDED_OUTPUT   FROM_LOOP_MAX_NEEDED_TO
#define LOOPFCT   FROM_LOOP
#define BODY
#define LOOP_NEED_FLAGS
#define EXTRA_LOOP_DECLS   , enum variant var, int *setp
#define INIT_PARAMS
#define UPDATE_PARAMS   *setp = set | set2
#define CVLIST(cv1, cv2, cv3, cv4, cv5)   ((cv1) + ((cv2) << 3) + ((cv3) << 6) + ((cv4) << 9) + ((cv5) << 12))
#define CVLIST_FIRST(cvl)   ((cvl) & ((1 << 3) - 1))
#define CVLIST_REST(cvl)   ((cvl) >> 3)
#define MIN_NEEDED_INPUT   TO_LOOP_MIN_NEEDED_FROM
#define MAX_NEEDED_INPUT   TO_LOOP_MAX_NEEDED_FROM
#define MIN_NEEDED_OUTPUT   TO_LOOP_MIN_NEEDED_TO
#define MAX_NEEDED_OUTPUT   TO_LOOP_MAX_NEEDED_TO
#define LOOPFCT   TO_LOOP
#define BODY
#define LOOP_NEED_FLAGS
#define EXTRA_LOOP_DECLS   , enum variant var, int *setp
#define INIT_PARAMS
#define REINIT_PARAMS
#define UPDATE_PARAMS   *setp = set | set2 | tag

Typedefs

typedef unsigned int cvlist_t

Enumerations

enum  direction {
  illegal_dir, to_iso2022jp, from_iso2022jp, illegal_dir,
  to_iso646, from_iso646, illegal_dir, to_unicode,
  from_unicode, illegal_dir, to_utf16, from_utf16,
  illegal_dir, to_utf32, from_utf32
}
enum  variant {
  illegal_var, iso2022jp, iso2022jp2, illegal_var,
  GB, CA, CA2, DE,
  DK, ES, ES2, CN,
  IT, JP, JP_OCR_B, YU,
  KR, HU, CU, FR,
  FR1, NO, NO2, PT,
  PT2, SE, SE2, illegal_var,
  UTF_16, UTF_16LE, UTF_16BE, illegal_var,
  UTF_32, UTF_32LE, UTF_32BE
}
enum  {
  ASCII_set = 0, JISX0208_1978_set = 1 << 3, JISX0208_1983_set = 2 << 3, JISX0201_Roman_set = 3 << 3,
  JISX0201_Kana_set = 4 << 3, GB2312_set = 5 << 3, KSC5601_set = 6 << 3, JISX0212_set = 7 << 3,
  CURRENT_SEL_MASK = 7 << 3
}
enum  { UNSPECIFIED_set = 0, ISO88591_set = 1 << 6, ISO88597_set = 2 << 6, CURRENT_ASSIGN_MASK = 3 << 6 }
enum  {
  TAG_none = 0, TAG_language = 4 << 8, TAG_language_j = 5 << 8, TAG_language_ja = 1 << 8,
  TAG_language_k = 6 << 8, TAG_language_ko = 2 << 8, TAG_language_z = 7 << 8, TAG_language_zh = 3 << 8,
  CURRENT_TAG_MASK = 7 << 8
}
enum  conversion {
  none = 0, european, japanese, chinese,
  korean, other
}

Functions

int gconv_init (struct __gconv_step *step)
void gconv_end (struct __gconv_step *data)

Variables

static const cvlist_t conversion_lists [4]

Class Documentation

struct gap

Definition at line 25 of file 8bit-gap.c.

Class Members
uint32_t end
uint16_t end
int32_t idx
uint32_t start
uint16_t start
struct iso2022jp_data

Definition at line 86 of file iso-2022-jp.c.


Define Documentation

#define BODY

Definition at line 477 of file iso-2022-jp.c.

#define BODY

Definition at line 477 of file iso-2022-jp.c.

#define CVLIST (   cv1,
  cv2,
  cv3,
  cv4,
  cv5 
)    ((cv1) + ((cv2) << 3) + ((cv3) << 6) + ((cv4) << 9) + ((cv5) << 12))

Definition at line 460 of file iso-2022-jp.c.

#define CVLIST_FIRST (   cvl)    ((cvl) & ((1 << 3) - 1))

Definition at line 462 of file iso-2022-jp.c.

#define CVLIST_REST (   cvl)    ((cvl) >> 3)

Definition at line 463 of file iso-2022-jp.c.

#define DEFINE_FINI   0

Definition at line 47 of file iso-2022-jp.c.

#define DEFINE_INIT   0

Definition at line 46 of file iso-2022-jp.c.

Definition at line 216 of file iso-2022-jp.c.

#define ESC   0x1b

Definition at line 43 of file iso-2022-jp.c.

#define EXTRA_LOOP_ARGS   , var, setp

Definition at line 66 of file iso-2022-jp.c.

#define EXTRA_LOOP_DECLS   , enum variant var, int *setp

Definition at line 986 of file iso-2022-jp.c.

#define EXTRA_LOOP_DECLS   , enum variant var, int *setp

Definition at line 986 of file iso-2022-jp.c.

#define FROM_DIRECTION   (dir == from_iso2022jp)

Definition at line 60 of file iso-2022-jp.c.

#define FROM_LOOP   from_iso2022jp_loop

Definition at line 50 of file iso-2022-jp.c.

#define FROM_LOOP_MAX_NEEDED_FROM   4

Definition at line 53 of file iso-2022-jp.c.

#define FROM_LOOP_MAX_NEEDED_TO   4

Definition at line 55 of file iso-2022-jp.c.

#define FROM_LOOP_MIN_NEEDED_FROM   1

Definition at line 52 of file iso-2022-jp.c.

#define FROM_LOOP_MIN_NEEDED_TO   4

Definition at line 54 of file iso-2022-jp.c.

#define INIT_PARAMS
Value:
int set = *setp & CURRENT_SEL_MASK;             \
                            int set2 = *setp & CURRENT_ASSIGN_MASK

Definition at line 987 of file iso-2022-jp.c.

#define INIT_PARAMS
Value:
int set = *setp & CURRENT_SEL_MASK;             \
                            int set2 = *setp & CURRENT_ASSIGN_MASK;         \
                            int tag = *setp & CURRENT_TAG_MASK;

Definition at line 987 of file iso-2022-jp.c.

#define LOOP_NEED_FLAGS

Definition at line 985 of file iso-2022-jp.c.

#define LOOP_NEED_FLAGS

Definition at line 985 of file iso-2022-jp.c.

#define LOOPFCT   FROM_LOOP

Definition at line 476 of file iso-2022-jp.c.

#define LOOPFCT   TO_LOOP

Definition at line 476 of file iso-2022-jp.c.

Definition at line 473 of file iso-2022-jp.c.

Definition at line 473 of file iso-2022-jp.c.

Definition at line 475 of file iso-2022-jp.c.

Definition at line 475 of file iso-2022-jp.c.

Definition at line 472 of file iso-2022-jp.c.

Definition at line 472 of file iso-2022-jp.c.

Definition at line 474 of file iso-2022-jp.c.

Definition at line 474 of file iso-2022-jp.c.

#define PREPARE_LOOP
Value:
enum direction dir = ((struct iso2022jp_data *) step->__data)->dir;         \
  enum variant var = ((struct iso2022jp_data *) step->__data)->var;         \
  int save_set;                                                             \
  int *setp = &data->__statep->__count;

Definition at line 61 of file iso-2022-jp.c.

#define REINIT_PARAMS
Value:
do                                       \
                              {                                      \
                                set = *setp & CURRENT_SEL_MASK;             \
                                set2 = *setp & CURRENT_ASSIGN_MASK;         \
                                tag = *setp & CURRENT_TAG_MASK;             \
                              }                                      \
                            while (0)

Definition at line 990 of file iso-2022-jp.c.

#define SAVE_RESET_STATE (   Save)
Value:
if (Save)                                                            \
    save_set = *setp;                                                       \
  else                                                               \
    *setp = save_set

Definition at line 251 of file iso-2022-jp.c.

#define TO_LOOP   to_iso2022jp_loop

Definition at line 51 of file iso-2022-jp.c.

#define TO_LOOP_MAX_NEEDED_FROM   4

Definition at line 57 of file iso-2022-jp.c.

#define TO_LOOP_MAX_NEEDED_TO   6

Definition at line 59 of file iso-2022-jp.c.

#define TO_LOOP_MIN_NEEDED_FROM   4

Definition at line 56 of file iso-2022-jp.c.

#define TO_LOOP_MIN_NEEDED_TO   1

Definition at line 58 of file iso-2022-jp.c.

#define UPDATE_PARAMS   *setp = set | set2

Definition at line 997 of file iso-2022-jp.c.

#define UPDATE_PARAMS   *setp = set | set2 | tag

Definition at line 997 of file iso-2022-jp.c.


Typedef Documentation

typedef unsigned int cvlist_t

Definition at line 459 of file iso-2022-jp.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
ASCII_set 
JISX0208_1978_set 
JISX0208_1983_set 
JISX0201_Roman_set 
JISX0201_Kana_set 
GB2312_set 
KSC5601_set 
JISX0212_set 
CURRENT_SEL_MASK 

Definition at line 95 of file iso-2022-jp.c.

{
  ASCII_set = 0,
  JISX0208_1978_set = 1 << 3,
  JISX0208_1983_set = 2 << 3,
  JISX0201_Roman_set = 3 << 3,
  JISX0201_Kana_set = 4 << 3,
  GB2312_set = 5 << 3,
  KSC5601_set = 6 << 3,
  JISX0212_set = 7 << 3,
  CURRENT_SEL_MASK = 7 << 3
};
anonymous enum
Enumerator:
UNSPECIFIED_set 
ISO88591_set 
ISO88597_set 
CURRENT_ASSIGN_MASK 

Definition at line 110 of file iso-2022-jp.c.

{
  UNSPECIFIED_set = 0,
  ISO88591_set = 1 << 6,
  ISO88597_set = 2 << 6,
  CURRENT_ASSIGN_MASK = 3 << 6
};
anonymous enum
Enumerator:
TAG_none 
TAG_language 
TAG_language_j 
TAG_language_ja 
TAG_language_k 
TAG_language_ko 
TAG_language_z 
TAG_language_zh 
CURRENT_TAG_MASK 

Definition at line 121 of file iso-2022-jp.c.

{
  TAG_none = 0,
  TAG_language = 4 << 8,
  TAG_language_j = 5 << 8,
  TAG_language_ja = 1 << 8,
  TAG_language_k = 6 << 8,
  TAG_language_ko = 2 << 8,
  TAG_language_z = 7 << 8,
  TAG_language_zh = 3 << 8,
  CURRENT_TAG_MASK = 7 << 8
};
enum conversion
Enumerator:
none 
european 
japanese 
chinese 
korean 
other 

Definition at line 456 of file iso-2022-jp.c.

enum direction
Enumerator:
illegal_dir 
to_iso2022jp 
from_iso2022jp 
illegal_dir 
to_iso646 
from_iso646 
illegal_dir 
to_unicode 
from_unicode 
illegal_dir 
to_utf16 
from_utf16 
illegal_dir 
to_utf32 
from_utf32 

Definition at line 70 of file iso-2022-jp.c.

enum variant
Enumerator:
illegal_var 
iso2022jp 
iso2022jp2 
illegal_var 
GB 
CA 
CA2 
DE 
DK 
ES 
ES2 
CN 
IT 
JP 
JP_OCR_B 
YU 
KR 
HU 
CU 
FR 
FR1 
NO 
NO2 
PT 
PT2 
SE 
SE2 
illegal_var 
UTF_16 
UTF_16LE 
UTF_16BE 
illegal_var 
UTF_32 
UTF_32LE 
UTF_32BE 

Definition at line 78 of file iso-2022-jp.c.


Function Documentation

void gconv_end ( struct __gconv_step data)

Definition at line 207 of file iso-2022-jp.c.

{
  free (data->__data);
}
int gconv_init ( struct __gconv_step step)

Definition at line 137 of file iso-2022-jp.c.

{
  /* Determine which direction.  */
  struct iso2022jp_data *new_data;
  enum direction dir = illegal_dir;
  enum variant var = illegal_var;
  int result;

  if (__strcasecmp (step->__from_name, "ISO-2022-JP//") == 0)
    {
      dir = from_iso2022jp;
      var = iso2022jp;
    }
  else if (__strcasecmp (step->__to_name, "ISO-2022-JP//") == 0)
    {
      dir = to_iso2022jp;
      var = iso2022jp;
    }
  else if (__strcasecmp (step->__from_name, "ISO-2022-JP-2//") == 0)
    {
      dir = from_iso2022jp;
      var = iso2022jp2;
    }
  else if (__strcasecmp (step->__to_name, "ISO-2022-JP-2//") == 0)
    {
      dir = to_iso2022jp;
      var = iso2022jp2;
    }

  result = __GCONV_NOCONV;
  if (__builtin_expect (dir, from_iso2022jp) != illegal_dir)
    {
      new_data
       = (struct iso2022jp_data *) malloc (sizeof (struct iso2022jp_data));

      result = __GCONV_NOMEM;
      if (new_data != NULL)
       {
         new_data->dir = dir;
         new_data->var = var;
         step->__data = new_data;

         if (dir == from_iso2022jp)
           {
             step->__min_needed_from = FROM_LOOP_MIN_NEEDED_FROM;
             step->__max_needed_from = FROM_LOOP_MAX_NEEDED_FROM;
             step->__min_needed_to = FROM_LOOP_MIN_NEEDED_TO;
             step->__max_needed_to = FROM_LOOP_MAX_NEEDED_TO;
           }
         else
           {
             step->__min_needed_from = TO_LOOP_MIN_NEEDED_FROM;
             step->__max_needed_from = TO_LOOP_MAX_NEEDED_FROM;
             step->__min_needed_to = TO_LOOP_MIN_NEEDED_TO;
             step->__max_needed_to = TO_LOOP_MAX_NEEDED_TO;
           }

         /* Yes, this is a stateful encoding.  */
         step->__stateful = 1;

         result = __GCONV_OK;
       }
    }

  return result;
}

Variable Documentation