Rizin
unix-like reverse engineering framework and cli tools
ebcdic.c File Reference

Go to the source code of this file.

Functions

IBM037
RZ_API int rz_str_ibm037_to_unicode (const ut8 src, RZ_NONNULL RZ_OUT RzRune *dst)
 Convert an ibm037 char into an unicode RzRune. More...
 
RZ_API int rz_str_ibm037_from_unicode (RZ_NONNULL RZ_OUT ut8 *dst, const RzRune src)
 Convert an unicode RzRune into an ibm037 char. More...
 
RZ_API int rz_str_ibm037_to_ascii (const ut8 src, RZ_NONNULL RZ_OUT ut8 *dst)
 Convert an ibm037 char into an ascii char. More...
 
RZ_API int rz_str_ibm037_from_ascii (RZ_NONNULL RZ_OUT ut8 *dst, const ut8 src)
 Convert an ascii char into an ibm037 char. More...
 
IBM290
RZ_API int rz_str_ibm290_to_unicode (const ut8 src, RZ_NONNULL RZ_OUT RzRune *dst)
 Convert an ibm290 char into an unicode RzRune. More...
 
RZ_API int rz_str_ibm290_from_unicode (RZ_NONNULL RZ_OUT ut8 *dst, const RzRune src)
 Convert an unicode RzRune into an ibm290 char. More...
 
RZ_API int rz_str_ibm290_to_ascii (const ut8 src, RZ_NONNULL RZ_OUT ut8 *dst)
 Convert an ibm290 char into an ascii char. More...
 
RZ_API int rz_str_ibm290_from_ascii (RZ_NONNULL RZ_OUT ut8 *dst, const ut8 src)
 Convert an ascii char into an ibm290 char. More...
 
EBCDIC-UK
RZ_API int rz_str_ebcdic_uk_to_unicode (const ut8 src, RZ_NONNULL RZ_OUT RzRune *dst)
 Convert an ebcdic_uk char into an unicode RzRune. More...
 
RZ_API int rz_str_ebcdic_uk_from_unicode (RZ_NONNULL RZ_OUT ut8 *dst, const RzRune src)
 Convert an unicode RzRune into an ebcdic_uk char. More...
 
RZ_API int rz_str_ebcdic_uk_to_ascii (const ut8 src, RZ_NONNULL RZ_OUT ut8 *dst)
 Convert an ebcdic_uk char into an ascii char. More...
 
RZ_API int rz_str_ebcdic_uk_from_ascii (RZ_NONNULL RZ_OUT ut8 *dst, const ut8 src)
 Convert an ascii char into an ebcdic_uk char. More...
 
EBCDIC-US
RZ_API int rz_str_ebcdic_us_to_unicode (const ut8 src, RZ_NONNULL RZ_OUT RzRune *dst)
 Convert an ebcdic_us char into an unicode RzRune. More...
 
RZ_API int rz_str_ebcdic_us_from_unicode (RZ_NONNULL RZ_OUT ut8 *dst, const RzRune src)
 Convert an unicode RzRune into an ebcdic_us char. More...
 
RZ_API int rz_str_ebcdic_us_to_ascii (const ut8 src, RZ_NONNULL RZ_OUT ut8 *dst)
 Convert an ebcdic_us char into an ascii char. More...
 
RZ_API int rz_str_ebcdic_us_from_ascii (RZ_NONNULL RZ_OUT ut8 *dst, const ut8 src)
 Convert an ascii char into an ebcdic_us char. More...
 
EBCDIC-ES
RZ_API int rz_str_ebcdic_es_to_unicode (const ut8 src, RZ_NONNULL RZ_OUT RzRune *dst)
 Convert an ebcdic_es char into an unicode RzRune. More...
 
RZ_API int rz_str_ebcdic_es_from_unicode (RZ_NONNULL RZ_OUT ut8 *dst, const RzRune src)
 Convert an unicode RzRune into an ebcdic_es char. More...
 
