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