#include <stdio.h>
#include <string.h>
#include "sharedmem.hh"
Include dependency graph for testshm.cc:
Go to the source code of this file.
Defines | |
#define | BUFFERSIZE 256 |
Functions | |
int | main (int argc, char **argv) |
|
|
|
Definition at line 15 of file testshm.cc. 00017 { 00018 RCS_SHAREDMEM *shm; 00019 00020 #if defined (VXWORKS) 00021 shm = 00022 new RCS_SHAREDMEM (0x100, 256, 00023 create ? RCS_SHAREDMEM_CREATE : RCS_SHAREDMEM_NOCREATE, 00024 0664); 00025 #else 00026 if (argc > 1) 00027 { 00028 /* any cmd line args mean this is the sharedmem creator */ 00029 shm = new RCS_SHAREDMEM (0x100, 256, RCS_SHAREDMEM_CREATE, 0664); 00030 } 00031 else 00032 { 00033 shm = new RCS_SHAREDMEM (0x100, 256, RCS_SHAREDMEM_NOCREATE); 00034 } 00035 #endif 00036 00037 if (shm->addr == NULL) 00038 { 00039 printf ("can't create shared memory-- exiting\n"); 00040 return 1; 00041 } 00042 00043 /* run give and take, interactively */ 00044 while (!feof (stdin)) 00045 { 00046 #define BUFFERSIZE 256 00047 char buf[BUFFERSIZE]; 00048 fputs ("r, w, or q? ", stdout); 00049 fgets (buf, BUFFERSIZE, stdin); 00050 00051 if (buf[0] == 'q') 00052 break; 00053 if (buf[0] == 'r') 00054 { 00055 printf ("%s\n", shm->addr); 00056 } 00057 if (buf[0] == 'w') 00058 { 00059 printf ("what string? "); 00060 scanf ("%s", buf); 00061 strcpy ((char *) shm->addr, buf); 00062 } 00063 } 00064 00065 delete shm; 00066 return 0; 00067 } |