00001 #ifndef foointernalhfoo 00002 #define foointernalhfoo 00003 00004 /* $Id: internal.h,v 1.3 2003/09/09 22:14:58 poettering Exp $ 00005 * 00006 * This file is part of libshbuf. 00007 * 00008 * libshbuf is free software; you can redistribute it and/or modify it under 00009 * the terms of the GNU General Public License as published by the Free 00010 * Software Foundation; either version 2 of the License, or (at your 00011 * option) any later version. 00012 * 00013 * libshbuf is distributed in the hope that it will be useful, but WITHOUT 00014 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00015 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00016 * for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with libshbuf; if not, write to the Free Software Foundation, 00020 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00021 */ 00022 00023 #include <sys/types.h> 00024 #include <sys/ipc.h> 00025 #include <sys/sem.h> 00026 #include <sys/shm.h> 00027 #include <sys/msg.h> 00028 #include <pthread.h> 00029 00030 typedef struct { 00031 unsigned int id; 00032 00033 // The following id may not be endian safe. But who cares? The ID 00034 // is not exchanged between machines, so endianess is irrelevant 00035 00036 #define SHBUF_CONTROL_ID ((unsigned int)'S' | (unsigned int)'H' << 8 | (unsigned int)'B' << 16 | (unsigned int)'F' << 24) 00037 00038 int version; 00039 #define SHBUF_CONTROL_VERSION 2 00040 00041 shbuf_status status; 00042 unsigned long size; 00043 00044 key_t buffer_shm_key; 00045 key_t sem_key; 00046 key_t msg_key; 00047 00048 int provider_attached; 00049 int client_attached; 00050 00051 int provider_notify; 00052 int client_notify; 00053 } shbuf_control; 00054 00055 struct _shbuf { 00056 key_t control_shm_key; 00057 00058 int control_shmid; 00059 int buffer_shmid; 00060 int semid; 00061 int msgid; 00062 00063 shbuf_control *control; 00064 unsigned char* buffer; 00065 00066 int fifo_fd_read; 00067 int fifo_fd_write; 00068 00069 int is_dead; 00070 int is_provider; 00071 00072 pthread_t thread; 00073 }; 00074 00075 #if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED) 00076 /* union semun is defined by including <sys/sem.h> */ 00077 #else 00078 /* according to X/OPEN we have to define it ourselves */ 00079 union semun { 00080 int val; /* value for SETVAL */ 00081 struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */ 00082 unsigned short *array; /* array for GETALL, SETALL */ 00083 /* Linux specific part: */ 00084 struct seminfo *__buf; /* buffer for IPC_INFO */ 00085 }; 00086 #endif 00087 00088 #endif