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__
34
#define wassertr(expr) {}
35
#define wassertrv(expr, val) {}
43
#define wassertr(expr) assert(expr)
45
#define wassertrv(expr, val) assert(expr)
49
#define wassertr(expr) \
51
wwarning("%s line %i (%s): assertion %s failed",\
52
__FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
56
#define wassertrv(expr, val) \
58
wwarning("%s line %i (%s): assertion %s failed",\
59
__FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
69
#endif /* __cplusplus */
83
} WMNotificationCoalescing;
86
/* The possible states for connections */
99
/* The possible states for connection timeouts */
104
} WMConnectionTimeoutState;
109
WBNotFound = INT_MIN, /* element was not found in WMBag */
110
WANotFound = -1 /* element was not found in WMArray */
114
typedef struct W_Array WMArray;
115
typedef struct W_Bag WMBag;
116
typedef struct W_Data WMData;
117
typedef struct W_TreeNode WMTreeNode;
118
typedef struct W_HashTable WMHashTable;
119
typedef struct W_UserDefaults WMUserDefaults;
120
typedef struct W_Notification WMNotification;
121
typedef struct W_NotificationQueue WMNotificationQueue;
122
typedef struct W_Host WMHost;
123
typedef struct W_Connection WMConnection;
124
typedef struct W_PropList WMPropList;
128
/* Some typedefs for the handler stuff */
129
typedef void *WMHandlerID;
131
typedef void WMCallback(void *data);
133
typedef void WMInputProc(int fd, int mask, void *clientData);
137
typedef int WMCompareDataProc(const void *item1, const void *item2);
139
typedef void WMFreeDataProc(void *data);
141
/* Used by WMBag or WMArray for matching data */
142
typedef int WMMatchDataProc(void *item, void *cdata);
153
/* DO NOT ACCESS THE CONTENTS OF THIS STRUCT */
162
/* NULL is pointer hash */
163
unsigned (*hash)(const void *);
164
/* NULL is pointer compare */
165
Bool (*keyIsEqual)(const void *, const void *);
166
/* NULL does nothing */
167
void* (*retainKey)(const void *);
168
/* NULL does nothing */
169
void (*releaseKey)(const void *);
170
} WMHashTableCallbacks;
173
typedef int WMArrayIterator;
174
typedef void *WMBagIterator;
179
char character; /* the escape character */
180
char *value; /* value to place */
185
/* The connection callbacks */
186
typedef struct ConnectionDelegate {
189
void (*canResumeSending)(struct ConnectionDelegate *self, WMConnection *cPtr);
191
void (*didCatchException)(struct ConnectionDelegate *self, WMConnection *cPtr);
193
void (*didDie)(struct ConnectionDelegate *self, WMConnection *cPtr);
195
void (*didInitialize)(struct ConnectionDelegate *self, WMConnection *cPtr);
197
void (*didReceiveInput)(struct ConnectionDelegate *self, WMConnection *cPtr);
199
void (*didTimeout)(struct ConnectionDelegate *self, WMConnection *cPtr);
201
} ConnectionDelegate;
204
typedef void WMNotificationObserverAction(void *observerData,
205
WMNotification *notification);
209
/*......................................................................*/
211
typedef void waborthandler(int);
213
waborthandler* wsetabort(waborthandler* handler);
216
/* don't free the returned string */
217
char* wstrerror(int errnum);
219
void wmessage(const char *msg, ...);
220
void wwarning(const char *msg, ...);
221
void wfatal(const char *msg, ...);
222
void wsyserror(const char *msg, ...);
223
void wsyserrorwithcode(int error, const char *msg, ...);
225
char* wfindfile(char *paths, char *file);
227
char* wfindfileinlist(char **path_list, char *file);
229
char* wfindfileinarray(WMPropList* array, char *file);
231
char* wexpandpath(char *path);
233
/* don't free the returned string */
236
void* wmalloc(size_t size);
237
void* wrealloc(void *ptr, size_t newsize);
238
void wfree(void *ptr);
241
void wrelease(void *ptr);
242
void* wretain(void *ptr);
244
char* wstrdup(char *str);
245
char* wstrndup(char *str, size_t len);
247
/* Concatenate str1 with str2 and return that in a newly malloc'ed string.
248
* str1 and str2 can be any strings including static and constant strings.
249
* str1 and str2 will not be modified.
250
* Free the returned string when you're done with it. */
251
char* wstrconcat(char *str1, char *str2);
253
/* This will append src to dst, and return dst. dst MUST be either NULL
254
* or a string that was a result of a dynamic allocation (malloc, realloc
255
* wmalloc, wrealloc, ...). dst CANNOT be a static or a constant string!
256
* Modifies dst (no new string is created except if dst==NULL in which case
257
* it is equivalent to calling wstrdup(src) ).
258
* The returned address may be different from the original address of dst,
259
* so always assign the returned address to avoid dangling pointers. */
260
char* wstrappend(char *dst, char *src);
263
void wtokensplit(char *command, char ***argv, int *argc);
265
char* wtokennext(char *word, char **next);
267
char* wtokenjoin(char **list, int count);
269
void wtokenfree(char **tokens, int count);
271
char* wtrimspace(char *s);
274
WMRange wmkrange(int start, int count);
275
#ifdef ANSI_C_DOESNT_LIKE_IT_THIS_WAY
276
#define wmkrange(position, count) (WMRange){(position), (count)}
280
char* wusergnusteppath();
282
char* wdefaultspathfordomain(char *domain);
284
void wusleep(unsigned int microsec);
287
int wsprintesc(char *buffer, int length, char *format, WMSEscapes **escapes,
291
/*......................................................................*/
293
/* Event handlers: timer, idle, input */
295
WMHandlerID WMAddTimerHandler(int milliseconds, WMCallback *callback,
298
WMHandlerID WMAddPersistentTimerHandler(int milliseconds, WMCallback *callback,
301
void WMDeleteTimerWithClientData(void *cdata);
303
void WMDeleteTimerHandler(WMHandlerID handlerID);
305
WMHandlerID WMAddIdleHandler(WMCallback *callback, void *cdata);
307
void WMDeleteIdleHandler(WMHandlerID handlerID);
309
WMHandlerID WMAddInputHandler(int fd, int condition, WMInputProc *proc,
312
void WMDeleteInputHandler(WMHandlerID handlerID);
315
/* This function is used _only_ if you create a non-GUI program.
316
* For GUI based programs use WMNextEvent()/WMHandleEvent() instead.
317
* This function will handle all input/timer/idle events, then return.
320
void WHandleEvents();
322
/*......................................................................*/
325
WMHashTable* WMCreateHashTable(WMHashTableCallbacks callbacks);
327
void WMFreeHashTable(WMHashTable *table);
329
void WMResetHashTable(WMHashTable *table);
331
unsigned WMCountHashTable(WMHashTable *table);
333
void* WMHashGet(WMHashTable *table, const void *key);
335
/* Returns True if there is a value associated with <key> in the table, in
336
* which case <retKey> and <retItem> will contain the item's internal key
337
* address and the item's value respectively.
338
* If there is no value associated with <key> it will return False and in
339
* this case <retKey> and <retItem> will be undefined.
340
* Use this when you need to perform your own custom retain/release mechanism
341
* which requires access to the keys too.
343
Bool WMHashGetItemAndKey(WMHashTable *table, const void *key,
344
void **retItem, void **retKey);
346
/* put data in table, replacing already existing data and returning
348
void* WMHashInsert(WMHashTable *table, const void *key, const void *data);
350
void WMHashRemove(WMHashTable *table, const void *key);
352
/* warning: do not manipulate the table while using the enumerator functions */
353
WMHashEnumerator WMEnumerateHashTable(WMHashTable *table);
355
void* WMNextHashEnumeratorItem(WMHashEnumerator *enumerator);
357
void* WMNextHashEnumeratorKey(WMHashEnumerator *enumerator);
359
/* Returns True if there is a next element, in which case key and item
360
* will contain the next element's key and value respectively.
361
* If there is no next element available it will return False and in this
362
* case key and item will be undefined.
364
Bool WMNextHashEnumeratorItemAndKey(WMHashEnumerator *enumerator,
365
void **item, void **key);
370
/* some predefined callback sets */
372
extern const WMHashTableCallbacks WMIntHashCallbacks;
373
/* sizeof(keys) are <= sizeof(void*) */
375
extern const WMHashTableCallbacks WMStringHashCallbacks;
376
/* keys are strings. Strings will be copied with wstrdup()
377
* and freed with wfree() */
379
extern const WMHashTableCallbacks WMStringPointerHashCallbacks;
380
/* keys are strings, but they are not copied */
383
/*......................................................................*/
386
* WMArray use an array to store the elements.
387
* Item indexes may be only positive integer numbers.
388
* The array cannot contain holes in it.
391
* Fast [O(1)] access to elements
392
* Fast [O(1)] push/pop
395
* A little slower [O(n)] for insertion/deletion of elements that
399
WMArray* WMCreateArray(int initialSize);
401
WMArray* WMCreateArrayWithDestructor(int initialSize, WMFreeDataProc *destructor);
403
WMArray* WMCreateArrayWithArray(WMArray *array);
405
#define WMDuplicateArray(array) WMCreateArrayWithArray(array)
407
void WMEmptyArray(WMArray *array);
409
void WMFreeArray(WMArray *array);
411
int WMGetArrayItemCount(WMArray *array);
413
/* appends other to array. other remains unchanged */
414
void WMAppendArray(WMArray *array, WMArray *other);
416
/* add will place the element at the end of the array */
417
void WMAddToArray(WMArray *array, void *item);
419
#define WMPushInArray(array, item) WMAddToArray(array, item)
421
/* insert will increment the index of elements after it by 1 */
422
void WMInsertInArray(WMArray *array, int index, void *item);
424
/* replace and set will return the old item WITHOUT calling the
425
* destructor on it even if its available. Free the returned item yourself.
427
void* WMReplaceInArray(WMArray *array, int index, void *item);
429
#define WMSetInArray(array, index, item) WMReplaceInArray(array, index, item)
431
/* delete and remove will remove the elements and cause the elements
432
* after them to decrement their indexes by 1. Also will call the
433
* destructor on the deleted element if there's one available.
435
int WMDeleteFromArray(WMArray *array, int index);
437
#define WMRemoveFromArray(array, item) WMRemoveFromArrayMatching(array, NULL, item)
439
int WMRemoveFromArrayMatching(WMArray *array, WMMatchDataProc *match, void *cdata);
441
void* WMGetFromArray(WMArray *array, int index);
443
#define WMGetFirstInArray(array, item) WMFindInArray(array, NULL, item)
445
/* pop will return the last element from the array, also removing it
446
* from the array. The destructor is NOT called, even if available.
447
* Free the returned element if needed by yourself
449
void* WMPopFromArray(WMArray *array);
451
int WMFindInArray(WMArray *array, WMMatchDataProc *match, void *cdata);
453
int WMCountInArray(WMArray *array, void *item);
455
/* comparer must return:
460
void WMSortArray(WMArray *array, WMCompareDataProc *comparer);
462
void WMMapArray(WMArray *array, void (*function)(void*, void*), void *data);
464
WMArray* WMGetSubarrayWithRange(WMArray* array, WMRange aRange);
466
void* WMArrayFirst(WMArray *array, WMArrayIterator *iter);
468
void* WMArrayLast(WMArray *array, WMArrayIterator *iter);
470
/* The following 2 functions assume that the array doesn't change between calls */
471
void* WMArrayNext(WMArray *array, WMArrayIterator *iter);
473
void* WMArrayPrevious(WMArray *array, WMArrayIterator *iter);
476
/* The following 2 macros assume that the array doesn't change in the for loop */
477
#define WM_ITERATE_ARRAY(array, var, i) \
478
for (var = WMArrayFirst(array, &(i)); (i) != WANotFound; \
479
var = WMArrayNext(array, &(i)))
481
#define WM_ETARETI_ARRAY(array, var, i) \
482
for (var = WMArrayLast(array, &(i)); (i) != WANotFound; \
483
var = WMArrayPrevious(array, &(i)))
485
/*..........................................................................*/
488
* Tree bags use a red-black tree for storage.
489
* Item indexes may be any integer number.
492
* O(lg n) insertion/deletion/search
493
* Good for large numbers of elements with sparse indexes
496
* O(lg n) insertion/deletion/search
497
* Slow for storing small numbers of elements
500
#define WMCreateBag(size) WMCreateTreeBag()
502
#define WMCreateBagWithDestructor(size, d) WMCreateTreeBagWithDestructor(d)
504
WMBag* WMCreateTreeBag(void);
506
WMBag* WMCreateTreeBagWithDestructor(WMFreeDataProc *destructor);
508
int WMGetBagItemCount(WMBag *bag);
510
void WMAppendBag(WMBag *bag, WMBag *other);
512
void WMPutInBag(WMBag *bag, void *item);
514
/* insert will increment the index of elements after it by 1 */
515
void WMInsertInBag(WMBag *bag, int index, void *item);
517
/* erase will remove the element from the bag,
518
* but will keep the index of the other elements unchanged */
519
int WMEraseFromBag(WMBag *bag, int index);
521
/* delete and remove will remove the elements and cause the elements
522
* after them to decrement their indexes by 1 */
523
int WMDeleteFromBag(WMBag *bag, int index);
525
int WMRemoveFromBag(WMBag *bag, void *item);
527
void* WMGetFromBag(WMBag *bag, int index);
529
void* WMReplaceInBag(WMBag *bag, int index, void *item);
531
#define WMSetInBag(bag, index, item) WMReplaceInBag(bag, index, item)
533
/* comparer must return:
538
void WMSortBag(WMBag *bag, WMCompareDataProc *comparer);
540
void WMEmptyBag(WMBag *bag);
542
void WMFreeBag(WMBag *bag);
544
void WMMapBag(WMBag *bag, void (*function)(void*, void*), void *data);
546
int WMGetFirstInBag(WMBag *bag, void *item);
548
int WMCountInBag(WMBag *bag, void *item);
550
int WMFindInBag(WMBag *bag, WMMatchDataProc *match, void *cdata);
552
void* WMBagFirst(WMBag *bag, WMBagIterator *ptr);
554
void* WMBagLast(WMBag *bag, WMBagIterator *ptr);
556
/* The following 4 functions assume that the bag doesn't change between calls */
557
void* WMBagNext(WMBag *bag, WMBagIterator *ptr);
559
void* WMBagPrevious(WMBag *bag, WMBagIterator *ptr);
561
void* WMBagIteratorAtIndex(WMBag *bag, int index, WMBagIterator *ptr);
563
int WMBagIndexForIterator(WMBag *bag, WMBagIterator ptr);
566
/* The following 2 macros assume that the bag doesn't change in the for loop */
567
#define WM_ITERATE_BAG(bag, var, i) \
568
for (var = WMBagFirst(bag, &(i)); (i) != NULL; \
569
var = WMBagNext(bag, &(i)))
571
#define WM_ETARETI_BAG(bag, var, i) \
572
for (var = WMBagLast(bag, &(i)); (i) != NULL; \
573
var = WMBagPrevious(bag, &(i)))
577
/*-------------------------------------------------------------------------*/
579
/* WMData handling */
581
/* Creating/destroying data */
583
WMData* WMCreateDataWithCapacity(unsigned capacity);
585
WMData* WMCreateDataWithLength(unsigned length);
587
WMData* WMCreateDataWithBytes(void *bytes, unsigned length);
589
/* destructor is a function called to free the data when releasing the data
590
* object, or NULL if no freeing of data is necesary. */
591
WMData* WMCreateDataWithBytesNoCopy(void *bytes, unsigned length,
592
WMFreeDataProc *destructor);
594
WMData* WMCreateDataWithData(WMData *aData);
596
WMData* WMRetainData(WMData *aData);
598
void WMReleaseData(WMData *aData);
600
/* Adjusting capacity */
602
void WMSetDataCapacity(WMData *aData, unsigned capacity);
604
void WMSetDataLength(WMData *aData, unsigned length);
606
void WMIncreaseDataLengthBy(WMData *aData, unsigned extraLength);
610
const void* WMDataBytes(WMData *aData);
612
void WMGetDataBytes(WMData *aData, void *buffer);
614
void WMGetDataBytesWithLength(WMData *aData, void *buffer, unsigned length);
616
void WMGetDataBytesWithRange(WMData *aData, void *buffer, WMRange aRange);
618
WMData* WMGetSubdataWithRange(WMData *aData, WMRange aRange);
622
Bool WMIsDataEqualToData(WMData *aData, WMData *anotherData);
624
unsigned WMGetDataLength(WMData *aData);
628
void WMAppendDataBytes(WMData *aData, void *bytes, unsigned length);
630
void WMAppendData(WMData *aData, WMData *anotherData);
634
void WMReplaceDataBytesInRange(WMData *aData, WMRange aRange, void *bytes);
636
void WMResetDataBytesInRange(WMData *aData, WMRange aRange);
638
void WMSetData(WMData *aData, WMData *anotherData);
641
void WMSetDataFormat(WMData *aData, unsigned format);
643
unsigned WMGetDataFormat(WMData *aData);
647
/*--------------------------------------------------------------------------*/
649
/* Generic Tree and TreeNode */
651
WMTreeNode* WMCreateTreeNode(void *data);
653
WMTreeNode* WMCreateTreeNodeWithDestructor(void *data, WMFreeDataProc *destructor);
655
WMTreeNode* WMInsertItemInTree(WMTreeNode *parent, int index, void *item);
657
#define WMAddItemToTree(parent, item) WMInsertItemInTree(parent, -1, item)
659
WMTreeNode* WMInsertNodeInTree(WMTreeNode *parent, int index, WMTreeNode *aNode);
661
#define WMAddNodeToTree(parent, aNode) WMInsertNodeInTree(parent, -1, aNode)
663
void WMDestroyTreeNode(WMTreeNode *aNode);
665
void WMDeleteLeafForTreeNode(WMTreeNode *aNode, int index);
667
void WMRemoveLeafForTreeNode(WMTreeNode *aNode, void *leaf);
669
void* WMReplaceDataForTreeNode(WMTreeNode *aNode, void *newData);
671
void* WMGetDataForTreeNode(WMTreeNode *aNode);
673
int WMGetTreeNodeDepth(WMTreeNode *aNode);
675
WMTreeNode* WMGetParentForTreeNode(WMTreeNode *aNode);
677
/* Sort only the leaves of the passed node */
678
void WMSortLeavesForTreeNode(WMTreeNode *aNode, WMCompareDataProc *comparer);
680
/* Sort all tree recursively starting from the passed node */
681
void WMSortTree(WMTreeNode *aNode, WMCompareDataProc *comparer);
683
/* Returns the first node which matches node's data with cdata by 'match' */
684
WMTreeNode* WMFindInTree(WMTreeNode *aTree, WMMatchDataProc *match, void *cdata);
686
/* Returns first tree node that has data == cdata */
687
#define WMGetFirstInTree(aTree, cdata) WMFindInTree(aTree, NULL, cdata)
690
/*--------------------------------------------------------------------------*/
693
WMNotification* WMCreateNotification(const char *name, void *object, void *clientData);
695
void WMReleaseNotification(WMNotification *notification);
697
WMNotification* WMRetainNotification(WMNotification *notification);
699
void* WMGetNotificationClientData(WMNotification *notification);
701
void* WMGetNotificationObject(WMNotification *notification);
703
const char* WMGetNotificationName(WMNotification *notification);
706
void WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
707
void *observer, const char *name, void *object);
709
void WMPostNotification(WMNotification *notification);
711
void WMRemoveNotificationObserver(void *observer);
713
void WMRemoveNotificationObserverWithName(void *observer, const char *name,
716
void WMPostNotificationName(const char *name, void *object, void *clientData);
718
WMNotificationQueue* WMGetDefaultNotificationQueue(void);
720
WMNotificationQueue* WMCreateNotificationQueue(void);
722
void WMDequeueNotificationMatching(WMNotificationQueue *queue,
723
WMNotification *notification,
726
void WMEnqueueNotification(WMNotificationQueue *queue,
727
WMNotification *notification,
728
WMPostingStyle postingStyle);
730
void WMEnqueueCoalesceNotification(WMNotificationQueue *queue,
731
WMNotification *notification,
732
WMPostingStyle postingStyle,
733
unsigned coalesceMask);
736
/*......................................................................*/
738
/* Property Lists handling */
740
void WMPLSetCaseSensitive(Bool caseSensitive);
742
WMPropList* WMCreatePLString(char *str);
744
WMPropList* WMCreatePLData(WMData *data);
746
WMPropList* WMCreatePLDataWithBytes(unsigned char *bytes, unsigned int length);
748
WMPropList* WMCreatePLDataWithBytesNoCopy(unsigned char *bytes,
750
WMFreeDataProc *destructor);
752
WMPropList* WMCreatePLArray(WMPropList *elem, ...);
754
WMPropList* WMCreatePLDictionary(WMPropList *key, WMPropList *value, ...);
756
WMPropList* WMRetainPropList(WMPropList *plist);
758
void WMReleasePropList(WMPropList *plist);
760
/* Objects inserted in arrays and dictionaries will be retained,
761
* so you can safely release them after insertion.
762
* For dictionaries both the key and value are retained.
763
* Objects removed from arrays or dictionaries are released */
764
void WMInsertInPLArray(WMPropList *plist, int index, WMPropList *item);
766
void WMAddToPLArray(WMPropList *plist, WMPropList *item);
768
void WMDeleteFromPLArray(WMPropList *plist, int index);
770
void WMRemoveFromPLArray(WMPropList *plist, WMPropList *item);
772
void WMPutInPLDictionary(WMPropList *plist, WMPropList *key, WMPropList *value);
774
void WMRemoveFromPLDictionary(WMPropList *plist, WMPropList *key);
776
/* It will insert all key/value pairs from source into dest, overwriting
777
* the values with the same keys from dest, keeping all values with keys
778
* only present in dest unchanged */
779
WMPropList* WMMergePLDictionaries(WMPropList *dest, WMPropList *source,
782
/* It will remove all key/value pairs from dest for which there is an
783
* identical key/value present in source. Entires only present in dest, or
784
* which have different values in dest than in source will be preserved. */
785
WMPropList* WMSubtractPLDictionaries(WMPropList *dest, WMPropList *source,
788
int WMGetPropListItemCount(WMPropList *plist);
790
Bool WMIsPLString(WMPropList *plist);
792
Bool WMIsPLData(WMPropList *plist);
794
Bool WMIsPLArray(WMPropList *plist);
796
Bool WMIsPLDictionary(WMPropList *plist);
798
Bool WMIsPropListEqualTo(WMPropList *plist, WMPropList *other);
800
/* Returns a reference. Do not free it! */
801
char* WMGetFromPLString(WMPropList *plist);
803
/* Returns a reference. Do not free it! */
804
WMData* WMGetFromPLData(WMPropList *plist);
806
/* Returns a reference. Do not free it! */
807
const unsigned char* WMGetPLDataBytes(WMPropList *plist);
809
int WMGetPLDataLength(WMPropList *plist);
811
/* Returns a reference. */
812
WMPropList* WMGetFromPLArray(WMPropList *plist, int index);
814
/* Returns a reference. */
815
WMPropList* WMGetFromPLDictionary(WMPropList *plist, WMPropList *key);
817
/* Returns a PropList array with all the dictionary keys. Release it when
818
* you're done. Keys in array are retained from the original dictionary
819
* not copied and need NOT to be released individually. */
820
WMPropList* WMGetPLDictionaryKeys(WMPropList *plist);
822
/* Creates only the first level deep object. All the elements inside are
823
* retained from the original */
824
WMPropList* WMShallowCopyPropList(WMPropList *plist);
826
/* Makes a completely separate replica of the original proplist */
827
WMPropList* WMDeepCopyPropList(WMPropList *plist);
829
WMPropList* WMCreatePropListFromDescription(char *desc);
831
/* Free the returned string when you no longer need it */
832
char* WMGetPropListDescription(WMPropList *plist, Bool indented);
834
WMPropList* WMReadPropListFromFile(char *file);
836
Bool WMWritePropListToFile(WMPropList *plist, char *path, Bool atomically);
838
/*......................................................................*/
840
WMUserDefaults* WMGetStandardUserDefaults(void);
842
WMUserDefaults* WMGetDefaultsFromPath(char *path);
844
void WMSynchronizeUserDefaults(WMUserDefaults *database);
846
void WMSaveUserDefaults(WMUserDefaults *database);
848
void WMEnableUDPeriodicSynchronization(WMUserDefaults *database, Bool enable);
850
/* Returns a WMPropList array with all the keys in the user defaults database.
851
* Free the array with WMReleasePropList() when no longer needed.
852
* Keys in array are just retained references to the original keys */
853
WMPropList* WMGetUDKeys(WMUserDefaults *database);
855
WMPropList* WMGetUDObjectForKey(WMUserDefaults *database, char *defaultName);
857
void WMSetUDObjectForKey(WMUserDefaults *database, WMPropList *object,
860
void WMRemoveUDObjectForKey(WMUserDefaults *database, char *defaultName);
862
char* WMGetUDStringForKey(WMUserDefaults *database, char *defaultName);
864
int WMGetUDIntegerForKey(WMUserDefaults *database, char *defaultName);
866
float WMGetUDFloatForKey(WMUserDefaults *database, char *defaultName);
868
Bool WMGetUDBoolForKey(WMUserDefaults *database, char *defaultName);
870
void WMSetUDStringForKey(WMUserDefaults *database, char *value,
873
void WMSetUDIntegerForKey(WMUserDefaults *database, int value,
876
void WMSetUDFloatForKey(WMUserDefaults *database, float value,
879
void WMSetUDBoolForKey(WMUserDefaults *database, Bool value,
882
WMPropList* WMGetUDSearchList(WMUserDefaults *database);
884
void WMSetUDSearchList(WMUserDefaults *database, WMPropList *list);
886
extern char *WMUserDefaultsDidChangeNotification;
889
/*-------------------------------------------------------------------------*/
891
/* WMHost: host handling */
893
WMHost* WMGetCurrentHost();
895
WMHost* WMGetHostWithName(char* name);
897
WMHost* WMGetHostWithAddress(char* address);
899
WMHost* WMRetainHost(WMHost *hPtr);
901
void WMReleaseHost(WMHost *hPtr);
904
* Host cache management
905
* If enabled, only one object representing each host will be created, and
906
* a shared instance will be returned by all methods that return a host.
907
* Enabled by default.
909
void WMSetHostCacheEnabled(Bool flag);
911
Bool WMIsHostCacheEnabled();
913
void WMFlushHostCache();
916
* Compare hosts: Hosts are equal if they share at least one address
918
Bool WMIsHostEqualToHost(WMHost* hPtr, WMHost* anotherHost);
922
* WMGetHostName() will return first name (official) if a host has several.
923
* WMGetHostNames() will return a R/O WMArray with all the names of the host.
925
char* WMGetHostName(WMHost* hPtr);
927
/* The returned array is R/O. Do not modify it, and do not free it! */
928
WMArray* WMGetHostNames(WMHost* hPtr);
932
* Addresses are represented as "Dotted Decimal" strings, e.g. "192.42.172.1"
933
* WMGetHostAddress() will return an arbitrary address if a host has several.
934
* WMGetHostAddresses() will return a R/O WMArray with all addresses of the host.
936
char* WMGetHostAddress(WMHost* hPtr);
938
/* The returned array is R/O. Do not modify it, and do not free it! */
939
WMArray* WMGetHostAddresses(WMHost* hPtr);
942
/*-------------------------------------------------------------------------*/
944
/* WMConnection functions */
946
WMConnection* WMCreateConnectionAsServerAtAddress(char *host, char *service,
949
WMConnection* WMCreateConnectionToAddress(char *host, char *service,
952
WMConnection* WMCreateConnectionToAddressAndNotify(char *host, char *service,
955
void WMCloseConnection(WMConnection *cPtr);
957
void WMDestroyConnection(WMConnection *cPtr);
959
WMConnection* WMAcceptConnection(WMConnection *listener);
961
/* Release the returned data! */
962
WMData* WMGetConnectionAvailableData(WMConnection *cPtr);
964
int WMSendConnectionData(WMConnection *cPtr, WMData *data);
966
Bool WMEnqueueConnectionData(WMConnection *cPtr, WMData *data);
968
#define WMFlushConnection(cPtr) WMSendConnectionData((cPtr), NULL)
970
void WMSetConnectionDelegate(WMConnection *cPtr, ConnectionDelegate *delegate);
972
/* Connection info */
974
char* WMGetConnectionAddress(WMConnection *cPtr);
976
char* WMGetConnectionService(WMConnection *cPtr);
978
char* WMGetConnectionProtocol(WMConnection *cPtr);
980
Bool WMSetConnectionNonBlocking(WMConnection *cPtr, Bool flag);
982
Bool WMSetConnectionCloseOnExec(WMConnection *cPtr, Bool flag);
984
void WMSetConnectionShutdownOnClose(WMConnection *cPtr, Bool flag);
986
void* WMGetConnectionClientData(WMConnection *cPtr);
988
void WMSetConnectionClientData(WMConnection *cPtr, void *data);
990
unsigned int WMGetConnectionFlags(WMConnection *cPtr);
992
void WMSetConnectionFlags(WMConnection *cPtr, unsigned int flags);
994
int WMGetConnectionSocket(WMConnection *cPtr);
996
WMConnectionState WMGetConnectionState(WMConnection *cPtr);
998
WMConnectionTimeoutState WMGetConnectionTimeoutState(WMConnection *cPtr);
1000
WMArray* WMGetConnectionUnsentData(WMConnection *cPtr);
1002
#define WMGetConnectionQueuedData(cPtr) WMGetConnectionUnsentData(cPtr)
1006
* Passing timeout==0 in the SetTimeout functions below, will reset that
1007
* timeout to its default value.
1010
/* The default timeout inherited by all WMConnection operations, if none set */
1011
void WMSetConnectionDefaultTimeout(unsigned int timeout);
1013
/* Global timeout for all WMConnection objects, for opening a new connection */
1014
void WMSetConnectionOpenTimeout(unsigned int timeout);
1016
/* Connection specific timeout for sending out data */
1017
void WMSetConnectionSendTimeout(WMConnection *cPtr, unsigned int timeout);
1020
/* Global variables */
1022
extern int WCErrorCode;
1025
/*-------------------------------------------------------------------------*/
1031
#endif /* __cplusplus */