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 ((__const char *) 0)
36 #define __ASSERT_FUNCTION __PRETTY_FUNCTION__
42 #define wassertr(expr, val) ((void)0)
46 #define wassertr(expr) \
48 wwarning("%s line %i (%s): assertion %s failed",\
49 __FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
53 #define wassertrv(expr, val) \
55 wwarning("%s line %i (%s): assertion %s failed",\
56 __FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
75 } WMNotificationCoalescing
;
80 typedef struct W_HashTable WMHashTable
;
81 typedef struct W_UserDefaults WMUserDefaults
;
82 typedef struct W_Notification WMNotification
;
83 typedef struct W_NotificationQueue WMNotificationQueue
;
86 /* DO NOT ACCESS THE CONTENTS OF THIS STRUCT */
95 /* NULL is pointer hash */
96 unsigned (*hash
)(const void *);
97 /* NULL is pointer compare */
98 Bool (*keyIsEqual
)(const void *, const void *);
99 /* NULL does nothing */
100 void* (*retainKey
)(const void *);
101 /* NULL does nothing */
102 void (*releaseKey
)(const void *);
103 } WMHashTableCallbacks
;
108 char character
; /* the escape character */
109 char *value
; /* value to place */
114 typedef void WMNotificationObserverAction(void *observerData
,
115 WMNotification
*notification
);
119 /*......................................................................*/
122 void wfatal(const char *msg
, ...);
123 void wwarning(const char *msg
, ...);
124 void wsyserror(const char *msg
, ...);
126 char *wfindfile(char *paths
, char *file
);
128 char *wfindfileinlist(char **path_list
, char *file
);
130 char *wexpandpath(char *path
);
132 /* don't free the returned string */
135 void *wmalloc(size_t size
);
136 void *wrealloc(void *ptr
, size_t newsize
);
138 void wrelease(void *ptr
);
139 void *wretain(void *ptr
);
141 char *wstrdup(char *str
);
143 char *wstrappend(char *dst
, char *src
);
145 char *wusergnusteppath();
147 char *wdefaultspathfordomain(char *domain
);
149 void wusleep(unsigned int microsec
);
152 int wsprintesc(char *buffer
, int length
, char *format
, WMSEscapes
**escapes
,
155 /*......................................................................*/
158 WMHashTable
*WMCreateHashTable(WMHashTableCallbacks callbacks
);
160 void WMFreeHashTable(WMHashTable
*table
);
162 void WMResetHashTable(WMHashTable
*table
);
164 void *WMHashGet(WMHashTable
*table
, const void *key
);
166 /* put data in table, replacing already existing data and returning
168 void *WMHashInsert(WMHashTable
*table
, void *key
, void *data
);
170 void WMHashRemove(WMHashTable
*table
, const void *key
);
172 /* warning: do not manipulate the table while using these functions */
173 WMHashEnumerator
WMEnumerateHashTable(WMHashTable
*table
);
175 void *WMNextHashEnumeratorItem(WMHashEnumerator
*enumerator
);
177 unsigned WMCountHashTable(WMHashTable
*table
);
182 /* some predefined callback sets */
184 extern const WMHashTableCallbacks WMIntHashCallbacks
;
185 /* sizeof(keys) are <= sizeof(void*) */
187 extern const WMHashTableCallbacks WMStringHashCallbacks
;
188 /* keys are strings. Strings will be copied with wstrdup()
189 * and freed with free() */
191 extern const WMHashTableCallbacks WMStringPointerHashCallbacks
;
192 /* keys are strings, bug they are not copied */
194 /*......................................................................*/
196 WMNotification
*WMCreateNotification(char *name
, void *object
, void *clientData
);
198 void WMReleaseNotification(WMNotification
*notification
);
200 WMNotification
*WMRetainNotification(WMNotification
*notification
);
202 void *WMGetNotificationClientData(WMNotification
*notification
);
204 void *WMGetNotificationObject(WMNotification
*notification
);
206 char *WMGetNotificationName(WMNotification
*notification
);
209 void WMAddNotificationObserver(WMNotificationObserverAction
*observerAction
,
210 void *observer
, char *name
, void *object
);
212 void WMPostNotification(WMNotification
*notification
);
214 void WMRemoveNotificationObserver(void *observer
);
216 void WMRemoveNotificationObserverWithName(void *observer
, char *name
,
219 void WMPostNotificationName(char *name
, void *object
, void *clientData
);
221 WMNotificationQueue
*WMGetDefaultNotificationQueue(void);
223 WMNotificationQueue
*WMCreateNotificationQueue(void);
225 void WMDequeueNotificationMatching(WMNotificationQueue
*queue
, unsigned mask
);
227 void WMEnqueueNotification(WMNotificationQueue
*queue
, WMNotification
*notification
,
228 WMPostingStyle postingStyle
);
230 void WMEnqueueCoalesceNotification(WMNotificationQueue
*queue
,
231 WMNotification
*notification
,
232 WMPostingStyle postingStyle
,
233 unsigned coalesceMask
);
236 /*......................................................................*/
238 WMUserDefaults
*WMGetStandardUserDefaults(void);
240 proplist_t
WMGetUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
242 void WMSetUDObjectForKey(WMUserDefaults
*database
, proplist_t object
,
245 void WMRemoveUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
247 /* you can free the returned string */
248 char *WMGetUDStringForKey(WMUserDefaults
*database
, char *defaultName
);
250 int WMGetUDIntegerForKey(WMUserDefaults
*database
, char *defaultName
);
252 int WMGetUDFloatForKey(WMUserDefaults
*database
, char *defaultName
);
254 Bool
WMGetUDBoolForKey(WMUserDefaults
*database
, char *defaultName
);
256 void WMSetUDStringForKey(WMUserDefaults
*database
, char *value
,
259 void WMSetUDIntegerForKey(WMUserDefaults
*database
, int value
,
262 void WMSetUDFloatForKey(WMUserDefaults
*database
, float value
,
265 void WMSetUDBoolForKey(WMUserDefaults
*database
, Bool value
,
268 proplist_t
WMGetUDSearchList(WMUserDefaults
*database
);
270 void WMSetUDSearchList(WMUserDefaults
*database
, proplist_t list
);