File: ripperX_plugin-toolame.c

package info (click to toggle)
ripperx 2.8.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,104 kB
  • sloc: cpp: 7,451; sh: 4,362; ansic: 945; makefile: 88; sed: 16
file content (45 lines) | stat: -rw-r--r-- 915 bytes parent folder | download | duplicates (10)
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

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>

/* plugin for toolame versin 0.2i */

#define OUTPUT_BUF_LENGTH	1024
#define OFFSET_LENGTH		16
#define PRINTOUT_INTERVAL	0.2

int
toolame_read_stat (int *current)
{
	char temp[OUTPUT_BUF_LENGTH];
	char string[100];
	char *string1;
	int bytes_read;
	/* Grab new ouput from 'toolame'  */
	bytes_read = read (0, (void *) temp, sizeof (temp));
        if (bytes_read > OFFSET_LENGTH) {
                sscanf (&temp[1], "%s]", string);
                *current = atoi(string);
                return (0);
        }
	return (-1);
}

int
main (int argc, char **argv)
{
	int begin, length;
	int current;

	sscanf (argv[1], "%d", &begin);
	sscanf (argv[2], "%d", &length);

	while (1) { 
		if (toolame_read_stat (&current) == 0) {
			printf ("[P %f]\n", ((double) current / (double) length) );
		}
		usleep (PRINTOUT_INTERVAL * 1000000);
	}
}