RZ_API int rz_str_ebcdic_es_to_ascii (const ut8 src, RZ_NONNULL RZ_OUT ut8 *dst)
 Convert an ebcdic_es char into an ascii char. More...
 
RZ_API int rz_str_ebcdic_es_from_ascii (RZ_NONNULL RZ_OUT ut8 *dst, const ut8 src)
 Convert an ascii char into an ebcdic char. More...
 

Variables

static const RzRune ibm037_to_uni [256]
 
static const ut8 ibm037_from_uni [256]
 
static const RzRune ibm290_to_uni [256]
 
static const ut8 ibm290_page00 [256]
 
static const ut8 ibm290_page30 [256]
 
static const RzRune ebcdic_uk_to_uni [256]
 
static const ut8 ebcdic_uk_from_uni [256]
 
static const RzRune ebcdic_us_to_uni [256]
 
static const ut8 ebcdic_us_from_uni [256]
 
static const RzRune ebcdic_es_to_uni [256]
 
static const ut8 ebcdic_es_page00 [256]
 
static const ut8 ebcdic_es_page20 [256]
 

Detailed Description

Function Documentation

◆ rz_str_ebcdic_es_from_ascii()

RZ_API int rz_str_ebcdic_es_from_ascii ( RZ_NONNULL RZ_OUT ut8 dst,
const ut8  src 
)

Convert an ascii char into an ebcdic char.

Definition at line 681 of file ebcdic.c.

681  {
684  return 1;
685 }
lzma_index * src
Definition: index.h:567
static const ut8 ebcdic_es_page00[256]
Definition: ebcdic.c:404
char * dst
Definition: lz4.h:724
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108

References dst, ebcdic_es_page00, rz_return_val_if_fail, and src.

◆ rz_str_ebcdic_es_from_unicode()

RZ_API int rz_str_ebcdic_es_from_unicode ( RZ_NONNULL RZ_OUT ut8 dst,
const RzRune  src 
)

Convert an unicode RzRune into an ebcdic_es char.

Definition at line 657 of file ebcdic.c.

657  {
659  if (src <= 0xff) {
661  return 1;
662  } else if (src >= 0x2000 && src <= 0x20ff) {
663  *dst = ebcdic_es_page20[src & 0xff];
664  return 1;
665  }
666  return 0;
667 }
static const ut8 ebcdic_es_page20[256]
Definition: ebcdic.c:439

References dst, ebcdic_es_page00, ebcdic_es_page20, rz_return_val_if_fail, and src.

◆ rz_str_ebcdic_es_to_ascii()

RZ_API int rz_str_ebcdic_es_to_ascii ( const ut8  src,
RZ_NONNULL RZ_OUT ut8 dst 
)

Convert an ebcdic_es char into an ascii char.

Definition at line 670 of file ebcdic.c.

670  {
673  if (c < 0x80) {
674  *dst = c;
675  return 1;
676  }
677  return 0;
678 }
static const RzRune ebcdic_es_to_uni[256]
Definition: ebcdic.c:369
uint8_t ut8
Definition: lh5801.h:11
#define c(i)
Definition: sha256.c:43

References c, dst, ebcdic_es_to_uni, rz_return_val_if_fail, and src.

◆ rz_str_ebcdic_es_to_unicode()

RZ_API int rz_str_ebcdic_es_to_unicode ( const ut8  src,
RZ_NONNULL RZ_OUT RzRune dst 
)

Convert an ebcdic_es char into an unicode RzRune.

Definition at line 650 of file ebcdic.c.

650  {
653  return 1;
654 }

References dst, ebcdic_es_to_uni, rz_return_val_if_fail, and src.

Referenced by process_one_string(), and rz_str_stringify_raw_buffer().

◆ rz_str_ebcdic_uk_from_ascii()

RZ_API int rz_str_ebcdic_uk_from_ascii ( RZ_NONNULL RZ_OUT ut8 dst,
const ut8  src 
)

Convert an ascii char into an ebcdic_uk char.

