[PATCH] powerpc: Add strne2a() to convert a string from EBCDIC to ASCII
authorMichael Ellerman <michael@ellerman.id.au>
Tue, 21 Mar 2006 09:46:08 +0000 (20:46 +1100)
committerPaul Mackerras <paulus@samba.org>
Wed, 22 Mar 2006 04:04:25 +0000 (15:04 +1100)
Add strne2a() which converts a string from EBCDIC to ASCII.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/lib/e2a.c
include/asm-powerpc/system.h

index 4f88f4cc21e84ff88a81fd8d3ebd0292e48c611b..4b72ed8fd50e1da6325f9634ac705f73ebf93791 100644 (file)
@@ -103,4 +103,14 @@ unsigned char e2a(unsigned char x)
 }
 EXPORT_SYMBOL(e2a);
 
+unsigned char* strne2a(unsigned char *dest, const unsigned char *src, size_t n)
+{
+       int i;
+
+       n = strnlen(src, n);
 
+       for (i = 0; i < n; i++)
+               dest[i] = e2a(src[i]);
+
+       return dest;
+}
index 41b7a5b3d701adca739fe90bd6e3c938398535e8..65f5a7b2646b1ed590ec45acb7a596eb7f170706 100644 (file)
@@ -171,6 +171,8 @@ extern u32 booke_wdt_period;
 
 /* EBCDIC -> ASCII conversion for [0-9A-Z] on iSeries */
 extern unsigned char e2a(unsigned char);
+extern unsigned char* strne2a(unsigned char *dest,
+               const unsigned char *src, size_t n);
 
 struct device_node;
 extern void note_scsi_host(struct device_node *, void *);