home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mmpm21tk.zip / TK / CASECONV / CONVCONV.C next >
C/C++ Source or Header  |  1993-04-05  |  7KB  |  131 lines

  1. /*static char *SCCSID = "@(#)convconv.c    13.2 92/01/23";*/
  2. #pragma title ("CONVCONV.C - Case Converter Example Routines")
  3.  
  4. /********************** START OF SPECIFICATIONS *****************************/
  5. /*                                                                          */
  6. /* SOURCE FILE NAME: CONVCONV.C                                             */
  7. /*                                                                          */
  8. /* DESCRIPTIVE NAME: CONV converter Procedure Example Routines.             */
  9. /*                                                                          */
  10. /* COPYRIGHT:                                                               */
  11. /*                  Copyright (c) IBM Corporation  1992, 1993               */
  12. /*                         All Rights Reserved                              */
  13. /*                                                                          */
  14. /* STATUS: OS/2 MM Release 1.10                                             */
  15. /*                                                                          */
  16. /* FUNCTION: This module contains case conversion routines for the          */
  17. /*           File Format I/O Procedure.                                     */
  18. /*                                                                          */
  19. /* NOTES:                                                                   */
  20. /*    DEPENDENCIES: NONE                                                    */
  21. /*    RESTRICTIONS: Runs in protect mode only                               */
  22. /*                                                                          */
  23. /* ENTRY POINTS:                                                            */
  24. /*                                                                          */
  25. /*   ROUTINES: convhlpToUpper                                               */
  26. /*             convhlpToLower                                               */
  27. /*                                                                          */
  28. /* EXTERNAL REFERENCES:                                                     */
  29. /*                                                                          */
  30. /* MODIFICATION HISTORY:                                                    */
  31. /* DATE      DEVELOPER         CHANGE DESCRIPTION                           */
  32. /* 09/30/91  JWO               Creation.                                    */
  33. /*                                                                          */
  34. /*********************** END OF SPECIFICATIONS ******************************/
  35.  
  36. #define INCL_NOPMAPI                   // no PM include files required
  37. #define INCL_DOSRESOURCES
  38. #define INCL_CONVPROC                  // use only include CONV proc info
  39.  
  40. #include <os2.h>
  41. #include <mmioos2.h>                   // mmio standard defines/prototypes
  42. #include "convproc.h"                  // header for CONV procedure
  43.  
  44. #pragma subtitle ("convhlpToUpper - Convert text to upper case.")
  45. #pragma page ()
  46.  
  47. /****************************************************************************
  48.  *  This routine will accept a NULL terminated buffer of characters and     *
  49.  *  convert them to upper case characters.  The characters are mapped to    *
  50.  *  the characters in the szMap  array by their ASCII value.  Therefore,    *
  51.  *  the uppercase ASCII chars are where the lowercase ASCII chars are.      *
  52.  *  All the other characters are left to be their normal ASCII value.       *
  53.  ****************************************************************************/
  54.  
  55. VOID APIENTRY convhlpToUpper( PUCHAR psz )
  56. {
  57.    static CHAR szMap[]  =
  58.       {
  59.        0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17,
  60.       18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, ' ', '!',
  61.       '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.',
  62.       '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
  63.       ':', ';', '<', '=', '>', '?', '@',
  64.       'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
  65.       'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
  66.       '[', '\\', ']', '^', '_', '`',
  67.       'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
  68.       'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
  69.       '{', '|', '}', '~', 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
  70.       137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
  71.       151, 152, 153, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 162,
  72.       163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
  73.       177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190,
  74.       191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
  75.       205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
  76.       219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232,
  77.       233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246,
  78.       247, 248, 249, 250, 251, 252, 253, 254, 255
  79.       };
  80.  
  81.    while (*psz)
  82.       {
  83.       *psz = *(szMap  + (*psz));
  84.       psz++;
  85.       }
  86. }
  87.  
  88. #pragma subtitle ("convhlpToLower - Convert text to lower case.")
  89. #pragma page ()
  90.  
  91. /****************************************************************************
  92.  *  This routine will accept a NULL terminated buffer of characters and     *
  93.  *  convert them to lower case characters.  The characters are mapped to    *
  94.  *  the characters in the szMap  array by their ASCII value.  Therefore,    *
  95.  *  the lowercase ASCII chars are where the uppercase ASCII chars are.      *
  96.  *  All the other characters are left to be their normal ASCII value.       *
  97.  ****************************************************************************/
  98.  
  99. VOID APIENTRY convhlpToLower( PUCHAR psz )
  100. {
  101.    static CHAR szMap[]  =
  102.       {
  103.        0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17,
  104.       18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, ' ', '!',
  105.       '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.',
  106.       '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
  107.       ':', ';', '<', '=', '>', '?', '@',
  108.       'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
  109.       'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
  110.       '[', '\\', ']', '^', '_', '`',
  111.       'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
  112.       'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
  113.       '{', '|', '}', '~', 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
  114.       137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
  115.       151, 152, 153, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 162,
  116.       163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
  117.       177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190,
  118.       191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
  119.       205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
  120.       219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232,
  121.       233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246,
  122.       247, 248, 249, 250, 251, 252, 253, 254, 255
  123.       };
  124.  
  125.    while (*psz)
  126.       {
  127.       *psz = *(szMap  + (*psz));
  128.       psz++;
  129.       }
  130. }
  131.