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
;
161 char character
; /* the escape character */
162 char *value
; /* value to place */
168 typedef void WMNotificationObserverAction(void *observerData
,
169 WMNotification
*notification
);
173 /*......................................................................*/
175 typedef void waborthandler(int);
177 waborthandler
* wsetabort(waborthandler
* handler
);
180 /* don't free the returned string */
181 char* wstrerror(int errnum
);
184 WMESSAGE_TYPE_MESSAGE
,
185 WMESSAGE_TYPE_WARNING
,
187 WMESSAGE_TYPE_WSYSERROR
,
188 WMESSAGE_TYPE_WSYSERRORWITHCODE
191 #define wmessage(fmt, args...) __wmessage( WMESSAGE_TYPE_MESSAGE, NULL, fmt, ## args)
192 #define wwarning(fmt, args...) __wmessage( WMESSAGE_TYPE_WARNING, NULL, fmt, ## args)
193 #define wfatal(fmt, args...) __wmessage( WMESSAGE_TYPE_FATAL, NULL, fmt, ## args)
194 #define wsyserror(fmt, args...) __wmessage( WMESSAGE_TYPE_WSYSERROR, NULL, fmt, ## args)
195 #define wsyserrorwithcode(errno, fmt, args...) \
196 __wmessage( WMESSAGE_TYPE_WSYSERRORWITHCODE, &errno, fmt, ## args)
198 void __wmessage(int type
, void *extra
, const char *msg
, ...) __attribute__((__format__(printf
,3,4)));
200 char* wfindfile(char *paths
, char *file
);
202 char* wfindfileinlist(char **path_list
, char *file
);
204 char* wfindfileinarray(WMPropList
* array
, char *file
);
206 char* wexpandpath(char *path
);
208 int wmkdirhier(const char *path
);
209 int wrmdirhier(const char *path
);
211 /* don't free the returned string */
214 void* wmalloc(size_t size
);
215 void* wrealloc(void *ptr
, size_t newsize
);
216 void wfree(void *ptr
);
218 #define wnew(type, count) wmalloc(sizeof(type)*count)
220 void wrelease(void *ptr
);
221 void* wretain(void *ptr
);
223 char *wstrdup(const char *str
);
224 char* wstrndup(const char *str
, size_t len
);
226 /* Concatenate str1 with str2 and return that in a newly malloc'ed string.
227 * str1 and str2 can be any strings including static and constant strings.
228 * str1 and str2 will not be modified.
229 * Free the returned string when you're done with it. */
230 char* wstrconcat(char *str1
, char *str2
);
232 /* This will append src to dst, and return dst. dst MUST be either NULL
233 * or a string that was a result of a dynamic allocation (malloc, realloc
234 * wmalloc, wrealloc, ...). dst CANNOT be a static or a constant string!
235 * Modifies dst (no new string is created except if dst==NULL in which case
236 * it is equivalent to calling wstrdup(src) ).
237 * The returned address may be different from the original address of dst,
238 * so always assign the returned address to avoid dangling pointers. */
239 char* wstrappend(char *dst
, char *src
);
242 void wtokensplit(char *command
, char ***argv
, int *argc
);
244 char* wtokennext(char *word
, char **next
);
246 char* wtokenjoin(char **list
, int count
);
248 void wtokenfree(char **tokens
, int count
);
250 char* wtrimspace(const char *s
);
253 WMRange
wmkrange(int start
, int count
);
254 #ifdef ANSI_C_DOESNT_LIKE_IT_THIS_WAY
255 #define wmkrange(position, count) (WMRange){(position), (count)}
259 char* wusergnusteppath();
261 char* wdefaultspathfordomain(char *domain
);
262 char* wglobaldefaultspathfordomain(const char *domain
);
264 void wusleep(unsigned int microsec
);
267 int wsprintesc(char *buffer
, int length
, char *format
, WMSEscapes
**escapes
,
271 /*......................................................................*/
273 /* Event handlers: timer, idle, input */
275 WMHandlerID
WMAddTimerHandler(int milliseconds
, WMCallback
*callback
,
278 WMHandlerID
WMAddPersistentTimerHandler(int milliseconds
, WMCallback
*callback
,
281 void WMDeleteTimerWithClientData(void *cdata
);
283 void WMDeleteTimerHandler(WMHandlerID handlerID
);
285 WMHandlerID
WMAddIdleHandler(WMCallback
*callback
, void *cdata
);
287 void WMDeleteIdleHandler(WMHandlerID handlerID
);
289 WMHandlerID
WMAddInputHandler(int fd
, int condition
, WMInputProc
*proc
,
292 void WMDeleteInputHandler(WMHandlerID handlerID
);
295 /* This function is used _only_ if you create a non-GUI program.
296 * For GUI based programs use WMNextEvent()/WMHandleEvent() instead.
297 * This function will handle all input/timer/idle events, then return.
300 void WHandleEvents();
302 /*......................................................................*/
305 WMHashTable
* WMCreateHashTable(WMHashTableCallbacks callbacks
);
307 void WMFreeHashTable(WMHashTable
*table
);
309 void WMResetHashTable(WMHashTable
*table
);
311 unsigned WMCountHashTable(WMHashTable
*table
);
313 void* WMHashGet(WMHashTable
*table
, const void *key
);
315 /* Returns True if there is a value associated with <key> in the table, in
316 * which case <retKey> and <retItem> will contain the item's internal key
317 * address and the item's value respectively.
318 * If there is no value associated with <key> it will return False and in
319 * this case <retKey> and <retItem> will be undefined.
320 * Use this when you need to perform your own custom retain/release mechanism
321 * which requires access to the keys too.
323 Bool
WMHashGetItemAndKey(WMHashTable
*table
, const void *key
,
324 void **retItem
, void **retKey
);
326 /* put data in table, replacing already existing data and returning
328 void* WMHashInsert(WMHashTable
*table
, const void *key
, const void *data
);
330 void WMHashRemove(WMHashTable
*table
, const void *key
);
332 /* warning: do not manipulate the table while using the enumerator functions */
333 WMHashEnumerator
WMEnumerateHashTable(WMHashTable
*table
);
335 void* WMNextHashEnumeratorItem(WMHashEnumerator
*enumerator
);
337 void* WMNextHashEnumeratorKey(WMHashEnumerator
*enumerator
);
339 /* Returns True if there is a next element, in which case key and item
340 * will contain the next element's key and value respectively.
341 * If there is no next element available it will return False and in this
342 * case key and item will be undefined.
344 Bool
WMNextHashEnumeratorItemAndKey(WMHashEnumerator
*enumerator
,
345 void **item
, void **key
);
350 /* some predefined callback sets */
352 extern const WMHashTableCallbacks WMIntHashCallbacks
;
353 /* sizeof(keys) are <= sizeof(void*) */
355 extern const WMHashTableCallbacks WMStringHashCallbacks
;
356 /* keys are strings. Strings will be copied with wstrdup()
357 * and freed with wfree() */
359 extern const WMHashTableCallbacks WMStringPointerHashCallbacks
;
360 /* keys are strings, but they are not copied */
363 /*......................................................................*/
366 * WMArray use an array to store the elements.
367 * Item indexes may be only positive integer numbers.
368 * The array cannot contain holes in it.
371 * Fast [O(1)] access to elements
372 * Fast [O(1)] push/pop
375 * A little slower [O(n)] for insertion/deletion of elements that
379 WMArray
* WMCreateArray(int initialSize
);
381 WMArray
* WMCreateArrayWithDestructor(int initialSize
, WMFreeDataProc
*destructor
);
383 WMArray
* WMCreateArrayWithArray(WMArray
*array
);
385 #define WMDuplicateArray(array) WMCreateArrayWithArray(array)
387 void WMEmptyArray(WMArray
*array
);
389 void WMFreeArray(WMArray
*array
);
391 int WMGetArrayItemCount(WMArray
*array
);
393 /* appends other to array. other remains unchanged */
394 void WMAppendArray(WMArray
*array
, WMArray
*other
);
396 /* add will place the element at the end of the array */
397 void WMAddToArray(WMArray
*array
, void *item
);
399 #define WMPushInArray(array, item) WMAddToArray(array, item)
401 /* insert will increment the index of elements after it by 1 */
402 void WMInsertInArray(WMArray
*array
, int index
, void *item
);
404 /* replace and set will return the old item WITHOUT calling the
405 * destructor on it even if its available. Free the returned item yourself.
407 void* WMReplaceInArray(WMArray
*array
, int index
, void *item
);
409 #define WMSetInArray(array, index, item) WMReplaceInArray(array, index, item)
411 /* delete and remove will remove the elements and cause the elements
412 * after them to decrement their indexes by 1. Also will call the
413 * destructor on the deleted element if there's one available.
415 int WMDeleteFromArray(WMArray
*array
, int index
);
417 #define WMRemoveFromArray(array, item) WMRemoveFromArrayMatching(array, NULL, item)
419 int WMRemoveFromArrayMatching(WMArray
*array
, WMMatchDataProc
*match
, void *cdata
);
421 void* WMGetFromArray(WMArray
*array
, int index
);
423 #define WMGetFirstInArray(array, item) WMFindInArray(array, NULL, item)
425 /* pop will return the last element from the array, also removing it
426 * from the array. The destructor is NOT called, even if available.
427 * Free the returned element if needed by yourself
429 void* WMPopFromArray(WMArray
*array
);
431 int WMFindInArray(WMArray
*array
, WMMatchDataProc
*match
, void *cdata
);
433 int WMCountInArray(WMArray
*array
, void *item
);
435 /* comparer must return:
440 void WMSortArray(WMArray
*array
, WMCompareDataProc
*comparer
);
442 void WMMapArray(WMArray
*array
, void (*function
)(void*, void*), void *data
);
444 WMArray
* WMGetSubarrayWithRange(WMArray
* array
, WMRange aRange
);
446 void* WMArrayFirst(WMArray
*array
, WMArrayIterator
*iter
);
448 void* WMArrayLast(WMArray
*array
, WMArrayIterator
*iter
);
450 /* The following 2 functions assume that the array doesn't change between calls */
451 void* WMArrayNext(WMArray
*array
, WMArrayIterator
*iter
);
453 void* WMArrayPrevious(WMArray
*array
, WMArrayIterator
*iter
);
456 /* The following 2 macros assume that the array doesn't change in the for loop */
457 #define WM_ITERATE_ARRAY(array, var, i) \
458 for (var = WMArrayFirst(array, &(i)); (i) != WANotFound; \
459 var = WMArrayNext(array, &(i)))
461 #define WM_ETARETI_ARRAY(array, var, i) \
462 for (var = WMArrayLast(array, &(i)); (i) != WANotFound; \
463 var = WMArrayPrevious(array, &(i)))
465 /*..........................................................................*/
468 * Tree bags use a red-black tree for storage.
469 * Item indexes may be any integer number.
472 * O(lg n) insertion/deletion/search
473 * Good for large numbers of elements with sparse indexes
476 * O(lg n) insertion/deletion/search
477 * Slow for storing small numbers of elements
480 #define WMCreateBag(size) WMCreateTreeBag()
482 #define WMCreateBagWithDestructor(size, d) WMCreateTreeBagWithDestructor(d)
484 WMBag
* WMCreateTreeBag(void);
486 WMBag
* WMCreateTreeBagWithDestructor(WMFreeDataProc
*destructor
);
488 int WMGetBagItemCount(WMBag
*bag
);
490 void WMAppendBag(WMBag
*bag
, WMBag
*other
);
492 void WMPutInBag(WMBag
*bag
, void *item
);
494 /* insert will increment the index of elements after it by 1 */
495 void WMInsertInBag(WMBag
*bag
, int index
, void *item
);
497 /* erase will remove the element from the bag,
498 * but will keep the index of the other elements unchanged */
499 int WMEraseFromBag(WMBag
*bag
, int index
);
501 /* delete and remove will remove the elements and cause the elements
502 * after them to decrement their indexes by 1 */
503 int WMDeleteFromBag(WMBag
*bag
, int index
);
505 int WMRemoveFromBag(WMBag
*bag
, void *item
);
507 void* WMGetFromBag(WMBag
*bag
, int index
);
509 void* WMReplaceInBag(WMBag
*bag
, int index
, void *item
);
511 #define WMSetInBag(bag, index, item) WMReplaceInBag(bag, index, item)
513 /* comparer must return:
518 void WMSortBag(WMBag
*bag
, WMCompareDataProc
*comparer
);
520 void WMEmptyBag(WMBag
*bag
);
522 void WMFreeBag(WMBag
*bag
);
524 void WMMapBag(WMBag
*bag
, void (*function
)(void*, void*), void *data
);
526 int WMGetFirstInBag(WMBag
*bag
, void *item
);
528 int WMCountInBag(WMBag
*bag
, void *item
);
530 int WMFindInBag(WMBag
*bag
, WMMatchDataProc
*match
, void *cdata
);
532 void* WMBagFirst(WMBag
*bag
, WMBagIterator
*ptr
);
534 void* WMBagLast(WMBag
*bag
, WMBagIterator
*ptr
);
536 /* The following 4 functions assume that the bag doesn't change between calls */
537 void* WMBagNext(WMBag
*bag
, WMBagIterator
*ptr
);
539 void* WMBagPrevious(WMBag
*bag
, WMBagIterator
*ptr
);
541 void* WMBagIteratorAtIndex(WMBag
*bag
, int index
, WMBagIterator
*ptr
);
543 int WMBagIndexForIterator(WMBag
*bag
, WMBagIterator ptr
);
546 /* The following 2 macros assume that the bag doesn't change in the for loop */
547 #define WM_ITERATE_BAG(bag, var, i) \
548 for (var = WMBagFirst(bag, &(i)); (i) != NULL; \
549 var = WMBagNext(bag, &(i)))
551 #define WM_ETARETI_BAG(bag, var, i) \
552 for (var = WMBagLast(bag, &(i)); (i) != NULL; \
553 var = WMBagPrevious(bag, &(i)))
557 /*-------------------------------------------------------------------------*/
559 /* WMData handling */
561 /* Creating/destroying data */
563 WMData
* WMCreateDataWithCapacity(unsigned capacity
);
565 WMData
* WMCreateDataWithLength(unsigned length
);
567 WMData
* WMCreateDataWithBytes(void *bytes
, unsigned length
);
569 /* destructor is a function called to free the data when releasing the data
570 * object, or NULL if no freeing of data is necesary. */
571 WMData
* WMCreateDataWithBytesNoCopy(void *bytes
, unsigned length
,
572 WMFreeDataProc
*destructor
);
574 WMData
* WMCreateDataWithData(WMData
*aData
);
576 WMData
* WMRetainData(WMData
*aData
);
578 void WMReleaseData(WMData
*aData
);
580 /* Adjusting capacity */
582 void WMSetDataCapacity(WMData
*aData
, unsigned capacity
);
584 void WMSetDataLength(WMData
*aData
, unsigned length
);
586 void WMIncreaseDataLengthBy(WMData
*aData
, unsigned extraLength
);
590 const void* WMDataBytes(WMData
*aData
);
592 void WMGetDataBytes(WMData
*aData
, void *buffer
);
594 void WMGetDataBytesWithLength(WMData
*aData
, void *buffer
, unsigned length
);
596 void WMGetDataBytesWithRange(WMData
*aData
, void *buffer
, WMRange aRange
);
598 WMData
* WMGetSubdataWithRange(WMData
*aData
, WMRange aRange
);
602 Bool
WMIsDataEqualToData(WMData
*aData
, WMData
*anotherData
);
604 unsigned WMGetDataLength(WMData
*aData
);
608 void WMAppendDataBytes(WMData
*aData
, void *bytes
, unsigned length
);
610 void WMAppendData(WMData
*aData
, WMData
*anotherData
);
614 void WMReplaceDataBytesInRange(WMData
*aData
, WMRange aRange
, void *bytes
);
616 void WMResetDataBytesInRange(WMData
*aData
, WMRange aRange
);
618 void WMSetData(WMData
*aData
, WMData
*anotherData
);
621 void WMSetDataFormat(WMData
*aData
, unsigned format
);
623 unsigned WMGetDataFormat(WMData
*aData
);
627 /*--------------------------------------------------------------------------*/
629 /* Generic Tree and TreeNode */
631 WMTreeNode
* WMCreateTreeNode(void *data
);
633 WMTreeNode
* WMCreateTreeNodeWithDestructor(void *data
, WMFreeDataProc
*destructor
);
635 WMTreeNode
* WMInsertItemInTree(WMTreeNode
*parent
, int index
, void *item
);
637 #define WMAddItemToTree(parent, item) WMInsertItemInTree(parent, -1, item)
639 WMTreeNode
* WMInsertNodeInTree(WMTreeNode
*parent
, int index
, WMTreeNode
*aNode
);
641 #define WMAddNodeToTree(parent, aNode) WMInsertNodeInTree(parent, -1, aNode)
643 void WMDestroyTreeNode(WMTreeNode
*aNode
);
645 void WMDeleteLeafForTreeNode(WMTreeNode
*aNode
, int index
);
647 void WMRemoveLeafForTreeNode(WMTreeNode
*aNode
, void *leaf
);
649 void* WMReplaceDataForTreeNode(WMTreeNode
*aNode
, void *newData
);
651 void* WMGetDataForTreeNode(WMTreeNode
*aNode
);
653 int WMGetTreeNodeDepth(WMTreeNode
*aNode
);
655 WMTreeNode
* WMGetParentForTreeNode(WMTreeNode
*aNode
);
657 /* Sort only the leaves of the passed node */
658 void WMSortLeavesForTreeNode(WMTreeNode
*aNode
, WMCompareDataProc
*comparer
);
660 /* Sort all tree recursively starting from the passed node */
661 void WMSortTree(WMTreeNode
*aNode
, WMCompareDataProc
*comparer
);
663 /* Returns the first node which matches node's data with cdata by 'match' */
664 WMTreeNode
* WMFindInTree(WMTreeNode
*aTree
, WMMatchDataProc
*match
, void *cdata
);
666 /* Returns first tree node that has data == cdata */
667 #define WMGetFirstInTree(aTree, cdata) WMFindInTree(aTree, NULL, cdata)
670 /*--------------------------------------------------------------------------*/
673 WMNotification
* WMCreateNotification(const char *name
, void *object
, void *clientData
);
675 void WMReleaseNotification(WMNotification
*notification
);
677 WMNotification
* WMRetainNotification(WMNotification
*notification
);
679 void* WMGetNotificationClientData(WMNotification
*notification
);
681 void* WMGetNotificationObject(WMNotification
*notification
);
683 const char* WMGetNotificationName(WMNotification
*notification
);
686 void WMAddNotificationObserver(WMNotificationObserverAction
*observerAction
,
687 void *observer
, const char *name
, void *object
);
689 void WMPostNotification(WMNotification
*notification
);
691 void WMRemoveNotificationObserver(void *observer
);
693 void WMRemoveNotificationObserverWithName(void *observer
, const char *name
,
696 void WMPostNotificationName(const char *name
, void *object
, void *clientData
);
698 WMNotificationQueue
* WMGetDefaultNotificationQueue(void);
700 WMNotificationQueue
* WMCreateNotificationQueue(void);
702 void WMDequeueNotificationMatching(WMNotificationQueue
*queue
,
703 WMNotification
*notification
,
706 void WMEnqueueNotification(WMNotificationQueue
*queue
,
707 WMNotification
*notification
,
708 WMPostingStyle postingStyle
);
710 void WMEnqueueCoalesceNotification(WMNotificationQueue
*queue
,
711 WMNotification
*notification
,
712 WMPostingStyle postingStyle
,
713 unsigned coalesceMask
);
716 /*......................................................................*/
718 /* Property Lists handling */
720 void WMPLSetCaseSensitive(Bool caseSensitive
);
722 WMPropList
* WMCreatePLString(char *str
);
724 WMPropList
* WMCreatePLData(WMData
*data
);
726 WMPropList
* WMCreatePLDataWithBytes(unsigned char *bytes
, unsigned int length
);
728 WMPropList
* WMCreatePLDataWithBytesNoCopy(unsigned char *bytes
,
730 WMFreeDataProc
*destructor
);
732 WMPropList
* WMCreatePLArray(WMPropList
*elem
, ...);
734 WMPropList
* WMCreatePLDictionary(WMPropList
*key
, WMPropList
*value
, ...);
736 WMPropList
* WMRetainPropList(WMPropList
*plist
);
738 void WMReleasePropList(WMPropList
*plist
);
740 /* Objects inserted in arrays and dictionaries will be retained,
741 * so you can safely release them after insertion.
742 * For dictionaries both the key and value are retained.
743 * Objects removed from arrays or dictionaries are released */
744 void WMInsertInPLArray(WMPropList
*plist
, int index
, WMPropList
*item
);
746 void WMAddToPLArray(WMPropList
*plist
, WMPropList
*item
);
748 void WMDeleteFromPLArray(WMPropList
*plist
, int index
);
750 void WMRemoveFromPLArray(WMPropList
*plist
, WMPropList
*item
);
752 void WMPutInPLDictionary(WMPropList
*plist
, WMPropList
*key
, WMPropList
*value
);
754 void WMRemoveFromPLDictionary(WMPropList
*plist
, WMPropList
*key
);
756 /* It will insert all key/value pairs from source into dest, overwriting
757 * the values with the same keys from dest, keeping all values with keys
758 * only present in dest unchanged */
759 WMPropList
* WMMergePLDictionaries(WMPropList
*dest
, WMPropList
*source
,
762 /* It will remove all key/value pairs from dest for which there is an
763 * identical key/value present in source. Entires only present in dest, or
764 * which have different values in dest than in source will be preserved. */
765 WMPropList
* WMSubtractPLDictionaries(WMPropList
*dest
, WMPropList
*source
,
768 int WMGetPropListItemCount(WMPropList
*plist
);
770 Bool
WMIsPLString(WMPropList
*plist
);
772 Bool
WMIsPLData(WMPropList
*plist
);
774 Bool
WMIsPLArray(WMPropList
*plist
);
776 Bool
WMIsPLDictionary(WMPropList
*plist
);
778 Bool
WMIsPropListEqualTo(WMPropList
*plist
, WMPropList
*other
);
780 /* Returns a reference. Do not free it! */
781 char* WMGetFromPLString(WMPropList
*plist
);
783 /* Returns a reference. Do not free it! */
784 WMData
* WMGetFromPLData(WMPropList
*plist
);
786 /* Returns a reference. Do not free it! */
787 const unsigned char* WMGetPLDataBytes(WMPropList
*plist
);
789 int WMGetPLDataLength(WMPropList
*plist
);
791 /* Returns a reference. */
792 WMPropList
* WMGetFromPLArray(WMPropList
*plist
, int index
);
794 /* Returns a reference. */
795 WMPropList
* WMGetFromPLDictionary(WMPropList
*plist
, WMPropList
*key
);
797 /* Returns a PropList array with all the dictionary keys. Release it when
798 * you're done. Keys in array are retained from the original dictionary
799 * not copied and need NOT to be released individually. */
800 WMPropList
* WMGetPLDictionaryKeys(WMPropList
*plist
);
802 /* Creates only the first level deep object. All the elements inside are
803 * retained from the original */
804 WMPropList
* WMShallowCopyPropList(WMPropList
*plist
);
806 /* Makes a completely separate replica of the original proplist */
807 WMPropList
* WMDeepCopyPropList(WMPropList
*plist
);
809 WMPropList
* WMCreatePropListFromDescription(char *desc
);
811 /* Free the returned string when you no longer need it */
812 char* WMGetPropListDescription(WMPropList
*plist
, Bool indented
);
814 WMPropList
* WMReadPropListFromFile(char *file
);
816 Bool
WMWritePropListToFile(WMPropList
*plist
, char *path
);
818 /*......................................................................*/
820 WMUserDefaults
* WMGetStandardUserDefaults(void);
822 WMUserDefaults
* WMGetDefaultsFromPath(char *path
);
824 void WMSynchronizeUserDefaults(WMUserDefaults
*database
);
826 void WMSaveUserDefaults(WMUserDefaults
*database
);
828 void WMEnableUDPeriodicSynchronization(WMUserDefaults
*database
, Bool enable
);
830 /* Returns a WMPropList array with all the keys in the user defaults database.
831 * Free the array with WMReleasePropList() when no longer needed.
832 * Keys in array are just retained references to the original keys */
833 WMPropList
* WMGetUDKeys(WMUserDefaults
*database
);
835 WMPropList
* WMGetUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
837 void WMSetUDObjectForKey(WMUserDefaults
*database
, WMPropList
*object
,
840 void WMRemoveUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
842 char* WMGetUDStringForKey(WMUserDefaults
*database
, char *defaultName
);
844 int WMGetUDIntegerForKey(WMUserDefaults
*database
, char *defaultName
);
846 float WMGetUDFloatForKey(WMUserDefaults
*database
, char *defaultName
);
848 Bool
WMGetUDBoolForKey(WMUserDefaults
*database
, char *defaultName
);
850 void WMSetUDStringForKey(WMUserDefaults
*database
, char *value
,
853 void WMSetUDIntegerForKey(WMUserDefaults
*database
, int value
,
856 void WMSetUDFloatForKey(WMUserDefaults
*database
, float value
,
859 void WMSetUDBoolForKey(WMUserDefaults
*database
, Bool value
,
862 WMPropList
* WMGetUDSearchList(WMUserDefaults
*database
);
864 void WMSetUDSearchList(WMUserDefaults
*database
, WMPropList
*list
);
866 extern char *WMUserDefaultsDidChangeNotification
;
869 /*-------------------------------------------------------------------------*/
871 /* Global variables */
873 extern int WCErrorCode
;
876 /*-------------------------------------------------------------------------*/
882 #endif /* __cplusplus */