1 /* Copyright (C) 1992-1998 The Geometry Center 2 * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips 3 * 4 * This file is part of Geomview. 5 * 6 * Geomview is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU Lesser General Public License as published 8 * by the Free Software Foundation; either version 2, or (at your option) 9 * any later version. 10 * 11 * Geomview is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with Geomview; see the file COPYING. If not, write 18 * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, 19 * USA, or visit http://www.gnu.org. 20 */ 21 22 23 /* Authors: Charlie Gunn, Stuart Levy, Tamara Munzner, Mark Phillips */ 24 25 #ifndef _HANDLEPOOLP_ 26 #define _HANDLEPOOLP_ 27 /* 28 * Communications -- Private definitions for Pools and Handles. 29 */ 30 #include <sys/time.h> 31 #include "ooglutil.h" 32 #include "streampool.h" 33 /*#include "sm.h"*/ 34 35 #define HANDLEMAGIC OOGLMagic('h',1) 36 37 typedef struct HRef { 38 DblListNode node; 39 Handle **hp; 40 Ref *parentobj; 41 void *info; 42 void (*update) P((Handle **, Ref *, void *)); 43 } HRef; 44 45 struct Handle { 46 REFERENCEFIELDS; 47 HandleOps *ops; /* Comm-related operations on our datatype */ 48 char *name; /* Char-string name */ 49 Ref *object; /* Current object value if any */ 50 DblListNode opsnode; /* node in list of all handles with given ops */ 51 DblListNode poolnode; /* node in list of all handles with given pool*/ 52 DblListNode objnode; /* node in list of all handles pointing to a 53 given object */ 54 Pool *whence; /* Where did this handle's value come from? */ 55 56 DblListNode refs; /* list of references to this Handle, 57 * which we update when the Handle's 58 * object changes. 59 */ 60 bool permanent; /* Retain even when last reference goes away? */ 61 bool obj_saved; /* Set during saving of objects when 62 * the handle has been dumped as 63 * reference to indicate that its 64 * objects also already has been 65 * saved. 66 */ 67 /* 68 * Pool-type-specific state 69 */ 70 #if 0 71 SMSym *sym; /* Address of our SM symbol */ 72 int version; /* Version number of shared-memory symbol */ 73 Pool *smpool; /* Pool in which our symbol lies */ 74 Handle *samepool; /* Link in list of handles on this pool */ 75 #endif 76 }; 77 78 #define P_SM 1 79 #define P_STREAM 2 80 81 struct Pool { 82 DblListNode node; /* Link in list of all Pools (or free pools) */ 83 int type; /* P_SM or P_STREAM */ 84 char *poolname; /* Name of this pool: typically a filename */ 85 DblListNode handles; /* All handles using this Pool */ 86 HandleOps *ops; /* I/O operations */ 87 88 long await; /* Unix time until which we should wait */ 89 int (*resyncing)(); /* We're resyncing, call this ... if non-NULL */ 90 91 /* 92 * State for P_STREAM pools. 93 */ 94 95 char otype; /* PO_HANDLES, PO_DATA, PO_ALL */ 96 char mode; /* read/write status: 0, 1, 2 as with open() */ 97 char seekable; /* 1 for plain file, 0 for pipe/socket */ 98 char softEOF; /* Can we hope to read more after EOF? 99 * 1 for tty or named pipe, 0 otherwise. 100 */ 101 IOBFILE *inf; 102 int infd; 103 FILE *outf; 104 105 short flags; /* Miscellaneous internal flags: */ 106 #define PF_TEMP 1 /* "Temporary pool" -- not in AllPools list */ 107 #define PF_ANY 2 /* any objects read from this Pool? */ 108 #define PF_REREAD 4 /* actually re-read on "<" */ 109 #define PF_CLOSING 0x10 /* Internal flag to avoid PoolClose() recursion */ 110 #define PF_ASLEEP 0x20 /* PoolSleep() called on this Pool. */ 111 #define PF_DELETED 0x40 /* Pool is on free list - don't touch! */ 112 #define PF_NOPREFETCH 0x80 /* Don't let PoolIn() prefetch the first char */ 113 114 short level; /* {} Bracket counter */ 115 116 long inf_mtime; /* modification time of p->inf file */ 117 /* A second explicit reference to the same 118 * file can cause it to be re-read if it's 119 * been changed since last time, or if it's 120 * a stream (not seekable). 121 */ 122 123 struct timeval awaken; /* Resume reading at this time */ 124 struct timeval timebase; /* Basis for our clock */ 125 126 /* 127 * State for P_SM pools. 128 */ 129 #if 0 130 SMRegion *sm; /* for shared-memory Pools */ 131 #endif 132 133 /* 134 * client data pointer, used by clients for whatever they want 135 */ 136 void *client_data; 137 138 }; 139 140 #endif /*_HANDLEPOOLP_*/ 141