Definition at line 591 of file ebcdic.c.

591  {
594  return 1;
595 }
static const ut8 ebcdic_uk_from_uni[256]
Definition: ebcdic.c:264

References dst, ebcdic_uk_from_uni, rz_return_val_if_fail, and src.

◆ rz_str_ebcdic_uk_from_unicode()

RZ_API int rz_str_ebcdic_uk_from_unicode ( RZ_NONNULL RZ_OUT ut8 dst,
const RzRune  src 
)

Convert an unicode RzRune into an ebcdic_uk char.

Definition at line 570 of file ebcdic.c.

570  {
572  if (src <= 0xff) {
574  return 1;
575  }
576  return 0;
577 }

References dst, ebcdic_uk_from_uni, rz_return_val_if_fail, and src.

◆ rz_str_ebcdic_uk_to_ascii()

RZ_API int rz_str_ebcdic_uk_to_ascii ( const ut8  src,
RZ_NONNULL RZ_OUT ut8 dst 
)

Convert an ebcdic_uk char into an ascii char.

Definition at line 580 of file ebcdic.c.

580  {
583  if (c < 0x80) {
584  *dst = c;
585  return 1;
586  }
587  return 0;
588 }
static const RzRune ebcdic_uk_to_uni[256]
Definition: ebcdic.c:229

References c, dst, ebcdic_uk_to_uni, rz_return_val_if_fail, and src.

◆ rz_str_ebcdic_uk_to_unicode()

RZ_API int rz_str_ebcdic_uk_to_unicode ( const ut8  src,
RZ_NONNULL RZ_OUT RzRune dst 
)

Convert an ebcdic_uk char into an unicode RzRune.

Definition at line 563 of file ebcdic.c.

563  {
566  return 1;
567 }

References dst, ebcdic_uk_to_uni, rz_return_val_if_fail, and src.

Referenced by process_one_string(), and rz_str_stringify_raw_buffer().

◆ rz_str_ebcdic_us_from_ascii()

RZ_API int rz_str_ebcdic_us_from_ascii ( RZ_NONNULL RZ_OUT ut8 dst,
const ut8  src 
)

Convert an ascii char into an ebcdic_us char.

Definition at line 635 of file ebcdic.c.

635  {
638  return 1;
639 }
static const ut8 ebcdic_us_from_uni[256]
Definition: ebcdic.c:334

References dst, ebcdic_us_from_uni, rz_return_val_if_fail, and src.

◆ rz_str_ebcdic_us_from_unicode()

RZ_API int rz_str_ebcdic_us_from_unicode ( RZ_NONNULL RZ_OUT ut8 dst,
const RzRune  src 
)

Convert an unicode RzRune into an ebcdic_us char.

Definition at line 614 of file ebcdic.c.

614  {
616  if (src <= 0xff) {
618  return 1;
619  }
620  return 0;
621 }

References dst, ebcdic_us_from_uni, rz_return_val_if_fail, and src.

◆ rz_str_ebcdic_us_to_ascii()

RZ_API int rz_str_ebcdic_us_to_ascii ( const ut8  src,
RZ_NONNULL RZ_OUT ut8 dst 
)

Convert an ebcdic_us char into an ascii char.

Definition at line 624 of file ebcdic.c.

624  {
627  if (c < 0x80) {
628  *dst = c;
629  return 1;
630  }
631  return 0;
632 }
static const RzRune ebcdic_us_to_uni[256]
Definition: ebcdic.c:299

References c, dst, ebcdic_us_to_uni, rz_return_val_if_fail, and src.

◆ rz_str_ebcdic_us_to_unicode()

RZ_API int rz_str_ebcdic_us_to_unicode ( const ut8  src,
RZ_NONNULL RZ_OUT RzRune dst 
)

Convert an ebcdic_us char into an unicode RzRune.

Definition at line 607 of file ebcdic.c.

607  {
610  return 1;
611 }

References dst, ebcdic_us_to_uni, rz_return_val_if_fail, and src.

