-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport.c
41 lines (34 loc) · 889 Bytes
/
report.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
/* See LICENSE file for copyright and license details. */
#include "report.h"
void
report(struct info *data)
{
struct track *t;
int index;
char *js, *url;
size_t len;
index = data->m->track_count - 1;
t = data->m->track[index];
/* Report only once */
if (t->reported == TRUE)
return;
/* Set up url */
len = strlen("http://8tracks.com/sets/") + strlen(data->playtoken) +
strlen("/report?track_id=") + intlen(t->id) +
strlen("&mix_id=") + intlen(data->m->id);
url = malloc(len * sizeof(char));
if (url == NULL)
err(1, NULL);
(void)snprintf(url, len,
"http://8tracks.com/sets/%s/report?track_id=%d&mix_id=%d",
data->playtoken, t->id, data->m->id);
/* Report track */
js = malloc(1);
if (js == NULL)
err(1, NULL);
(void)fetch(&js, url); /* Just reporting, result doesn't matter. */
t->reported = TRUE;
/* Cleanup */
free(js);
free(url);
}