Files
s390-tools/zipl/boot/ebcdic.c
Marc Hartmayer a37170b8be zipl: refactor all EBCDIC code into separate files
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>
2020-03-16 13:39:10 +01:00

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;
}