e2a.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * EBCDIC to ASCII conversion
  3. *
  4. * This function moved here from arch/powerpc/platforms/iseries/viopath.c
  5. *
  6. * (C) Copyright 2000-2004 IBM Corporation
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of the
  11. * License, or (at your option) anyu later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software Foundation,
  20. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <linux/module.h>
  24. unsigned char e2a(unsigned char x)
  25. {
  26. switch (x) {
  27. case 0xF0:
  28. return '0';
  29. case 0xF1:
  30. return '1';
  31. case 0xF2:
  32. return '2';
  33. case 0xF3:
  34. return '3';
  35. case 0xF4:
  36. return '4';
  37. case 0xF5:
  38. return '5';
  39. case 0xF6:
  40. return '6';
  41. case 0xF7:
  42. return '7';
  43. case 0xF8:
  44. return '8';
  45. case 0xF9:
  46. return '9';
  47. case 0xC1:
  48. return 'A';
  49. case 0xC2:
  50. return 'B';
  51. case 0xC3:
  52. return 'C';
  53. case 0xC4:
  54. return 'D';
  55. case 0xC5:
  56. return 'E';
  57. case 0xC6:
  58. return 'F';
  59. case 0xC7:
  60. return 'G';
  61. case 0xC8:
  62. return 'H';
  63. case 0xC9:
  64. return 'I';
  65. case 0xD1:
  66. return 'J';
  67. case 0xD2:
  68. return 'K';
  69. case 0xD3:
  70. return 'L';
  71. case 0xD4:
  72. return 'M';
  73. case 0xD5:
  74. return 'N';
  75. case 0xD6:
  76. return 'O';
  77. case 0xD7:
  78. return 'P';
  79. case 0xD8:
  80. return 'Q';
  81. case 0xD9:
  82. return 'R';
  83. case 0xE2:
  84. return 'S';
  85. case 0xE3:
  86. return 'T';
  87. case 0xE4:
  88. return 'U';
  89. case 0xE5:
  90. return 'V';
  91. case 0xE6:
  92. return 'W';
  93. case 0xE7:
  94. return 'X';
  95. case 0xE8:
  96. return 'Y';
  97. case 0xE9:
  98. return 'Z';
  99. }
  100. return ' ';
  101. }
  102. EXPORT_SYMBOL(e2a);
  103. unsigned char* strne2a(unsigned char *dest, const unsigned char *src, size_t n)
  104. {
  105. int i;
  106. n = strnlen(src, n);
  107. for (i = 0; i < n; i++)
  108. dest[i] = e2a(src[i]);
  109. return dest;
  110. }