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 */
159 void *wmalloc(size_t size
);
160 void *wrealloc(void *ptr
, size_t newsize
);
161 void wfree(void *ptr
);
164 void wrelease(void *ptr
);
165 void *wretain(void *ptr
);
167 char *wstrdup(char *str
);
169 char *wstrappend(char *dst
, char *src
);
171 char *wusergnusteppath();
173 char *wdefaultspathfordomain(char *domain
);
175 void wusleep(unsigned int microsec
);
178 int wsprintesc(char *buffer
, int length
, char *format
, WMSEscapes
**escapes
,
182 /*......................................................................*/
184 /* This function is used _only_ if you create a NON-GUI program.
185 * For GUI based programs use WMNextEvent()/WMHandleEvent() instead.
186 * This function will handle all input/timer/idle events, then return.
189 void WHandleEvents();
191 /*......................................................................*/
194 WMHashTable
*WMCreateHashTable(WMHashTableCallbacks callbacks
);
196 void WMFreeHashTable(WMHashTable
*table
);
198 void WMResetHashTable(WMHashTable
*table
);
200 void *WMHashGet(WMHashTable
*table
, const void *key
);
202 /* put data in table, replacing already existing data and returning
204 void *WMHashInsert(WMHashTable
*table
, void *key
, void *data
);
206 void WMHashRemove(WMHashTable
*table
, const void *key
);
208 /* warning: do not manipulate the table while using these functions */
209 WMHashEnumerator
WMEnumerateHashTable(WMHashTable
*table
);
211 void *WMNextHashEnumeratorItem(WMHashEnumerator
*enumerator
);
213 unsigned WMCountHashTable(WMHashTable
*table
);
218 /* some predefined callback sets */
220 extern const WMHashTableCallbacks WMIntHashCallbacks
;
221 /* sizeof(keys) are <= sizeof(void*) */
223 extern const WMHashTableCallbacks WMStringHashCallbacks
;
224 /* keys are strings. Strings will be copied with wstrdup()
225 * and freed with free() */
227 extern const WMHashTableCallbacks WMStringPointerHashCallbacks
;
228 /* keys are strings, bug they are not copied */
231 /*......................................................................*/
234 WMBag
*WMCreateBag(int size
);
236 int WMGetBagItemCount(WMBag
*bag
);
238 void WMAppendBag(WMBag
*bag
, WMBag
*appendedBag
);
240 void WMPutInBag(WMBag
*bag
, void *item
);
242 void WMInsertInBag(WMBag
*bag
, int index
, void *item
);
244 int WMGetFirstInBag(WMBag
*bag
, void *item
);
246 int WMGetLastInBag(WMBag
*bag
, void *item
);
248 void WMRemoveFromBag(WMBag
*bag
, void *item
);
250 void WMDeleteFromBag(WMBag
*bag
, int index
);
252 void *WMGetFromBag(WMBag
*bag
, int index
);
254 int WMCountInBag(WMBag
*bag
, void *item
);
257 /* comparer must return:
262 void WMSortBag(WMBag
*bag
, int (*comparer
)(const void*, const void*));
264 void WMEmptyBag(WMBag
*bag
);
266 void WMFreeBag(WMBag
*bag
);
268 WMBag
*WMMapBag(WMBag
*bag
, void* (*function
)(void*));
270 /*......................................................................*/
272 WMNotification
*WMCreateNotification(char *name
, void *object
, void *clientData
);
274 void WMReleaseNotification(WMNotification
*notification
);
276 WMNotification
*WMRetainNotification(WMNotification
*notification
);
278 void *WMGetNotificationClientData(WMNotification
*notification
);
280 void *WMGetNotificationObject(WMNotification
*notification
);
282 char *WMGetNotificationName(WMNotification
*notification
);
285 void WMAddNotificationObserver(WMNotificationObserverAction
*observerAction
,
286 void *observer
, char *name
, void *object
);
288 void WMPostNotification(WMNotification
*notification
);
290 void WMRemoveNotificationObserver(void *observer
);
292 void WMRemoveNotificationObserverWithName(void *observer
, char *name
,
295 void WMPostNotificationName(char *name
, void *object
, void *clientData
);
297 WMNotificationQueue
*WMGetDefaultNotificationQueue(void);
299 WMNotificationQueue
*WMCreateNotificationQueue(void);
301 void WMDequeueNotificationMatching(WMNotificationQueue
*queue
,
302 WMNotification
*notification
,
305 void WMEnqueueNotification(WMNotificationQueue
*queue
,
306 WMNotification
*notification
,
307 WMPostingStyle postingStyle
);
309 void WMEnqueueCoalesceNotification(WMNotificationQueue
*queue
,
310 WMNotification
*notification
,
311 WMPostingStyle postingStyle
,
312 unsigned coalesceMask
);
315 /*......................................................................*/
317 WMUserDefaults
*WMGetStandardUserDefaults(void);
319 WMUserDefaults
*WMGetDefaultsFromPath(char *path
);
321 void WMSynchronizeUserDefaults(WMUserDefaults
*database
);
323 void WMSaveUserDefaults(WMUserDefaults
*database
);
325 proplist_t
WMGetUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
327 void WMSetUDObjectForKey(WMUserDefaults
*database
, proplist_t object
,
330 void WMRemoveUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
332 /* you can free the returned string */
333 char *WMGetUDStringForKey(WMUserDefaults
*database
, char *defaultName
);
335 int WMGetUDIntegerForKey(WMUserDefaults
*database
, char *defaultName
);
337 float WMGetUDFloatForKey(WMUserDefaults
*database
, char *defaultName
);
339 Bool
WMGetUDBoolForKey(WMUserDefaults
*database
, char *defaultName
);
341 void WMSetUDStringForKey(WMUserDefaults
*database
, char *value
,
344 void WMSetUDIntegerForKey(WMUserDefaults
*database
, int value
,
347 void WMSetUDFloatForKey(WMUserDefaults
*database
, float value
,
350 void WMSetUDBoolForKey(WMUserDefaults
*database
, Bool value
,
353 proplist_t
WMGetUDSearchList(WMUserDefaults
*database
);
355 void WMSetUDSearchList(WMUserDefaults
*database
, proplist_t list
);
359 #endif /* __cplusplus */