TestShm.cpp



/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 2 -*- */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include <shm.hpp>

int main(int argc, char *argv[])
{
  if(argc<2)
  {
    puts("\nUSE:\nTestShm <type>\n");
    puts("types:");
    puts("\tread <id>");
    puts("\twrite <id> <cadena>\n");
    puts("\t  e.g.");
    puts("\t    TestShm read 13 => Reads from the id '13' shared memory segment.");
    puts("\t    TestShm write 13 \"Hello world\" => Sends 'Hello world' to the id '13' shared memory segment.\n");

    exit(EXIT_SUCCESS);
  }

  if(strcmp(argv[1],"read")==0)
  {
    CMShm here(atoi(argv[2]),1024);
    char *buffer;
    buffer = (char *)malloc(sizeof(char) * 1024);
    here.read(buffer);
    printf("%s\n",buffer);
    free(buffer);
  }

  if(strcmp(argv[1],"write")==0)
  {
    CMShm here(atoi(argv[2]),1024);
    here.write(argv[3]);
  }

}
 All Data Structures Functions Variables
Generated on Mon Sep 12 07:59:09 2011 for API MokArdu by  doxygen 1.6.3