©2004 by Marc J. Rochkind. All rights reserved. Portions marked "Open Source" may be copied under license.

 

Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ux/uxsysvipc.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2003 by Marc J. Rochkind. All rights reserved.
00003     May be copied only for purposes and under conditions described
00004     on the Web page www.basepath.com/aup/copyright.htm.
00005 
00006     The Example Files are provided "as is," without any warranty;
00007     without even the implied warranty of merchantability or fitness
00008     for a particular purpose. The author and his publisher are not
00009     responsible for any damages, direct or incidental, resulting
00010     from the use or non-use of these Example Files.
00011 
00012     The Example Files may contain defects, and some contain deliberate
00013     coding mistakes that were included for educational reasons.
00014     You are responsible for determining if and how the Example Files
00015     are to be used.
00016 
00017 */
00018 #ifndef _UXSYSVIPC_HPP_
00019 #define _UXSYSVIPC_HPP_
00020 
00021 #include <sys/ipc.h>
00022 #include <sys/msg.h>
00023 #include <sys/shm.h>
00024 #include <sys/sem.h>
00025 
00026 namespace Ux {
00027 
00028 /**
00029     \ingroup Ux
00030 */
00031 class SysVIPC : public Base {
00032 protected:
00033     int id;
00034 
00035 public:
00036     SysVIPC(int n = -1)
00037         : id(n)
00038         {  }
00039     static key_t ftok(const char *path, int id);
00040     operator int()
00041         { return id; }
00042 };
00043 
00044 /**
00045     \ingroup Ux
00046 */
00047 class SysVMsg : public SysVIPC {
00048 public:
00049     void    get(key_t key, int flags = IPC_CREAT | PERM_FILE);
00050     void    ctl(int cmd, struct msqid_ds *data = NULL);
00051     void    snd(const void *msgp, size_t msgsize, int flags = 0);
00052     ssize_t rcv(void *msgp, size_t mtextsize, long msgtype = 0, int flags = 0);
00053 };
00054 
00055 /**
00056     \ingroup Ux
00057 */
00058 class SysVShm : public SysVIPC {
00059 public:
00060     void    get(key_t key, size_t size, int flags = IPC_CREAT | PERM_FILE);
00061     void    ctl(int cmd, struct shmid_ds *data = NULL);
00062     void *  at(const void *shmaddr = NULL, int flags = 0);
00063     void    dt(const void *shmaddr);
00064 };
00065 
00066 /**
00067     \ingroup Ux
00068     Union defined by SUS, but not in any standard header.
00069 */
00070 union semun {
00071     int val;
00072     struct semid_ds *buf;
00073     unsigned short *array;
00074 };
00075 
00076 /**
00077     \ingroup Ux
00078 */
00079 class SysVSem : public SysVIPC {
00080 public:
00081     void    get(key_t key, int nsems, int flags = IPC_CREAT | PERM_FILE);
00082     int     ctl(int semnum, int cmd, union semun arg);
00083     void    op(struct sembuf *sops, size_t nsops);
00084 };
00085 
00086 } // namespace
00087 
00088 #endif // _UXSYSVIPC_HPP_

Generated on Fri Apr 23 10:57:06 2004 for AUP2 Example Source by doxygen 1.3.1