Debian Codegraph @

doc/librplay.info

raw ◀ ▶
Source reconstructed at patch state 1 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
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) &lt; 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)
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 
467 File: librplay.info, Node: RPLAY Error Reporting, Next: RPTP Core Functions, Prev: RPLAY Miscellaneous Functions, Up: Top
468
469 RPLAY Error Reporting
470 *********************
471
472 - Function: void rplay_perror (char *MESSAGE)
473 Report errors return by rplay library routines to standard error.
474 Errors are obtained using `rplay_errno' and `rplay_errlist'. This
475 should be called when routines return -1 or NULL.
476
477 The MESSAGE argument followed by `: ' will prefix the rplay error
478 message.
479
480 
481 File: librplay.info, Node: RPTP Core Functions, Next: RPTP Helper Functions, Prev: RPLAY Error Reporting, Up: Top
482
483 RPTP Core Functions
484 *******************
485
486 - Function: int rptp_open (char *HOST, int PORT, char *RESPONSE, int
487 RESPONSE_SIZE)
488 Open a TCP socket connection for a RPTP session.
489
490 The HOST argument is the name or IP address of a RPTP server, PORT
491 is the TCP port at HOST to connect to, and up-to RESPONSE_SIZE
492 bytes of the server's initial reponse are stored in RESPONSE.
493
494 The return value is a TCP socket descriptor and `-1' on failure.
495
496 Example:
497 int rptp_fd;
498 char buf[RPTP_MAX_LINE]; /* defined in rplay.h */
499
500 rptp_fd = rptp_open ("bozo.sdsu.edu", RPTP_PORT, buf, sizeof(buf));
501 if (rptp_fd < 0)
502 {
503 rptp_perror ("bozo.sdsu.edu");
504 exit(1);
505 }
506
507 - Function: int rptp_close (int RPTP_FD)
508 Close a TCP socket descriptor created by `rptp_open'.
509
510 The return value is `0' on success and `-1' on failure.
511
512 - Function: int rptp_read (int RPTP_FD, char *BUF, int NBYTES)
513 Read data from a RPTP server.
514
515 The RPTP_FD argument should be a TCP socket descriptor returned by
516 RPTP_OPEN. At most NBYTES will be read into the BUF.
517
518 The return value is the number of bytes read and `-1' on failure.
519
520 Example:
521 if (rptp_read (rptp_fd, buf, sizeof(buf)) < 0)
522 {
523 rptp_perror ("rptp_read");
524 exit (1);
525 }
526
527 - Function: int rptp_write (int RPTP_FD, char *BUF, int NBYTES)
528 Write data to a RPTP server.
529
530 The RPTP_FD argument should be a TCP socket descriptor returned by
531 RPTP_OPEN. NBYTES of data will be written from BUF.
532
533 The return value is the number of bytes written and `-1' on
534 failure.
535
536 Example:
537 if (rptp_write (rptp_fd, buf, sizeof(buf)) != sizeof(buf))
538 {
539 rptp_perror ("rptp_write");
540 exit (1);
541 }
542
543 
544 File: librplay.info, Node: RPTP Helper Functions, Next: RPTP Error Reporting, Prev: RPTP Core Functions, Up: Top
545
546 RPTP Helper Functions
547 *********************
548
549 - Function: int rptp_command (int RPTP_FD, char *COMMAND, char
550 *RESPONSE, int RESPONSE_SIZE)
551 Send a RPTP command a RPTP server, storing the server's response
552 in a buffer.
553
554 The RPTP_FD argument should be a TCP socket descriptor returned by
555 RPTP_OPEN. COMMAND is the command that will be sent and RESPONSE
556 is where up-to RESPONSE_SIZE bytes of the command response will be
557 stored.
558
559 The return value is `0' if the response begins with `RPTP_OK' or
560 or `RPTP_NOTIFY', `1' if the response beings with `RPTP_ERROR',
561 and `-1' if the response beings with `RPTP_TIMEOUT' or there's an
562 error.
563
564 Example:
565 char *error;
566
567 switch (rptp_command (rptp_fd, command, response, sizeof(response)))
568 {
569 case -1:
570 rptp_perror (command);
571 break;
572
573 case 1:
574 error = rptp_parse (response, "error");
575 printf ("%s\n", error);
576 break;
577
578 case 0:
579 /* Success! Now do something useful. */
580 break;
581 }
582
583 - Function: int rptp_getline (int RPTP_FD, char *BUF, int NBYTES)
584 Read a line from a RPTP connection. `\r\n' will be removed from
585 the line.
586
587 The RPTP_FD argument should be a TCP socket descriptor returned by
588 RPTP_OPEN. BUF is the buffer where up-to NBYTES of the line will
589 be stored.
590
591 The return value is the number of bytes read and `-1' on failure.
592
593 Example:
594 if (rptp_getline (rptp_fd, buf, sizeof(buf)) < 0)
595 {
596 rptp_perror ("rptp_getline");
597 exit (1);
598 }
599
600 - Function: char * rptp_parse (char *RESPONSE, char *NAME)
601 Parse name-value pairs contained in RPTP responses.
602
603 The RESPONSE argument can be a list of name-value pairs or `NULL'.
604 The NAME can be the name of specific name-value pair or `NULL'.
605 The example below gives more details. Note that any leading
606 dashes in any name-value pair will be ignored.
607
608 The return value can be name or value of a name-value pair
609 depending on the arguments.
610
611 Example:
612 /* Return the value of `name' where `name=value' is
613 in the response string. */
614 value = rptp_parse (response, "name")
615
616 /* Same as above but return the value of `name' in
617 the previously specified response. */
618 value = rptp_parse (NULL, "name")
619
620 /* Return the first `name' in the response `name=value' list. */
621 name = rptp_parse (response, NULL)
622
623 /* Same as above but return the next `name' is the
624 previously specified response.
625 name = rptp_parse (NULL, NULL)
626
627 - Function: int rptp_putline (int RPTP_FD, char *FMT, ...)
628 Send a line to a RPTP server. This routine will always append
629 `\r\n' to the line sent.
630
631 The RPTP_FD argument should be a TCP socket descriptor returned by
632 RPTP_OPEN. FMT is any `printf' format string and the rest of the
633 arguments are the values for the format specified.
634
635 The return value is `0' on success and `-1' on failure.
636
637 Example:
638 if (rptp_putline (rptp_fd, "find sound=%s", "bogus.au") < 0)
639 {
640 rptp_perror ("rptp_putline");
641 exit (1);
642 }
643
644 
645 File: librplay.info, Node: RPTP Error Reporting, Next: Function Index, Prev: RPTP Helper Functions, Up: Top
646
647 RPTP Error Reporting
648 ********************
649
650 - Function: void rptp_perror (char *MESSAGE)
651 Report errors return by rptp library routines to standard error.
652 Errors are obtained using `rptp_errno' and `rptp_errlist'. This
653 should be called when routines return -1 or NULL.
654
655 The MESSAGE argument followed by `: ' will prefix the rptp error
656 message.
657
658 
659 File: librplay.info, Node: Function Index, Prev: RPTP Error Reporting, Up: Top
660
661 Function Index
662 **************
663
664 * Menu:
665
666 * rplay: RPLAY Core Functions.
667 * rplay_close: RPLAY Core Functions.
668 * rplay_convert: RPLAY Miscellaneous Functions.
669 * rplay_create: RPLAY Core Functions.
670 * rplay_default: RPLAY Helper Functions.
671 * rplay_default_host: RPLAY Helper Functions.
672 * rplay_destroy: RPLAY Core Functions.
673 * rplay_display: RPLAY Helper Functions.
674 * rplay_get: RPLAY Core Functions.
675 * rplay_host: RPLAY Helper Functions.
676 * rplay_host_volume: RPLAY Helper Functions.
677 * rplay_local: RPLAY Helper Functions.
678 * rplay_open: RPLAY Core Functions.
679 * rplay_open_default: RPLAY Helper Functions.
680 * rplay_open_display: RPLAY Helper Functions.
681 * rplay_open_port: RPLAY Helper Functions.
682 * rplay_open_sockaddr_in: RPLAY Helper Functions.
683 * rplay_pack: RPLAY Miscellaneous Functions.
684 * rplay_perror: RPLAY Error Reporting.
685 * rplay_ping: RPLAY Helper Functions.
686 * rplay_ping_sockaddr_in: RPLAY Helper Functions.
687 * rplay_ping_sockfd: RPLAY Helper Functions.
688 * rplay_set: RPLAY Core Functions.
689 * rplay_sound: RPLAY Helper Functions.
690 * rplay_unpack: RPLAY Miscellaneous Functions.
691 * rptp_close: RPTP Core Functions.
692 * rptp_command: RPTP Helper Functions.
693 * rptp_getline: RPTP Helper Functions.
694 * rptp_open: RPTP Core Functions.
695 * rptp_parse: RPTP Helper Functions.
696 * rptp_perror: RPTP Error Reporting.
697 * rptp_putline: RPTP Helper Functions.
698 * rptp_read: RPTP Core Functions.
699 * rptp_write: RPTP Core Functions.
700
701
702 
703 Tag Table:
704 Node: Top835
705 Node: RPLAY Core Functions1987
706 Node: RPLAY Helper Functions7114
707 Node: RPLAY Miscellaneous Functions12829
708 Node: RPLAY Error Reporting13993
709 Node: RPTP Core Functions14499
710 Node: RPTP Helper Functions16409
711 Node: RPTP Error Reporting19729
712 Node: Function Index20214
713 
714 End Tag Table