home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxusmp.zip / tests2s.c < prev    next >
Text File  |  1993-10-21  |  1KB  |  60 lines

  1.  
  2. /* This program builds a structure in shared memory and starts */
  3. /* a Rexx program which accesses the elements of this structure */
  4.  
  5. #define INCL_DOS
  6. #include <os2.h>
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <rexxsaa.h>
  10.  
  11. #pragma pack(1)
  12. struct _mystruct
  13.   {
  14.   ULONG  ulOne;
  15.   UCHAR  uchTwo[35];
  16.   SHORT  sThree;
  17.   double dFour;
  18.   UCHAR  uchFive[10];
  19.   };
  20. #pragma pack()
  21. typedef struct _mystruct MYSTRUCT, *PMYSTRUCT;
  22.  
  23. void main(void)
  24.  
  25. {
  26.  
  27.   PMYSTRUCT pbuf;
  28.   APIRET    rc;
  29.  
  30.   rc = DosAllocSharedMem((PPVOID)&pbuf,"\\SHAREMEM\\SOMEMEM",4096,
  31.                          PAG_COMMIT | PAG_WRITE);
  32.   if (rc)
  33.     {
  34.     printf("DosAllocSharedMem failed with rc = %ld\n",rc);
  35.     return;
  36.     }
  37.  
  38.   pbuf->ulOne = sizeof(MYSTRUCT);
  39.   strcpy(pbuf->uchTwo,"Some test data from TESTS2S.C");
  40.   pbuf->sThree = -24365;
  41.   pbuf->dFour = 6.3e5;
  42.   sprintf(pbuf->uchFive,"0x%08x",pbuf);
  43.  
  44.   printf("Shared memory '\\SHAREMEM\\SOMEMEM' has been set\n");
  45.   system("start /c tests2s.cmd \\SHAREMEM\\SOMEMEM");
  46.   system("pause");
  47.  
  48.   printf("Structure as set by tests2s.cmd:\n");
  49.   printf("ulOne = %ld\n",pbuf->ulOne);
  50.   printf("uchTwo = '%.*s'\n",sizeof(pbuf->uchTwo),pbuf->uchTwo);
  51.   printf("sThree = %d\n",pbuf->sThree);
  52.   printf("dFour = %f\n",pbuf->dFour);
  53.   printf("uchFive = '%.*s'\n",sizeof(pbuf->uchFive),pbuf->uchFive);
  54.  
  55.   DosFreeMem(pbuf);
  56.  
  57.   return;
  58.  
  59. }
  60.