1
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
// % Project : GUSI - Grand Unified Socket Interface
3
// % File : GUSIConfig.nw - Configuration settings
4
// % Author : Matthias Neeracher
7
// % $Log: GUSIConfig.h,v $
8
// % Revision 1.1 2001/03/11 22:33:34 sgehani%netscape.com
11
// % Revision 1.18 2001/01/22 04:31:11 neeri
12
// % Last minute changes for 2.1.5
14
// % Revision 1.17 2001/01/17 08:40:17 neeri
15
// % Prevent inlining of overridable functions
17
// % Revision 1.16 2000/05/23 06:54:39 neeri
18
// % Improve formatting, update to latest universal headers
20
// % Revision 1.15 2000/03/15 07:10:29 neeri
21
// % Fix suffix searching code
23
// % Revision 1.14 2000/03/06 06:24:34 neeri
24
// % Fix plausibility tests for A5
26
// % Revision 1.13 1999/09/26 03:56:44 neeri
27
// % Sanity check for A5
29
// % Revision 1.12 1999/08/26 05:44:59 neeri
30
// % Fixes for literate edition of source code
32
// % Revision 1.11 1999/06/28 05:57:03 neeri
33
// % Support SIGINT generation
35
// % Revision 1.10 1999/05/29 06:26:41 neeri
36
// % Fixed header guards
38
// % Revision 1.9 1999/03/29 09:51:28 neeri
39
// % New configuration system with support for hardcoded configurations.
41
// % Revision 1.8 1999/03/17 09:05:05 neeri
42
// % Added GUSITimer, expanded docs
44
// % Revision 1.7 1998/10/11 16:45:10 neeri
45
// % Ready to release 2.0a2
47
// % Revision 1.6 1998/08/01 21:32:01 neeri
48
// % About ready for 2.0a1
50
// % Revision 1.5 1998/01/25 20:53:52 neeri
51
// % Engine implemented, except for signals & scheduling
53
// % Revision 1.4 1997/11/13 21:12:10 neeri
56
// % Revision 1.3 1996/11/24 13:00:27 neeri
57
// % Fix comment leaders
59
// % Revision 1.2 1996/11/24 12:52:06 neeri
60
// % Added GUSIPipeSockets
62
// % Revision 1.1.1.1 1996/11/03 02:43:32 neeri
63
// % Imported into CVS
65
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67
// \chapter{GUSI Configuration settings}
69
// GUSI stores its global configuration settings in the [[GUSIConfiguration]]
70
// singleton class. To create the instance, GUSI calls the [[GUSISetupConfig]]
79
#include "GUSIFileSpec.h"
81
#include <ConditionalMacros.h>
83
#if PRAGMA_STRUCT_ALIGN
84
#pragma options align=native
87
// \section{Definition of configuration settings}
89
// The GUSIConfiguration has a single instance with read only access, accessible
90
// with the static [[Instance]] member function.
92
// <Definition of class [[GUSIConfiguration]]>=
93
class GUSIConfiguration {
95
enum { kNoResource = -1, kDefaultResourceID = 10240 };
97
static GUSIConfiguration * Instance();
98
static GUSIConfiguration * CreateInstance(short resourceID = kDefaultResourceID);
100
// To determine the file type and creator of a newly created file, we first try
101
// to match one of the [[FileSuffix]] suffices.
103
// <Type and creator rules for newly created files>=
110
FileSuffix * fSuffices;
112
void ConfigureSuffices(short numSuffices, FileSuffix * suffices);
113
// If none of the suffices matches, we apply the default type and creator. These
114
// rules are applied with [[SetDefaultFType]].
116
// <Type and creator rules for newly created files>=
118
OSType fDefaultCreator;
120
void ConfigureDefaultTypeCreator(OSType defaultType, OSType defaultCreator);
121
void SetDefaultFType(const GUSIFileSpec & name) const;
122
// To simplify Macintosh friendly ports of simple, I/O bound programs it is
123
// possible to specify automatic yielding on read() and write() calls.
124
// [[AutoSpin]] will spin a cursor and/or yield the CPU if desired.
126
// <Automatic cursor spin>=
129
void ConfigureAutoSpin(bool autoSpin);
130
void AutoSpin() const;
131
// GUSI applications can crash hard if QuickDraw is not initialized. Therefore, we
132
// offer to initialize it automatically with the [[fAutoInitGraf]] feature.
134
// <Automatic initialization of QuickDraw>=
137
void ConfigureAutoInitGraf(bool autoInitGraf);
139
// Due to the organization of a UNIX filesystem, it is fairly easy to find
140
// out how many subdirectories a given directory has, since the [[nlink]] field of
141
// its inode will automatically contain the number of subdirectories[[+2]]. Therefore,
142
// some UNIX derived code depends on this behaviour. When [[fAccurateStat]] is set,
143
// GUSI emulates this behaviour, but be warned that this makes [[stat]] on
144
// directories a much more expensive operation. If [[fAccurateStat]] is not set,
145
// stat() gives the total number of entries in the directory[[+2]] as a conservative
151
void ConfigureAccurateStat(bool accurateState);
152
// The [[fSigPipe]] feature causes a signal [[SIGPIPE]] to be raised if an attempt
153
// is made to write to a broken pipe.
158
void ConfigureSigPipe(bool sigPipe);
160
// The [[fSigInt]] feature causes a signal [[SIGINT]] to be raised if the user presses
166
void ConfigureSigInt(bool sigInt);
167
void CheckInterrupt();
168
// If [[fSharedOpen]] is set, open() opens files with shared read/write permission.
173
void ConfigureSharedOpen(bool sharedOpen);
174
// If [[fHandleAppleEvents]] is set, GUSI automatically handles AppleEvents in its
175
// event handling routine.
178
bool fHandleAppleEvents;
180
void ConfigureHandleAppleEvents(bool handleAppleEvents);
182
GUSIConfiguration(short resourceID = kDefaultResourceID);
184
// \section{Implementation of configuration settings}
186
// The sole instance of [[GUSIConfiguration]] is created on demand.
188
// <Privatissima of [[GUSIConfiguration]]>=
189
static GUSIConfiguration * sInstance;
190
// [[ConfigureSuffices]] sets up the suffix table.
192
// <Privatissima of [[GUSIConfiguration]]>=
194
// [[AutoSpin]] tests the flag inline, but performs the actual spinning out of
197
// <Privatissima of [[GUSIConfiguration]]>=
198
void DoAutoSpin() const;
199
// [[AutoInitGraf]] works rather similarly to [[AutoSpin]].
201
// <Privatissima of [[GUSIConfiguration]]>=
202
void DoAutoInitGraf();
203
// [[CheckInterrupt]] raises a [[SIGINT]] signal if desired.
205
// <Privatissima of [[GUSIConfiguration]]>=
206
bool CmdPeriod(const EventRecord * event);
209
#if PRAGMA_STRUCT_ALIGN
210
#pragma options align=reset
213
// To create the sole instance of [[GUSIConfiguration]], we call [[GUSISetupConfig]]
214
// which has to call [[GUSIConfiguration::CreateInstance]].
216
// <Definition of [[GUSISetupConfig]] hook>=
218
#pragma noinline_func GUSISetupConfig
221
extern "C" void GUSISetupConfig();
222
// <Inline member functions for class [[GUSIConfiguration]]>=
223
inline GUSIConfiguration * GUSIConfiguration::Instance()
228
sInstance = new GUSIConfiguration();
233
inline GUSIConfiguration * GUSIConfiguration::CreateInstance(short resourceID)
236
sInstance = new GUSIConfiguration(resourceID);
240
// <Inline member functions for class [[GUSIConfiguration]]>=
241
inline void GUSIConfiguration::ConfigureDefaultTypeCreator(OSType defaultType, OSType defaultCreator)
243
fDefaultType = defaultType;
244
fDefaultCreator = defaultCreator;
246
// <Inline member functions for class [[GUSIConfiguration]]>=
247
inline void GUSIConfiguration::ConfigureAutoSpin(bool autoSpin)
249
fAutoSpin = autoSpin;
251
// <Inline member functions for class [[GUSIConfiguration]]>=
252
inline void GUSIConfiguration::AutoSpin() const
257
// <Inline member functions for class [[GUSIConfiguration]]>=
258
inline void GUSIConfiguration::ConfigureAutoInitGraf(bool autoInitGraf)
260
fAutoInitGraf = autoInitGraf;
262
// <Inline member functions for class [[GUSIConfiguration]]>=
263
inline void GUSIConfiguration::AutoInitGraf()
268
// <Inline member functions for class [[GUSIConfiguration]]>=
269
inline void GUSIConfiguration::ConfigureSigPipe(bool sigPipe)
273
// <Inline member functions for class [[GUSIConfiguration]]>=
274
inline void GUSIConfiguration::ConfigureSigInt(bool sigInt)
278
// <Inline member functions for class [[GUSIConfiguration]]>=
279
inline void GUSIConfiguration::ConfigureAccurateStat(bool accurateStat)
281
fAccurateStat = accurateStat;
283
inline void GUSIConfiguration::ConfigureSharedOpen(bool sharedOpen)
285
fSharedOpen = sharedOpen;
287
#endif /* GUSI_SOURCE */
289
#endif /* _GUSIConfig_ */