diff options
author | Benny Prijono <bennylp@teluu.com> | 2005-11-07 15:47:28 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2005-11-07 15:47:28 +0000 |
commit | e25a988d098a075f5519090c24237c3b97bc1323 (patch) | |
tree | e6f4110d717550912cc25bb4e016bd60177d0016 /pjlib/src/pj/ioqueue_winnt.c | |
parent | 4539be1bf3b88417e3b52fdbeb17d6a74266cb4a (diff) |
Added file I/O and file access API
git-svn-id: http://svn.pjsip.org/repos/pjproject/main@18 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/ioqueue_winnt.c')
-rw-r--r-- | pjlib/src/pj/ioqueue_winnt.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/pjlib/src/pj/ioqueue_winnt.c b/pjlib/src/pj/ioqueue_winnt.c index afb75c54..32a74666 100644 --- a/pjlib/src/pj/ioqueue_winnt.c +++ b/pjlib/src/pj/ioqueue_winnt.c @@ -33,9 +33,9 @@ typedef struct generic_overlapped WSAOVERLAPPED overlapped;
pj_ioqueue_operation_e operation;
} generic_overlapped;
- +
/* - * OVERLAP structure for send and receive. + * OVERLAPPPED structure for send and receive. */ typedef struct ioqueue_overlapped { @@ -74,6 +74,14 @@ union operation_key ioqueue_accept_rec accept;
#endif
};
+
+/* Type of handle in the key. */
+enum handle_type
+{
+ HND_IS_UNKNOWN,
+ HND_IS_FILE,
+ HND_IS_SOCKET,
+};
/* * Structure for individual socket. @@ -82,7 +90,8 @@ struct pj_ioqueue_key_t {
pj_ioqueue_t *ioqueue; HANDLE hnd; - void *user_data; + void *user_data;
+ enum handle_type hnd_type; #if PJ_HAS_TCP int connecting; #endif @@ -316,7 +325,8 @@ PJ_DEF(pj_status_t) pj_ioqueue_register_sock( pj_pool_t *pool, /* Build the key for this socket. */ rec = pj_pool_zalloc(pool, sizeof(pj_ioqueue_key_t));
rec->ioqueue = ioqueue; - rec->hnd = (HANDLE)sock; + rec->hnd = (HANDLE)sock;
+ rec->hnd_type = HND_IS_SOCKET; rec->user_data = user_data; pj_memcpy(&rec->cb, cb, sizeof(pj_ioqueue_callback)); @@ -336,7 +346,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_register_sock( pj_pool_t *pool, *key = rec; return PJ_SUCCESS; } - +
/* * pj_ioqueue_unregister()
*/ @@ -362,7 +372,10 @@ PJ_DEF(pj_status_t) pj_ioqueue_unregister( pj_ioqueue_key_t *key ) key->connecting = 0;
pj_lock_release(ioqueue->lock); } -#endif +#endif
+ if (key->hnd_type == HND_IS_FILE) {
+ CloseHandle(key->hnd);
+ } return PJ_SUCCESS; } @@ -482,7 +495,7 @@ PJ_DEF(int) pj_ioqueue_poll( pj_ioqueue_t *ioqueue, const pj_time_val *timeout) } return -1; } - +
/* * pj_ioqueue_recv() * @@ -505,7 +518,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_recv( pj_ioqueue_key_t *key, union operation_key *op_key_rec;
PJ_CHECK_STACK();
- PJ_ASSERT_RETURN(key && op_key && buffer, PJ_EINVAL);
+ PJ_ASSERT_RETURN(key && op_key && buffer && length, PJ_EINVAL);
op_key_rec = (union operation_key*)op_key->internal__;
op_key_rec->overlapped.wsabuf.buf = buffer;
|