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