comparison Plugins/Input/wma/libffwma/mmsio.h @ 1407:b94847e68f33 trunk

[svn] Newer libmms, from their CVS. Needs to be hooked up properly as it wants more arguments to its functions.
author chainsaw
date Sat, 15 Jul 2006 16:39:37 -0700
parents
children
comparison
equal deleted inserted replaced
1406:f40d0496fda5 1407:b94847e68f33
1 #ifndef __MMS_IO_H__
2 #define __MMS_IO_H__
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif /* __cplusplus */
7
8 typedef off_t (*mms_io_write_func)(void *data, int socket, char *buf, off_t num);
9 typedef off_t (*mms_io_read_func)(void *data, int socket, char *buf, off_t num);
10
11 /* select states */
12 #define MMS_IO_READ_READY 1
13 #define MMS_IO_WRITE_READY 2
14
15 enum
16 {
17 MMS_IO_STATUS_READY, /* IO can be safely performed */
18 MMS_IO_STATUS_ERROR, /* There was IO error */
19 MMS_IO_STATUS_ABORTED, /* IO command was (somehow)
20 aborted. This is not error, but invalidates IO for further operations*/
21 MMS_IO_STATUS_TIMEOUT /* Timeout was exceeded */
22 };
23
24 /*
25 * Waits for a file descriptor/socket to change status.
26 *
27 * users can use this handler to provide their own implementations,
28 * for example abortable ones
29 *
30 * params :
31 * data whatever parameter may be needed by implementation
32 * fd file/socket descriptor
33 * state MMS_IO_READ_READY, MMS_IO_WRITE_READY
34 * timeout_sec timeout in seconds
35 *
36 *
37 * return value :
38 * MMS_IO_READY the file descriptor is ready for cmd
39 * MMS_IO_ERROR an i/o error occured
40 * MMS_IO_ABORTED command aborted
41 * MMS_IO_TIMEOUT the file descriptor is not ready after timeout_msec milliseconds
42 * every other return value is interpreted same as MMS_IO_ABORTED
43 */
44 typedef int (*mms_io_select_func)(void *data, int fd, int state, int timeout_msec);
45
46 /*
47 * open a tcp connection
48 *
49 * params :
50 * stream needed for reporting errors but may be NULL
51 * host address of target
52 * port port on target
53 *
54 * returns a socket descriptor or -1 if an error occured
55 */
56 typedef int (*mms_io_tcp_connect_func)(void *data, const char *host, int port);
57
58 typedef struct
59 {
60 mms_io_select_func select;
61 void *select_data;
62 mms_io_read_func read;
63 void *read_data;
64 mms_io_write_func write;
65 void *write_data;
66 mms_io_tcp_connect_func connect;
67 void *connect_data;
68 } mms_io_t;
69
70 /* set default IO implementation, it will be used in absence of specific IO
71 parameter. Structure is referenced, not copied, must remain valid for entire
72 usage period. Passing NULL reverts to default, POSIX based implementation */
73 void mms_set_default_io_impl(const mms_io_t *io);
74 const mms_io_t* mms_get_default_io_impl();
75
76 #ifdef __cplusplus
77 }
78 #endif /* __cplusplus */
79
80 #endif /* __MMS_IO_H__ */