| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#ifndef _connection_h |
| 27 |
#define _connection_h |
| 28 |
|
| 29 |
#ifdef HAVE_CONFIG_H |
| 30 |
#include "config.h" |
| 31 |
#endif |
| 32 |
#include <sys/param.h> |
| 33 |
#include <sys/types.h> |
| 34 |
#include <sys/time.h> |
| 35 |
#include "sound.h" |
| 36 |
#include "server.h" |
| 37 |
#include "buffer.h" |
| 38 |
#include "spool.h" |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
#define EVENT_NULL 0 |
| 44 |
#define EVENT_READ_COMMAND (1<<0) |
| 45 |
#define EVENT_CONNECT (1<<1) |
| 46 |
#define EVENT_READ_CONNECT_REPLY (1<<2) |
| 47 |
#define EVENT_WRITE_FIND (1<<3) |
| 48 |
#define EVENT_READ_FIND_REPLY (1<<4) |
| 49 |
#define EVENT_WRITE_GET (1<<5) |
| 50 |
#define EVENT_READ_GET_REPLY (1<<6) |
| 51 |
#define EVENT_READ_SOUND (1<<7) |
| 52 |
#define EVENT_WRITE (1<<8) |
| 53 |
#define EVENT_WRITE_SOUND (1<<9) |
| 54 |
#define EVENT_WRITE_TIMEOUT (1<<10) |
| 55 |
#define EVENT_NOTIFY (1<<11) |
| 56 |
#define EVENT_READ_FLOW (1<<12) |
| 57 |
#define EVENT_WAIT_FLOW (1<<13) |
| 58 |
#define EVENT_PIPE_FLOW (1<<14) |
| 59 |
#define EVENT_WRITE_MONITOR (1<<15) |
| 60 |
#define EVENT_WAIT_MONITOR (1<<16) |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
#define NOTIFY_NONE 0 |
| 66 |
#define NOTIFY_VOLUME (1<<0) |
| 67 |
#define NOTIFY_PLAY (1<<1) |
| 68 |
#define NOTIFY_PAUSE (1<<2) |
| 69 |
#define NOTIFY_CONTINUE (1<<3) |
| 70 |
#define NOTIFY_STOP (1<<4) |
| 71 |
#define NOTIFY_DONE (1<<5) |
| 72 |
#define NOTIFY_SKIP (1<<6) |
| 73 |
#define NOTIFY_STATE (1<<7) |
| 74 |
#define NOTIFY_FLOW (1<<8) |
| 75 |
#define NOTIFY_MODIFY (1<<9) |
| 76 |
#define NOTIFY_LEVEL (1<<10) |
| 77 |
#define NOTIFY_POSITION (1<<11) |
| 78 |
#define NOTIFY_MONITOR (1<<12) |
| 79 |
#define NOTIFY_ANY (0xffffffff) |
| 80 |
#define NOTIFY_SPOOL (NOTIFY_PLAY|NOTIFY_PAUSE|NOTIFY_CONTINUE|NOTIFY_STOP|NOTIFY_DONE|NOTIFY_SKIP|NOTIFY_MODIFY|NOTIFY_FLOW) |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
#define CONNECTION_NULL 0 |
| 86 |
#define CONNECTION_CLIENT 1 |
| 87 |
#define CONNECTION_SERVER 2 |
| 88 |
|
| 89 |
typedef struct _event |
| 90 |
{ |
| 91 |
struct _event *next; |
| 92 |
int type; |
| 93 |
int nbytes; |
| 94 |
int byte_offset; |
| 95 |
int nleft; |
| 96 |
char *start; |
| 97 |
char *ptr; |
| 98 |
BUFFER *buffer; |
| 99 |
SOUND *sound; |
| 100 |
int fd; |
| 101 |
int nconnects; |
| 102 |
time_t time; |
| 103 |
int success; |
| 104 |
int id; |
| 105 |
int wait_mask; |
| 106 |
SINDEX *si; |
| 107 |
} |
| 108 |
EVENT; |
| 109 |
|
| 110 |
#define NOTIFY_RATE_LEVEL 0 |
| 111 |
#define NOTIFY_RATE_POSITION 1 |
| 112 |
#define NOTIFY_RATE_MAX 2 |
| 113 |
|
| 114 |
typedef struct |
| 115 |
{ |
| 116 |
double rate; |
| 117 |
double next; |
| 118 |
} |
| 119 |
NOTIFY_RATE; |
| 120 |
|
| 121 |
typedef struct _connection |
| 122 |
{ |
| 123 |
struct _connection *next; |
| 124 |
struct _connection *prev; |
| 125 |
struct sockaddr_in sin; |
| 126 |
int type; |
| 127 |
int fd; |
| 128 |
EVENT *event; |
| 129 |
EVENT **ep; |
| 130 |
SERVER *server; |
| 131 |
time_t time; |
| 132 |
char *application; |
| 133 |
int notify_mask; |
| 134 |
int notify_id; |
| 135 |
NOTIFY_RATE notify_rate[NOTIFY_RATE_MAX]; |
| 136 |
int monitor; |
| 137 |
} |
| 138 |
CONNECTION; |
| 139 |
|
| 140 |
extern CONNECTION *connections; |
| 141 |
extern int nconnections; |
| 142 |
extern int connection_want_level_notify; |
| 143 |
extern int connection_level_notify; |
| 144 |
|
| 145 |
#ifdef __STDC__ |
| 146 |
extern CONNECTION *connection_create (int type); |
| 147 |
extern void connection_destroy (CONNECTION *c); |
| 148 |
extern void connection_client_open (int fd); |
| 149 |
extern void connection_update (fd_set * read_fds, fd_set * write_fds); |
| 150 |
extern void connection_close (CONNECTION *c); |
| 151 |
extern void connection_cleanup (); |
| 152 |
extern void connection_update_fdset (CONNECTION *c); |
| 153 |
extern void connection_reply (CONNECTION *c, char *fmt,...); |
| 154 |
extern CONNECTION *connection_server_open (SERVER *server, SOUND *sound); |
| 155 |
extern void connection_server_reopen (CONNECTION *c); |
| 156 |
extern void connection_server_ping (CONNECTION *c); |
| 157 |
extern void connection_check_timeout (); |
| 158 |
extern void connection_timeout (CONNECTION *c); |
| 159 |
extern void connection_server_forward_sound (CONNECTION *c, SOUND *s); |
| 160 |
extern void connection_server_foward (CONNECTION *c); |
| 161 |
extern BUFFER *connection_list_create (); |
| 162 |
extern void connection_notify (CONNECTION *c, int wait_event,...); |
| 163 |
extern void connection_flow_pause (SPOOL *sp); |
| 164 |
extern void connection_flow_continue (SPOOL *sp); |
| •165 |
extern void connection_monitor_continue(); |
| 166 |
extern int connection_idle (); |
| 167 |
extern EVENT *event_create (int event_type,...); |
| 168 |
extern void event_first (CONNECTION *c, EVENT *e); |
| 169 |
extern void event_insert_before (CONNECTION *c, EVENT *e, int mask); |
| 170 |
extern void event_insert (CONNECTION *c, EVENT *e); |
| 171 |
extern void event_delete (CONNECTION *c, int replace); |
| 172 |
extern void event_update (CONNECTION *c); |
| 173 |
extern void event_destroy (EVENT *e); |
| 174 |
extern void event_replace (CONNECTION *c, EVENT *e); |
| 175 |
#else |
| 176 |
extern CONNECTION *connection_create ( ); |
| 177 |
extern void connection_destroy ( ); |
| 178 |
extern void connection_client_open ( ); |
| 179 |
extern void connection_update ( ); |
| 180 |
extern void connection_close ( ); |
| 181 |
extern void connection_cleanup (); |
| 182 |
extern void connection_update_fdset ( ); |
| 183 |
extern void connection_reply ( ); |
| 184 |
extern CONNECTION *connection_server_open ( ); |
| 185 |
extern void connection_server_ping ( ); |
| 186 |
extern void connection_check_timeout (); |
| 187 |
extern void connection_timeout ( ); |
| 188 |
extern void connection_server_forward_sound ( ); |
| 189 |
extern void connection_server_foward ( ); |
| 190 |
extern BUFFER *connection_list_create (); |
| 191 |
extern void connection_notify ( ); |
| 192 |
extern void connection_flow_pause ( ); |
| 193 |
extern void connection_flow_continue ( ); |
| •194 |
extern void connection_monitor_continue(); |
| 195 |
extern int connection_idle (); |
| 196 |
extern EVENT *event_create ( ); |
| 197 |
extern void event_first ( ); |
| 198 |
extern void event_insert_before ( ); |
| 199 |
extern void event_insert ( ); |
| 200 |
extern void event_delete ( ); |
| 201 |
extern void event_update ( ); |
| 202 |
extern void event_destroy ( ); |
| 203 |
extern void event_replace ( ); |
| 204 |
#endif |
| 205 |
|
| 206 |
#endif |