Referenced by process_one_string(), and rz_str_stringify_raw_buffer().

◆ rz_str_ibm037_from_ascii()

RZ_API int rz_str_ibm037_from_ascii ( RZ_NONNULL RZ_OUT ut8 dst,
const ut8  src 
)

Convert an ascii char into an ibm037 char.

Parameters
dstibm037 char
srcascii char

Definition at line 500 of file ebcdic.c.

500  {
502  *dst = ibm037_from_uni[src];
503  return 1;
504 }
static const ut8 ibm037_from_uni[256]
Definition: ebcdic.c:57

References dst, ibm037_from_uni, rz_return_val_if_fail, and src.

◆ rz_str_ibm037_from_unicode()

RZ_API int rz_str_ibm037_from_unicode ( RZ_NONNULL RZ_OUT ut8 dst,
const RzRune  src 
)

Convert an unicode RzRune into an ibm037 char.

Parameters
dstibm037 char
srcunicode RzRune

Definition at line 469 of file ebcdic.c.

469  {
471  if (src <= 0xff) {
472  *dst = ibm037_from_uni[src];
473  return 1;
474  }
475  return 0;
476 }

References dst, ibm037_from_uni, rz_return_val_if_fail, and src.

◆ rz_str_ibm037_to_ascii()

RZ_API int rz_str_ibm037_to_ascii ( const ut8  src,
RZ_NONNULL RZ_OUT ut8 dst 
)

Convert an ibm037 char into an ascii char.

Parameters
dstibm037 char
srcascii char

Definition at line 484 of file ebcdic.c.

484  {
486  ut8 c = ibm037_to_uni[src];
487  if (c < 0x80) {
488  *dst = c;
489  return 1;
490  }
491  return 0;
492 }
static const RzRune ibm037_to_uni[256]
Definition: ebcdic.c:22

References c, dst, ibm037_to_uni, rz_return_val_if_fail, and src.

◆ rz_str_ibm037_to_unicode()

RZ_API int rz_str_ibm037_to_unicode ( const ut8  src,
RZ_NONNULL RZ_OUT RzRune dst 
)

Convert an ibm037 char into an unicode RzRune.

Parameters
srcibm037 char
dstunicode RzRune
Return values
0if dst is null
1if convert successful

Definition at line 457 of file ebcdic.c.

457  {
459  *dst = ibm037_to_uni[src];
460  return 1;
461 }

References dst, ibm037_to_uni, rz_return_val_if_fail, and src.

Referenced by process_one_string(), rz_scan_strings_raw(), and rz_str_stringify_raw_buffer().

◆ rz_str_ibm290_from_ascii()

RZ_API int rz_str_ibm290_from_ascii ( RZ_NONNULL RZ_OUT ut8 dst,
const ut8  src 
)

Convert an ascii char into an ibm290 char.

Definition at line 547 of file ebcdic.c.

547  {
549  *dst = ibm290_page00[src];
550  return 1;
551 }
static const ut8 ibm290_page00[256]
Definition: ebcdic.c:127

References dst, ibm290_page00, rz_return_val_if_fail, and src.

◆ rz_str_ibm290_from_unicode()

RZ_API int rz_str_ibm290_from_unicode ( RZ_NONNULL RZ_OUT ut8 dst,
const RzRune  src 
)

Convert an unicode RzRune into an ibm290 char.

Definition at line 523 of file ebcdic.c.

523  {
525  if (src <= 0xff) {
526  *dst = ibm290_page00[src];
527  return 1;
528  } else if (src >= 0x3000 && src <= 0x30ff) {
529  *dst = ibm290_page30[src & 0xff];
530  return 1;
531  }
532  return 0;
533 }
static const ut8 ibm290_page30[256]
Definition: ebcdic.c:162

References dst, ibm290_page00, ibm290_page30, rz_return_val_if_fail, and src.

◆ rz_str_ibm290_to_ascii()

RZ_API int rz_str_ibm290_to_ascii ( const ut8  src,
RZ_NONNULL RZ_OUT ut8 dst 
)

