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 *wexpandpath(char *path
);
141 /* don't free the returned string */
144 void *wmalloc(size_t size
);
145 void *wrealloc(void *ptr
, size_t newsize
);
147 void wrelease(void *ptr
);
148 void *wretain(void *ptr
);
150 char *wstrdup(char *str
);
152 char *wstrappend(char *dst
, char *src
);
154 char *wusergnusteppath();
156 char *wdefaultspathfordomain(char *domain
);
158 void wusleep(unsigned int microsec
);
161 int wsprintesc(char *buffer
, int length
, char *format
, WMSEscapes
**escapes
,
164 /*......................................................................*/
167 WMHashTable
*WMCreateHashTable(WMHashTableCallbacks callbacks
);
169 void WMFreeHashTable(WMHashTable
*table
);
171 void WMResetHashTable(WMHashTable
*table
);
173 void *WMHashGet(WMHashTable
*table
, const void *key
);
175 /* put data in table, replacing already existing data and returning
177 void *WMHashInsert(WMHashTable
*table
, void *key
, void *data
);
179 void WMHashRemove(WMHashTable
*table
, const void *key
);
181 /* warning: do not manipulate the table while using these functions */
182 WMHashEnumerator
WMEnumerateHashTable(WMHashTable
*table
);
184 void *WMNextHashEnumeratorItem(WMHashEnumerator
*enumerator
);
186 unsigned WMCountHashTable(WMHashTable
*table
);
191 /* some predefined callback sets */
193 extern const WMHashTableCallbacks WMIntHashCallbacks
;
194 /* sizeof(keys) are <= sizeof(void*) */
196 extern const WMHashTableCallbacks WMStringHashCallbacks
;
197 /* keys are strings. Strings will be copied with wstrdup()
198 * and freed with free() */
200 extern const WMHashTableCallbacks WMStringPointerHashCallbacks
;
201 /* keys are strings, bug they are not copied */
203 /*......................................................................*/
205 WMNotification
*WMCreateNotification(char *name
, void *object
, void *clientData
);
207 void WMReleaseNotification(WMNotification
*notification
);
209 WMNotification
*WMRetainNotification(WMNotification
*notification
);
211 void *WMGetNotificationClientData(WMNotification
*notification
);
213 void *WMGetNotificationObject(WMNotification
*notification
);
215 char *WMGetNotificationName(WMNotification
*notification
);
218 void WMAddNotificationObserver(WMNotificationObserverAction
*observerAction
,
219 void *observer
, char *name
, void *object
);
221 void WMPostNotification(WMNotification
*notification
);
223 void WMRemoveNotificationObserver(void *observer
);
225 void WMRemoveNotificationObserverWithName(void *observer
, char *name
,
228 void WMPostNotificationName(char *name
, void *object
, void *clientData
);
230 WMNotificationQueue
*WMGetDefaultNotificationQueue(void);
232 WMNotificationQueue
*WMCreateNotificationQueue(void);
234 void WMDequeueNotificationMatching(WMNotificationQueue
*queue
,
235 WMNotification
*notification
,
238 void WMEnqueueNotification(WMNotificationQueue
*queue
,
239 WMNotification
*notification
,
240 WMPostingStyle postingStyle
);
242 void WMEnqueueCoalesceNotification(WMNotificationQueue
*queue
,
243 WMNotification
*notification
,
244 WMPostingStyle postingStyle
,
245 unsigned coalesceMask
);
248 /*......................................................................*/
250 WMUserDefaults
*WMGetStandardUserDefaults(void);
252 proplist_t
WMGetUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
254 void WMSetUDObjectForKey(WMUserDefaults
*database
, proplist_t object
,
257 void WMRemoveUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
259 /* you can free the returned string */
260 char *WMGetUDStringForKey(WMUserDefaults
*database
, char *defaultName
);
262 int WMGetUDIntegerForKey(WMUserDefaults
*database
, char *defaultName
);
264 float WMGetUDFloatForKey(WMUserDefaults
*database
, char *defaultName
);
266 Bool
WMGetUDBoolForKey(WMUserDefaults
*database
, char *defaultName
);
268 void WMSetUDStringForKey(WMUserDefaults
*database
, char *value
,
271 void WMSetUDIntegerForKey(WMUserDefaults
*database
, int value
,
274 void WMSetUDFloatForKey(WMUserDefaults
*database
, float value
,
277 void WMSetUDBoolForKey(WMUserDefaults
*database
, Bool value
,
280 proplist_t
WMGetUDSearchList(WMUserDefaults
*database
);
282 void WMSetUDSearchList(WMUserDefaults
*database
, proplist_t list
);
286 #endif /* __cplusplus */