コード例 #1
0
ファイル: mb_discid.c プロジェクト: GunioRobot/Marmot
/**
 * call-seq:
 *  sectors() -> int or nil
 * 
 * Return the length of the disc in sectors.
 * 
 * Returns +nil+ if no ID was yet read.
 */
static VALUE mb_discid_sectors(VALUE self)
{
	if (rb_iv_get(self, "@read") == Qfalse)
		return Qnil;
	else
	{
		DiscId *disc;
		Data_Get_Struct(self, DiscId, disc);
		
		return INT2FIX(discid_get_sectors(disc));
	}
}
コード例 #2
0
ファイル: discid.c プロジェクト: Zastai/libdiscid
int main(int argc, char *argv[]) {
	int i, first_track, last_track;
	char *device = NULL;
	char time_str[14];
	int sectors;
	DiscId *disc;

	disc = discid_new();

	/* If we have an argument, use it as the device name */
	if (argc > 1) {
		device = argv[1];
	} else {
		/* this will use discid_get_default_device() internally */
		device = NULL;
	}

	if (discid_read_sparse(disc, device, 0) == 0) {
		fprintf(stderr, "Error: %s\n", discid_get_error_msg(disc));
		discid_free(disc);
		return 1;
	}

	printf("DiscID        : %s\n", discid_get_id(disc));
	printf("FreeDB DiscID : %s\n", discid_get_freedb_id(disc));

	first_track = discid_get_first_track_num(disc);
	last_track = discid_get_last_track_num(disc);
	printf("First track   : %d\n", first_track);
	printf("Last track    : %d\n", last_track);

	sectors = discid_get_sectors(disc);
	sectors_to_time(sectors, ROUND_SECONDS, time_str, sizeof time_str);
	printf("Length        : %d sectors (%s)\n", sectors, time_str);

	for ( i = first_track; i <= last_track; i++ ) {
		sectors = discid_get_track_length(disc, i);
		sectors_to_time(sectors, ROUND_SECONDS,
				time_str, sizeof time_str);
		printf("Track %-2d      : %8d %8d (%s)\n",
				i, discid_get_track_offset(disc, i),
				sectors, time_str);
	}

	printf("Submit via    : %s\n", discid_get_submission_url(disc));

	discid_free(disc);

	return 0;
}