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>
31 lines
545 B
C
31 lines
545 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.
|
|
*
|
|
*/
|
|
|
|
#include "ebcdic.h"
|
|
|
|
|
|
/*
|
|
* Convert ebcdic string to number with given base
|
|
*/
|
|
unsigned long ebcdic_strtoul(char *nptr, char **endptr, int base)
|
|
{
|
|
unsigned long val = 0;
|
|
|
|
while (ebcdic_isdigit(*nptr)) {
|
|
if (val != 0)
|
|
val *= base;
|
|
val += *nptr - 0xf0;
|
|
nptr++;
|
|
}
|
|
if (endptr)
|
|
*endptr = (char *)nptr;
|
|
return val;
|
|
}
|