-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
47 lines (40 loc) · 951 Bytes
/
main.c
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
#include <stdlib.h>
#include <stdio.h>
#include <event2/event.h>
#include <event2/thread.h>
#include "spotify.h"
int
main(int argc, char *argv[])
{
spotify_t *spotify;
int error;
int ret;
if (argc <= 2) {
fprintf(stderr, "Usage: %s <username> <password>\n", argv[0]);
return -1;
}
#if defined(EVTHREAD_USE_PTHREADS_IMPLEMENTED)
if (evthread_use_pthreads()) {
return -2;
}
#elif defined(EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED)
if (evthread_use_windows_threads()) {
return -3;
}
#else
# error "The libevent threading support not available"
#endif
spotify = spotify_init(&error);
if (!spotify) {
fprintf(stderr, "Spotify failed to initialize\n");
return -4;
}
spotify_login(spotify, argv[1], argv[2]);
ret = spotify_run(spotify);
if (ret) {
fprintf(stderr, "Event loop returned %d\n", ret);
}
spotify_logout(spotify);
spotify_destroy(spotify);
return 0;
}