8 /* SunOS 4.x Blargh.... */
10 #define NULL ((void*)0)
15 # define WMAX(a,b) ((a)>(b) ? (a) : (b))
18 # define WMIN(a,b) ((a)<(b) ? (a) : (b))
22 #ifndef __ASSERT_FUNCTION
23 # if (!defined (__GNUC__) || (__GNUC__ < 2 && \
24 __GNUC_MINOR__ < (defined (__cplusplus) ? 6 : 4)))
25 # define __ASSERT_FUNCTION ((char *) 0)
27 # define __ASSERT_FUNCTION __PRETTY_FUNCTION__
32 #define __attribute__(x) /*NOTHING*/
37 #define wassertr(expr) {}
38 #define wassertrv(expr, val) {}
46 #define wassertr(expr) assert(expr)
48 #define wassertrv(expr, val) assert(expr)
52 #define wassertr(expr) \
54 wwarning("%s line %i (%s): assertion %s failed",\
55 __FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
59 #define wassertrv(expr, val) \
61 wwarning("%s line %i (%s): assertion %s failed",\
62 __FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
72 #endif /* __cplusplus */
86 } WMNotificationCoalescing
;
91 WBNotFound
= INT_MIN
, /* element was not found in WMBag */
92 WANotFound
= -1 /* element was not found in WMArray */
96 typedef struct W_Array WMArray
;
97 typedef struct W_Bag WMBag
;
98 typedef struct W_Data WMData
;
99 typedef struct W_TreeNode WMTreeNode
;
100 typedef struct W_HashTable WMHashTable
;
101 typedef struct W_UserDefaults WMUserDefaults
;
102 typedef struct W_Notification WMNotification
;
103 typedef struct W_NotificationQueue WMNotificationQueue
;
104 typedef struct W_Host WMHost
;
105 typedef struct W_Connection WMConnection
;
106 typedef struct W_PropList WMPropList
;
110 /* Some typedefs for the handler stuff */
111 typedef void *WMHandlerID
;
113 typedef void WMCallback(void *data
);
115 typedef void WMInputProc(int fd
, int mask
, void *clientData
);
119 typedef int WMCompareDataProc(const void *item1
, const void *item2
);
121 typedef void WMFreeDataProc(void *data
);
123 /* Used by WMBag or WMArray for matching data */
124 typedef int WMMatchDataProc(const void *item
, const void *cdata
);
135 /* DO NOT ACCESS THE CONTENTS OF THIS STRUCT */
144 /* NULL is pointer hash */
145 unsigned (*hash
)(const void *);
146 /* NULL is pointer compare */
147 Bool (*keyIsEqual
)(const void *, const void *);
148 /* NULL does nothing */
149 void* (*retainKey
)(const void *);
150 /* NULL does nothing */
151 void (*releaseKey
)(const void *);
152 } WMHashTableCallbacks
;
155 typedef int WMArrayIterator
;
156 typedef void *WMBagIterator
;
159 typedef void WMNotificationObserverAction(void *observerData
,
160 WMNotification
*notification
);
163 /*......................................................................*/
165 typedef void waborthandler(int);
167 waborthandler
* wsetabort(waborthandler
* handler
);
170 WMESSAGE_TYPE_MESSAGE
,
171 WMESSAGE_TYPE_WARNING
,
176 #define wmessage(fmt, args...) __wmessage( __func__, __FILE__, __LINE__, WMESSAGE_TYPE_MESSAGE, fmt, ## args)
177 #define wwarning(fmt, args...) __wmessage( __func__, __FILE__, __LINE__, WMESSAGE_TYPE_WARNING, fmt, ## args)
178 #define werror(fmt, args...) __wmessage( __func__, __FILE__, __LINE__, WMESSAGE_TYPE_ERROR, fmt, ## args)
179 #define wfatal(fmt, args...) __wmessage( __func__, __FILE__, __LINE__, WMESSAGE_TYPE_FATAL, fmt, ## args)
181 void __wmessage(const char *func
, const char *file
, int line
, int type
, const char *msg
, ...)
182 __attribute__((__format__(printf
,5,6)));
184 char* wfindfile(char *paths
, char *file
);
186 char* wfindfileinlist(char **path_list
, char *file
);
188 char* wfindfileinarray(WMPropList
* array
, char *file
);
190 char* wexpandpath(char *path
);
192 int wmkdirhier(const char *path
);
193 int wrmdirhier(const char *path
);
195 /* don't free the returned string */
196 char* wgethomedir(void);
198 void* wmalloc(size_t size
);
199 void* wrealloc(void *ptr
, size_t newsize
);
200 void wfree(void *ptr
);
202 void wrelease(void *ptr
);
203 void* wretain(void *ptr
);
205 char *wstrdup(const char *str
);
206 char* wstrndup(const char *str
, size_t len
);
208 /* Concatenate str1 with str2 and return that in a newly malloc'ed string.
209 * str1 and str2 can be any strings including static and constant strings.
210 * str1 and str2 will not be modified.
211 * Free the returned string when you're done with it. */
212 char* wstrconcat(char *str1
, char *str2
);
214 /* This will append src to dst, and return dst. dst MUST be either NULL
215 * or a string that was a result of a dynamic allocation (malloc, realloc
216 * wmalloc, wrealloc, ...). dst CANNOT be a static or a constant string!
217 * Modifies dst (no new string is created except if dst==NULL in which case
218 * it is equivalent to calling wstrdup(src) ).
219 * The returned address may be different from the original address of dst,
220 * so always assign the returned address to avoid dangling pointers. */
221 char* wstrappend(char *dst
, char *src
);
223 size_t wstrlcpy(char *, const char *, size_t);
224 size_t wstrlcat(char *, const char *, size_t);
227 void wtokensplit(char *command
, char ***argv
, int *argc
);
229 char* wtokennext(char *word
, char **next
);
231 char* wtokenjoin(char **list
, int count
);
233 void wtokenfree(char **tokens
, int count
);
235 char* wtrimspace(const char *s
);
238 WMRange
wmkrange(int start
, int count
);
241 char* wusergnusteppath(void);
243 char* wdefaultspathfordomain(char *domain
);
244 char* wglobaldefaultspathfordomain(const char *domain
);
246 void wusleep(unsigned int microsec
);
248 /*......................................................................*/
250 /* Event handlers: timer, idle, input */
252 WMHandlerID
WMAddTimerHandler(int milliseconds
, WMCallback
*callback
,
255 WMHandlerID
WMAddPersistentTimerHandler(int milliseconds
, WMCallback
*callback
,
258 void WMDeleteTimerWithClientData(void *cdata
);
260 void WMDeleteTimerHandler(WMHandlerID handlerID
);
262 WMHandlerID
WMAddIdleHandler(WMCallback
*callback
, void *cdata
);
264 void WMDeleteIdleHandler(WMHandlerID handlerID
);
266 WMHandlerID
WMAddInputHandler(int fd
, int condition
, WMInputProc
*proc
,
269 void WMDeleteInputHandler(WMHandlerID handlerID
);
272 /* This function is used _only_ if you create a non-GUI program.
273 * For GUI based programs use WMNextEvent()/WMHandleEvent() instead.
274 * This function will handle all input/timer/idle events, then return.
277 void WHandleEvents(void);
279 /*......................................................................*/
282 WMHashTable
* WMCreateHashTable(WMHashTableCallbacks callbacks
);
284 void WMFreeHashTable(WMHashTable
*table
);
286 void WMResetHashTable(WMHashTable
*table
);
288 unsigned WMCountHashTable(WMHashTable
*table
);
290 void* WMHashGet(WMHashTable
*table
, const void *key
);
292 /* Returns True if there is a value associated with <key> in the table, in
293 * which case <retKey> and <retItem> will contain the item's internal key
294 * address and the item's value respectively.
295 * If there is no value associated with <key> it will return False and in
296 * this case <retKey> and <retItem> will be undefined.
297 * Use this when you need to perform your own custom retain/release mechanism
298 * which requires access to the keys too.
300 Bool
WMHashGetItemAndKey(WMHashTable
*table
, const void *key
,
301 void **retItem
, void **retKey
);
303 /* put data in table, replacing already existing data and returning
305 void* WMHashInsert(WMHashTable
*table
, const void *key
, const void *data
);
307 void WMHashRemove(WMHashTable
*table
, const void *key
);
309 /* warning: do not manipulate the table while using the enumerator functions */
310 WMHashEnumerator
WMEnumerateHashTable(WMHashTable
*table
);
312 void* WMNextHashEnumeratorItem(WMHashEnumerator
*enumerator
);
314 void* WMNextHashEnumeratorKey(WMHashEnumerator
*enumerator
);
316 /* Returns True if there is a next element, in which case key and item
317 * will contain the next element's key and value respectively.
318 * If there is no next element available it will return False and in this
319 * case key and item will be undefined.
321 Bool
WMNextHashEnumeratorItemAndKey(WMHashEnumerator
*enumerator
,
322 void **item
, void **key
);
327 /* some predefined callback sets */
329 extern const WMHashTableCallbacks WMIntHashCallbacks
;
330 /* sizeof(keys) are <= sizeof(void*) */
332 extern const WMHashTableCallbacks WMStringHashCallbacks
;
333 /* keys are strings. Strings will be copied with wstrdup()
334 * and freed with wfree() */
336 extern const WMHashTableCallbacks WMStringPointerHashCallbacks
;
337 /* keys are strings, but they are not copied */
340 /*......................................................................*/
343 * WMArray use an array to store the elements.
344 * Item indexes may be only positive integer numbers.
345 * The array cannot contain holes in it.
348 * Fast [O(1)] access to elements
349 * Fast [O(1)] push/pop
352 * A little slower [O(n)] for insertion/deletion of elements that
356 WMArray
* WMCreateArray(int initialSize
);
358 WMArray
* WMCreateArrayWithDestructor(int initialSize
, WMFreeDataProc
*destructor
);
360 WMArray
* WMCreateArrayWithArray(WMArray
*array
);
362 #define WMDuplicateArray(array) WMCreateArrayWithArray(array)
364 void WMEmptyArray(WMArray
*array
);
366 void WMFreeArray(WMArray
*array
);
368 int WMGetArrayItemCount(WMArray
*array
);
370 /* appends other to array. other remains unchanged */
371 void WMAppendArray(WMArray
*array
, WMArray
*other
);
373 /* add will place the element at the end of the array */
374 void WMAddToArray(WMArray
*array
, void *item
);
376 /* insert will increment the index of elements after it by 1 */
377 void WMInsertInArray(WMArray
*array
, int index
, void *item
);
379 /* replace and set will return the old item WITHOUT calling the
380 * destructor on it even if its available. Free the returned item yourself.
382 void* WMReplaceInArray(WMArray
*array
, int index
, void *item
);
384 #define WMSetInArray(array, index, item) WMReplaceInArray(array, index, item)
386 /* delete and remove will remove the elements and cause the elements
387 * after them to decrement their indexes by 1. Also will call the
388 * destructor on the deleted element if there's one available.
390 int WMDeleteFromArray(WMArray
*array
, int index
);
392 #define WMRemoveFromArray(array, item) WMRemoveFromArrayMatching(array, NULL, item)
394 int WMRemoveFromArrayMatching(WMArray
*array
, WMMatchDataProc
*match
, void *cdata
);
396 void* WMGetFromArray(WMArray
*array
, int index
);
398 #define WMGetFirstInArray(array, item) WMFindInArray(array, NULL, item)
400 /* pop will return the last element from the array, also removing it
401 * from the array. The destructor is NOT called, even if available.
402 * Free the returned element if needed by yourself
404 void* WMPopFromArray(WMArray
*array
);
406 int WMFindInArray(WMArray
*array
, WMMatchDataProc
*match
, void *cdata
);
408 int WMCountInArray(WMArray
*array
, void *item
);
410 /* comparer must return:
415 void WMSortArray(WMArray
*array
, WMCompareDataProc
*comparer
);
417 void WMMapArray(WMArray
*array
, void (*function
)(void*, void*), void *data
);
419 WMArray
* WMGetSubarrayWithRange(WMArray
* array
, WMRange aRange
);
421 void* WMArrayFirst(WMArray
*array
, WMArrayIterator
*iter
);
423 void* WMArrayLast(WMArray
*array
, WMArrayIterator
*iter
);
425 /* The following 2 functions assume that the array doesn't change between calls */
426 void* WMArrayNext(WMArray
*array
, WMArrayIterator
*iter
);
428 void* WMArrayPrevious(WMArray
*array
, WMArrayIterator
*iter
);
431 /* The following 2 macros assume that the array doesn't change in the for loop */
432 #define WM_ITERATE_ARRAY(array, var, i) \
433 for (var = WMArrayFirst(array, &(i)); (i) != WANotFound; \
434 var = WMArrayNext(array, &(i)))
436 #define WM_ETARETI_ARRAY(array, var, i) \
437 for (var = WMArrayLast(array, &(i)); (i) != WANotFound; \
438 var = WMArrayPrevious(array, &(i)))
440 /*..........................................................................*/
443 * Tree bags use a red-black tree for storage.
444 * Item indexes may be any integer number.
447 * O(lg n) insertion/deletion/search
448 * Good for large numbers of elements with sparse indexes
451 * O(lg n) insertion/deletion/search
452 * Slow for storing small numbers of elements
455 #define WMCreateBag(size) WMCreateTreeBag()
457 #define WMCreateBagWithDestructor(size, d) WMCreateTreeBagWithDestructor(d)
459 WMBag
* WMCreateTreeBag(void);
461 WMBag
* WMCreateTreeBagWithDestructor(WMFreeDataProc
*destructor
);
463 int WMGetBagItemCount(WMBag
*bag
);
465 void WMAppendBag(WMBag
*bag
, WMBag
*other
);
467 void WMPutInBag(WMBag
*bag
, void *item
);
469 /* insert will increment the index of elements after it by 1 */
470 void WMInsertInBag(WMBag
*bag
, int index
, void *item
);
472 /* erase will remove the element from the bag,
473 * but will keep the index of the other elements unchanged */
474 int WMEraseFromBag(WMBag
*bag
, int index
);
476 /* delete and remove will remove the elements and cause the elements
477 * after them to decrement their indexes by 1 */
478 int WMDeleteFromBag(WMBag
*bag
, int index
);
480 int WMRemoveFromBag(WMBag
*bag
, void *item
);
482 void* WMGetFromBag(WMBag
*bag
, int index
);
484 void* WMReplaceInBag(WMBag
*bag
, int index
, void *item
);
486 #define WMSetInBag(bag, index, item) WMReplaceInBag(bag, index, item)
488 /* comparer must return:
493 void WMSortBag(WMBag
*bag
, WMCompareDataProc
*comparer
);
495 void WMEmptyBag(WMBag
*bag
);
497 void WMFreeBag(WMBag
*bag
);
499 void WMMapBag(WMBag
*bag
, void (*function
)(void*, void*), void *data
);
501 int WMGetFirstInBag(WMBag
*bag
, void *item
);
503 int WMCountInBag(WMBag
*bag
, void *item
);
505 int WMFindInBag(WMBag
*bag
, WMMatchDataProc
*match
, void *cdata
);
507 void* WMBagFirst(WMBag
*bag
, WMBagIterator
*ptr
);
509 void* WMBagLast(WMBag
*bag
, WMBagIterator
*ptr
);
511 /* The following 4 functions assume that the bag doesn't change between calls */
512 void* WMBagNext(WMBag
*bag
, WMBagIterator
*ptr
);
514 void* WMBagPrevious(WMBag
*bag
, WMBagIterator
*ptr
);
516 void* WMBagIteratorAtIndex(WMBag
*bag
, int index
, WMBagIterator
*ptr
);
518 int WMBagIndexForIterator(WMBag
*bag
, WMBagIterator ptr
);
521 /* The following 2 macros assume that the bag doesn't change in the for loop */
522 #define WM_ITERATE_BAG(bag, var, i) \
523 for (var = WMBagFirst(bag, &(i)); (i) != NULL; \
524 var = WMBagNext(bag, &(i)))
526 #define WM_ETARETI_BAG(bag, var, i) \
527 for (var = WMBagLast(bag, &(i)); (i) != NULL; \
528 var = WMBagPrevious(bag, &(i)))
532 /*-------------------------------------------------------------------------*/
534 /* WMData handling */
536 /* Creating/destroying data */
538 WMData
* WMCreateDataWithCapacity(unsigned capacity
);
540 WMData
* WMCreateDataWithLength(unsigned length
);
542 WMData
* WMCreateDataWithBytes(void *bytes
, unsigned length
);
544 /* destructor is a function called to free the data when releasing the data
545 * object, or NULL if no freeing of data is necesary. */
546 WMData
* WMCreateDataWithBytesNoCopy(void *bytes
, unsigned length
,
547 WMFreeDataProc
*destructor
);
549 WMData
* WMCreateDataWithData(WMData
*aData
);
551 WMData
* WMRetainData(WMData
*aData
);
553 void WMReleaseData(WMData
*aData
);
555 /* Adjusting capacity */
557 void WMSetDataCapacity(WMData
*aData
, unsigned capacity
);
559 void WMSetDataLength(WMData
*aData
, unsigned length
);
561 void WMIncreaseDataLengthBy(WMData
*aData
, unsigned extraLength
);
565 const void* WMDataBytes(WMData
*aData
);
567 void WMGetDataBytes(WMData
*aData
, void *buffer
);
569 void WMGetDataBytesWithLength(WMData
*aData
, void *buffer
, unsigned length
);
571 void WMGetDataBytesWithRange(WMData
*aData
, void *buffer
, WMRange aRange
);
573 WMData
* WMGetSubdataWithRange(WMData
*aData
, WMRange aRange
);
577 Bool
WMIsDataEqualToData(WMData
*aData
, WMData
*anotherData
);
579 unsigned WMGetDataLength(WMData
*aData
);
583 void WMAppendDataBytes(WMData
*aData
, void *bytes
, unsigned length
);
585 void WMAppendData(WMData
*aData
, WMData
*anotherData
);
589 void WMReplaceDataBytesInRange(WMData
*aData
, WMRange aRange
, void *bytes
);
591 void WMResetDataBytesInRange(WMData
*aData
, WMRange aRange
);
593 void WMSetData(WMData
*aData
, WMData
*anotherData
);
596 void WMSetDataFormat(WMData
*aData
, unsigned format
);
598 unsigned WMGetDataFormat(WMData
*aData
);
602 /*--------------------------------------------------------------------------*/
604 /* Generic Tree and TreeNode */
606 WMTreeNode
* WMCreateTreeNode(void *data
);
608 WMTreeNode
* WMCreateTreeNodeWithDestructor(void *data
, WMFreeDataProc
*destructor
);
610 WMTreeNode
* WMInsertItemInTree(WMTreeNode
*parent
, int index
, void *item
);
612 #define WMAddItemToTree(parent, item) WMInsertItemInTree(parent, -1, item)
614 WMTreeNode
* WMInsertNodeInTree(WMTreeNode
*parent
, int index
, WMTreeNode
*aNode
);
616 #define WMAddNodeToTree(parent, aNode) WMInsertNodeInTree(parent, -1, aNode)
618 void WMDestroyTreeNode(WMTreeNode
*aNode
);
620 void WMDeleteLeafForTreeNode(WMTreeNode
*aNode
, int index
);
622 void WMRemoveLeafForTreeNode(WMTreeNode
*aNode
, void *leaf
);
624 void* WMReplaceDataForTreeNode(WMTreeNode
*aNode
, void *newData
);
626 void* WMGetDataForTreeNode(WMTreeNode
*aNode
);
628 int WMGetTreeNodeDepth(WMTreeNode
*aNode
);
630 WMTreeNode
* WMGetParentForTreeNode(WMTreeNode
*aNode
);
632 /* Sort only the leaves of the passed node */
633 void WMSortLeavesForTreeNode(WMTreeNode
*aNode
, WMCompareDataProc
*comparer
);
635 /* Sort all tree recursively starting from the passed node */
636 void WMSortTree(WMTreeNode
*aNode
, WMCompareDataProc
*comparer
);
638 /* Returns the first node which matches node's data with cdata by 'match' */
639 WMTreeNode
* WMFindInTree(WMTreeNode
*aTree
, WMMatchDataProc
*match
, void *cdata
);
641 /* Returns first tree node that has data == cdata */
642 #define WMGetFirstInTree(aTree, cdata) WMFindInTree(aTree, NULL, cdata)
645 /*--------------------------------------------------------------------------*/
648 WMNotification
* WMCreateNotification(const char *name
, void *object
, void *clientData
);
650 void WMReleaseNotification(WMNotification
*notification
);
652 WMNotification
* WMRetainNotification(WMNotification
*notification
);
654 void* WMGetNotificationClientData(WMNotification
*notification
);
656 void* WMGetNotificationObject(WMNotification
*notification
);
658 const char* WMGetNotificationName(WMNotification
*notification
);
661 void WMAddNotificationObserver(WMNotificationObserverAction
*observerAction
,
662 void *observer
, const char *name
, void *object
);
664 void WMPostNotification(WMNotification
*notification
);
666 void WMRemoveNotificationObserver(void *observer
);
668 void WMRemoveNotificationObserverWithName(void *observer
, const char *name
,
671 void WMPostNotificationName(const char *name
, void *object
, void *clientData
);
673 WMNotificationQueue
* WMGetDefaultNotificationQueue(void);
675 WMNotificationQueue
* WMCreateNotificationQueue(void);
677 void WMDequeueNotificationMatching(WMNotificationQueue
*queue
,
678 WMNotification
*notification
,
681 void WMEnqueueNotification(WMNotificationQueue
*queue
,
682 WMNotification
*notification
,
683 WMPostingStyle postingStyle
);
685 void WMEnqueueCoalesceNotification(WMNotificationQueue
*queue
,
686 WMNotification
*notification
,
687 WMPostingStyle postingStyle
,
688 unsigned coalesceMask
);
691 /*......................................................................*/
693 /* Property Lists handling */
695 void WMPLSetCaseSensitive(Bool caseSensitive
);
697 WMPropList
* WMCreatePLString(char *str
);
699 WMPropList
* WMCreatePLData(WMData
*data
);
701 WMPropList
* WMCreatePLDataWithBytes(unsigned char *bytes
, unsigned int length
);
703 WMPropList
* WMCreatePLDataWithBytesNoCopy(unsigned char *bytes
,
705 WMFreeDataProc
*destructor
);
707 WMPropList
* WMCreatePLArray(WMPropList
*elem
, ...);
709 WMPropList
* WMCreatePLDictionary(WMPropList
*key
, WMPropList
*value
, ...);
711 WMPropList
* WMRetainPropList(WMPropList
*plist
);
713 void WMReleasePropList(WMPropList
*plist
);
715 /* Objects inserted in arrays and dictionaries will be retained,
716 * so you can safely release them after insertion.
717 * For dictionaries both the key and value are retained.
718 * Objects removed from arrays or dictionaries are released */
719 void WMInsertInPLArray(WMPropList
*plist
, int index
, WMPropList
*item
);
721 void WMAddToPLArray(WMPropList
*plist
, WMPropList
*item
);
723 void WMDeleteFromPLArray(WMPropList
*plist
, int index
);
725 void WMRemoveFromPLArray(WMPropList
*plist
, WMPropList
*item
);
727 void WMPutInPLDictionary(WMPropList
*plist
, WMPropList
*key
, WMPropList
*value
);
729 void WMRemoveFromPLDictionary(WMPropList
*plist
, WMPropList
*key
);
731 /* It will insert all key/value pairs from source into dest, overwriting
732 * the values with the same keys from dest, keeping all values with keys
733 * only present in dest unchanged */
734 WMPropList
* WMMergePLDictionaries(WMPropList
*dest
, WMPropList
*source
,
737 /* It will remove all key/value pairs from dest for which there is an
738 * identical key/value present in source. Entires only present in dest, or
739 * which have different values in dest than in source will be preserved. */
740 WMPropList
* WMSubtractPLDictionaries(WMPropList
*dest
, WMPropList
*source
,
743 int WMGetPropListItemCount(WMPropList
*plist
);
745 Bool
WMIsPLString(WMPropList
*plist
);
747 Bool
WMIsPLData(WMPropList
*plist
);
749 Bool
WMIsPLArray(WMPropList
*plist
);
751 Bool
WMIsPLDictionary(WMPropList
*plist
);
753 Bool
WMIsPropListEqualTo(WMPropList
*plist
, WMPropList
*other
);
755 /* Returns a reference. Do not free it! */
756 char* WMGetFromPLString(WMPropList
*plist
);
758 /* Returns a reference. Do not free it! */
759 WMData
* WMGetFromPLData(WMPropList
*plist
);
761 /* Returns a reference. Do not free it! */
762 const unsigned char* WMGetPLDataBytes(WMPropList
*plist
);
764 int WMGetPLDataLength(WMPropList
*plist
);
766 /* Returns a reference. */
767 WMPropList
* WMGetFromPLArray(WMPropList
*plist
, int index
);
769 /* Returns a reference. */
770 WMPropList
* WMGetFromPLDictionary(WMPropList
*plist
, WMPropList
*key
);
772 /* Returns a PropList array with all the dictionary keys. Release it when
773 * you're done. Keys in array are retained from the original dictionary
774 * not copied and need NOT to be released individually. */
775 WMPropList
* WMGetPLDictionaryKeys(WMPropList
*plist
);
777 /* Creates only the first level deep object. All the elements inside are
778 * retained from the original */
779 WMPropList
* WMShallowCopyPropList(WMPropList
*plist
);
781 /* Makes a completely separate replica of the original proplist */
782 WMPropList
* WMDeepCopyPropList(WMPropList
*plist
);
784 WMPropList
* WMCreatePropListFromDescription(char *desc
);
786 /* Free the returned string when you no longer need it */
787 char* WMGetPropListDescription(WMPropList
*plist
, Bool indented
);
789 WMPropList
* WMReadPropListFromFile(char *file
);
791 Bool
WMWritePropListToFile(WMPropList
*plist
, char *path
);
793 /*......................................................................*/
795 WMUserDefaults
* WMGetStandardUserDefaults(void);
797 WMUserDefaults
* WMGetDefaultsFromPath(char *path
);
799 void WMSynchronizeUserDefaults(WMUserDefaults
*database
);
801 void WMSaveUserDefaults(WMUserDefaults
*database
);
803 void WMEnableUDPeriodicSynchronization(WMUserDefaults
*database
, Bool enable
);
805 /* Returns a WMPropList array with all the keys in the user defaults database.
806 * Free the array with WMReleasePropList() when no longer needed.
807 * Keys in array are just retained references to the original keys */
808 WMPropList
* WMGetUDKeys(WMUserDefaults
*database
);
810 WMPropList
* WMGetUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
812 void WMSetUDObjectForKey(WMUserDefaults
*database
, WMPropList
*object
,
815 void WMRemoveUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
817 char* WMGetUDStringForKey(WMUserDefaults
*database
, char *defaultName
);
819 int WMGetUDIntegerForKey(WMUserDefaults
*database
, char *defaultName
);
821 float WMGetUDFloatForKey(WMUserDefaults
*database
, char *defaultName
);
823 Bool
WMGetUDBoolForKey(WMUserDefaults
*database
, char *defaultName
);
825 void WMSetUDStringForKey(WMUserDefaults
*database
, char *value
,
828 void WMSetUDIntegerForKey(WMUserDefaults
*database
, int value
,
831 void WMSetUDFloatForKey(WMUserDefaults
*database
, float value
,
834 void WMSetUDBoolForKey(WMUserDefaults
*database
, Bool value
,
837 WMPropList
* WMGetUDSearchList(WMUserDefaults
*database
);
839 void WMSetUDSearchList(WMUserDefaults
*database
, WMPropList
*list
);
841 extern char *WMUserDefaultsDidChangeNotification
;
844 /*-------------------------------------------------------------------------*/
846 /* Global variables */
848 extern int WCErrorCode
;
851 /*-------------------------------------------------------------------------*/
855 #endif /* __cplusplus */