| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#ifdef HAVE_CONFIG_H |
| 24 |
#include "config.h" |
| 25 |
#endif |
| 26 |
#include "version.h" |
| 27 |
#include "rplay.h" |
| 28 |
#include <stdio.h> |
| 29 |
#include <fcntl.h> |
| 30 |
#include <stdlib.h> |
| 31 |
#include <errno.h> |
| 32 |
#include <sys/time.h> |
| 33 |
#include <sys/types.h> |
| 34 |
#include <unistd.h> |
| 35 |
#include <string.h> |
| 36 |
#include <memory.h> |
| 37 |
#ifdef __STDC__ |
| 38 |
# include <stdarg.h> |
| 39 |
#else |
| 40 |
# include <varargs.h> |
| 41 |
#endif |
| 42 |
|
| •43 |
typedef void (*cb)(int, int, char *); |
| 44 |
|
| 45 |
typedef struct obuf_s |
| 46 |
{ |
| 47 |
struct obuf_s *next; |
| 48 |
char *data; |
| 49 |
char *current; |
| 50 |
int length; |
| •51 |
|
| 52 |
cb (callback); |
| 53 |
} obuf; |
| 54 |
|
| 55 |
typedef struct ibuf_s |
| 56 |
{ |
| 57 |
struct ibuf_s *next; |
| 58 |
char *data; |
| 59 |
char *current; |
| 60 |
int length; |
| 61 |
} ibuf; |
| 62 |
|
| 63 |
typedef struct |
| 64 |
{ |
| 65 |
obuf *olist; |
| 66 |
obuf *otail; |
| 67 |
ibuf *ilist; |
| 68 |
ibuf *itail; |
| 69 |
int writing; |
| 70 |
int notify_mask; |
| •71 |
cb (rcallback); |
| 72 |
|
| 73 |
int rraw; |
| •74 |
|
| 75 |
cb (wcallback); |
| 76 |
int wraw; |
| 77 |
} grp; |
| 78 |
|
| 79 |
|
| 80 |
static grp group[FD_SETSIZE]; |
| 81 |
static int looping; |
| 82 |
static int main_loop_return_value; |
| 83 |
|
| 84 |
|
| 85 |
#ifdef __STDC__ |
| 86 |
static void write_proc(int rptp_fd); |
| 87 |
static void do_register(int rptp_fd); |
| 88 |
static void do_unregister(int rptp_fd); |
| 89 |
static void notify_line(int rptp_fd, char *line); |
| 90 |
static void read_proc(int rptp_fd); |
| 91 |
static void process_input(int rptp_fd); |
| 92 |
#else |
| 93 |
static void write_proc(); |
| 94 |
static void do_register(); |
| 95 |
static void do_unregister(); |
| 96 |
static void notify_line(); |
| 97 |
static void read_proc(); |
| 98 |
static void process_input(); |
| 99 |
#endif |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
int |
| 106 |
rptp_main_loop() |
| 107 |
{ |
| 108 |
fd_set read_fds; |
| 109 |
fd_set write_fds; |
| 110 |
int i, n; |
| 111 |
|
| 112 |
looping = 1; |
| 113 |
main_loop_return_value = 0; |
| 114 |
while (looping) |
| 115 |
{ |
| 116 |
FD_ZERO(&read_fds); |
| 117 |
FD_ZERO(&write_fds); |
| 118 |
|
| 119 |
for (i = 0; i < FD_SETSIZE; i++) |
| 120 |
{ |
| 121 |
if (group[i].olist) |
| 122 |
FD_SET(i, &write_fds); |
| 123 |
if (group[i].rcallback) |
| 124 |
FD_SET(i, &read_fds); |
| 125 |
} |
| 126 |
|
| 127 |
n = select(FD_SETSIZE, &read_fds, &write_fds, NULL, NULL); |
| 128 |
if (n < 0) |
| 129 |
{ |
| 130 |
if (errno == EINTR) |
| 131 |
continue; |
| 132 |
return -1; |
| 133 |
} |
| 134 |
|
| 135 |
for (i = 0; i < FD_SETSIZE && n; i++) |
| 136 |
{ |
| 137 |
if (FD_ISSET(i, &read_fds)) |
| 138 |
{ |
| 139 |
n--; |
| 140 |
if (group[i].rcallback) |
| 141 |
rptp_async_process(i, RPTP_ASYNC_READ); |
| 142 |
} |
| 143 |
if (FD_ISSET(i, &write_fds)) |
| 144 |
{ |
| 145 |
n--; |
| 146 |
if (group[i].writing) |
| 147 |
rptp_async_process(i, RPTP_ASYNC_WRITE); |
| 148 |
} |
| 149 |
} |
| 150 |
} |
| 151 |
return main_loop_return_value; |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
#ifdef __STDC__ |
| 160 |
void |
| 161 |
rptp_stop_main_loop(int return_value) |
| 162 |
#else |
| 163 |
void |
| 164 |
rptp_stop_main_loop(return_value) |
| 165 |
int return_value; |
| 166 |
#endif |
| 167 |
{ |
| 168 |
looping = 0; |
| 169 |
main_loop_return_value = return_value; |
| 170 |
} |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
#ifdef __STDC__ |
| 179 |
int |
| 180 |
rptp_async_putline(int rptp_fd, cb callback, char *fmt, ...) |
| 181 |
#else |
| 182 |
int |
| 183 |
rptp_async_putline(va_alist) |
| 184 |
va_dcl |
| 185 |
#endif |
| 186 |
{ |
| 187 |
va_list args; |
| 188 |
char buf[RPTP_MAX_LINE]; |
| 189 |
|
| 190 |
#ifdef __STDC__ |
| 191 |
va_start(args, fmt); |
| 192 |
#else |
| 193 |
int rptp_fd; |
| 194 |
char *fmt; |
| 195 |
cb callback; |
| 196 |
char *tmp; |
| 197 |
va_start(args); |
| 198 |
rptp_fd = va_arg(args, int); |
| 199 |
tmp = va_arg(args, char *); |
| 200 |
callback = (cb) tmp; |
| 201 |
fmt = va_arg(args, char *); |
| 202 |
#endif |
| 203 |
|
| 204 |
if (rptp_fd < 0 || rptp_fd >= FD_SETSIZE) |
| 205 |
{ |
| 206 |
rptp_errno = RPTP_ERROR_SOCKET; |
| 207 |
return -1; |
| 208 |
} |
| 209 |
|
| 210 |
rptp_errno = RPTP_ERROR_NONE; |
| 211 |
|
| 212 |
vsprintf(buf, fmt, args); |
| 213 |
va_end(args); |
| 214 |
strcat(buf, "\r\n"); |
| 215 |
|
| 216 |
return rptp_async_write(rptp_fd, callback, buf, strlen(buf)) != strlen(buf) ? -1 : 0; |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
#ifdef __STDC__ |
| 227 |
int |
| 228 |
rptp_async_write(int rptp_fd, cb callback, char *ptr, int nbytes) |
| 229 |
#else |
| 230 |
int |
| 231 |
rptp_async_write(rptp_fd, callback, ptr, nbytes) |
| 232 |
int rptp_fd; |
| 233 |
cb callback; |
| 234 |
char *ptr; |
| 235 |
int nbytes; |
| 236 |
#endif |
| 237 |
{ |
| 238 |
obuf *new; |
| 239 |
|
| 240 |
if (rptp_fd < 0 || rptp_fd >= FD_SETSIZE) |
| 241 |
{ |
| 242 |
rptp_errno = RPTP_ERROR_SOCKET; |
| 243 |
return -1; |
| 244 |
} |
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
new = (obuf *) malloc(sizeof(obuf)); |
| 250 |
new->next = NULL; |
| 251 |
if (nbytes > 0 && ptr) |
| 252 |
{ |
| 253 |
new->data = malloc(nbytes); |
| 254 |
memcpy(new->data, ptr, nbytes); |
| 255 |
} |
| 256 |
else |
| 257 |
{ |
| 258 |
new->data = NULL; |
| 259 |
} |
| 260 |
new->current = new->data; |
| 261 |
new->length = nbytes; |
| 262 |
new->callback = callback; |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
if (group[rptp_fd].otail) |
| 268 |
{ |
| 269 |
group[rptp_fd].otail->next = new; |
| 270 |
group[rptp_fd].otail = new; |
| 271 |
} |
| 272 |
else |
| 273 |
{ |
| 274 |
group[rptp_fd].otail = group[rptp_fd].olist = new; |
| 275 |
} |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
if (!group[rptp_fd].writing) |
| 282 |
{ |
| 283 |
do_register(rptp_fd); |
| 284 |
} |
| 285 |
} |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
#ifdef __STDC__ |
| 308 |
void |
| 309 |
rptp_async_register(int rptp_fd, int what, cb callback) |
| 310 |
#else |
| 311 |
void |
| •312 |
rptp_async_register(int rptp_fd, int what, cb callback) |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
#endif |
| 317 |
{ |
| 318 |
if (rptp_fd < 0 || rptp_fd >= FD_SETSIZE) |
| 319 |
{ |
| 320 |
rptp_errno = RPTP_ERROR_SOCKET; |
| 321 |
return; |
| 322 |
} |
| 323 |
|
| 324 |
switch (what) |
| 325 |
{ |
| 326 |
case RPTP_ASYNC_WRITE: |
| 327 |
group[rptp_fd].wcallback = callback; |
| 328 |
group[rptp_fd].wraw = 0; |
| 329 |
break; |
| 330 |
|
| 331 |
case RPTP_ASYNC_WRITE | RPTP_ASYNC_RAW: |
| 332 |
group[rptp_fd].wcallback = callback; |
| 333 |
group[rptp_fd].wraw = 1; |
| 334 |
break; |
| 335 |
|
| 336 |
case RPTP_ASYNC_READ: |
| 337 |
group[rptp_fd].rcallback = callback; |
| 338 |
group[rptp_fd].rraw = 1; |
| 339 |
break; |
| 340 |
} |
| 341 |
} |
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
#ifdef __STDC__ |
| 353 |
void |
| 354 |
rptp_async_process(int rptp_fd, int what) |
| 355 |
#else |
| 356 |
void |
| •357 |
rptp_async_process(int rptp_fd, int what) |
| 358 |
|
| 359 |
|
| 360 |
#endif |
| 361 |
{ |
| 362 |
if (rptp_fd < 0 || rptp_fd >= FD_SETSIZE) |
| 363 |
{ |
| 364 |
rptp_errno = RPTP_ERROR_SOCKET; |
| 365 |
return; |
| 366 |
} |
| 367 |
|
| 368 |
switch (what) |
| 369 |
{ |
| 370 |
case RPTP_ASYNC_READ: |
| 371 |
if (group[rptp_fd].rraw && group[rptp_fd].rcallback) |
| •372 |
(*group[rptp_fd].rcallback)(rptp_fd, 0, ""); |
| 373 |
else |
| 374 |
read_proc(rptp_fd); |
| 375 |
break; |
| 376 |
|
| 377 |
case RPTP_ASYNC_WRITE: |
| 378 |
if (group[rptp_fd].wraw && group[rptp_fd].wcallback) |
| •379 |
(*group[rptp_fd].wcallback)(rptp_fd, 0, ""); |
| 380 |
else |
| 381 |
write_proc(rptp_fd); |
| 382 |
break; |
| 383 |
} |
| 384 |
} |
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
#ifdef __STDC__ |
| 397 |
void |
| •398 |
rptp_async_notify(int rptp_fd, int mask, void (*callback)(int, int, char *)) |
| 399 |
#else |
| 400 |
void |
| •401 |
rptp_async_notify(int rptp_fd, int mask, void (*callback)(int, int, char *)) |
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
#endif |
| 406 |
{ |
| 407 |
char command[RPTP_MAX_LINE]; |
| 408 |
char *p; |
| 409 |
|
| 410 |
strcpy (command, "set notify="); |
| 411 |
|
| 412 |
if (mask & RPTP_EVENT_CONTINUE) |
| 413 |
strcat(command, "continue,"); |
| 414 |
if (mask & RPTP_EVENT_DONE) |
| 415 |
strcat(command, "done,"); |
| 416 |
if (mask & RPTP_EVENT_PAUSE) |
| 417 |
strcat(command, "pause,"); |
| 418 |
if (mask & RPTP_EVENT_PLAY) |
| 419 |
strcat(command, "play,"); |
| 420 |
if (mask & RPTP_EVENT_SKIP) |
| 421 |
strcat(command, "skip,"); |
| 422 |
if (mask & RPTP_EVENT_STATE) |
| 423 |
strcat(command, "state,"); |
| 424 |
if (mask & RPTP_EVENT_STOP) |
| 425 |
strcat(command, "stop,"); |
| 426 |
if (mask & RPTP_EVENT_VOLUME) |
| 427 |
strcat(command, "volume,"); |
| 428 |
if (mask & RPTP_EVENT_FLOW) |
| 429 |
strcat(command, "flow,"); |
| 430 |
if (mask & RPTP_EVENT_MODIFY) |
| 431 |
strcat(command, "modify,"); |
| 432 |
if (mask & RPTP_EVENT_LEVEL) |
| 433 |
strcat(command, "level,"); |
| 434 |
if (mask & RPTP_EVENT_POSITION) |
| 435 |
strcat(command, "position,"); |
| 436 |
|
| 437 |
p = strrchr(command, ','); |
| 438 |
if (!p) |
| 439 |
strcat(command, "none"); |
| 440 |
else |
| 441 |
*p = '\0'; |
| 442 |
|
| 443 |
rptp_async_putline(rptp_fd, NULL, command); |
| 444 |
|
| 445 |
group[rptp_fd].rcallback = callback; |
| 446 |
group[rptp_fd].notify_mask = mask; |
| 447 |
group[rptp_fd].rraw = 0; |
| 448 |
} |
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
#ifdef __STDC__ |
| 460 |
static void |
| 461 |
write_proc(int rptp_fd) |
| 462 |
#else |
| 463 |
static void |
| •464 |
write_proc(int rptp_fd) |
| 465 |
#endif |
| 466 |
{ |
| 467 |
obuf *current; |
| 468 |
int n; |
| 469 |
|
| 470 |
if (!group[rptp_fd].olist) |
| 471 |
{ |
| 472 |
do_unregister(rptp_fd); |
| 473 |
} |
| 474 |
|
| 475 |
current = group[rptp_fd].olist; |
| 476 |
if (current->current) |
| 477 |
{ |
| 478 |
n = write(rptp_fd, current->current, current->length); |
| 479 |
if (n < 0) |
| 480 |
{ |
| 481 |
return; |
| 482 |
} |
| 483 |
} |
| 484 |
else |
| 485 |
{ |
| 486 |
n = 0; |
| 487 |
} |
| 488 |
current->length -= n; |
| 489 |
current->current += n; |
| 490 |
if (current->length <= 0) |
| 491 |
{ |
| 492 |
if (current->callback) |
| 493 |
{ |
| •494 |
(*current->callback)(rptp_fd, 0, ""); |
| 495 |
} |
| 496 |
if (current->data) |
| 497 |
{ |
| 498 |
free(current->data); |
| 499 |
} |
| 500 |
group[rptp_fd].olist = current->next; |
| 501 |
if (group[rptp_fd].otail == current) |
| 502 |
{ |
| 503 |
group[rptp_fd].otail = NULL; |
| 504 |
} |
| 505 |
free(current); |
| 506 |
|
| 507 |
if (!group[rptp_fd].olist) |
| 508 |
{ |
| 509 |
do_unregister(rptp_fd); |
| 510 |
} |
| 511 |
} |
| 512 |
} |
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
#ifdef __STDC__ |
| 519 |
static void |
| 520 |
read_proc(int rptp_fd) |
| 521 |
#else |
| 522 |
static void |
| •523 |
read_proc(int rptp_fd) |
| 524 |
#endif |
| 525 |
{ |
| 526 |
char buffer[RPTP_MAX_LINE]; |
| 527 |
int n; |
| 528 |
ibuf *new; |
| 529 |
|
| 530 |
n = read(rptp_fd, buffer, sizeof(buffer)); |
| 531 |
if (n <= 0) |
| 532 |
{ |
| 533 |
if (group[rptp_fd].notify_mask & RPTP_EVENT_CLOSE && group[rptp_fd].rcallback) |
| 534 |
{ |
| 535 |
(*group[rptp_fd].rcallback)(rptp_fd, RPTP_EVENT_CLOSE, ""); |
| 536 |
group[rptp_fd].rcallback = NULL; |
| 537 |
} |
| 538 |
return; |
| 539 |
} |
| 540 |
|
| 541 |
new = (ibuf *) malloc(sizeof(ibuf)); |
| 542 |
new->next = NULL; |
| 543 |
new->data = malloc(n); |
| 544 |
memcpy(new->data, buffer, n); |
| 545 |
new->length = n; |
| 546 |
new->current = new->data; |
| 547 |
|
| 548 |
if (group[rptp_fd].itail) |
| 549 |
{ |
| 550 |
group[rptp_fd].itail->next = new; |
| 551 |
group[rptp_fd].itail = new; |
| 552 |
} |
| 553 |
else |
| 554 |
{ |
| 555 |
group[rptp_fd].itail = group[rptp_fd].ilist = new; |
| 556 |
} |
| 557 |
|
| 558 |
process_input(rptp_fd); |
| 559 |
} |
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
#ifdef __STDC__ |
| 567 |
static void |
| 568 |
process_input(int rptp_fd) |
| 569 |
#else |
| 570 |
static void |
| •571 |
process_input(int rptp_fd) |
| 572 |
#endif |
| 573 |
{ |
| 574 |
char *p; |
| 575 |
ibuf *ptr; |
| 576 |
static char line[RPTP_MAX_LINE * 2] = ""; |
| 577 |
static int length = 0; |
| 578 |
|
| 579 |
while ((ptr = group[rptp_fd].ilist)) |
| 580 |
{ |
| 581 |
if (p = memchr(ptr->current, '\r', ptr->length)) |
| 582 |
{ |
| 583 |
memcpy(&line[length], ptr->current, p - ptr->current); |
| 584 |
length += p - ptr->current; |
| 585 |
line[length] = '\0'; |
| 586 |
notify_line(rptp_fd, line); |
| 587 |
length = 0; |
| 588 |
|
| 589 |
p+= 2; |
| 590 |
if (p < ptr->current + ptr->length) |
| 591 |
{ |
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
ptr->length -= p - ptr->current; |
| 596 |
ptr->current = p; |
| 597 |
} |
| 598 |
else |
| 599 |
{ |
| 600 |
free(ptr->data); |
| 601 |
if (ptr == group[rptp_fd].itail) |
| 602 |
{ |
| 603 |
group[rptp_fd].ilist = group[rptp_fd].itail = NULL; |
| 604 |
} |
| 605 |
else |
| 606 |
{ |
| 607 |
group[rptp_fd].ilist = ptr->next; |
| 608 |
} |
| 609 |
free(ptr); |
| 610 |
} |
| 611 |
} |
| 612 |
else |
| 613 |
{ |
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
memcpy(&line[length], ptr->current, ptr->length); |
| 619 |
length += ptr->length; |
| 620 |
free(ptr->data); |
| 621 |
if (ptr == group[rptp_fd].itail) |
| 622 |
{ |
| 623 |
group[rptp_fd].ilist = group[rptp_fd].itail = NULL; |
| 624 |
} |
| 625 |
else |
| 626 |
{ |
| 627 |
group[rptp_fd].ilist = ptr->next; |
| 628 |
} |
| 629 |
free(ptr); |
| 630 |
} |
| 631 |
} |
| 632 |
} |
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
static struct |
| 639 |
{ |
| 640 |
char *event; |
| 641 |
int mask; |
| 642 |
} events[] = |
| 643 |
{ |
| 644 |
{"continue", RPTP_EVENT_CONTINUE}, |
| 645 |
{"done", RPTP_EVENT_DONE}, |
| 646 |
{"pause", RPTP_EVENT_PAUSE}, |
| 647 |
{"play", RPTP_EVENT_PLAY}, |
| 648 |
{"skip", RPTP_EVENT_SKIP}, |
| 649 |
{"state", RPTP_EVENT_STATE}, |
| 650 |
{"stop", RPTP_EVENT_STOP}, |
| 651 |
{"volume", RPTP_EVENT_VOLUME}, |
| 652 |
{"flow", RPTP_EVENT_FLOW}, |
| 653 |
{"modify", RPTP_EVENT_MODIFY}, |
| 654 |
{"level", RPTP_EVENT_LEVEL}, |
| 655 |
{"position", RPTP_EVENT_POSITION}, |
| 656 |
{NULL, 0} |
| 657 |
}; |
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
#ifdef __STDC__ |
| 664 |
static void |
| 665 |
notify_line(int rptp_fd, char *line) |
| 666 |
#else |
| 667 |
static void |
| •668 |
notify_line(int rptp_fd, char *line) |
| 669 |
#endif |
| 670 |
{ |
| 671 |
int what; |
| 672 |
char *event; |
| 673 |
int i; |
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
if (!group[rptp_fd].rcallback) |
| 680 |
return; |
| 681 |
|
| 682 |
switch (*line) |
| 683 |
{ |
| 684 |
case '+': |
| 685 |
what = RPTP_EVENT_OK; |
| 686 |
break; |
| 687 |
|
| 688 |
case '-': |
| 689 |
what = RPTP_EVENT_ERROR; |
| 690 |
break; |
| 691 |
|
| 692 |
case '!': |
| 693 |
what = RPTP_EVENT_TIMEOUT; |
| 694 |
break; |
| 695 |
|
| 696 |
case '@': |
| 697 |
event = rptp_parse(line, "event"); |
| 698 |
what = RPTP_EVENT_OTHER; |
| 699 |
for (i = 0; events[i].event; i++) |
| 700 |
{ |
| 701 |
if (strcmp(events[i].event, event) == 0) |
| 702 |
{ |
| 703 |
what = events[i].mask; |
| 704 |
break; |
| 705 |
} |
| 706 |
} |
| 707 |
break; |
| 708 |
|
| 709 |
default: |
| 710 |
what = RPTP_EVENT_OTHER; |
| 711 |
break; |
| 712 |
} |
| 713 |
if (what & group[rptp_fd].notify_mask) |
| 714 |
{ |
| 715 |
(*group[rptp_fd].rcallback)(rptp_fd, what, line); |
| 716 |
} |
| 717 |
#if 0 |
| 718 |
else |
| 719 |
{ |
| 720 |
printf("Input line being ignored: '%s'\n", line); |
| 721 |
} |
| 722 |
#endif |
| 723 |
} |
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
#ifdef __STDC__ |
| 730 |
static void |
| 731 |
do_register(int rptp_fd) |
| 732 |
#else |
| 733 |
static void |
| •734 |
do_register(int rptp_fd) |
| 735 |
#endif |
| 736 |
{ |
| 737 |
if (group[rptp_fd].wcallback) |
| 738 |
{ |
| •739 |
(*group[rptp_fd].wcallback)(rptp_fd, RPTP_ASYNC_ENABLE, ""); |
| 740 |
} |
| 741 |
group[rptp_fd].writing = 1; |
| 742 |
} |
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
#ifdef __STDC__ |
| 749 |
static void |
| 750 |
do_unregister(int rptp_fd) |
| 751 |
#else |
| 752 |
static void |
| •753 |
do_unregister(int rptp_fd) |
| 754 |
#endif |
| 755 |
{ |
| 756 |
if (group[rptp_fd].wcallback) |
| 757 |
{ |
| •758 |
(*group[rptp_fd].wcallback)(rptp_fd, RPTP_ASYNC_DISABLE, ""); |
| 759 |
} |
| 760 |
group[rptp_fd].writing = 0; |
| 761 |
} |
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|