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
;
96 typedef struct W_HashTable WMHashTable
;
97 typedef struct W_UserDefaults WMUserDefaults
;
98 typedef struct W_Notification WMNotification
;
99 typedef struct W_NotificationQueue WMNotificationQueue
;
102 /* DO NOT ACCESS THE CONTENTS OF THIS STRUCT */
111 /* NULL is pointer hash */
112 unsigned (*hash
)(const void *);
113 /* NULL is pointer compare */
114 Bool (*keyIsEqual
)(const void *, const void *);
115 /* NULL does nothing */
116 void* (*retainKey
)(const void *);
117 /* NULL does nothing */
118 void (*releaseKey
)(const void *);
119 } WMHashTableCallbacks
;
124 char character
; /* the escape character */
125 char *value
; /* value to place */
130 typedef void WMNotificationObserverAction(void *observerData
,
131 WMNotification
*notification
);
135 /*......................................................................*/
137 typedef void (waborthandler
)(int);
139 waborthandler
*wsetabort(waborthandler
*);
142 void wfatal(const char *msg
, ...);
143 void wwarning(const char *msg
, ...);
144 void wsyserror(const char *msg
, ...);
146 char *wfindfile(char *paths
, char *file
);
148 char *wfindfileinlist(char **path_list
, char *file
);
150 char *wfindfileinarray(proplist_t array
, char *file
);
152 char *wexpandpath(char *path
);
154 /* don't free the returned string */
157 void *wmalloc(size_t size
);
158 void *wrealloc(void *ptr
, size_t newsize
);
160 void wrelease(void *ptr
);
161 void *wretain(void *ptr
);
163 char *wstrdup(char *str
);
165 char *wstrappend(char *dst
, char *src
);
167 char *wusergnusteppath();
169 char *wdefaultspathfordomain(char *domain
);
171 void wusleep(unsigned int microsec
);
174 int wsprintesc(char *buffer
, int length
, char *format
, WMSEscapes
**escapes
,
177 /*......................................................................*/
180 WMHashTable
*WMCreateHashTable(WMHashTableCallbacks callbacks
);
182 void WMFreeHashTable(WMHashTable
*table
);
184 void WMResetHashTable(WMHashTable
*table
);
186 void *WMHashGet(WMHashTable
*table
, const void *key
);
188 /* put data in table, replacing already existing data and returning
190 void *WMHashInsert(WMHashTable
*table
, void *key
, void *data
);
192 void WMHashRemove(WMHashTable
*table
, const void *key
);
194 /* warning: do not manipulate the table while using these functions */
195 WMHashEnumerator
WMEnumerateHashTable(WMHashTable
*table
);
197 void *WMNextHashEnumeratorItem(WMHashEnumerator
*enumerator
);
199 unsigned WMCountHashTable(WMHashTable
*table
);
204 /* some predefined callback sets */
206 extern const WMHashTableCallbacks WMIntHashCallbacks
;
207 /* sizeof(keys) are <= sizeof(void*) */
209 extern const WMHashTableCallbacks WMStringHashCallbacks
;
210 /* keys are strings. Strings will be copied with wstrdup()
211 * and freed with free() */
213 extern const WMHashTableCallbacks WMStringPointerHashCallbacks
;
214 /* keys are strings, bug they are not copied */
216 /*......................................................................*/
218 WMNotification
*WMCreateNotification(char *name
, void *object
, void *clientData
);
220 void WMReleaseNotification(WMNotification
*notification
);
222 WMNotification
*WMRetainNotification(WMNotification
*notification
);
224 void *WMGetNotificationClientData(WMNotification
*notification
);
226 void *WMGetNotificationObject(WMNotification
*notification
);
228 char *WMGetNotificationName(WMNotification
*notification
);
231 void WMAddNotificationObserver(WMNotificationObserverAction
*observerAction
,
232 void *observer
, char *name
, void *object
);
234 void WMPostNotification(WMNotification
*notification
);
236 void WMRemoveNotificationObserver(void *observer
);
238 void WMRemoveNotificationObserverWithName(void *observer
, char *name
,
241 void WMPostNotificationName(char *name
, void *object
, void *clientData
);
243 WMNotificationQueue
*WMGetDefaultNotificationQueue(void);
245 WMNotificationQueue
*WMCreateNotificationQueue(void);
247 void WMDequeueNotificationMatching(WMNotificationQueue
*queue
,
248 WMNotification
*notification
,
251 void WMEnqueueNotification(WMNotificationQueue
*queue
,
252 WMNotification
*notification
,
253 WMPostingStyle postingStyle
);
255 void WMEnqueueCoalesceNotification(WMNotificationQueue
*queue
,
256 WMNotification
*notification
,
257 WMPostingStyle postingStyle
,
258 unsigned coalesceMask
);
261 /*......................................................................*/
263 WMUserDefaults
*WMGetStandardUserDefaults(void);
265 WMUserDefaults
*WMGetDefaultsFromPath(char *path
);
267 void WMSynchronizeUserDefaults(WMUserDefaults
*database
);
269 proplist_t
WMGetUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
271 void WMSetUDObjectForKey(WMUserDefaults
*database
, proplist_t object
,
274 void WMRemoveUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
276 /* you can free the returned string */
277 char *WMGetUDStringForKey(WMUserDefaults
*database
, char *defaultName
);
279 int WMGetUDIntegerForKey(WMUserDefaults
*database
, char *defaultName
);
281 float WMGetUDFloatForKey(WMUserDefaults
*database
, char *defaultName
);
283 Bool
WMGetUDBoolForKey(WMUserDefaults
*database
, char *defaultName
);
285 void WMSetUDStringForKey(WMUserDefaults
*database
, char *value
,
288 void WMSetUDIntegerForKey(WMUserDefaults
*database
, int value
,
291 void WMSetUDFloatForKey(WMUserDefaults
*database
, float value
,
294 void WMSetUDBoolForKey(WMUserDefaults
*database
, Bool value
,
297 proplist_t
WMGetUDSearchList(WMUserDefaults
*database
);
299 void WMSetUDSearchList(WMUserDefaults
*database
, proplist_t list
);
303 #endif /* __cplusplus */