Debian Codegraph @

doc/librplay.info

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