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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875
|
\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename librplay.info
@settitle The rplay Programmer's Manual
@iftex
@finalout
@end iftex
@setchapternewpage odd
@c %**end of header
@ifinfo
@dircategory Development
@direntry
* librplay: (librplay). The rplay library.
@end direntry
This file documents librplay.
Copyright (C) 1995 Mark Boyns
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
@ignore
Permission is granted to process this file through Tex and print the
results, provided the printed document carries copying permission
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).
@end ignore
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided also that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions.
@end ifinfo
@titlepage
@title The rplay Programmer's Manual
@author by Mark Boyns
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1995 Mark Boyns
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions.
@end titlepage
@page
@node Top, RPLAY Core Functions, (dir), (dir)
@top librplay
This file documents @samp{librplay}, the C library interface to the
RPLAY and RPTP protocols. Programs that wish to use @samp{librplay}
must include @file{rplay.h} and link with @file{librplay}.
rplay is based on two protocols and therefore this library has two
distinct sets of routines. The routines can be distinguished by either
a @samp{rplay_} or @samp{rptp_} prefix. To avoid conflicts, user
programs are encouraged not to use variables or functions that
begin with either of these prefixes.
In most cases, each function description includes one or more examples
to help illustrate how the function can be used.
@menu
* RPLAY Core Functions:: Low-level routines.
* RPLAY Helper Functions::
* RPLAY Miscellaneous Functions:: Routines that may not be very useful.
* RPLAY Error Reporting:: How to deal with RPLAY errors.
* RPTP Core Functions:: Low-level routines.
* RPTP Helper Functions::
* RPTP Error Reporting:: How to deal with RPTP errors.
* Function Index:: Function Index.
@end menu
@node RPLAY Core Functions, RPLAY Helper Functions, Top, Top
@chapter RPLAY Core Functions
@c
@c rplay_open
@c
@deftypefun int rplay_open (char *@var{host})
Open a UDP socket connection to send RPLAY packets to host.
The @var{host} argument is the name or IP address of the host where
packets will be sent. The IP address can be a subnet mask which
is used to broadcast packets to multiple hosts.
The return value is a socket descriptor on success and @code{-1} on
failure.
@end deftypefun
Example:
@example
int rplay_fd;
rplay_fd = rplay_open ("130.191.255.255");
if (rplay_fd < 0)
@{
rplay_perror ("rplay_open");
exit (1);
@}
@end example
@c
@c rplay_close
@c
@deftypefun int rplay_close (int @var{rplay_fd})
This function closes a rplay connection.
The @var{rplay_fd} argument should be a socket descriptor opened by
@code{rplay_open}.
The return value is @code{0} on success and @code{-1} on failure.
@end deftypefun
@c
@c rplay_create
@c
@deftypefun {RPLAY *} rplay_create (int @var{command})
Create a RPLAY object to perform a specific command.
The @var{command} argument should be one of the following:
@code{RPLAY_PLAY}, @code{RPLAY_STOP}, @code{RPLAY_PAUSE},
@code{RPLAY_CONTINUE}, @code{RPLAY_PING}, or @code{RPLAY_RESET}.
The return value is a pointer to a new RPLAY object on success
and @code{NULL} on failure.
@end deftypefun
Example:
@example
RPLAY *rp;
rp = rplay_create (RPLAY_PLAY);
if (rp == NULL)
@{
rplay_perror ("rplay_create");
exit (1);
@}
@end example
@c
@c rplay_set
@c
@deftypefun int rplay_set (RPLAY *@var{rp}, ...)
Modify attributes of a RPLAY object.
The @var{rp} argument should be a pointer to a RPLAY object created
by @code{rplay_create}. The remaining arguments will be:
@table @code
@item RPLAY_APPEND
Append a sound and its attributes.
@item RPLAY_DELETE
Delete a sound and its attributes.
@item RPLAY_INSERT
Insert a sound and its attributes.
@item RPLAY_RANDOM_SOUND
Choose a sound at random from the sound list. Only the chosen
sound will be played, not entire sound list.
@end table
The attribute list must be terminated with @code{NULL}.
The return value is @code{0} on success and @code{-1} on failure.
@end deftypefun
Example:
@example
/* Add a sound named `bogus.au' with volume 200. */
rplay_set (rp, RPLAY_APPEND,
RPLAY_SOUND, "bogus.au",
RPLAY_VOLUME, 200,
NULL);
/* Insert a sound named `bogus.au' with volume 200. */
rplay_set (rp, RPLAY_INSERT, 0,
RPLAY_SOUND, "bogus.au",
RPLAY_VOLUME, 200,
NULL);
/* Prepare to stop a sound named `excellent.au'. */
rp = rplay_create(RPLAY_STOP);
rplay_set (rp, RPLAY_APPEND,
RPLAY_SOUND, "excellent.au",
NULL);
/* Delete the sound at position 1. */
rplay_set (rp, RPLAY_DELETE, 1, NULL);
/*
* count and list count example
*
* result = gong.au gong.au drip.au drip.au
* gong.au gong.au drip.au drip.au
*
*/
rplay_set (rp, RPLAY_LIST_COUNT, 2, NULL);
rplay_set (rp, RPLAY_APPEND,
RPLAY_SOUND, "gong.au",
RPLAY_COUNT, 2,
NULL);
rplay_set (rp, RPLAY_APPEND,
RPLAY_SOUND, "drip.au",
RPLAY_COUNT, 2,
NULL);
/*
* random example (assume there is already a sound list)
*/
rplay_set (rp, RPLAY_RANDOM_SOUND, NULL); /* pick a sound randomly */
rplay_set (rp, RPLAY_RANDOM_SOUND, NULL); /* pick another sound */
rplay (rplay_fd, rp); /* play the random sound */
@end example
@c
@c rplay_get
@c
@deftypefun int rplay_get (RPLAY *@var{rp}, ...)
Retrieve attributes from a RPLAY object.
The @var{rp} argument should be a pointer to a RPLAY object created by
@code{rplay_create} and modified using @code{rplay_set}. This argument
is followed by a rplay attribute and its optional attribute argument.
The return value will be either @code{int} or @code{char *} depending on
the attribute. The caller will need to cast the return value to
@code{char *} when necessary.
@end deftypefun
Example:
@example
RPLAY *rp;
int n;
char *p;
/* Get the number of sounds. */
n = rplay_get (rp, RPLAY_NSOUNDS);
/* Get the name of sound 0. */
p = (char *) rplay_get (rp, RPLAY_SOUND, 0);
/* Get the volume of sound 1. */
n = rplay_get (rp, RPLAY_VOLUME, 1);
/* Get the rplay command. */
n = rplay_get (rp, RPLAY_COMMAND);
@end example
@c
@c rplay
@c
@deftypefun int rplay (int @var{rplay_fd}, RPLAY *@var{rp})
This function uses a RPLAY packet to send @var{rp} to the host
connected to @var{rplay_fd}.
The @var{rplay_fd} argument should be a socket descriptor opened by
@code{rplay_open}. @var{rp} should be a pointer to a @code{RPLAY}
object created by @code{rplay_create} and modified using
@code{rplay_set}.
The return value is @code{0} on success and @code{-1} on failure.
@end deftypefun
Example:
@example
if (rplay (rplay_fd, rp) < 0)
@{
rplay_perror ("rplay");
exit (1);
@}
@end example
@c
@c rplay_destroy
@c
@deftypefun void rplay_destroy (RPLAY *@var{rp})
Release all memory used by a RPLAY object.
The @var{rp} argument should be a pointer to a RPLAY object
created by @code{rplay_create}.
@end deftypefun
@node RPLAY Helper Functions, RPLAY Miscellaneous Functions, RPLAY Core Functions, Top
@chapter RPLAY Helper Functions
@c
@c rplay_default
@c
@deftypefun int rplay_default (char *@var{sound})
Play @var{sound} on the default rplay host which is obtained
using @code{rplay_default_host}.
The @var{sound} argument is the name of the sound to play.
The return value is @code{0} on success and @code{-1} on failure.
@end deftypefun
Example:
@example
if (rplay_default ("bogus.au") < 0)
@{
rplay_perror ("rplay_default");
exit (1);
@}
@end example
@c
@c rplay_default_host
@c
@deftypefun {char *} rplay_default_host (void)
Obtain the name of the default rplay host. A default rplay host
can be specified by the user with the @code{RPLAY_HOST} environment
variable. If this variable is not defined, @code{localhost} will
be used instead.
@end deftypefun
Example:
@example
char *hostname;
hostname = rplay_default_host ();
@end example
@c
@c rplay_display
@c
@deftypefun int rplay_display (char *@var{sound})
Play a sound on the host returned by rplay_open_display.
The @var{sound} argument is the name of the sound to play.
The return value is @code{0} on success and @code{-1} on failure.
@end deftypefun
Example:
@example
if (rplay_display ("bogus.au") < 0)
@{
rplay_perror ("rplay_display");
exit (1);
@}
@end example
@c
@c rplay_host
@c
@deftypefun int rplay_host (char *@var{host}, char *@var{sound})
Play a sound on a host.
The @var{host} is the name or IP address of the host where @var{sound}
will be played.
The return value is @code{0} on success and @code{-1} on failure.
@end deftypefun
Example:
@example
if (rplay_host ("bozo.sdsu.edu", "bogus.au") < 0)
@{
rplay_perror ("rplay_host");
exit (1);
@}
@end example
@c
@c rplay_host_volume
@c
@deftypefun int rplay_host_volume (char *@var{host}, char *@var{sound}, int @var{volume})
Play a sound at specific volume on a host.
The @var{host} is the name or IP address of the host where @var{sound}
will be played using @var{volume}.
The return value is @code{0} on success and @code{-1} on failure.
@end deftypefun
Example:
@example
if (rplay_host_volume ("bozo.sdsu.edu", "bogus.au", 200) < 0)
@{
rplay_perror ("rplay_host_volume");
exit (1);
@}
@end example
@c
@c rplay_local
@c
@deftypefun int rplay_local (char *@var{sound})
Play a sound on the localhost.
The @var{sound} argument is the name of the sound to play.
The return value is @code{0} on success and @code{-1} on failure.
@end deftypefun
Example:
@example
if (rplay_local ("bogus.au") < 0)
@{
rplay_perror ("rplay_local");
exit (1);
@}
@end example
@c
@c rplay_open_default
@c
@deftypefun int rplay_open_default (void)
Open a UDP socket connection to send RPLAY packets to the user's
default rplay host. The default rplay host is obtained using
@code{rplay_default_host}.
The return value is a socket descriptor on success and @code{-1} on
failure.
@end deftypefun
Example:
@example
int rplay_fd;
rplay_fd = rplay_open_default ();
if (rplay_fd < 0)
@{
rplay_perror ("rplay_open_default");
exit (1);
@}
@end example
@c
@c rplay_open_display
@c
@deftypefun int rplay_open_display (void)
Open a UDP socket connection to the host associated with the current X
Windows display. The @code{DISPLAY} environment variable is used obtain
the name of the X Windows display host. If this variable is not
defined, @code{localhost} is used.
The return value is a socket descriptor on success and @code{-1} on
failure.
@end deftypefun
Example:
@example
int rplay_fd;
rplay_fd = rplay_open_display ();
if (rplay_fd < 0)
@{
rplay_perror ("rplay_open_display");
exit (1);
@}
@end example
@c
@c rplay_open_port
@c
@deftypefun int rplay_open_port (char *@var{host}, int @var{port})
Open a UDP socket connection to send RPLAY packets to host at a
specific port.
The @var{host} argument is the same as @code{rplay_open} and the
@var{port} argument should be the port number desired. The default
port is defined in rplay.h as @code{RPLAY_PORT}.
The return value is a socket descriptor on success and @code{-1} on
failure.
@end deftypefun
Example:
@example
int rplay_fd;
rplay_fd = rplay_open_port ("130.191.224.3", 5555);
if (rplay_fd < 0)
@{
rplay_perror ("rplay_open_port");
exit (1);
@}
@end example
@c
@c rplay_open_sockaddr_in
@c
@deftypefun int rplay_open_sockaddr_in (struct sockaddr_in *@var{addr})
Open a UDP socket connection to send RPLAY packets to the address
specified in a @code{struct sockaddr_in}.
The return value is a socket descriptor on success and @code{-1} on
failure.
@end deftypefun
Example:
@example
struct sockaddr_in *saddr;
int rplay_fd;
rplay_fd = rplay_open_sockaddr_in (saddr);
if (rplay_fd < 0)
@{
rplay_perror ("rplay_open_sockaddr_in");
exit (1);
@}
@end example
@c
@c rplay_ping
@c
@deftypefun int rplay_ping (char *@var{host})
Send a @code{RPLAY_PING} package to a host. This funcion is used to
wake-up rplay servers that are started by inetd.
The @var{host} argument is the name or IP address of the host that will
receive the ping.
The return value is @code{0} on success and @code{-1} on failure.
@end deftypefun
Example:
@example
if (rplay_ping ("bozo.sdsu.edu") < 0)
@{
rplay_perror ("rplay_ping");
exit (1);
@}
@end example
@c
@c rplay_ping_sockaddr_in
@c
@deftypefun int rplay_ping_sockaddr_in (struct sockaddr_in *@var{addr})
The same as @code{rplay_ping} except the ping is sent to the host
addressed by @var{addr}.
@end deftypefun
@c
@c rplay_ping_sockfd
@c
@deftypefun int rplay_ping_sockfd (int @var{sockfd})
The same as @code{rplay_ping} except the ping is sent to the host
associated with UDP socket descriptor @var{sockfd}.
@end deftypefun
@c
@c rplay_sound
@c
@deftypefun int rplay_sound (int @var{rplay_fd}, char *@var{sound})
Play a sound on a host associated with a UDP socket descriptor.
The @var{rplay_fd} argument is a UDP socket descriptor returned by any
of the rplay_open routines and the @var{sound} argument is the name of
the sound to be played.
The return value is @code{0} on success and @code{-1} on failure.
@end deftypefun
Example:
@example
rplay_sound (rplay_fd, "bogus.au");
@end example
@node RPLAY Miscellaneous Functions, RPLAY Error Reporting, RPLAY Helper Functions, Top
@chapter RPLAY Miscellaneous Functions
@c
@c rplay_convert
@c
@deftypefun {char *} rplay_convert (char *@var{ptr})
Convert a RPLAY 2.0 packet to a RPLAY 3.0 packet.
The @var{ptr} argument should be a pointer to the data contained
in a RPLAY 2.0.
The return value is the data pointed to by @var{ptr} converted
to a RPLAY 3.0 packet.
@end deftypefun
@c
@c rplay_pack
@c
@deftypefun int rplay_pack (RPLAY *@var{rp})
Pack-up the attributes of the RPLAY object into the packet buffer
associated with the object. This routine is called automatically
by all routines that modify attributes.
The @var{rp} argument should be a pointer to a RPLAY object
created by @code{rplay_create}.
The return value is @code{0} on success and @code{-1} on failure.
@end deftypefun
@c
@c rplay_unpack
@c
@deftypefun {RPLAY *} rplay_unpack (char *@var{raw_ptr})
Unpack a raw rplay 3.0 packet into a new RPLAY object.
The @var{raw_ptr} argument should be a pointer to a rplay 3.0 packet
sent by a rplay client.
The return value is a pointer to a new RPLAY object that is created
using @code{rplay_create}.
@end deftypefun
@node RPLAY Error Reporting, RPTP Core Functions, RPLAY Miscellaneous Functions, Top
@chapter RPLAY Error Reporting
@c
@c rplay_perror
@c
@deftypefun void rplay_perror (char *@var{message})
Report errors return by rplay library routines to standard error.
Errors are obtained using @code{rplay_errno} and @code{rplay_errlist}.
This should be called when routines return -1 or NULL.
The @var{message} argument followed by @code{: } will prefix the rplay
error message.
@end deftypefun
@node RPTP Core Functions, RPTP Helper Functions, RPLAY Error Reporting, Top
@chapter RPTP Core Functions
@c
@c rptp_open
@c
@deftypefun int rptp_open (char *@var{host}, int @var{port}, char *@var{response}, int @var{response_size})
Open a TCP socket connection for a RPTP session.
The @var{host} argument is the name or IP address of a RPTP server,
@var{port} is the TCP port at @var{host} to connect to, and up-to
@var{response_size} bytes of the server's initial reponse are stored in
@var{response}.
The return value is a TCP socket descriptor and @code{-1} on failure.
@end deftypefun
Example:
@example
int rptp_fd;
char buf[RPTP_MAX_LINE]; /* defined in rplay.h */
rptp_fd = rptp_open ("bozo.sdsu.edu", RPTP_PORT, buf, sizeof(buf));
if (rptp_fd < 0)
@{
rptp_perror ("bozo.sdsu.edu");
exit(1);
@}
@end example
@c
@c rptp_close
@c
@deftypefun int rptp_close (int @var{rptp_fd})
Close a TCP socket descriptor created by @code{rptp_open}.
The return value is @code{0} on success and @code{-1} on failure.
@end deftypefun
@c
@c rptp_read
@c
@deftypefun int rptp_read (int @var{rptp_fd}, char *@var{buf}, int @var{nbytes})
Read data from a RPTP server.
The @var{rptp_fd} argument should be a TCP socket descriptor returned by
@var{rptp_open}. At most @var{nbytes} will be read into the @var{buf}.
The return value is the number of bytes read and @code{-1} on failure.
@end deftypefun
Example:
@example
if (rptp_read (rptp_fd, buf, sizeof(buf)) < 0)
@{
rptp_perror ("rptp_read");
exit (1);
@}
@end example
@c
@c rptp_write
@c
@deftypefun int rptp_write (int @var{rptp_fd}, char *@var{buf}, int @var{nbytes})
Write data to a RPTP server.
The @var{rptp_fd} argument should be a TCP socket descriptor returned by
@var{rptp_open}. @var{nbytes} of data will be written from @var{buf}.
The return value is the number of bytes written and @code{-1} on failure.
@end deftypefun
Example:
@example
if (rptp_write (rptp_fd, buf, sizeof(buf)) != sizeof(buf))
@{
rptp_perror ("rptp_write");
exit (1);
@}
@end example
@node RPTP Helper Functions, RPTP Error Reporting, RPTP Core Functions, Top
@chapter RPTP Helper Functions
@c
@c rptp_command
@c
@deftypefun int rptp_command (int @var{rptp_fd}, char *@var{command}, char *@var{response}, int @var{response_size})
Send a RPTP command a RPTP server, storing the server's response in a
buffer.
The @var{rptp_fd} argument should be a TCP socket descriptor returned by
@var{rptp_open}. @var{command} is the command that will be sent and
@var{response} is where up-to @var{response_size} bytes of the command
response will be stored.
The return value is @code{0} if the response begins with @code{RPTP_OK}
or or @code{RPTP_NOTIFY}, @code{1} if the response beings with
@code{RPTP_ERROR}, and @code{-1} if the response beings with
@code{RPTP_TIMEOUT} or there's an error.
@end deftypefun
Example:
@example
char *error;
switch (rptp_command (rptp_fd, command, response, sizeof(response)))
@{
case -1:
rptp_perror (command);
break;
case 1:
error = rptp_parse (response, "error");
printf ("%s\n", error);
break;
case 0:
/* Success! Now do something useful. */
break;
@}
@end example
@c
@c rptp_getline
@c
@deftypefun int rptp_getline (int @var{rptp_fd}, char *@var{buf}, int @var{nbytes})
Read a line from a RPTP connection. @code{\r\n} will be removed from
the line.
The @var{rptp_fd} argument should be a TCP socket descriptor returned by
@var{rptp_open}. @var{buf} is the buffer where up-to @var{nbytes} of
the line will be stored.
The return value is the number of bytes read and @code{-1} on failure.
@end deftypefun
Example:
@example
if (rptp_getline (rptp_fd, buf, sizeof(buf)) < 0)
@{
rptp_perror ("rptp_getline");
exit (1);
@}
@end example
@c
@c rptp_parse
@c
@deftypefun {char *} rptp_parse (char *@var{response}, char *@var{name})
Parse name-value pairs contained in RPTP responses.
The @var{response} argument can be a list of name-value pairs or
@code{NULL}. The @var{name} can be the name of specific name-value pair
or @code{NULL}. The example below gives more details. Note that any
leading dashes in any name-value pair will be ignored.
The return value can be name or value of a name-value pair depending on
the arguments.
@end deftypefun
Example:
@example
/* Return the value of `name' where `name=value' is
in the response string. */
value = rptp_parse (response, "name")
/* Same as above but return the value of `name' in
the previously specified response. */
value = rptp_parse (NULL, "name")
/* Return the first `name' in the response `name=value' list. */
name = rptp_parse (response, NULL)
/* Same as above but return the next `name' is the
previously specified response.
name = rptp_parse (NULL, NULL)
@end example
@c
@c rptp_putline
@c
@deftypefun int rptp_putline (int @var{rptp_fd}, char *@var{fmt}, ...)
Send a line to a RPTP server. This routine will always append
@samp{\r\n} to the line sent.
The @var{rptp_fd} argument should be a TCP socket descriptor returned by
@var{rptp_open}. @var{fmt} is any @code{printf} format string and the
rest of the arguments are the values for the format specified.
The return value is @code{0} on success and @code{-1} on failure.
@end deftypefun
Example:
@example
if (rptp_putline (rptp_fd, "find sound=%s", "bogus.au") < 0)
@{
rptp_perror ("rptp_putline");
exit (1);
@}
@end example
@node RPTP Error Reporting, Function Index, RPTP Helper Functions, Top
@chapter RPTP Error Reporting
@c
@c rptp_perror
@c
@deftypefun void rptp_perror (char *@var{message})
Report errors return by rptp library routines to standard error.
Errors are obtained using @code{rptp_errno} and @code{rptp_errlist}.
This should be called when routines return -1 or NULL.
The @var{message} argument followed by @code{: } will prefix the rptp
error message.
@end deftypefun
@node Function Index, , RPTP Error Reporting, Top
@appendix Function Index
@printindex fn
@summarycontents
@contents
@bye
|