Debian Codegraph @

doc/librplay.texi

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