9 /* SunOS 4.x Blargh.... */
11 #define NULL ((void*)0)
16 * Warning: proplist.h #defines BOOL which will clash with the
17 * typedef BOOL in Xmd.h
18 * proplist.h should use Bool (which is a #define in Xlib.h) instead.
25 # define WMAX(a,b) ((a)>(b) ? (a) : (b))
28 # define WMIN(a,b) ((a)<(b) ? (a) : (b))
32 #if (!defined (__GNUC__) || __GNUC__ < 2 || \
33 __GNUC_MINOR__ < (defined (__cplusplus) ? 6 : 4))
34 #define __ASSERT_FUNCTION ((char *) 0)
36 #define __ASSERT_FUNCTION __PRETTY_FUNCTION__
42 #define wassertr(expr) {}
43 #define wassertrv(expr, val) {}
47 #define wassertr(expr) \
49 wwarning("%s line %i (%s): assertion %s failed",\
50 __FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
54 #define wassertrv(expr, val) \
56 wwarning("%s line %i (%s): assertion %s failed",\
57 __FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
66 #endif /* __cplusplus */
80 } WMNotificationCoalescing
;
85 typedef struct W_HashTable WMHashTable
;
86 typedef struct W_UserDefaults WMUserDefaults
;
87 typedef struct W_Notification WMNotification
;
88 typedef struct W_NotificationQueue WMNotificationQueue
;
91 /* DO NOT ACCESS THE CONTENTS OF THIS STRUCT */
100 /* NULL is pointer hash */
101 unsigned (*hash
)(const void *);
102 /* NULL is pointer compare */
103 Bool (*keyIsEqual
)(const void *, const void *);
104 /* NULL does nothing */
105 void* (*retainKey
)(const void *);
106 /* NULL does nothing */
107 void (*releaseKey
)(const void *);
108 } WMHashTableCallbacks
;
113 char character
; /* the escape character */
114 char *value
; /* value to place */
119 typedef void WMNotificationObserverAction(void *observerData
,
120 WMNotification
*notification
);
124 /*......................................................................*/
126 typedef void (waborthandler
)(int);
128 waborthandler
*wsetabort(waborthandler
*);
131 void wfatal(const char *msg
, ...);
132 void wwarning(const char *msg
, ...);
133 void wsyserror(const char *msg
, ...);
135 char *wfindfile(char *paths
, char *file
);
137 char *wfindfileinlist(char **path_list
, char *file
);
139 char *wfindfileinarray(proplist_t array
, char *file
);
141 char *wexpandpath(char *path
);
143 /* don't free the returned string */
146 void *wmalloc(size_t size
);
147 void *wrealloc(void *ptr
, size_t newsize
);
149 void wrelease(void *ptr
);
150 void *wretain(void *ptr
);
152 char *wstrdup(char *str
);
154 char *wstrappend(char *dst
, char *src
);
156 char *wusergnusteppath();
158 char *wdefaultspathfordomain(char *domain
);
160 void wusleep(unsigned int microsec
);
163 int wsprintesc(char *buffer
, int length
, char *format
, WMSEscapes
**escapes
,
166 /*......................................................................*/
169 WMHashTable
*WMCreateHashTable(WMHashTableCallbacks callbacks
);
171 void WMFreeHashTable(WMHashTable
*table
);
173 void WMResetHashTable(WMHashTable
*table
);
175 void *WMHashGet(WMHashTable
*table
, const void *key
);
177 /* put data in table, replacing already existing data and returning
179 void *WMHashInsert(WMHashTable
*table
, void *key
, void *data
);
181 void WMHashRemove(WMHashTable
*table
, const void *key
);
183 /* warning: do not manipulate the table while using these functions */
184 WMHashEnumerator
WMEnumerateHashTable(WMHashTable
*table
);
186 void *WMNextHashEnumeratorItem(WMHashEnumerator
*enumerator
);
188 unsigned WMCountHashTable(WMHashTable
*table
);
193 /* some predefined callback sets */
195 extern const WMHashTableCallbacks WMIntHashCallbacks
;
196 /* sizeof(keys) are <= sizeof(void*) */
198 extern const WMHashTableCallbacks WMStringHashCallbacks
;
199 /* keys are strings. Strings will be copied with wstrdup()
200 * and freed with free() */
202 extern const WMHashTableCallbacks WMStringPointerHashCallbacks
;
203 /* keys are strings, bug they are not copied */
205 /*......................................................................*/
207 WMNotification
*WMCreateNotification(char *name
, void *object
, void *clientData
);
209 void WMReleaseNotification(WMNotification
*notification
);
211 WMNotification
*WMRetainNotification(WMNotification
*notification
);
213 void *WMGetNotificationClientData(WMNotification
*notification
);
215 void *WMGetNotificationObject(WMNotification
*notification
);
217 char *WMGetNotificationName(WMNotification
*notification
);
220 void WMAddNotificationObserver(WMNotificationObserverAction
*observerAction
,
221 void *observer
, char *name
, void *object
);
223 void WMPostNotification(WMNotification
*notification
);
225 void WMRemoveNotificationObserver(void *observer
);
227 void WMRemoveNotificationObserverWithName(void *observer
, char *name
,
230 void WMPostNotificationName(char *name
, void *object
, void *clientData
);
232 WMNotificationQueue
*WMGetDefaultNotificationQueue(void);
234 WMNotificationQueue
*WMCreateNotificationQueue(void);
236 void WMDequeueNotificationMatching(WMNotificationQueue
*queue
,
237 WMNotification
*notification
,
240 void WMEnqueueNotification(WMNotificationQueue
*queue
,
241 WMNotification
*notification
,
242 WMPostingStyle postingStyle
);
244 void WMEnqueueCoalesceNotification(WMNotificationQueue
*queue
,
245 WMNotification
*notification
,
246 WMPostingStyle postingStyle
,
247 unsigned coalesceMask
);
250 /*......................................................................*/
252 WMUserDefaults
*WMGetStandardUserDefaults(void);
254 proplist_t
WMGetUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
256 void WMSetUDObjectForKey(WMUserDefaults
*database
, proplist_t object
,
259 void WMRemoveUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
261 /* you can free the returned string */
262 char *WMGetUDStringForKey(WMUserDefaults
*database
, char *defaultName
);
264 int WMGetUDIntegerForKey(WMUserDefaults
*database
, char *defaultName
);
266 float WMGetUDFloatForKey(WMUserDefaults
*database
, char *defaultName
);
268 Bool
WMGetUDBoolForKey(WMUserDefaults
*database
, char *defaultName
);
270 void WMSetUDStringForKey(WMUserDefaults
*database
, char *value
,
273 void WMSetUDIntegerForKey(WMUserDefaults
*database
, int value
,
276 void WMSetUDFloatForKey(WMUserDefaults
*database
, float value
,
279 void WMSetUDBoolForKey(WMUserDefaults
*database
, Bool value
,
282 proplist_t
WMGetUDSearchList(WMUserDefaults
*database
);
284 void WMSetUDSearchList(WMUserDefaults
*database
, proplist_t list
);
288 #endif /* __cplusplus */