File: playlists.c

package info (click to toggle)
libnjb1 1.1-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,400 kB
  • ctags: 594
  • sloc: ansic: 10,288; sh: 6,541; makefile: 175
file content (62 lines) | stat: -rw-r--r-- 1,112 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <limits.h>
#include <libnjb.h>
#include <unistd.h>

extern int njb_error;

int main (int argc, char **argv)
{
	njb_t njbs[NJB_MAX_DEVICES], *njb;
	int n, debug;
	playlist_t *playlist;
	extern char *optarg;
	int opt;

	debug= 0;
	while ( (opt= getopt(argc, argv, "D:")) != -1 ) {
		switch (opt) {
		case 'D':
			debug= atoi(optarg);
			break;
		default:
			fprintf(stderr, "usage: playlists [ -D debuglvl ]\n");
			return 1;
		}
	}

	if ( debug ) NJB_Set_Debug(debug);

	if ( NJB_Discover(njbs, 0, &n) == -1 ) njb_error_dump(stderr);
	if ( n == 0 ) {
		fprintf(stderr, "no NJB devices found\n");
		return 0;
	} 

	njb= njbs;

	if ( NJB_Open(njb) == -1 ) {
		njb_error_dump(stderr);
		return 1;
	}

	if ( NJB_Capture(njb) == -1 ) {
		njb_error_dump(stderr);
		return 1;
	}

	NJB_Reset_Get_Playlist(njb);
	while ( (playlist= NJB_Get_Playlist(njb)) ) {
		playlist_dump(playlist, stdout);
		printf("----------------------------------\n");
	}
	if ( njb_error != EO_EOM ) njb_error_dump(stderr);

	NJB_Release(njb);

	NJB_Close(njb);
	return 0;
}