8 /* SunOS 4.x Blargh.... */
10 #define NULL ((void*)0)
14 * Warning: proplist.h #defines BOOL which will clash with the
15 * typedef BOOL in Xmd.h
16 * proplist.h should use Bool (which is a #define in Xlib.h) instead.
23 # define WMAX(a,b) ((a)>(b) ? (a) : (b))
26 # define WMIN(a,b) ((a)<(b) ? (a) : (b))
30 #if (!defined (__GNUC__) || __GNUC__ < 2 || \
31 __GNUC_MINOR__ < (defined (__cplusplus) ? 6 : 4))
32 #define __ASSERT_FUNCTION ((char *) 0)
34 #define __ASSERT_FUNCTION __PRETTY_FUNCTION__
40 #define wassertr(expr) {}
41 #define wassertrv(expr, val) {}
49 #define wassertr(expr) assert(expr)
51 #define wassertrv(expr, val) assert(expr)
55 #define wassertr(expr) \
57 wwarning("%s line %i (%s): assertion %s failed",\
58 __FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
62 #define wassertrv(expr, val) \
64 wwarning("%s line %i (%s): assertion %s failed",\
65 __FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
75 #endif /* __cplusplus */
89 } WMNotificationCoalescing
;
92 /* The possible states for connections */
105 /* The possible states for connection timeouts */
110 } WMConnectionTimeoutState
;
115 WBNotFound
= INT_MIN
, /* element was not found in WMBag */
116 WANotFound
= -1 /* element was not found in WMArray */
120 typedef struct W_Array WMArray
;
121 typedef struct W_Bag WMBag
;
122 typedef struct W_Data WMData
;
123 typedef struct W_TreeNode WMTreeNode
;
124 typedef struct W_HashTable WMHashTable
;
125 typedef struct W_UserDefaults WMUserDefaults
;
126 typedef struct W_Notification WMNotification
;
127 typedef struct W_NotificationQueue WMNotificationQueue
;
128 typedef struct W_Host WMHost
;
129 typedef struct W_Connection WMConnection
;
130 typedef struct W_PropList WMPropList
;
134 /* Some typedefs for the handler stuff */
135 typedef void *WMHandlerID
;
137 typedef void WMCallback(void *data
);
139 typedef void WMInputProc(int fd
, int mask
, void *clientData
);
143 typedef int WMCompareDataProc(const void *item1
, const void *item2
);
145 typedef void WMFreeDataProc(void *data
);
147 /* Used by WMBag or WMArray for matching data */
148 typedef int WMMatchDataProc(void *item
, void *cdata
);
159 /* DO NOT ACCESS THE CONTENTS OF THIS STRUCT */
168 /* NULL is pointer hash */
169 unsigned (*hash
)(const void *);
170 /* NULL is pointer compare */
171 Bool (*keyIsEqual
)(const void *, const void *);
172 /* NULL does nothing */
173 void* (*retainKey
)(const void *);
174 /* NULL does nothing */
175 void (*releaseKey
)(const void *);
176 } WMHashTableCallbacks
;
179 typedef int WMArrayIterator
;
180 typedef void *WMBagIterator
;
185 char character
; /* the escape character */
186 char *value
; /* value to place */
191 /* The connection callbacks */
192 typedef struct ConnectionDelegate
{
195 void (*didCatchException
)(struct ConnectionDelegate
*self
,
198 void (*didDie
)(struct ConnectionDelegate
*self
, WMConnection
*cPtr
);
200 void (*didInitialize
)(struct ConnectionDelegate
*self
, WMConnection
*cPtr
);
202 void (*didReceiveInput
)(struct ConnectionDelegate
*self
, WMConnection
*cPtr
);
204 void (*didTimeout
)(struct ConnectionDelegate
*self
, WMConnection
*cPtr
);
206 } ConnectionDelegate
;
209 typedef void WMNotificationObserverAction(void *observerData
,
210 WMNotification
*notification
);
214 /*......................................................................*/
216 typedef void (waborthandler
)(int);
218 waborthandler
* wsetabort(waborthandler
*);
221 /* don't free the returned string */
222 char* wstrerror(int errnum
);
224 void wmessage(const char *msg
, ...);
225 void wwarning(const char *msg
, ...);
226 void wfatal(const char *msg
, ...);
227 void wsyserror(const char *msg
, ...);
228 void wsyserrorwithcode(int error
, const char *msg
, ...);
230 char* wfindfile(char *paths
, char *file
);
232 char* wfindfileinlist(char **path_list
, char *file
);
234 char* wfindfileinarray(proplist_t array
, char *file
);
236 char* wexpandpath(char *path
);
238 /* don't free the returned string */
241 void* wmalloc(size_t size
);
242 void* wrealloc(void *ptr
, size_t newsize
);
243 void wfree(void *ptr
);
246 void wrelease(void *ptr
);
247 void* wretain(void *ptr
);
249 char* wstrdup(char *str
);
251 /* Concatenate str1 with str2 and return that in a newly malloc'ed string.
252 * str1 and str2 can be any strings including static and constant strings.
253 * str1 and str2 will not be modified.
254 * Free the returned string when you're done with it. */
255 char* wstrconcat(char *str1
, char *str2
);
257 /* This will append src to dst, and return dst. dst MUST be either NULL
258 * or a string that was a result of a dynamic allocation (malloc, realloc
259 * wmalloc, wrealloc, ...). dst CANNOT be a static or a constant string!
260 * Modifies dst (no new string is created except if dst==NULL in which case
261 * it is equivalent to calling wstrdup(src) ).
262 * The returned address may be different from the original address of dst,
263 * so always assign the returned address to avoid dangling pointers. */
264 char* wstrappend(char *dst
, char *src
);
267 void wtokensplit(char *command
, char ***argv
, int *argc
);
269 char* wtokennext(char *word
, char **next
);
271 char* wtokenjoin(char **list
, int count
);
273 void wtokenfree(char **tokens
, int count
);
275 char* wtrimspace(char *s
);
278 WMRange
wmkrange(int start
, int count
);
279 #ifdef ANSI_C_DOESNT_LIKE_IT_THIS_WAY
280 #define wmkrange(position, count) (WMRange){(position), (count)}
284 char* wusergnusteppath();
286 char* wdefaultspathfordomain(char *domain
);
288 void wusleep(unsigned int microsec
);
291 int wsprintesc(char *buffer
, int length
, char *format
, WMSEscapes
**escapes
,
295 /*......................................................................*/
297 /* Event handlers: timer, idle, input */
299 WMHandlerID
WMAddTimerHandler(int milliseconds
, WMCallback
*callback
,
302 WMHandlerID
WMAddPersistentTimerHandler(int milliseconds
, WMCallback
*callback
,
305 void WMDeleteTimerWithClientData(void *cdata
);
307 void WMDeleteTimerHandler(WMHandlerID handlerID
);
309 WMHandlerID
WMAddIdleHandler(WMCallback
*callback
, void *cdata
);
311 void WMDeleteIdleHandler(WMHandlerID handlerID
);
313 WMHandlerID
WMAddInputHandler(int fd
, int condition
, WMInputProc
*proc
,
316 void WMDeleteInputHandler(WMHandlerID handlerID
);
319 /* This function is used _only_ if you create a non-GUI program.
320 * For GUI based programs use WMNextEvent()/WMHandleEvent() instead.
321 * This function will handle all input/timer/idle events, then return.
324 void WHandleEvents();
326 /*......................................................................*/
329 WMHashTable
* WMCreateHashTable(WMHashTableCallbacks callbacks
);
331 void WMFreeHashTable(WMHashTable
*table
);
333 void WMResetHashTable(WMHashTable
*table
);
335 unsigned WMCountHashTable(WMHashTable
*table
);
337 void* WMHashGet(WMHashTable
*table
, const void *key
);
339 /* put data in table, replacing already existing data and returning
341 void* WMHashInsert(WMHashTable
*table
, const void *key
, const void *data
);
343 void WMHashRemove(WMHashTable
*table
, const void *key
);
345 /* warning: do not manipulate the table while using the enumerator functions */
346 WMHashEnumerator
WMEnumerateHashTable(WMHashTable
*table
);
348 void* WMNextHashEnumeratorItem(WMHashEnumerator
*enumerator
);
350 void* WMNextHashEnumeratorKey(WMHashEnumerator
*enumerator
);
352 /* Returns True if there is a next element, in which case key and item
353 * will contain the next element's key and value respectively.
354 * If there is no next element available it will return False and in this
355 * case key and item will be undefined.
357 Bool
WMNextHashEnumeratorItemAndKey(WMHashEnumerator
*enumerator
,
358 void **item
, void **key
);
363 /* some predefined callback sets */
365 extern const WMHashTableCallbacks WMIntHashCallbacks
;
366 /* sizeof(keys) are <= sizeof(void*) */
368 extern const WMHashTableCallbacks WMStringHashCallbacks
;
369 /* keys are strings. Strings will be copied with wstrdup()
370 * and freed with wfree() */
372 extern const WMHashTableCallbacks WMStringPointerHashCallbacks
;
373 /* keys are strings, bug they are not copied */
376 /*......................................................................*/
379 * WMArray use an array to store the elements.
380 * Item indexes may be only positive integer numbers.
381 * The array cannot contain holes in it.
384 * Fast [O(1)] access to elements
385 * Fast [O(1)] push/pop
388 * A little slower [O(n)] for insertion/deletion of elements that
392 WMArray
* WMCreateArray(int initialSize
);
394 WMArray
* WMCreateArrayWithDestructor(int initialSize
, WMFreeDataProc
*destructor
);
396 WMArray
* WMCreateArrayWithArray(WMArray
*array
);
398 #define WMDuplicateArray(array) WMCreateArrayWithArray(array)
400 void WMEmptyArray(WMArray
*array
);
402 void WMFreeArray(WMArray
*array
);
404 int WMGetArrayItemCount(WMArray
*array
);
406 /* appends other to array. other remains unchanged */
407 void WMAppendArray(WMArray
*array
, WMArray
*other
);
409 /* add will place the element at the end of the array */
410 void WMAddToArray(WMArray
*array
, void *item
);
412 #define WMPushInArray(array, item) WMAddToArray(array, item)
414 /* insert will increment the index of elements after it by 1 */
415 void WMInsertInArray(WMArray
*array
, int index
, void *item
);
417 /* replace and set will return the old item WITHOUT calling the
418 * destructor on it even if its available. Free the returned item yourself.
420 void* WMReplaceInArray(WMArray
*array
, int index
, void *item
);
422 #define WMSetInArray(array, index, item) WMReplaceInArray(array, index, item)
424 /* delete and remove will remove the elements and cause the elements
425 * after them to decrement their indexes by 1. Also will call the
426 * destructor on the deleted element if there's one available.
428 int WMDeleteFromArray(WMArray
*array
, int index
);
430 #define WMRemoveFromArray(array, item) WMRemoveFromArrayMatching(array, NULL, item)
432 int WMRemoveFromArrayMatching(WMArray
*array
, WMMatchDataProc
*match
, void *cdata
);
434 void* WMGetFromArray(WMArray
*array
, int index
);
436 #define WMGetFirstInArray(array, item) WMFindInArray(array, NULL, item)
438 /* pop will return the last element from the array, also removing it
439 * from the array. The destructor is NOT called, even if available.
440 * Free the returned element if needed by yourself
442 void* WMPopFromArray(WMArray
*array
);
444 int WMFindInArray(WMArray
*array
, WMMatchDataProc
*match
, void *cdata
);
446 int WMCountInArray(WMArray
*array
, void *item
);
448 /* comparer must return:
453 void WMSortArray(WMArray
*array
, WMCompareDataProc
*comparer
);
455 void WMMapArray(WMArray
*array
, void (*function
)(void*, void*), void *data
);
457 WMArray
* WMGetSubarrayWithRange(WMArray
* array
, WMRange aRange
);
459 void* WMArrayFirst(WMArray
*array
, WMArrayIterator
*iter
);
461 void* WMArrayLast(WMArray
*array
, WMArrayIterator
*iter
);
463 /* The following 2 functions assume that the array doesn't change between calls */
464 void* WMArrayNext(WMArray
*array
, WMArrayIterator
*iter
);
466 void* WMArrayPrevious(WMArray
*array
, WMArrayIterator
*iter
);
469 /* The following 2 macros assume that the array doesn't change in the for loop */
470 #define WM_ITERATE_ARRAY(array, var, i) \
471 for (var = WMArrayFirst(array, &(i)); (i) != WANotFound; \
472 var = WMArrayNext(array, &(i)))
474 #define WM_ETARETI_ARRAY(array, var, i) \
475 for (var = WMArrayLast(array, &(i)); (i) != WANotFound; \
476 var = WMArrayPrevious(array, &(i)))
478 /*..........................................................................*/
481 * Tree bags use a red-black tree for storage.
482 * Item indexes may be any integer number.
485 * O(lg n) insertion/deletion/search
486 * Good for large numbers of elements with sparse indexes
489 * O(lg n) insertion/deletion/search
490 * Slow for storing small numbers of elements
493 #define WMCreateBag(size) WMCreateTreeBag()
495 #define WMCreateBagWithDestructor(size, d) WMCreateTreeBagWithDestructor(d)
497 WMBag
* WMCreateTreeBag(void);
499 WMBag
* WMCreateTreeBagWithDestructor(WMFreeDataProc
*destructor
);
501 int WMGetBagItemCount(WMBag
*bag
);
503 void WMAppendBag(WMBag
*bag
, WMBag
*other
);
505 void WMPutInBag(WMBag
*bag
, void *item
);
507 /* insert will increment the index of elements after it by 1 */
508 void WMInsertInBag(WMBag
*bag
, int index
, void *item
);
510 /* erase will remove the element from the bag,
511 * but will keep the index of the other elements unchanged */
512 int WMEraseFromBag(WMBag
*bag
, int index
);
514 /* delete and remove will remove the elements and cause the elements
515 * after them to decrement their indexes by 1 */
516 int WMDeleteFromBag(WMBag
*bag
, int index
);
518 int WMRemoveFromBag(WMBag
*bag
, void *item
);
520 void* WMGetFromBag(WMBag
*bag
, int index
);
522 void* WMReplaceInBag(WMBag
*bag
, int index
, void *item
);
524 #define WMSetInBag(bag, index, item) WMReplaceInBag(bag, index, item)
526 /* comparer must return:
531 void WMSortBag(WMBag
*bag
, WMCompareDataProc
*comparer
);
533 void WMEmptyBag(WMBag
*bag
);
535 void WMFreeBag(WMBag
*bag
);
537 void WMMapBag(WMBag
*bag
, void (*function
)(void*, void*), void *data
);
539 int WMGetFirstInBag(WMBag
*bag
, void *item
);
541 int WMCountInBag(WMBag
*bag
, void *item
);
543 int WMFindInBag(WMBag
*bag
, WMMatchDataProc
*match
, void *cdata
);
545 void* WMBagFirst(WMBag
*bag
, WMBagIterator
*ptr
);
547 void* WMBagLast(WMBag
*bag
, WMBagIterator
*ptr
);
549 /* The following 4 functions assume that the bag doesn't change between calls */
550 void* WMBagNext(WMBag
*bag
, WMBagIterator
*ptr
);
552 void* WMBagPrevious(WMBag
*bag
, WMBagIterator
*ptr
);
554 void* WMBagIteratorAtIndex(WMBag
*bag
, int index
, WMBagIterator
*ptr
);
556 int WMBagIndexForIterator(WMBag
*bag
, WMBagIterator ptr
);
559 /* The following 2 macros assume that the bag doesn't change in the for loop */
560 #define WM_ITERATE_BAG(bag, var, i) \
561 for (var = WMBagFirst(bag, &(i)); (i) != NULL; \
562 var = WMBagNext(bag, &(i)))
564 #define WM_ETARETI_BAG(bag, var, i) \
565 for (var = WMBagLast(bag, &(i)); (i) != NULL; \
566 var = WMBagPrevious(bag, &(i)))
570 /*-------------------------------------------------------------------------*/
572 /* WMData handling */
574 /* Creating/destroying data */
576 WMData
* WMCreateDataWithCapacity(unsigned capacity
);
578 WMData
* WMCreateDataWithLength(unsigned length
);
580 WMData
* WMCreateDataWithBytes(void *bytes
, unsigned length
);
582 /* destructor is a function called to free the data when releasing the data
583 * object, or NULL if no freeing of data is necesary. */
584 WMData
* WMCreateDataWithBytesNoCopy(void *bytes
, unsigned length
,
585 WMFreeDataProc
*destructor
);
587 WMData
* WMCreateDataWithData(WMData
*aData
);
589 WMData
* WMRetainData(WMData
*aData
);
591 void WMReleaseData(WMData
*aData
);
593 /* Adjusting capacity */
595 void WMSetDataCapacity(WMData
*aData
, unsigned capacity
);
597 void WMSetDataLength(WMData
*aData
, unsigned length
);
599 void WMIncreaseDataLengthBy(WMData
*aData
, unsigned extraLength
);
603 const void* WMDataBytes(WMData
*aData
);
605 void WMGetDataBytes(WMData
*aData
, void *buffer
);
607 void WMGetDataBytesWithLength(WMData
*aData
, void *buffer
, unsigned length
);
609 void WMGetDataBytesWithRange(WMData
*aData
, void *buffer
, WMRange aRange
);
611 WMData
* WMGetSubdataWithRange(WMData
*aData
, WMRange aRange
);
615 Bool
WMIsDataEqualToData(WMData
*aData
, WMData
*anotherData
);
617 unsigned WMGetDataLength(WMData
*aData
);
621 void WMAppendDataBytes(WMData
*aData
, void *bytes
, unsigned length
);
623 void WMAppendData(WMData
*aData
, WMData
*anotherData
);
627 void WMReplaceDataBytesInRange(WMData
*aData
, WMRange aRange
, void *bytes
);
629 void WMResetDataBytesInRange(WMData
*aData
, WMRange aRange
);
631 void WMSetData(WMData
*aData
, WMData
*anotherData
);
634 void WMSetDataFormat(WMData
*aData
, unsigned format
);
636 unsigned WMGetDataFormat(WMData
*aData
);
640 /*--------------------------------------------------------------------------*/
642 /* Generic Tree and TreeNode */
644 WMTreeNode
* WMCreateTreeNode(void *data
);
646 WMTreeNode
* WMCreateTreeNodeWithDestructor(void *data
, WMFreeDataProc
*destructor
);
648 WMTreeNode
* WMInsertItemInTree(WMTreeNode
*parent
, int index
, void *item
);
650 #define WMAddItemToTree(parent, item) WMInsertItemInTree(parent, -1, item)
652 WMTreeNode
* WMInsertNodeInTree(WMTreeNode
*parent
, int index
, WMTreeNode
*aNode
);
654 #define WMAddNodeToTree(parent, aNode) WMInsertNodeInTree(parent, -1, aNode)
656 void WMDestroyTreeNode(WMTreeNode
*aNode
);
658 void WMDeleteLeafForTreeNode(WMTreeNode
*aNode
, int index
);
660 void WMRemoveLeafForTreeNode(WMTreeNode
*aNode
, void *leaf
);
662 void* WMReplaceDataForTreeNode(WMTreeNode
*aNode
, void *newData
);
664 void* WMGetDataForTreeNode(WMTreeNode
*aNode
);
666 int WMGetTreeNodeDepth(WMTreeNode
*aNode
);
668 WMTreeNode
* WMGetParentForTreeNode(WMTreeNode
*aNode
);
670 /* Sort only the leaves of the passed node */
671 void WMSortLeavesForTreeNode(WMTreeNode
*aNode
, WMCompareDataProc
*comparer
);
673 /* Sort all tree recursively starting from the passed node */
674 void WMSortTree(WMTreeNode
*aNode
, WMCompareDataProc
*comparer
);
676 /* Returns the first node which matches node's data with cdata by 'match' */
677 WMTreeNode
* WMFindInTree(WMTreeNode
*aTree
, WMMatchDataProc
*match
, void *cdata
);
679 /* Returns first tree node that has data == cdata */
680 #define WMGetFirstInTree(aTree, cdata) WMFindInTree(atree, NULL, cdata)
683 /*--------------------------------------------------------------------------*/
687 WMDictionary* WMCreateDictionaryFromElements(void *key, void *value, ...);
689 #define WMGetDictionaryEntryForKey(dict, key) WMHashGet(dict, key)
691 WMArray* WMGetAllDictionaryKeys(WMDictionary *dPtr);
694 /*--------------------------------------------------------------------------*/
697 WMNotification
* WMCreateNotification(const char *name
, void *object
, void *clientData
);
699 void WMReleaseNotification(WMNotification
*notification
);
701 WMNotification
* WMRetainNotification(WMNotification
*notification
);
703 void* WMGetNotificationClientData(WMNotification
*notification
);
705 void* WMGetNotificationObject(WMNotification
*notification
);
707 const char* WMGetNotificationName(WMNotification
*notification
);
710 void WMAddNotificationObserver(WMNotificationObserverAction
*observerAction
,
711 void *observer
, const char *name
, void *object
);
713 void WMPostNotification(WMNotification
*notification
);
715 void WMRemoveNotificationObserver(void *observer
);
717 void WMRemoveNotificationObserverWithName(void *observer
, const char *name
,
720 void WMPostNotificationName(const char *name
, void *object
, void *clientData
);
722 WMNotificationQueue
* WMGetDefaultNotificationQueue(void);
724 WMNotificationQueue
* WMCreateNotificationQueue(void);
726 void WMDequeueNotificationMatching(WMNotificationQueue
*queue
,
727 WMNotification
*notification
,
730 void WMEnqueueNotification(WMNotificationQueue
*queue
,
731 WMNotification
*notification
,
732 WMPostingStyle postingStyle
);
734 void WMEnqueueCoalesceNotification(WMNotificationQueue
*queue
,
735 WMNotification
*notification
,
736 WMPostingStyle postingStyle
,
737 unsigned coalesceMask
);
740 /*......................................................................*/
742 WMUserDefaults
* WMGetStandardUserDefaults(void);
744 WMUserDefaults
* WMGetDefaultsFromPath(char *path
);
746 void WMSynchronizeUserDefaults(WMUserDefaults
*database
);
748 void WMSaveUserDefaults(WMUserDefaults
*database
);
750 void WMEnableUDPeriodicSynchronization(WMUserDefaults
*database
, Bool enable
);
752 /* Returns a PLArray with all keys in the user defaults database.
753 * Free the returned array with PLRelease() when no longer needed,
754 * but do not free the elements of the array! They're just references. */
755 proplist_t
WMGetUDAllKeys(WMUserDefaults
*database
);
757 proplist_t
WMGetUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
759 void WMSetUDObjectForKey(WMUserDefaults
*database
, proplist_t object
,
762 void WMRemoveUDObjectForKey(WMUserDefaults
*database
, char *defaultName
);
764 char* WMGetUDStringForKey(WMUserDefaults
*database
, char *defaultName
);
766 int WMGetUDIntegerForKey(WMUserDefaults
*database
, char *defaultName
);
768 float WMGetUDFloatForKey(WMUserDefaults
*database
, char *defaultName
);
770 Bool
WMGetUDBoolForKey(WMUserDefaults
*database
, char *defaultName
);
772 void WMSetUDStringForKey(WMUserDefaults
*database
, char *value
,
775 void WMSetUDIntegerForKey(WMUserDefaults
*database
, int value
,
778 void WMSetUDFloatForKey(WMUserDefaults
*database
, float value
,
781 void WMSetUDBoolForKey(WMUserDefaults
*database
, Bool value
,
784 proplist_t
WMGetUDSearchList(WMUserDefaults
*database
);
786 void WMSetUDSearchList(WMUserDefaults
*database
, proplist_t list
);
788 extern char *WMUserDefaultsDidChangeNotification
;
791 /*-------------------------------------------------------------------------*/
793 /* WMHost: host handling */
795 WMHost
* WMGetCurrentHost();
797 WMHost
* WMGetHostWithName(char* name
);
799 WMHost
* WMGetHostWithAddress(char* address
);
801 WMHost
* WMRetainHost(WMHost
*hPtr
);
803 void WMReleaseHost(WMHost
*hPtr
);
806 * Host cache management
807 * If enabled, only one object representing each host will be created, and
808 * a shared instance will be returned by all methods that return a host.
809 * Enabled by default.
811 void WMSetHostCacheEnabled(Bool flag
);
813 Bool
WMIsHostCacheEnabled();
815 void WMFlushHostCache();
818 * Compare hosts: Hosts are equal if they share at least one address
820 Bool
WMIsHostEqualToHost(WMHost
* hPtr
, WMHost
* anotherHost
);
824 * WMGetHostName() will return first name (official) if a host has several.
825 * WMGetHostNames() will return a R/O WMArray with all the names of the host.
827 char* WMGetHostName(WMHost
* hPtr
);
829 /* The returned array is R/O. Do not modify it, and do not free it! */
830 WMArray
* WMGetHostNames(WMHost
* hPtr
);
834 * Addresses are represented as "Dotted Decimal" strings, e.g. "192.42.172.1"
835 * WMGetHostAddress() will return an arbitrary address if a host has several.
836 * WMGetHostAddresses() will return a R/O WMArray with all addresses of the host.
838 char* WMGetHostAddress(WMHost
* hPtr
);
840 /* The returned array is R/O. Do not modify it, and do not free it! */
841 WMArray
* WMGetHostAddresses(WMHost
* hPtr
);
844 /*-------------------------------------------------------------------------*/
846 /* WMConnection functions */
848 WMConnection
* WMCreateConnectionAsServerAtAddress(char *host
, char *service
,
851 WMConnection
* WMCreateConnectionToAddress(char *host
, char *service
,
854 WMConnection
* WMCreateConnectionToAddressAndNotify(char *host
, char *service
,
857 void WMCloseConnection(WMConnection
*cPtr
);
859 void WMDestroyConnection(WMConnection
*cPtr
);
861 WMConnection
* WMAcceptConnection(WMConnection
*listener
);
863 /* Release the returned data! */
864 WMData
* WMGetConnectionAvailableData(WMConnection
*cPtr
);
866 int WMSendConnectionData(WMConnection
*cPtr
, WMData
*data
);
868 Bool
WMEnqueueConnectionData(WMConnection
*cPtr
, WMData
*data
);
870 #define WMFlushConnection(cPtr) WMSendConnectionData((cPtr), NULL)
872 void WMSetConnectionDelegate(WMConnection
*cPtr
, ConnectionDelegate
*delegate
);
874 /* Connection info */
876 char* WMGetConnectionAddress(WMConnection
*cPtr
);
878 char* WMGetConnectionService(WMConnection
*cPtr
);
880 char* WMGetConnectionProtocol(WMConnection
*cPtr
);
882 Bool
WMSetConnectionNonBlocking(WMConnection
*cPtr
, Bool flag
);
884 Bool
WMSetConnectionCloseOnExec(WMConnection
*cPtr
, Bool flag
);
886 void* WMGetConnectionClientData(WMConnection
*cPtr
);
888 void WMSetConnectionClientData(WMConnection
*cPtr
, void *data
);
890 unsigned int WMGetConnectionFlags(WMConnection
*cPtr
);
892 void WMSetConnectionFlags(WMConnection
*cPtr
, unsigned int flags
);
894 int WMGetConnectionSocket(WMConnection
*cPtr
);
896 WMConnectionState
WMGetConnectionState(WMConnection
*cPtr
);
898 WMConnectionTimeoutState
WMGetConnectionTimeoutState(WMConnection
*cPtr
);
900 WMArray
* WMGetConnectionUnsentData(WMConnection
*cPtr
);
902 #define WMGetConnectionQueuedData(cPtr) WMGetConnectionUnsentData(cPtr)
906 * Passing timeout==0 in the SetTimeout functions below, will reset that
907 * timeout to its default value.
910 /* The default timeout inherited by all WMConnection operations, if none set */
911 void WMSetConnectionDefaultTimeout(unsigned int timeout
);
913 /* Global timeout for all WMConnection objects, for opening a new connection */
914 void WMSetConnectionOpenTimeout(unsigned int timeout
);
916 /* Connection specific timeout for sending out data */
917 void WMSetConnectionSendTimeout(WMConnection
*cPtr
, unsigned int timeout
);
920 /* Global variables */
922 extern int WCErrorCode
;
925 /*-------------------------------------------------------------------------*/
931 #endif /* __cplusplus */