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) {}
51 #define wassertr(expr) assert(expr)
53 #define wassertrv(expr, val) assert(expr)
57 #define wassertr(expr) \
59 wwarning("%s line %i (%s): assertion %s failed",\
60 __FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
64 #define wassertrv(expr, val) \
66 wwarning("%s line %i (%s): assertion %s failed",\
67 __FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
77 #endif /* __cplusplus */
91 } WMNotificationCoalescing
;
95 typedef struct W_Bag WMBag
; /* equivalent to a linked list or array */
96 typedef struct W_HashTable WMHashTable
;
97 typedef struct W_UserDefaults WMUserDefaults
;
98 typedef struct W_Notification WMNotification
;
99 typedef struct W_NotificationQueue WMNotificationQueue
;
103 /* DO NOT ACCESS THE CONTENTS OF THIS STRUCT */
112 /* NULL is pointer hash */
113 unsigned (*hash
)(const void *);
114 /* NULL is pointer compare */
115 Bool (*keyIsEqual
)(const void *, const void *);
116 /* NULL does nothing */
117 void* (*retainKey
)(const void *);
118 /* NULL does nothing */
119 void (*releaseKey
)(const void *);
120 } WMHashTableCallbacks
;
126 char character
; /* the escape character */
127 char *value
; /* value to place */
133 typedef void WMNotificationObserverAction(void *observerData
,
134 WMNotification
*notification
);
138 /*......................................................................*/
140 typedef void (waborthandler
)(int);
142 waborthandler
*wsetabort(waborthandler
*);
145 void wfatal(const char *msg
, ...);
146 void wwarning(const char *msg
, ...);
147 void wsyserror(const char *msg
, ...);
149 char *wfindfile(char *paths
, char *file
);
151 char *wfindfileinlist(char **path_list
, char *file
);
153 char *wfindfileinarray(proplist_t array
, char *file
);
155 char *wexpandpath(char *path
);
157 /* don't free the returned string */
160 void *wmalloc(size_t size
);
161 void *wrealloc(void *ptr
, size_t newsize
);
163 void wrelease(void *ptr
);
164 void *wretain(void *ptr
);
166 char *wstrdup(char *str
);
168 char *wstrappend(char *dst
, char *src
);
170 char *wusergnusteppath();
172 char *wdefaultspathfordomain(char *domain
);
174 void wusleep(unsigned int microsec
);
177 int wsprintesc(char *buffer
, int length
, char *format
, WMSEscapes
**escapes
,
181 /*......................................................................*/
183 /* This function is used _only_ if you create a NON-GUI program.
184 * For GUI based programs use WMNextEvent()/WMHandleEvent() instead.
185 * This function will handle all input/timer/idle events, then return.
188 void WHandleEvents();
190 /*......................................................................*/
193 WMHashTable
*WMCreateHashTable(WMHashTableCallbacks callbacks
);
195 void WMFreeHashTable(WMHashTable
*table
);
197 void WMResetHashTable(WMHashTable
*table
);
199 void *WMHashGet(WMHashTable
*table
, const void *key
);
201 /* put data in table, replacing already existing data and returning
203 void *WMHashInsert(WMHashTable
*table
, void *key
, void *data
);
205 void WMHashRemove(WMHashTable
*table
, const void *key
);
207 /* warning: do not manipulate the table while using these functions */
208 WMHashEnumerator
WMEnumerateHashTable(WMHashTable
*table
);
210 void *WMNextHashEnumeratorItem(WMHashEnumerator
*enumerator
);
212 unsigned WMCountHashTable(WMHashTable
*table
);
217 /* some predefined callback sets */
219 extern const WMHashTableCallbacks WMIntHashCallbacks
;
220 /* sizeof(keys) are <= sizeof(void*) */
222 extern const WMHashTableCallbacks WMStringHashCallbacks
;
223 /* keys are strings. Strings will be copied with wstrdup()
224 * and freed with free() */
226 extern const WMHashTableCallbacks WMStringPointerHashCallbacks
;
227 /* keys are strings, bug they are not copied */
230 /*......................................................................*/
233 WMBag
*WMCreateBag(int size
);
235 int WMGetBagItemCount(WMBag
*bag
);
237 void WMAppendBag(WMBag
*bag
, WMBag
*appendedBag
);
239 void WMPutInBag(WMBag
*bag
, void *item
);
241 void WMInsertInBag(WMBag
*bag
, int index
, void *item
);
243 int WMGetFirstInBag(WMBag
*bag
, void *item
);
245 int WMGetLastInBag(WMBag
*bag
, void *item
);
247 void WMRemoveFromBag(WMBag
*bag
, void *item
);
249 void WMDeleteFromBag(WMBag
*bag
, int index
);
251 void *WMGetFromBag(WMBag
*bag
, int index
);
253 int WMCountInBag(WMBag
*bag
, void *item
);
256 /* comparer must return:
261 void WMSortBag(WMBag
*bag
, int (*comparer
)(const void*, const void*));
263 void WMEmptyBag(WMBag
*bag
);
265 void WMFreeBag(WMBag
*bag
);
267 WMBag
*WMMapBag(WMBag
*bag
, void* (*function
)(void*));
269 /*......................................................................*/
271 WMNotification
*WMCreateNotification(char *name
, void *object
, void *clientData
);
273 void WMReleaseNotification(WMNotification
*notification
);
275 WMNotification
*WMRetainNotification(WMNotification
*notification
);
277 void *WMGetNotificationClientData(WMNotification
*notification
);
279 void *WMGetNotificationObject(WMNotification
*notification
);
281 char *WMGetNotificationName(WMNotification
*notification
);
284 void WMAddNotificationObserver(WMNotificationObserverAction
*observerAction
,
285 void *observer
, char *name
, void *object
);
287 void WMPostNotification(WMNotification
*notification
);
289 void WMRemoveNotificationObserver(void *observer
);
291 void WMRemoveNotificationObserverWithName(void *observer
, char *name
,
294 void WMPostNotificationName(char *name
, void *object
, void *clientData
);
296 WMNotificationQueue
*WMGetDefaultNotificationQueue(void);
298 WMNotificationQueue
*WMCreateNotificationQueue(void);
300 void WMDequeueNotificationMatching(WMNotificationQueue
*queue
,
301 WMNotification
*notification
,
304 void WMEnqueueNotification(WMNotificationQueue
*queue
,
305 WMNotification
*notification
,
306 WMPostingStyle postingStyle
);
308 void WMEnqueueCoalesceNotification(WMNotificationQueue
*queue
,
309 WMNotification
*notification
,
310 WMPostingStyle postingStyle
,
311 unsigned coalesceMask
);
314 /*......................................................................*/
316 WMUserDefaults
*WMGetStandardUserDefaults(void);
318 WMUserDefaults
*WMGetDefaultsFromPath(char *path
);
320 void WMSynchronizeUserDefaults(WMUserDefaults
*database
);
322 void WMSaveUserDefaults(WMUserDefaults
*database
);
324 proplist_t
WMGetUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
326 void WMSetUDObjectForKey(WMUserDefaults
*database
, proplist_t object
,
329 void WMRemoveUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
331 /* you can free the returned string */
332 char *WMGetUDStringForKey(WMUserDefaults
*database
, char *defaultName
);
334 int WMGetUDIntegerForKey(WMUserDefaults
*database
, char *defaultName
);
336 float WMGetUDFloatForKey(WMUserDefaults
*database
, char *defaultName
);
338 Bool
WMGetUDBoolForKey(WMUserDefaults
*database
, char *defaultName
);
340 void WMSetUDStringForKey(WMUserDefaults
*database
, char *value
,
343 void WMSetUDIntegerForKey(WMUserDefaults
*database
, int value
,
346 void WMSetUDFloatForKey(WMUserDefaults
*database
, float value
,
349 void WMSetUDBoolForKey(WMUserDefaults
*database
, Bool value
,
352 proplist_t
WMGetUDSearchList(WMUserDefaults
*database
);
354 void WMSetUDSearchList(WMUserDefaults
*database
, proplist_t list
);
358 #endif /* __cplusplus */