Convert an ibm290 char into an ascii char.

Definition at line 536 of file ebcdic.c.

536  {
538  ut8 c = ibm290_to_uni[src];
539  if (c < 0x80) {
540  *dst = c;
541  return 1;
542  }
543  return 0;
544 }
static const RzRune ibm290_to_uni[256]
Definition: ebcdic.c:92

References c, dst, ibm290_to_uni, rz_return_val_if_fail, and src.

◆ rz_str_ibm290_to_unicode()

RZ_API int rz_str_ibm290_to_unicode ( const ut8  src,
RZ_NONNULL RZ_OUT RzRune dst 
)

Convert an ibm290 char into an unicode RzRune.

Definition at line 516 of file ebcdic.c.

516  {
518  *dst = ibm290_to_uni[src];
519  return 1;
520 }

References dst, ibm290_to_uni, rz_return_val_if_fail, and src.

Referenced by process_one_string(), and rz_str_stringify_raw_buffer().

Variable Documentation

◆ ebcdic_es_page00

const ut8 ebcdic_es_page00[256]
static

Definition at line 404 of file ebcdic.c.

Referenced by rz_str_ebcdic_es_from_ascii(), and rz_str_ebcdic_es_from_unicode().

◆ ebcdic_es_page20

const ut8 ebcdic_es_page20[256]
static
Initial value:
= {
[0xa7] = 0x5b,
}

Definition at line 439 of file ebcdic.c.

Referenced by rz_str_ebcdic_es_from_unicode().

◆ ebcdic_es_to_uni

const RzRune ebcdic_es_to_uni[256]
static

Definition at line 369 of file ebcdic.c.

Referenced by rz_str_ebcdic_es_to_ascii(), and rz_str_ebcdic_es_to_unicode().

◆ ebcdic_uk_from_uni

const ut8 ebcdic_uk_from_uni[256]
static

Definition at line 264 of file ebcdic.c.

Referenced by rz_str_ebcdic_uk_from_ascii(), and rz_str_ebcdic_uk_from_unicode().

◆ ebcdic_uk_to_uni

const RzRune ebcdic_uk_to_uni[256]
static

Definition at line 229 of file ebcdic.c.

Referenced by rz_str_ebcdic_uk_to_ascii(), and rz_str_ebcdic_uk_to_unicode().

◆ ebcdic_us_from_uni

const ut8 ebcdic_us_from_uni[256]
static

Definition at line 334 of file ebcdic.c.

Referenced by rz_str_ebcdic_us_from_ascii(), and rz_str_ebcdic_us_from_unicode().

◆ ebcdic_us_to_uni

const RzRune ebcdic_us_to_uni[256]
static

Definition at line 299 of file ebcdic.c.

Referenced by rz_str_ebcdic_us_to_ascii(), and rz_str_ebcdic_us_to_unicode().

◆ ibm037_from_uni

const ut8 ibm037_from_uni[256]
static

Definition at line 57 of file ebcdic.c.

Referenced by rz_str_ibm037_from_ascii(), and rz_str_ibm037_from_unicode().

◆ ibm037_to_uni

const RzRune ibm037_to_uni[256]
static

Definition at line 22 of file ebcdic.c.

Referenced by rz_str_ibm037_to_ascii(), and rz_str_ibm037_to_unicode().

◆ ibm290_page00

const ut8 ibm290_page00[256]
static

Definition at line 127 of file ebcdic.c.

Referenced by rz_str_ibm290_from_ascii(), and rz_str_ibm290_from_unicode().

◆ ibm290_page30

const ut8 ibm290_page30[256]
static

Definition at line 162 of file ebcdic.c.

Referenced by rz_str_ibm290_from_unicode().

◆ ibm290_to_uni

const RzRune ibm290_to_uni[256]
static

Definition at line 92 of file ebcdic.c.

Referenced by rz_str_ibm290_to_ascii(), and rz_str_ibm290_to_unicode().