Debian Codegraph @

doc/librplay.texi

raw ◀ ▶
Source reconstructed at patch state 1 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
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) &lt; 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
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_perror
639 @c
640 @deftypefun void rplay_perror (char *@var{message})
641 Report errors return by rplay library routines to standard error.
642 Errors are obtained using @code{rplay_errno} and @code{rplay_errlist}.
643 This should be called when routines return -1 or NULL.
644
645 The @var{message} argument followed by @code{: } will prefix the rplay
646 error message.
647 @end deftypefun
648
649 @node RPTP Core Functions, RPTP Helper Functions, RPLAY Error Reporting, Top
650 @chapter RPTP Core Functions
651
652 @c
653 @c rptp_open
654 @c
655 @deftypefun int rptp_open (char *@var{host}, int @var{port}, char *@var{response}, int @var{response_size})
656 Open a TCP socket connection for a RPTP session.
657
658 The @var{host} argument is the name or IP address of a RPTP server,
659 @var{port} is the TCP port at @var{host} to connect to, and up-to
660 @var{response_size} bytes of the server's initial reponse are stored in
661 @var{response}.
662
663 The return value is a TCP socket descriptor and @code{-1} on failure.
664 @end deftypefun
665
666 Example:
667 @example
668 int rptp_fd;
669 char buf[RPTP_MAX_LINE]; /* defined in rplay.h */
670
671 rptp_fd = rptp_open ("bozo.sdsu.edu", RPTP_PORT, buf, sizeof(buf));
672 if (rptp_fd < 0)
673 @{
674 rptp_perror ("bozo.sdsu.edu");
675 exit(1);
676 @}
677 @end example
678
679 @c
680 @c rptp_close
681 @c
682 @deftypefun int rptp_close (int @var{rptp_fd})
683 Close a TCP socket descriptor created by @code{rptp_open}.
684
685 The return value is @code{0} on success and @code{-1} on failure.
686 @end deftypefun
687
688 @c
689 @c rptp_read
690 @c
691 @deftypefun int rptp_read (int @var{rptp_fd}, char *@var{buf}, int @var{nbytes})
692 Read data from a RPTP server.
693
694 The @var{rptp_fd} argument should be a TCP socket descriptor returned by
695 @var{rptp_open}. At most @var{nbytes} will be read into the @var{buf}.
696
697 The return value is the number of bytes read and @code{-1} on failure.
698 @end deftypefun
699
700 Example:
701 @example
702 if (rptp_read (rptp_fd, buf, sizeof(buf)) < 0)
703 @{
704 rptp_perror ("rptp_read");
705 exit (1);
706 @}
707 @end example
708
709 @c
710 @c rptp_write
711 @c
712 @deftypefun int rptp_write (int @var{rptp_fd}, char *@var{buf}, int @var{nbytes})
713 Write data to a RPTP server.
714
715 The @var{rptp_fd} argument should be a TCP socket descriptor returned by
716 @var{rptp_open}. @var{nbytes} of data will be written from @var{buf}.
717
718 The return value is the number of bytes written and @code{-1} on failure.
719 @end deftypefun
720
721 Example:
722 @example
723 if (rptp_write (rptp_fd, buf, sizeof(buf)) != sizeof(buf))
724 @{
725 rptp_perror ("rptp_write");
726 exit (1);
727 @}
728 @end example
729
730 @node RPTP Helper Functions, RPTP Error Reporting, RPTP Core Functions, Top
731 @chapter RPTP Helper Functions
732
733 @c
734 @c rptp_command
735 @c
736 @deftypefun int rptp_command (int @var{rptp_fd}, char *@var{command}, char *@var{response}, int @var{response_size})
737 Send a RPTP command a RPTP server, storing the server's response in a
738 buffer.
739
740 The @var{rptp_fd} argument should be a TCP socket descriptor returned by
741 @var{rptp_open}. @var{command} is the command that will be sent and
742 @var{response} is where up-to @var{response_size} bytes of the command
743 response will be stored.
744
745 The return value is @code{0} if the response begins with @code{RPTP_OK}
746 or or @code{RPTP_NOTIFY}, @code{1} if the response beings with
747 @code{RPTP_ERROR}, and @code{-1} if the response beings with
748 @code{RPTP_TIMEOUT} or there's an error.
749 @end deftypefun
750
751 Example:
752 @example
753 char *error;
754
755 switch (rptp_command (rptp_fd, command, response, sizeof(response)))
756 @{
757 case -1:
758 rptp_perror (command);
759 break;
760
761 case 1:
762 error = rptp_parse (response, "error");
763 printf ("%s\n", error);
764 break;
765
766 case 0:
767 /* Success! Now do something useful. */
768 break;
769 @}
770 @end example
771
772 @c
773 @c rptp_getline
774 @c
775 @deftypefun int rptp_getline (int @var{rptp_fd}, char *@var{buf}, int @var{nbytes})
776 Read a line from a RPTP connection. @code{\r\n} will be removed from
777 the line.
778
779 The @var{rptp_fd} argument should be a TCP socket descriptor returned by
780 @var{rptp_open}. @var{buf} is the buffer where up-to @var{nbytes} of
781 the line will be stored.
782
783 The return value is the number of bytes read and @code{-1} on failure.
784 @end deftypefun
785
786 Example:
787 @example
788 if (rptp_getline (rptp_fd, buf, sizeof(buf)) < 0)
789 @{
790 rptp_perror ("rptp_getline");
791 exit (1);
792 @}
793 @end example
794
795
796 @c
797 @c rptp_parse
798 @c
799 @deftypefun {char *} rptp_parse (char *@var{response}, char *@var{name})
800 Parse name-value pairs contained in RPTP responses.
801
802 The @var{response} argument can be a list of name-value pairs or
803 @code{NULL}. The @var{name} can be the name of specific name-value pair
804 or @code{NULL}. The example below gives more details. Note that any
805 leading dashes in any name-value pair will be ignored.
806
807 The return value can be name or value of a name-value pair depending on
808 the arguments.
809 @end deftypefun
810
811 Example:
812 @example
813 /* Return the value of `name' where `name=value' is
814 in the response string. */
815 value = rptp_parse (response, "name")
816
817 /* Same as above but return the value of `name' in
818 the previously specified response. */
819 value = rptp_parse (NULL, "name")
820
821 /* Return the first `name' in the response `name=value' list. */
822 name = rptp_parse (response, NULL)
823
824 /* Same as above but return the next `name' is the
825 previously specified response.
826 name = rptp_parse (NULL, NULL)
827 @end example
828
829
830 @c
831 @c rptp_putline
832 @c
833 @deftypefun int rptp_putline (int @var{rptp_fd}, char *@var{fmt}, ...)
834 Send a line to a RPTP server. This routine will always append
835 @samp{\r\n} to the line sent.
836
837 The @var{rptp_fd} argument should be a TCP socket descriptor returned by
838 @var{rptp_open}. @var{fmt} is any @code{printf} format string and the
839 rest of the arguments are the values for the format specified.
840
841 The return value is @code{0} on success and @code{-1} on failure.
842 @end deftypefun
843
844 Example:
845 @example
846 if (rptp_putline (rptp_fd, "find sound=%s", "bogus.au") < 0)
847 @{
848 rptp_perror ("rptp_putline");
849 exit (1);
850 @}
851 @end example
852
853 @node RPTP Error Reporting, Function Index, RPTP Helper Functions, Top
854 @chapter RPTP Error Reporting
855
856 @c
857 @c rptp_perror
858 @c
859 @deftypefun void rptp_perror (char *@var{message})
860 Report errors return by rptp library routines to standard error.
861 Errors are obtained using @code{rptp_errno} and @code{rptp_errlist}.
862 This should be called when routines return -1 or NULL.
863
864 The @var{message} argument followed by @code{: } will prefix the rptp
865 error message.
866 @end deftypefun
867
868 @node Function Index, , RPTP Error Reporting, Top
869 @appendix Function Index
870 @printindex fn
871
872 @summarycontents
873 @contents
874
875 @bye