home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / emx / test / msgtest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-23  |  1.2 KB  |  51 lines

  1. /* msg.c (emx+gcc) */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #define INCL_DOSMISC
  7. #include <os2.h>
  8.  
  9. int main (int argc, char *argv[])
  10. {
  11.   ULONG rc, len;
  12.   char text[512];
  13.   unsigned char buf[512];
  14.   int i, j;
  15.   USHORT count, codepage;
  16.   ULONG lang;
  17.  
  18.   rc = DosGetMessage (argv, 1, text, sizeof (text), 1, "msgtest.msg", &len);
  19.   if (rc != 0)
  20.     {
  21.       fprintf (stderr, "DosGetMessage failed, rc=%lu\n", rc);
  22.       return (1);
  23.     }
  24.   if (len >= sizeof (text))
  25.     --len;
  26.   text[len] = 0;
  27.   puts (text);
  28. #if 0                           /* does not work */
  29.   rc = DosQueryMessageCP (buf, sizeof (buf), "msgtest.msg", &len);
  30.   if (rc != 0)
  31.     {
  32.       fprintf (stderr, "DosQueryMessageCP failed, rc=%lu\n", rc);
  33.       return (1);
  34.     }
  35.   i = 0;
  36.   while (i < len)
  37.     {
  38.       count = *(USHORT *)&buf[i]; i += sizeof (USHORT);
  39.       printf ("Code pages:");
  40.       for (j = 0; j < count; ++j)
  41.         {
  42.           codepage = *(USHORT *)&buf[i]; i += sizeof (USHORT);
  43.           printf (" %d", codepage);
  44.         }
  45.       lang = *(ULONG *)&buf[i]; i += sizeof (ULONG);
  46.       printf (" language=%lu\n", lang);
  47.     }
  48. #endif
  49.   return (0);
  50. }
  51.