mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
This allows the reuse of the code later in sclp.c. While at it, also declare @source parameter of `ebcdic_to_ascii` function as `const` and rename all `ebc_` function name prefixes into `ebcdic_`. Move conversion tables to separate file so it only gets linked into loaders that need it. Reviewed-by: Philipp Rudo <prudo@linux.ibm.com> Reviewed-by: Stefan Haberland <sth@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
46 lines
915 B
C
46 lines
915 B
C
/*
|
|
* EBCDIC specific functions
|
|
*
|
|
* Copyright IBM Corp. 2013, 2020
|
|
*
|
|
* s390-tools is free software; you can redistribute it and/or modify
|
|
* it under the terms of the MIT license. See LICENSE for details.
|
|
*
|
|
*/
|
|
|
|
#ifndef EBCDIC_H
|
|
#define EBCDIC_H
|
|
|
|
#include "lib/zt_common.h"
|
|
|
|
|
|
#ifndef __ASSEMBLER__
|
|
|
|
unsigned long ebcdic_strtoul(char *, char **, int);
|
|
|
|
static __always_inline int ecbdic_isspace(char c)
|
|
{
|
|
return (c == 0x40) || (c == 0x05) || (c == 0x15) || (c == 0x25) ||
|
|
(c == 0x0b) || (c == 0x0c) || (c == 0x0d);
|
|
}
|
|
|
|
static __always_inline int ebcdic_isdigit(char c)
|
|
{
|
|
return (c >= 0xf0) && (c <= 0xf9);
|
|
}
|
|
|
|
static __always_inline int ebcdic_isupper(char c)
|
|
{
|
|
return (c >= 0xC1 && c <= 0xC9) || (c >= 0xD1 && c <= 0xD9) ||
|
|
(c >= 0xE2 && c <= 0xE9);
|
|
}
|
|
|
|
static __always_inline char ebcdic_tolower(char c)
|
|
{
|
|
if (ebcdic_isupper(c))
|
|
c -= 0x40;
|
|
return c;
|
|
}
|
|
#endif /* __ASSEMBLER__ */
|
|
#endif /* EBCDIC_H */
|